from abaqus import *
from abaqusConstants import *
session.Viewport(name='Viewport: 1', origin=(0.0, 0.0), width=175.7109375, 
    height=141.653641134501)
session.viewports['Viewport: 1'].makeCurrent()
session.viewports['Viewport: 1'].maximize()
from caeModules import *
from driverUtils import executeOnCaeStartup
executeOnCaeStartup()
Mdb()
session.viewports['Viewport: 1'].setValues(displayedObject=None)
mdb.models.changeKey(fromName='Model-1', toName='My-Beam')
session.viewports['Viewport: 1'].setValues(displayedObject=None)
s = mdb.models['My-Beam'].ConstrainedSketch(name='__profile__', sheetSize=0.4)
g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints
s.setPrimaryObject(option=STANDALONE)
s.Line(point1=(0.0, 0.0), point2=(0.0, 0.2))
s.VerticalConstraint(entity=g[2])
p = mdb.models['My-Beam'].Part(name='My-Beam', dimensionality=TWO_D_PLANAR, 
    type=DEFORMABLE_BODY)
p = mdb.models['My-Beam'].parts['My-Beam']
p.BaseWire(sketch=s)
s.unsetPrimaryObject()
p = mdb.models['My-Beam'].parts['My-Beam']
session.viewports['Viewport: 1'].setValues(displayedObject=p)
del mdb.models['My-Beam'].sketches['__profile__']
mdb.models['My-Beam'].RectangularProfile(name='Profile-Rect', a=0.0005, 
    b=0.0005)
mdb.models['My-Beam'].BeamSection(name='Sect-Beam', profile='Profile-Rect', 
    integration=BEFORE_ANALYSIS, poissonRatio=0.33, density=7850.0, 
    thermalExpansion=OFF, temperatureDependency=OFF, dependencies=0, table=((
    3000000000000.0, 3000000000000.0), ), alphaDamping=0.0, betaDamping=0.0, 
    compositeDamping=0.0, centroid=(0.0, 0.0), shearCenter=(0.0, 0.0))
p = mdb.models['My-Beam'].parts['My-Beam']
e = p.edges
edges = e.getSequenceFromMask(mask=('[#1 ]', ), )
region = regionToolset.Region(edges=edges)
p = mdb.models['My-Beam'].parts['My-Beam']
p.SectionAssignment(region=region, sectionName='Sect-Beam', offset=0.0)
p = mdb.models['My-Beam'].parts['My-Beam']
e = p.edges
edges = e.getSequenceFromMask(mask=('[#1 ]', ), )
region=regionToolset.Region(edges=edges)
p = mdb.models['My-Beam'].parts['My-Beam']
p.assignBeamSectionOrientation(region=region, method=N1_COSINES, n1=(0.0, 0.0, 
    -1.0))
a = mdb.models['My-Beam'].rootAssembly
session.viewports['Viewport: 1'].setValues(displayedObject=a)
a = mdb.models['My-Beam'].rootAssembly
a.DatumCsysByDefault(CARTESIAN)
p = mdb.models['My-Beam'].parts['My-Beam']
a.Instance(name='My-Beam-1', part=p, dependent=OFF)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(
    adaptiveMeshConstraints=ON)
mdb.models['My-Beam'].StaticStep(name='Step-1', previous='Initial', 
    description='Apply force on the top of beam', nlgeom=ON)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='Step-1')
session.viewports['Viewport: 1'].assemblyDisplay.setValues(
    adaptiveMeshConstraints=ON)
mdb.models['My-Beam'].steps['Step-1'].setValues(maxNumInc=10000, 
    initialInc=0.1)
mdb.models['My-Beam'].FieldOutputRequest(name='Reaction-force', 
    createStepName='Step-1', variables=('RF', 'RT'))
session.viewports['Viewport: 1'].assemblyDisplay.setValues(loads=ON, bcs=ON, 
    predefinedFields=ON, connectors=ON, adaptiveMeshConstraints=OFF)
a = mdb.models['My-Beam'].rootAssembly
v1 = a.instances['My-Beam-1'].vertices
verts1 = v1.getSequenceFromMask(mask=('[#1 ]', ), )
a.Set(vertices=verts1, name='Beam-Bottom')
a = mdb.models['My-Beam'].rootAssembly
v1 = a.instances['My-Beam-1'].vertices
verts1 = v1.getSequenceFromMask(mask=('[#2 ]', ), )
a.Set(vertices=verts1, name='Beam-Top')
session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='Initial')
a = mdb.models['My-Beam'].rootAssembly
region = a.sets['Beam-Bottom']
mdb.models['My-Beam'].DisplacementBC(name='Fixed-Bottom', 
    createStepName='Initial', region=region, u1=SET, u2=SET, ur3=SET, 
    amplitude=UNSET, distributionType=UNIFORM, localCsys=None)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(step='Step-1')
a = mdb.models['My-Beam'].rootAssembly
region = a.sets['Beam-Top']
mdb.models['My-Beam'].ConcentratedForce(name='CForce', createStepName='Step-1', 
    region=region, cf1=0.5, cf2=-50.0, localCsys=None)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON, loads=OFF, 
    bcs=OFF, predefinedFields=OFF, connectors=OFF)
session.viewports['Viewport: 1'].assemblyDisplay.meshOptions.setValues(
    meshTechnique=ON)
a = mdb.models['My-Beam'].rootAssembly
e1 = a.instances['My-Beam-1'].edges
edges1 = e1.getSequenceFromMask(mask=('[#1 ]', ), )
a.Set(edges=edges1, name='Beam_All')
a = mdb.models['My-Beam'].rootAssembly
e1 = a.instances['My-Beam-1'].edges
pickedEdges = e1.getSequenceFromMask(mask=('[#1 ]', ), )
a.seedEdgeByNumber(edges=pickedEdges, number=10)
elemType1 = mesh.ElemType(elemCode=B21, elemLibrary=STANDARD)
a = mdb.models['My-Beam'].rootAssembly
e1 = a.instances['My-Beam-1'].edges
edges1 = e1.getSequenceFromMask(mask=('[#1 ]', ), )
pickedRegions =(edges1, )
a.setElementType(regions=pickedRegions, elemTypes=(elemType1, ))
a = mdb.models['My-Beam'].rootAssembly
partInstances =(a.instances['My-Beam-1'], )
a.generateMesh(regions=partInstances)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=OFF)
session.viewports['Viewport: 1'].assemblyDisplay.meshOptions.setValues(
    meshTechnique=OFF)
mdb.Job(name='My-Beam', model='My-Beam', type=ANALYSIS, 
    explicitPrecision=SINGLE, nodalOutputPrecision=SINGLE, 
    description='My first analysis using Python script', 
    parallelizationMethodExplicit=DOMAIN, multiprocessingMode=DEFAULT, 
    numDomains=1, userSubroutine='', numCpus=1, preMemory=2048.0, 
    standardMemory=2048.0, standardMemoryPolicy=MODERATE, scratch='', 
    echoPrint=OFF, modelPrint=OFF, contactPrint=OFF, historyPrint=OFF)
mdb.jobs['My-Beam'].writeInput(consistencyChecking=OFF)
mdb.jobs['My-Beam'].submit(consistencyChecking=OFF)