前言
从未打开过Abaqus开始的二次开发。参考书籍《Abaqus Python二次开发攻略》,书里写的很详细。 参考RVE教程:https://www.bilibili.com/video/BV1c64y1b7dz?spm_id_from=333.337.search-card.all.click Abaqus版本:2020
初始rpy文件
from abaqus import *
from abaqusConstants import *
session.Viewport(name='Viewport: 1', origin=(0.0, 0.0), width=250.050506591797,
height=145.686111450195)
session.viewports['Viewport: 1'].makeCurrent()
session.viewports['Viewport: 1'].maximize()
from caeModules import *
from driverUtils import executeOnCaeStartup
executeOnCaeStartup()
session.viewports['Viewport: 1'].partDisplay.geometryOptions.setValues(
referenceRepresentation=ON)
4个import导入必要的模块; 其余行生成Viewport:1用于显示。
RVE建立
模型建立
GUI操作,建立一个边长10的正方体作为基体
s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__',
sheetSize=200.0)
g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints
s.setPrimaryObject(option=STANDALONE)
s.rectangle(point1=(0.0, 0.0), point2=(10.0, 10.0))
p = mdb.models['Model-1'].Part(name='MATRIX', dimensionality=THREE_D,
type=DEFORMABLE_BODY)
p = mdb.models['Model-1'].parts['MATRIX']
p.BaseSolidExtrude(sketch=s, depth=10.0)
s.unsetPrimaryObject()
p = mdb.models['Model-1'].parts['MATRIX']
session.viewports['Viewport: 1'].setValues(displayedObject=p)
del mdb.models['Model-1'].sketches['__profile__']
前5行建立草图对象s; 6-10行使用草图s生成Solid部件p; 最后两行书上没说,但看意思大概就是设定一下当前显示对象,然后删掉草图。可以看到,草图对象是在mdb.models仓库里的。
GUI操作,创建纤维,其实就是在方体一个面上画圆,后期算法主要针对这里的圆圈生成
p = mdb.models['Model-1'].parts['MATRIX']
f, e = p.faces, p.edges
t = p.MakeSketchTransform(sketchPlane=f[4], sketchUpEdge=e[7],
sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(5.0, 5.0, 10.0))
s1 = mdb.models['Model-1'].ConstrainedSketch(name='__profile__',
sheetSize=34.64, gridSpacing=0.86, transform=t)
g, v, d, c = s1.geometry, s1.vertices, s1.dimensions, s1.constraints
s1.setPrimaryObject(option=SUPERIMPOSE)
p = mdb.models['Model-1'].parts['MATRIX']
p.projectReferencesOntoSketch(sketch=s1, filter=COPLANAR_EDGES)
s1.CircleByCenterPerimeter(center=(0.0, 0.0), point1=(1.72, 0.0))
p = mdb.models['Model-1'].parts['MATRIX']
f1, e1 = p.faces, p.edges
p.SolidExtrude(sketchPlane=f1[4], sketchUpEdge=e1[7], sketchPlaneSide=SIDE1,
sketchOrientation=RIGHT, sketch=s1, depth=10.0, flipExtrudeDirection=ON,
keepInternalBoundaries=ON)
s1.unsetPrimaryObject()
del mdb.models['Model-1'].sketches['__profile__']
材料属性
GUI操作,分别为基体和纤维创建材料属性,FIBER属性与MATRIX类似
session.viewports['Viewport: 1'].partDisplay.setValues(sectionAssignments=ON,
engineeringFeatures=ON)
session.viewports['Viewport: 1'].partDisplay.geometryOptions.setValues(
referenceRepresentation=OFF)
mdb.models['Model-1'].Material(name='MATRIX')
mdb.models['Model-1'].materials['MATRIX'].Elastic(table=((7000.0, 0.38), ))
mdb.models['Model-1'].Material(name='FIBER')
mdb.models['Model-1'].materials['FIBER'].Elastic(table=((220000.0, 0.2), ))
创建截面
为纤维和基体创建两个截面,并赋予
mdb.models['Model-1'].HomogeneousSolidSection(name='FIBER-SEC',
material='FIBER', thickness=None)
mdb.models['Model-1'].HomogeneousSolidSection(name='MATRIX-SET',
material='MATRIX', thickness=None)
p = mdb.models['Model-1'].parts['MATRIX']
c = p.cells
cells = c.getSequenceFromMask(mask=('[#1 ]', ), )
region = p.Set(cells=cells, name='Set-1')
p = mdb.models['Model-1'].parts['MATRIX']
p.SectionAssignment(region=region, sectionName='FIBER-SEC', offset=0.0,
offsetType=MIDDLE_SURFACE, offsetField='',
thicknessAssignment=FROM_SECTION)
p = mdb.models['Model-1'].parts['MATRIX']
c = p.cells
cells = c.getSequenceFromMask(mask=('[#2 ]', ), )
region = p.Set(cells=cells, name='Set-2')
p = mdb.models['Model-1'].parts['MATRIX']
p.SectionAssignment(region=region, sectionName='MATRIX-SET', offset=0.0,
offsetType=MIDDLE_SURFACE, offsetField='',
thicknessAssignment=FROM_SECTION)
创建装配体
a = mdb.models['Model-1'].rootAssembly
session.viewports['Viewport: 1'].setValues(displayedObject=a)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(
optimizationTasks=OFF, geometricRestrictions=OFF, stopConditions=OFF)
a = mdb.models['Model-1'].rootAssembly
a.DatumCsysByDefault(CARTESIAN)
p = mdb.models['Model-1'].parts['MATRIX']
a.Instance(name='MATRIX-1', part=p, dependent=OFF)
Mesh
布种为0.5
session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON)
session.viewports['Viewport: 1'].assemblyDisplay.meshOptions.setValues(
meshTechnique=ON)
a = mdb.models['Model-1'].rootAssembly
c1 = a.instances['MATRIX-1'].cells
pickedRegions = c1.getSequenceFromMask(mask=('[#3 ]', ), )
a.setMeshControls(regions=pickedRegions, elemShape=WEDGE)
a = mdb.models['Model-1'].rootAssembly
partInstances =(a.instances['MATRIX-1'], )
a.seedPartInstance(regions=partInstances, size=0.5, deviationFactor=0.1,
minSizeFactor=0.1)
a = mdb.models['Model-1'].rootAssembly
partInstances =(a.instances['MATRIX-1'], )
a.generateMesh(regions=partInstances)
session.viewports['Viewport: 1'].enableMultipleColors()
session.viewports['Viewport: 1'].setColor(initialColor='#BDBDBD')
cmap=session.viewports['Viewport: 1'].colorMappings['Material']
session.viewports['Viewport: 1'].setColor(colorMapping=cmap)
session.viewports['Viewport: 1'].disableMultipleColors()
EasyPBC
这里模型名字一定要输入对,之所以Instance name不是Part-1-1是因为之前的装配体名字搞成MATRIX-1了。不过名字什么的无所谓。
import sys
sys.path.insert(8, r'e:/CAE/abaqus_plugins/EasyPBC V.1.4')
import easypbc
easypbc.feasypbc(part='Model-1', inst='MATRIX-1', meshsens=1E-07, CPU=1,
E11=True, E22=True, E33=False, G12=True, G13=False, G23=False,
onlyPBC=False, CTE=False, intemp=0, fntemp=100)
结束之后文件结果如图
一个简单的二次开发
对于本案例,改改纤维直径、材料属性参数就可以了
fiberR = 2
matrixE = 2000
matrixV = 0.4
fiberE = 220000
fiberV = 0.2
from abaqus import *
from abaqusConstants import *
session.Viewport(name='Viewport: 1', origin=(0.0, 0.0), width=250.050506591797,
height=145.686111450195)
session.viewports['Viewport: 1'].makeCurrent()
session.viewports['Viewport: 1'].maximize()
from caeModules import *
from driverUtils import executeOnCaeStartup
executeOnCaeStartup()
session.viewports['Viewport: 1'].partDisplay.geometryOptions.setValues(
referenceRepresentation=ON)
s = mdb.models['Model-1'].ConstrainedSketch(name='__profile__',
sheetSize=200.0)
g, v, d, c = s.geometry, s.vertices, s.dimensions, s.constraints
s.setPrimaryObject(option=STANDALONE)
s.rectangle(point1=(0.0, 0.0), point2=(10.0, 10.0))
p = mdb.models['Model-1'].Part(name='MATRIX', dimensionality=THREE_D,
type=DEFORMABLE_BODY)
p = mdb.models['Model-1'].parts['MATRIX']
p.BaseSolidExtrude(sketch=s, depth=10.0)
s.unsetPrimaryObject()
p = mdb.models['Model-1'].parts['MATRIX']
session.viewports['Viewport: 1'].setValues(displayedObject=p)
del mdb.models['Model-1'].sketches['__profile__']
p = mdb.models['Model-1'].parts['MATRIX']
f, e = p.faces, p.edges
t = p.MakeSketchTransform(sketchPlane=f[4], sketchUpEdge=e[7],
sketchPlaneSide=SIDE1, sketchOrientation=RIGHT, origin=(5.0, 5.0, 10.0))
s1 = mdb.models['Model-1'].ConstrainedSketch(name='__profile__',
sheetSize=34.64, gridSpacing=0.86, transform=t)
g, v, d, c = s1.geometry, s1.vertices, s1.dimensions, s1.constraints
s1.setPrimaryObject(option=SUPERIMPOSE)
p = mdb.models['Model-1'].parts['MATRIX']
p.projectReferencesOntoSketch(sketch=s1, filter=COPLANAR_EDGES)
s1.CircleByCenterPerimeter(center=(0.0, 0.0), point1=(fiberR, 0.0))
p = mdb.models['Model-1'].parts['MATRIX']
f1, e1 = p.faces, p.edges
p.SolidExtrude(sketchPlane=f1[4], sketchUpEdge=e1[7], sketchPlaneSide=SIDE1,
sketchOrientation=RIGHT, sketch=s1, depth=10.0, flipExtrudeDirection=ON,
keepInternalBoundaries=ON)
s1.unsetPrimaryObject()
del mdb.models['Model-1'].sketches['__profile__']
session.viewports['Viewport: 1'].partDisplay.setValues(sectionAssignments=ON,
engineeringFeatures=ON)
session.viewports['Viewport: 1'].partDisplay.geometryOptions.setValues(
referenceRepresentation=OFF)
mdb.models['Model-1'].Material(name='MATRIX')
mdb.models['Model-1'].materials['MATRIX'].Elastic(table=((matrixE, matrixV), ))
mdb.models['Model-1'].Material(name='FIBER')
mdb.models['Model-1'].materials['FIBER'].Elastic(table=((fiberE, fiberV), ))
mdb.models['Model-1'].HomogeneousSolidSection(name='FIBER-SEC',
material='FIBER', thickness=None)
mdb.models['Model-1'].HomogeneousSolidSection(name='MATRIX-SET',
material='MATRIX', thickness=None)
p = mdb.models['Model-1'].parts['MATRIX']
c = p.cells
cells = c.getSequenceFromMask(mask=('[#1 ]', ), )
region = p.Set(cells=cells, name='Set-1')
p = mdb.models['Model-1'].parts['MATRIX']
p.SectionAssignment(region=region, sectionName='FIBER-SEC', offset=0.0,
offsetType=MIDDLE_SURFACE, offsetField='',
thicknessAssignment=FROM_SECTION)
p = mdb.models['Model-1'].parts['MATRIX']
c = p.cells
cells = c.getSequenceFromMask(mask=('[#2 ]', ), )
region = p.Set(cells=cells, name='Set-2')
p = mdb.models['Model-1'].parts['MATRIX']
p.SectionAssignment(region=region, sectionName='MATRIX-SET', offset=0.0,
offsetType=MIDDLE_SURFACE, offsetField='',
thicknessAssignment=FROM_SECTION)
a = mdb.models['Model-1'].rootAssembly
session.viewports['Viewport: 1'].setValues(displayedObject=a)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(
optimizationTasks=OFF, geometricRestrictions=OFF, stopConditions=OFF)
a = mdb.models['Model-1'].rootAssembly
a.DatumCsysByDefault(CARTESIAN)
p = mdb.models['Model-1'].parts['MATRIX']
a.Instance(name='MATRIX-1', part=p, dependent=OFF)
session.viewports['Viewport: 1'].assemblyDisplay.setValues(mesh=ON)
session.viewports['Viewport: 1'].assemblyDisplay.meshOptions.setValues(
meshTechnique=ON)
a = mdb.models['Model-1'].rootAssembly
c1 = a.instances['MATRIX-1'].cells
pickedRegions = c1.getSequenceFromMask(mask=('[#3 ]', ), )
a.setMeshControls(regions=pickedRegions, elemShape=WEDGE)
a = mdb.models['Model-1'].rootAssembly
partInstances =(a.instances['MATRIX-1'], )
a.seedPartInstance(regions=partInstances, size=0.5, deviationFactor=0.1,
minSizeFactor=0.1)
a = mdb.models['Model-1'].rootAssembly
partInstances =(a.instances['MATRIX-1'], )
a.generateMesh(regions=partInstances)
session.viewports['Viewport: 1'].enableMultipleColors()
session.viewports['Viewport: 1'].setColor(initialColor='#BDBDBD')
cmap=session.viewports['Viewport: 1'].colorMappings['Material']
session.viewports['Viewport: 1'].setColor(colorMapping=cmap)
session.viewports['Viewport: 1'].disableMultipleColors()
import sys
sys.path.insert(8, r'e:/CAE/abaqus_plugins/EasyPBC V.1.4')
import easypbc
easypbc.feasypbc(part='Model-1', inst='MATRIX-1', meshsens=1E-07, CPU=1,
E11=True, E22=True, E33=False, G12=True, G13=False, G23=False,
onlyPBC=False, CTE=False, intemp=0, fntemp=100)
运行结果如下,可以看到结果有所不同
|