72. plugins.fe_abq
— Export finite element models in Abaqus™ input file format.¶
This module provides functions and classes to export finite element models
from pyFormex in the Abaqus™ input format (.inp).
The exporter handles the mesh geometry as well as model, node and element
properties gathered in a PropertyDB
database (see module
properties
).
While this module provides only a small part of the Abaqus input file format, it suffices for most standard jobs. While we continue to expand the interface, depending on our own necessities or when asked by third parties, we do not intend to make this into a full implementation of the Abaqus input specification. If you urgently need some missing function, there is always the possibility to edit the resulting text file or to import it into the Abaqus environment for further processing.
The module provides two levels of functionality: on the lowest level, there are functions that just generate a part of an Abaqus input file, conforming to the Abaqus™ Keywords manual.
Then there are higher level functions that read data from the property module and write them to the Abaqus input file and some data classes to organize all the data involved with the finite element model.
72.1. Classes defined in module plugins.fe_abq¶
- class plugins.fe_abq.Command(cmd, *args, **kargs)[source]¶
A class to format a keyword block in an INP file.
- Parameters:
cmd (str, required) – The Abaqus command. It can be just the keyword but can also contain already formatted options. It will be converted to upper case and put after an initial ‘*’ character.
options (str) – A string to be added to the command line after any other args and kargs keyword options have been formatted (even those added later with the
add()
method). If the string does not start with a comma, a ‘, ‘ will be interposed.data (list-like or list of tuple.) – Specifies the data to be put below the command line. A list of tuples will be formatted with one tuple per line. Any other data type will be transformed to a flat sequence and be formatted with maximum 8 values per line. Each individual item is converted to str type, so the data sequence may contain numerical (float or int) as well as string data.
extra (str) – A (possibly multiline) string to be added as is below the command and data. This can be used to add complete preformatted sections to the command output, possibly even other command blocks.
args (any other non-keyword arguments are added as options to the) – command line, after conversion to string and upper case.
kargs (any other keyword arguments are added to the command line as) – options of the form ‘KEY=value’. The keys are converted to upper case, the values are not.
Notes
After initial construction, the
add()
method can be used to add more parts to the command.There is no check whether a certain option contains multiple occurrences of the same option.
Examples
>>> cmd1 = Command('Key', 'material=plastic', options='material=steel', ... data=[1,2,3,4.0,'last'], ... extra='*AnotherKey, opt=optionalSet1,\n 1, 4.7') >>> cmd1.add(material='wood') >>> print(cmd1) *KEY, MATERIAL=PLASTIC, MATERIAL=wood, material=steel 1, 2, 3, 4.0, last *AnotherKey, opt=optionalSet1, 1, 4.7
- add(*args, **kargs)[source]¶
Add more parts to the Command.
This method takes all the parameters as the initializer, except for cmd. Specifying data will overwrite any previously defined data for the command. All other parameters will be added to the already existing.
- property out¶
The formatted command as a string
- class plugins.fe_abq.Output(kind='', vars='PRESELECT', set=None, typeset=None, type='FIELD', options='', extra='', variable=None, keys=None, *args, **kargs)[source]¶
A request for output to .odb.
Parameters:
type: ‘FIELD’ (default), ‘HISTORY’ or ‘’.
kind: string: one of ‘’, ‘N’, ‘NODE’, ‘E’, ‘ELEMENT’, ‘ENERGY’, ‘CONTACT’. ‘N’ and ‘E’ are abbreviations for ‘NODE’, ‘ELEMENT’, respectively.
vars: ‘ALL’, ‘PRESELECT’ or, if kind != None, a list of output identifiers compatible with the specified kind.
set: a single set name or a list of node/element set names. This can not be specified for kind==’’. If no set is specified, the default is ‘Nall’ for kind==’NODE’ and ‘Eall’ for kind==’ELEMENT’
typeset: string: it is equal to the corresponding abaqus parameter to identify the kind of set. If not specified, the default is the default is ‘NSET’ for kind==’NODE’ , ‘CONTACT’ and ‘ELSET’ for kind==’ELEMENT’ , ‘ENERGY’
options: (opt) options string to be added to the keyword line.
extra: (opt) extra string to be added below the keyword line and optional data.
Examples:
>>> out1 = Output(type='field') >>> print(out1.fmt()) *OUTPUT, FIELD, VARIABLE=PRESELECT >>> out0 = Output(vars=None) >>> out2 = Output(type='field', kind='e', vars=['S','SP']) >>> print(out0.fmt()+out2.fmt()) *OUTPUT, FIELD *ELEMENT OUTPUT, ELSET=Eall S, SP >>> out3 = Output(type='field', kind='e', vars=['S','SP'], set=['set1','set2']) >>> print(out0.fmt()+out3.fmt()) *OUTPUT, FIELD *ELEMENT OUTPUT, ELSET=set1 S, SP *ELEMENT OUTPUT, ELSET=set2 S, SP >>> out4 = Output(type='',diagnostic='yes') >>> print(out4.fmt()) *OUTPUT, DIAGNOSTIC=yes
- class plugins.fe_abq.Result(kind, keys, set=None, output='FILE', freq=1, time=False, **kargs)[source]¶
A request for output of results on nodes or elements.
Parameters:
kind: ‘NODE’ or ‘ELEMENT’ (first character suffices)
keys: a list of output identifiers (compatible with kind type)
set: a single item or a list of items, where each item is either a property number or a node/element set name for which the results should be written. If no set is specified, the default is ‘Nall’ for kind==’NODE’ and ‘Eall’ for kind=’ELEMENT’
output is either
FILE
(for .fil output) orPRINT
(for .dat output)(Abaqus/Standard only)freq is the output frequency in increments (0 = no output)
Extra keyword arguments are available: see the writeNodeResults and writeElemResults methods for details.
- class plugins.fe_abq.Step(analysis='STATIC', time=[0.0, 0.0, 0.0, 0.0], *, nlgeom=False, name=None, tags=None, out=[], res=[], options=None, heading=None, analysisOptions=None, extra=None)[source]¶
An elementary step in a simulation history.
In Abaqus, a step is the smallest logical entity in the simulation history. It is typically a time step in a dynamic simulation, but it can also describe different loading states in a (quasi-)static simulation.
Our Step class holds all the data describing the global step parameters. It combines the Abaqus ‘STEP’, ‘STATIC’, ‘DYNAMIC’ and ‘BUCKLE’ keyword commands (and even some more global parameter setting commands).
- Parameters:
analysis (str) – The analysis type: one of the values in
analysis_types
.name (str) – A name given to the step, for reference. It is added to the STEP command.
time (float | list of floats) –
The required parameters for the analysis type:
a single float value specifying the step time,
a list of 2 values (special cases with analysis=EXPLICIT)
a list of 4 values: time inc, step time, min. time inc, max. time inc (most of the other cases)
a list of 5 values (LANCZOS)
a list of 8 values (RIKS)
In most cases, only the step time needs to be specified.
nlgeom (bool) – If True, the analysis will be geometrically non-linear. Default is False and produces a linear analysis. Exceptions: for Analysis type ‘RIKS’, nlgeom is always set True, for ‘BUCKLE’ it is set False, ‘PERTURBATION’ ignores the
nlgeom
.tags (list of str) – A list of property tags to include in this step. If specified, only the property records having one of the listed values as their tag attribute will be included in this step.
out – Defines specific output records for this step (in addition to the global ones).
res – Defines specific result records for this step (in addition to the global ones).
options (str) – A string to be added on the STEP command
heading (str) – A (multiline) string to be added below the STEP command and before the analysis type command.
analysisOptions (str) – A multiline string to be added at the step level below the line with the analysis type command.
extra (str) – A multiline string to be added at the step level below the time data.
Examples
>>> import io >>> buf = io.StringIO() >>> from pyformex.plugins.properties import PropertyDB >>> P = PropertyDB() >>> step = Step('Dynamic', time=0.3, options=", inc=1000, unsymm=yes") >>> pf.verbosity = 0 # silence output >>> step.write(buf, P) >>> print(buf.getvalue()) *STEP, inc=1000, unsymm=yes *DYNAMIC 0.0, 0.3, 0.0, 0.0 *END STEP
- write(fil, propDB, out=[], res=[], resfreq=1, timemarks=False)[source]¶
Write a simulation step.
propDB is the properties database to use.
Except for the step data itself, this will also write the passed output and result requests. out is a list of Output-instances. res is a list of Result-instances. resfreq and timemarks are global values only used by Explicit
- class plugins.fe_abq.AbqData(model, prop, nprop=None, eprop=None, steps=[], res=[], out=[], initial=None, eofs=1, nofs=1, extra='')[source]¶
A class collecting all data required to write the Abaqus input file.
- Parameters:
model (
FEModel
) – The FEModel representing the geometry of the problem. This is a Finite Element discretization of the real geometry.prop (
plugins.properties.PropertyDB
) – The database containing all physical properties (materials, loads, boundary conditions) pretaining to the FEModel.nprop (int array-like) – The node property numbers to be used for by-prop properties.
eprop (int array-like) – The element property numbers to be used for by-prop properties.
steps (list of Step) – A list of load/boundary conditions to be applied to the model.
res (list of Result) – A list of result requests to be applied on all steps.
out (list of Output) – A list of output requests to be applied on all steps.
initial (str or list) – A tag or a list of initial data, such as boundary conditions, that will be applied as initial conditions (i.e. before the first step is applied. The default is to apply ALL boundary conditions initially. Specify a (possibly non-existing) tag to override the default.
eofs (int) – An offset for the element numbering. Default value is 1.
nofs (int) – An offset for the node numbering. Default value is 1.
extra (str) – A (multiline) string to be added to the .inp file at the model level.
- write(jobname=None, group_by_eset=True, group_by_group=False, subsets=True, comment=None, header='', create_part=False)[source]¶
Write an Abaqus input (INP) file.
jobname: relative or absolute path name of the exported Abaqus INP file. If the name does not end in ‘.inp’, this extension will be appended. If no name is specified, the output is written to sys.stdout.
comment: A text to be included at the top of the INP file, right after the ‘created by pyFormex’ line. The text can be a multiline string or a function returning such string. Any other object will be dumped to a string in JSON format. All lines of the resulting text are prepended with ‘** ‘ before inclusion in the INP file, so Abaqus will recognize them as comments.
header: A text like comments, but this one will be inserted in the header section of the INP file, and not marked as comments. This is commonly used to add information that should appear in the result files.
create_part : if True, the model will be created as an Abaqus Part, followed by an assembly of that part.
72.2. Functions defined in module plugins.fe_abq¶
- plugins.fe_abq.abqInputNames(job)[source]¶
Returns corresponding jobname and input filename.
- Parameters:
job (str or Path) – The job name or input file name, with or without a directory part, with or without a suffix ‘.inp’.
- Returns:
jobname (str) – The basename of job, without the suffix (stem).
filename (Path) – The absolute path name of the input file.
Examples
>>> jobname, filename = abqInputNames('myjob.inp') >>> jobname, filename.relative_to(Path.cwd()) ('myjob', Path('myjob.inp')) >>> jobname, filename = abqInputNames('/home/user/mydict/myjob.inp') >>> print(jobname, filename) myjob /home/user/mydict/myjob.inp >>> jobname, filename = abqInputNames('mydict/myjob') >>> jobname, filename.relative_to(Path.cwd()) ('myjob', Path('mydict/myjob.inp'))
- plugins.fe_abq.fmtData2d(data, linesep='\n')[source]¶
Format 2D data.
- Parameters:
Examples
>>> print(fmtData2d([('set0', 1, 5.0),('set1', 2, 10.0)])) set0, 1, 5.0 set1, 2, 10.0
- plugins.fe_abq.fmtData(data, linesep='\n')[source]¶
Format the data part of a command.
- Parameters:
data (list of tuples | 2D array | 1D array_like) – The data to be formatted below the command line. If data is a list of tuples or a 2D array, each item/row of data is formatted on a separate line. Any other data will be formatted as a 1D sequence with 8 items per line.
linesep (str) – Separator between lines of data.
Examples
>>> print(fmtData([1,2,3,4.0,'last'])) 1, 2, 3, 4.0, last >>> print(fmtData([(1,2),(3,4.0,'last')])) 1, 2 3, 4.0, last
- plugins.fe_abq.fmtOption(key, value)[source]¶
Format a single command option.
- Parameters:
- Returns:
str – A string ‘, KEY=value’ or just ‘, KEY’ if value is an empty string. The key is converted to upper case and underscores in the key are replaced with blanks.
Examples
>>> fmtOption('key', 'value') ', KEY=value' >>> fmtOption('two_words', '') ', TWO WORDS'
- plugins.fe_abq.fmtOptions(**kargs)[source]¶
Format the options of an Abaqus command line.
Each key,value pair in the argument list is formated into a string ‘KEY=value’, or just ‘KEY’ if the value is an empty string. The key is always converted to upper case, and any underscore in the key is replaced with a space. The resulting strings are joined with ‘, ‘ between them.
- Returns:
str – A comma-separated string of ‘key’ or ‘key=value’ fields. The string has a leading but no trailing comma.
Notes
If you specified two arguments whose key only differs by case, both will appear in the output with the same key. Also note that the order in which the options appear is unspecified.
Examples
>>> print(fmtOptions(var_a = 123., var_B = '123.', Var_C = '')) , VAR A=123.0, VAR B=123., VAR C
- plugins.fe_abq.fmtKeyword(keyword, options='', data=None, extra='', **kargs)[source]¶
Format a keyword block in an Abaqus .inp file.
- Parameters:
keyword (str) – The command keyword, possibly also including options.
options (str) –
- A string to be added to the command as is. If it does not start with
a comma, ‘, ‘ is prepended.
- kargs:
Individual options to be added. Each option has the form key=value, where value may be a str or numeric. All these arguments are formatted with
fmtOptions()
and then appended to the command.
data – Data for the command. The data are formatted with
fmtData()
and the resulting string is added below the command line.extra (str) – A string that is added as is below the command and data lines.
- Returns:
str – A multiline string containing a full Abaqus command block.
Notes
The keyword may contain preformated options. See Examples.
Examples
>>> print(fmtKeyword('keyword', option_1='', option_2=1.e2, ... options=', more options=default', ... data=range(10), extra='a line with more data')) *KEYWORD, OPTION 1, OPTION 2=100.0, more options=default 0, 1, 2, 3, 4, 5, 6, 7 8, 9 a line with more data >>> print(fmtKeyword('keyword, with option=5')) *KEYWORD, WITH OPTION=5
- plugins.fe_abq.fmtWatermark()[source]¶
Format the pyFormex watermark.
The pyFormex watermark contains the version used to create the output. This is always written as the first line(s) of the output file.
Examples
>>> print(fmtWatermark()) ** Abaqus input file created by pyFormex 3.4 (http://pyformex.org) ** ...
- plugins.fe_abq.fmtComment(text=None)[source]¶
Format the initial comment section.
- Parameters:
text (str) – A multiline string that is added as comment at the start of the output file, directly after the
fmtWatermark()
.
Examples
>>> print(fmtComment("This is a comment\n of two lines.")) **This is a comment ** of two lines.
- plugins.fe_abq.fmtHeading(text='')[source]¶
Format the HEADING command.
- Parameters:
text (str) – A multiline string that is added as data to the HEADING command.
Examples
>>> print(fmtHeading("This is the heading")) ** *HEADING This is the heading
- plugins.fe_abq.fmtSectionHeading(text='')[source]¶
Format a section heading of the Abaqus input file.
Section headings are comments that are inserted to visually separate specific parts of the INP file.
- Parameters:
text (str) – A short string that is printed as section heading.
Examples
>>> print(fmtSectionHeading('NODES')) ** ** NODES **
- plugins.fe_abq.fmtPart(name='')[source]¶
Format a PART command.
- Parameters:
name (str) – The part name.
Examples
>>> print(fmtPart('NODES')) *PART, name=NODES
- plugins.fe_abq.fmtMaterial(mat)[source]¶
Format a MATERIAL command.
- Parameters:
mat (dict) – Material properties. See Notes.
Notes
The mat dict recognizes the following keys. Optional keys are labeled (opt):
name: if specified, and a material with this name has already been written, this function does nothing.
elasticity: one of ‘LINEAR’, ‘HYPERELASTIC’, ‘ANISOTROPIC HYPERELASTIC’, ‘USER’ or another string specifying a valid material command. Default is ‘LINEAR’. Defines the elastic behavior class of the material. The required and recognized keys depend on this parameter (see below).
constants : list of floats or None. The material constants to be used in the model. For ‘LINEAR’ elasticity, these may alternatively be specified by other keywords (see below).
options (opt): string: will be added to the material command as is.
extra (opt): (multiline) string: will be added to the material data as is.
plastic (opt): arraylike, float, shape (N,2). Definition of the material plasticity law. Each row contains a tuple of a yield stress value and the corresponding equivalent plastic strain.
damping (opt): tuple (alpha,beta). Adds damping into the material. See Abaqus manual for the meaning of alpha and beta. Either of them can be a float or None.
field (opt): boolean. If True, a keyword “USER DEFINED FIELD” is added.
Recognized keys depending on model:
‘LINEAR’: allows the specification of the material constants using the following keys:
young_modulus: float
shear_modulus (opt): float
poisson_ratio (opt): float: if not specified, it is calculated from the above two values.
‘HYPERELASTIC’: has a required key ‘model’:
model: one of ‘OGDEN’, ‘POLYNOMIAL’ or ‘REDUCED POLYNOMIAL’. The number of constants to be specified depends on the model and the order. The temperature should not be included in the temperature.
order (opt): order of the model. If omitted, it is calculated from the number of constants specified.
temp (opt): temperature at which these constants are valid. If omitted, temperature is set to 0.0 degrees.
testdata (opt): list. The first item of the list is one of ‘UNIFORM’, ‘PLANAR’, BIAXIAL’. The second item of the list is the array of values of the test data shaped as they should be written in the input file. The third item is optional. It is a an integer representing the smooth factor of the data (see Abaqus manual).
‘ANISOTROPIC HYPERELASTIC’: has a required key ‘model’:
model: one of ‘FUNG-ANISOTROPIC’, ‘FUNG-ORTHOTROPIC’, ‘HOLZAPFEL’ or ‘USER’.
depvar (opt): see below (‘USER’)
localdir (opt): int: number of local directions.
‘USER’:
depvar (opt): list. The first item in the list is the number of solution dependent variables. Further items are optional and are to specify output names for (some of) solution dependent state variables. Each item is a tuple of a variable number and the corresponding variable name. See the examples below.
Examples
>>> steel = { ... 'name': 'steel', ... 'young_modulus': 207000, ... 'poisson_ratio': 0.3, ... 'density': 7.85e-9, ... 'plastic': [(200.,0.), (900.,0.5)], ... } >>> from pyformex.attributes import Attributes >>> print(fmtMaterial(Attributes(steel))) *MATERIAL, NAME=steel *ELASTIC 207000.0, 0.3 *DENSITY 7.85e-09 *PLASTIC 200.0, 0.0 900.0, 0.5
>>> intima = { ... 'name': 'intima', ... 'density': 0.1, ... 'elasticity':'hyperelastic', ... 'model':'reduced polynomial', ... 'constants': [6.79E-03, 5.40E-01, -1.11, 10.65, -7.27, 1.63, ... 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ... } >>> print(fmtMaterial(Attributes(intima))) *MATERIAL, NAME=intima *HYPERELASTIC, REDUCED POLYNOMIAL, N=6 0.00679, 0.54, -1.11, 10.65, -7.27, 1.63, 0.0, 0.0 0.0, 0.0, 0.0, 0.0, 0.0 *DENSITY 0.1
>>> nitinol = { ... 'name': 'ABQ_SUPER_ELASTIC_N3D', ... 'elasticity': 'user', ... 'density': 6.5e-9, ... 'depvar' : [24, (1,'VAR1'), (3,'DAMAGE')], ... 'constants' : [10000., 0.3, 5000, 0.3, 0.03, 6.5, 200., 300., ... 0.0, 6.5, 260., 100.,0., 0.03, ] ... } >>> print(fmtMaterial(Attributes(nitinol))) *MATERIAL, NAME=ABQ_SUPER_ELASTIC_N3D *DEPVAR 24 1, VAR1 3, DAMAGE *USER MATERIAL, CONSTANTS=14 10000.0, 0.3, 5000, 0.3, 0.03, 6.5, 200.0, 300.0 0.0, 6.5, 260.0, 100.0, 0.0, 0.03 *DENSITY 6.5e-09
>>> material = { ... 'name': 'GDS_metal', ... 'elasticity': 'linear', ... 'young_modulus': 200000., ... 'poisson_ratio': 0.3, ... 'density': 8.55E-09, ... 'extra': '''*PLASTIC, Hardening=Combined ... 500.0, 0.0 ... 10500.0, 4.0 ... *Cyclic Hardening, Parameters ... 500., 3000., 0.4'''} >>> print(fmtMaterial(Attributes(material))) *MATERIAL, NAME=GDS_metal *ELASTIC 200000.0, 0.3 *DENSITY 8.55e-09 *PLASTIC, Hardening=Combined 500.0, 0.0 10500.0, 4.0 *Cyclic Hardening, Parameters 500., 3000., 0.4
- plugins.fe_abq.fmtAnySection(section, setname)[source]¶
Generic documentation for all fmt…SECTION functions.
All the fmt…SECTION functions have the following parameters.
- Parameters:
section (dict) –
Section properties. The following generic keys from the class:Command are recognized:
options: string to add to the command line
extra: string to add below the command line and its data
The specific keys for each fmt…SECTION function are listed in the Notes section for that function.
setname (str) – Element set name to which these section properties are to be applied.
- plugins.fe_abq.fmtSolidSection(section, setname)[source]¶
Format a SOLID SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
matname
orientation
thickness
Examples
>>> sec1 = dict(matname='steel',thickness=0.12) >>> from pyformex.attributes import Attributes >>> print(fmtSolidSection(Attributes(sec1),'section1')) *SOLID SECTION, ELSET=section1, MATERIAL=steel 0.12
- plugins.fe_abq.fmtSolid2dSection(section, setname)¶
Format a SOLID SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
matname
orientation
thickness
Examples
>>> sec1 = dict(matname='steel',thickness=0.12) >>> from pyformex.attributes import Attributes >>> print(fmtSolidSection(Attributes(sec1),'section1')) *SOLID SECTION, ELSET=section1, MATERIAL=steel 0.12
- plugins.fe_abq.fmtSolid3dSection(section, setname)¶
Format a SOLID SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
matname
orientation
thickness
Examples
>>> sec1 = dict(matname='steel',thickness=0.12) >>> from pyformex.attributes import Attributes >>> print(fmtSolidSection(Attributes(sec1),'section1')) *SOLID SECTION, ELSET=section1, MATERIAL=steel 0.12
- plugins.fe_abq.fmtShellSection(section, setname)[source]¶
Format a SHELL SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
matname
thickness
offset (opt): for contact surface SPOS or 0.5, SNEG or -0.5
transverseshearstiffness (opt):
poisson (opt): ?? CLASH WITH MATERIAL ??
thicknessmodulus (opt):
- plugins.fe_abq.fmtMembraneSection(section, setname)[source]¶
Format a MEMBRANE SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
matname
thickness: float
- plugins.fe_abq.fmtSurfaceSection(section, setname)[source]¶
Format a SURFACE SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
matname
density (opt): float
- plugins.fe_abq.fmtBeamSection(section, setname)[source]¶
Format a BEAM SECTION or BEAM GENERAL SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
matname, optional: if specified, a BEAM SECTION is formatted, else, a BEAM GENERAL SECTION (see
fmtGeneralBeamSection()
)sectiontype: ‘ARBITRARY’, ‘BOX’, ‘CIRC’, ‘HEX’, ‘I’, ‘L’, ‘PIPE’, ‘RECT’, ‘TRAPEZOID’ or ‘ELBOW’
data: list of tuples: data corresponding with the sectiontype.
poisson
transverseshearstiffness
See also
fmtGeneralBeamSection
formats the BEAM GENERAL SECTION
- plugins.fe_abq.fmtGeneralBeamSection(section, setname)[source]¶
Format a BEAM GENERAL SECTION command.
This specifies a beam section when numerical integration over the section is not required and the material constants are specified directly. See also func:fmtBeamSection.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
all sectiontypes:
sectiontype (opt): ‘GENERAL’ (default), ‘CIRC’ or ‘RECT’
data (opt): list of tuples: section data (see Abaqus Manual). For some sections, the data may be specified by other arguments instead (see below). In those cases data should not be used.
density (opt): density of the material (required in Abaqus/Explicit)
transverseshearstiffness (opt):
sectiontype GENERAL:
cross_section
moment_inertia_11
moment_inertia_12
moment_inertia_22
torsional_constant
sectiontype CIRC:
radius
sectiontype RECT:
width, height
sectiontype GENERAL, CIRC or RECT:
orientation (opt): a vector with the direction cosines of the 1 axis
young_modulus
shear_modulus or poisson_ratio
- plugins.fe_abq.fmtFrameSection(section, setname)[source]¶
Format a FRAME SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
all sectiontypes:
sectiontype (opt): ‘GENERAL’ (default), ‘CIRC’ or ‘RECT’
young_modulus
shear_modulus
density (opt): density of the material
yield_stress (opt): yield stress of the material
orientation (opt): a vector with the direction cosines of the 1 axis
sectiontype GENERAL:
cross_section
moment_inertia_11
moment_inertia_12
moment_inertia_22
torsional_constant
sectiontype CIRC:
radius
sectiontype RECT:
width
height
- plugins.fe_abq.fmtTrussSection(section, setname)[source]¶
Format a TRUSS SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
all sectiontypes:
sectiontype (opt): ‘GENERAL’ (default), ‘CIRC’ or ‘RECT’
material
sectiontype GENERAL:
cross_section
sectiontype CIRC:
radius
sectiontype RECT:
width
height
- plugins.fe_abq.fmtConnectorSection(section, setname)[source]¶
Format a CONNECTOR SECTION command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
sectiontype: ‘JOIN’, ‘HINGE’, …
behavior (opt): connector behavior name
orientation (opt): connector orientation
elimination (opt): ‘NO’ (default), ‘YES’
Examples
>>> from pyformex.attributes import Attributes >>> orientation = { ... 'name': 'radial2', ... 'definition': 'coordinates', ... 'system': 'cylindrical', ... 'a': (0.0, 0.0, 0.0), ... 'b': (0.0, 0.0, 1.0), ... 'extra': '3, 90.0', ... } >>> print(fmtOrientation([Attributes(orientation)])) *ORIENTATION, NAME=RADIAL2, DEFINITION=COORDINATES, SYSTEM=CYLINDRICAL 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 3, 90.0 >>> connector = { ... 'name': 'connector', ... 'sectiontype': 'UJOINT', ... 'extra' : 'radial2', ... } >>> print(fmtConnectorSection(Attributes(connector), 'connset')) *CONNECTOR SECTION, ELSET=connset UJOINT radial2
- plugins.fe_abq.fmtSpringOrDashpot(section, setname, eltype)[source]¶
Format a SPRING or DASHPOT command.
This is a utilitarian function for
fmtSpringSection()
andfmtDashpotSection()
.- Parameters:
See also
- plugins.fe_abq.fmtSpringSection(section, setname)[source]¶
Shorthand for fmtSpringOrDashpot(“SPRING”, section, setname)
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
stiffness: float: sprong stiffness
- plugins.fe_abq.fmtDashpotSection(section, setname)[source]¶
Shorthand for fmtSpringOrDashpot(“SPRING”, section, setname)
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
stiffness: float: dashpot stiffness
- plugins.fe_abq.fmtMassSection(section, setname)[source]¶
Format a MASS command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
mass: float: mass magnitude
Examples
>>> from pyformex.plugins.properties import ElemSection >>> es = ElemSection(name='mass', sectiontype='MASS', mass=1.E-6, ... options=', ALPHA = 1e3') >>> print(fmtMassSection(es, 'SETNAME')) *MASS, ELSET=SETNAME, ALPHA = 1e3 1e-06
- plugins.fe_abq.fmtInertiaSection(section, setname)[source]¶
Format a ROTARY INERTIA command.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
inertia: list of six floats: [I11, I22, I33, I12, I13, I23]
- plugins.fe_abq.fmtRigidSection(section, setname)[source]¶
Format rigid body sectiontype.
Parameters: see
fmtAnySection()
Notes
Recognized specific keys:
refnode: string (set name) or integer (node number)
density (opt): float:
density (opt): float:
- plugins.fe_abq.fmtTransform(csys, setname)[source]¶
Format a coordinate transform for the given set.
- Parameters:
csys (CoordSystem) – The target coordinates system of the transform.
setname (str) – Node set name to which this transform is applied.
- plugins.fe_abq.fmtOrientation(prop)[source]¶
Format an orientation.
Optional:
definition
system: coordinate system
a: a first point
b: a second point
Examples
>>> from pyformex.attributes import Attributes >>> orientation = Attributes({ ... 'name': 'radial2', ... 'definition': 'coordinates', ... 'system': 'cylindrical', ... 'a': (0.0, 0.0, 0.0), ... 'b': (0.0, 0.0, 1.0), ... 'extra': '3, 90.0', ... }) >>> print(fmtOrientation([orientation])) *ORIENTATION, NAME=RADIAL2, DEFINITION=COORDINATES, SYSTEM=CYLINDRICAL 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 3, 90.0
- plugins.fe_abq.fmtSurface(prop)[source]¶
Format the surface definitions.
- Parameters:
prop (a property record containing the key surftype.) –
Notes
The following keys in the property record are recognized:
set: string, list of strings or list of integers:
string : name of an existing set.
list of integers: list of elements/nodes of the surface.
list of strings: list of existing set names.
name: string. The surface name.
- surftype: string. Can assume values ‘ELEMENT’ or ‘NODE’ , other abaqus
surface types or an empty string for special cases that do not need a
label (opt): string, or a list of strings storing the abaqus face or edge identifier. It is only required for surftype == ‘ELEMENT’.
options (opt): a string that is added as is to the command line.
Examples
>>> PDB = PropertyDB() >>> p = PDB.Prop(set='quad_set', name='quad_surface', surftype='element', ... label='SPOS') >>> print(fmtSurface(p)) *SURFACE, NAME=QUAD_SURFACE, TYPE=ELEMENT quad_set, SPOS
Specifying a surface from already existing sets of brick elements using different label identifiers per each set
>>> p = PDB.Prop(set=['hex_set1', 'hex_set2'] ,name='quad_surface', ... surftype='element',label=['S1','S2']) >>> print(fmtSurface(p)) *SURFACE, NAME=QUAD_SURFACE, TYPE=ELEMENT hex_set1, S1 hex_set2, S2
Use different identifiers for the different elements in the surface
>>> p = PDB.Prop(name='mysurf', set=[0,1,2,6], surftype='element', ... label=['S1','S2','S1','S3']) >>> print(fmtSurface(p)) *SURFACE, NAME=MYSURF, TYPE=ELEMENT 1, S1 2, S2 3, S1 7, S3
- plugins.fe_abq.fmtAnalyticalSurface(prop)[source]¶
Format the analytical surface rigid body.
Required:
nodeset: refnode.
name: the surface name
surftype: ‘ELEMENT’ or ‘NODE’
label: face or edge identifier (only required for surftype = ‘NODE’)
Example:
P.Prop(name='AnalySurf', nodeset = 'REFNOD', analyticalsurface='')
- plugins.fe_abq.fmtSurfaceInteraction(prop)[source]¶
Format the interactions.
Required:
name
Optional:
cross_section (for node based interaction)
friction : friction coeff or ‘rough’
surface behavior: no separation
surface behavior: pressureoverclosure
- plugins.fe_abq.fmtContact(prop)[source]¶
Format a contact property record.
Parameters:
prop: a Property record having a key ‘contact’
Recognized keys:
contact: string, one of ‘GENERAL’ or ‘PAIR’
interaction: string, the name of a surface interaction
For ‘GENERAL’ contact:
include: tuple or list of tuples (surf1,surf2). surf1 and surf2 are the names of defined surfaces or an empty string. If surf1 is empty, a surface containing all exterior surfaces defined in the model is used. If surf2 is empty, it is equal to surf1 a case of self-contact results. If both are empty, self contact between all surfaces is modeled.
exclude (opt): tuple or list of tuples (surf1,surf2). Specifies names of surfaces on which no contact is to be modeled.
For ‘PAIR’ contact:
include: tuple or list of tuples (slave,master). slave and master are the names of defined surfaces. Each tuple can optionally contain one or two more values, with the orientation of the tangential slip directions for the slave, resp. master surface. They are strings with the name of defined orientations.
Examples
>>> PDB = PropertyDB() >>> p1 = PDB.Prop(contact='pair',include=('s1','m1'),interaction='i1') >>> print(fmtContact(p1)) *CONTACT PAIR, INTERACTION=I1 s1, m1
>>> p2 = PDB.Prop(contact='pair',include=[('s1','m1'),('s2','m2')],interaction='i1') >>> print(fmtContact(p2)) *CONTACT PAIR, INTERACTION=I1 s1, m1 s2, m2
>>> g1 = PDB.Prop(contact='general',include=('s1','m1'),interaction='i1') >>> print(fmtContact(g1)) *CONTACT *CONTACT INCLUSIONS s1, m1 *CONTACT PROPERTY ASSIGNMENT s1, m1, i1
>>> g2 = PDB.Prop(contact='general',include=[('s1','m1'),('s2','m2')], ... interaction='i1') >>> print(fmtContact(g2)) *CONTACT *CONTACT INCLUSIONS s1, m1 s2, m2 *CONTACT PROPERTY ASSIGNMENT s1, m1, i1 s2, m2, i1
- plugins.fe_abq.fmtContactPair(prop)[source]¶
Format the contact pair.
Required:
master: master surface
slave: slave surface
interaction: interaction properties : name or Dict
Example:
P.Prop(name='contact0',interaction=Interaction(name ='contactprop', surfacebehavior=True, pressureoverclosure=['hard','linear',0.0, 0.0, 0.001]), master ='quadtubeINTSURF1', slave='hexstentEXTSURF', contacttype='NODE TO SURFACE')
- plugins.fe_abq.fmtConstraint(prop)[source]¶
Format Tie constraint
Required:
name
adjust (yes or no)
slave
master
Optional:
type (surf2surf, node2surf)
positiontolerance
no rotation
tiednset (it cannot be used in combination with positiontolerance)
Example:
P.Prop(constraint='1', name = 'constr1', adjust = 'no', master = 'hexstentbarSURF', slave = 'hexstentEXTSURF',type='NODE TO SURFACE')
- plugins.fe_abq.fmtInitialConditions(prop)[source]¶
Format initial conditions
The following keys in the property record are required:
type
nodes
data
Examples
>>> PDB = PropertyDB() >>> p = PDB.Prop(initialcondition='', nodes ='Nall', ... type = 'TEMPERATURE', data = 37.) >>> print(fmtInitialConditions([p])) *Initial Conditions, type = TEMPERATURE Nall,37.00
- plugins.fe_abq.fmtEquation(prop)[source]¶
Format multi-point constraint using an equation
- Parameters:
prop (a property record containing the key equation.) –
Notes
The following keys in the property record are required:
equation: list of tuples (node,dof,coeff), where
node: is a node number or node set name
dof: is the number of the degree of freedom (0 based)
coeff: is the coefficient for this variable in the equation
Examples
>>> PDB = PropertyDB() >>> eq1 = PDB.Prop(equation=[(9,1,1.),(32,2,-1.)]) >>> eq2 = PDB.Prop(equation=[('seta',0,1)])
The first equation forces the Z-displacement of node 32 to be equal to the Y-displacement of node 9. The second forces the sum of the X-displacement of all nodes in node set ‘seta’ to be equal to zero.
>>> print(fmtEquation(eq1)+fmtEquation(eq2)) *EQUATION 2 10, 2, 1.0 33, 3, -1.0 *EQUATION 1 seta, 1, 1
- plugins.fe_abq.fmtMass(prop)[source]¶
Format a MASS command.
Required:
mass: float: mass magnitude
set: name of the element set on which mass is applied
- plugins.fe_abq.fmtInertia(prop)[source]¶
Format rotary inertia
Required:
inertia : inertia tensor i11, i22, i33, i12, i13, i23
set : name of the element set on which inertia is applied
- plugins.fe_abq.fmtBoundary(prop)[source]¶
Format nodal boundary conditions.
prop is a node property record having the ‘bound’ key.
Recognized keys:
bound : either of:
a string, representing a standard set of boundary conditions
a list of 6 integer values (0 or 1) corresponding with the 6 degrees of freedom UX,UY,UZ,RX,RY,RZ. The dofs corresponding to the 1’s will be restrained (given a value 0.0).
a list of tuples (dofid, value) : this allows for nonzero boundary values to be specified. NOTE: this can also be achieved by a ‘displ’ keyword (see writeDisplacements) and that is the prefered way of specifying nonzero boundary conditions.
op (opt): ‘MOD’ (default) or ‘NEW’. By default, the boundary conditions are applied as a modification of the existing boundary conditions, i.e. initial conditions and conditions from previous steps remain in effect. The user can set op=’NEW’ to remove the previous conditions. This will remove ALL conditions of the same type.
ampl (opt): string: specifies the name of an amplitude that is to be multiplied with the values to have the time history of the variable. Only relevant if bound specifies nonzero values. Its use is discouraged (see above).
options (opt): string that is added as is to the command line.
Examples:
# The following are quivalent P.nodeProp(tag='init',set='setA',name='pinned_nodes',bound='pinned') P.nodeProp(tag='init',set='setA',name='pinned_nodes',bound=[1,1,1,0,0,0]) # this is possible, but discouraged P.nodeProp(tag='init',set='setB',name='forced_displ',bound=[(1,3.0)]) # it is better to use: P.nodeProp(tag='step0',set='setB',name='forced_displ',displ=[(1,3.0)])
- plugins.fe_abq.writeSection(fil, prop)[source]¶
Write an element section.
prop is an element property record with a section and eltype attribute
- plugins.fe_abq.writeNodes(fil, nodes, name='Nall', nofs=1)[source]¶
Write nodal coordinates.
The nodes are added to the named node set. If a name different from ‘Nall’ is specified, the nodes will also be added to a set named ‘Nall’. The nofs specifies an offset for the node numbers. The default is 1, because Abaqus numbering starts at 1.
- plugins.fe_abq.writeElems(fil, elems, type, name='Eall', eid=None, eofs=1, nofs=1, create_Eall=True)[source]¶
Write element group of given type.
elems is the list with the element node numbers. The elements are added to the named element set. If a name different from ‘Eall’ is specified, the elements will also be added to a set named ‘Eall’. The eofs and nofs specify offsets for element and node numbers. The default is 1, because Abaqus numbering starts at 1. If eid is specified, it contains the element numbers increased with eofs.
- plugins.fe_abq.writeSet(fil, type, name, set, ofs=1)[source]¶
Write a named set of nodes or elements (type=NSET|ELSET)
set : an ndarray. set can be a list of node/element numbers, in which case the ofs value will be added to them, or a list of names the name of another already defined set.
- plugins.fe_abq.writeDistribution(fil, prop)[source]¶
Write a distribution table.
Parameters:
prop: a Property record having with the key distribution.
Recognized keys:
distribution: string. Name of the distribution.
location:string. can assume values ‘ELEMENT’,’NODE’ or ‘NONE’
- table: arraylike. The array needs to be passed as should be written in the
abaqus data line. Every row is a new line and it is in the form [element_or_node_number,data1,data2, …]. NB For the first line used in Abaqus as default, the element_or_node_number should be an empty string.
- format: list of strings. Every string is an abaqus word to be used
in the distribution table. See Abaqus documentation for allowed words.
options (opt): string that is added as is to the command line.
The name of the distribution table (required) is derived from the name of the distribution.
- plugins.fe_abq.writeDisplacements(fil, prop, btype)[source]¶
Write prescribed displacements, velocities or accelerations
Parameters:
prop is a list of node property records containing one (or more) of the keys ‘displ’, ‘veloc’ ‘accel’.
btype is the boundary type: one of ‘displacement’, ‘velocity’ or ‘acceleration’
Recognized property keys:
displ, veloc, accel: each is optional and is a list of tuples (dofid, value), for respectively the displacement, velocity or acceleration. A special value ‘reset’ may also be specified to reset the prescribed condition for these variables.
op (opt): ‘MOD’ (default) or ‘NEW’. By default, the boundary conditions are applied as a modification of the existing boundary conditions, i.e. initial conditions and conditions from previous steps remain in effect. The user can set op=’NEW’ to remove the previous conditions. This will remove ALL conditions of the same type.
ampl (opt): string: specifies the name of an amplitude that is to be multiplied with the values to have the time history of the variable.
options (opt): string that is added to the command line.
- plugins.fe_abq.fmtLoad(key, prop)[source]¶
Format a load input block.
Parameters:
key: load type, one of: ‘cload’, ‘dload’ or ‘dsload’
prop: a node property record containing the specified key.
Recognized keys: - op (opt): string: ‘MOD’ or ‘NEW’. See func:writeDisplacements. - ampl (opt): string: amplitude name. See func:writeDisplacements. - options (opt): string: see func:fmtKeyWord - extra (opt): string: see func:fmtKeyWord
For load type ‘cload’:
set: node set on which to apply the load
cload: list of tuples (dofid, magnitude)
For load type ‘dload’:
set: element set on which to apply the load
dload: ElemLoad or data
For load type ‘dsload’:
surface: string: name of surface on which to apply the load
dsload: ElemLoad or data
- plugins.fe_abq.writeAmplitude(fil, prop)[source]¶
Write Amplitude.
Parameters:
-prop: list of property records having an attribute amplitude.
Recognized keys:
name: string. The name of the amplitude.
amplitude: class Amplitude (see plugins.property).
options (opt): string that is added as is to the command line.
Examples:
P=PropertyDB() t=[0,1] a=[0,0.5] amp = Amplitude(data=np.column_stack([t,a])) P.Prop(amplitude=amp,name=’ampl1’,options=’definition=TABULAR,smooth=0.1’)
- plugins.fe_abq.writeNodeResult(fil, kind, keys, set='Nall', output='FILE', freq=1, globalaxes=False, lastmode=None, summary=False, total=False)[source]¶
Write a request for nodal result output to the .fil or .dat file.
keys: a list of NODE output identifiers
set: a single item or a list of items, where each item is either a property number or a node set name for which the results should be written
output is either
FILE
(for .fil output) orPRINT
(for .dat output)(Abaqus/Standard only)freq is the output frequency in increments (0 = no output)
Extra arguments:
globalaxes: If ‘YES’, the requested output is returned in the global axes. Default is to use the local axes wherever defined.
Extra arguments for output=``PRINT``:
summary: if True, a summary with minimum and maximum is written
total: if True, sums the values for each key
‘Remark that the kind argument is not used, but is included so that we can easily call it with a Results dict as arguments.’
- plugins.fe_abq.writeElemResult(fil, kind, keys, set='Eall', output='FILE', freq=1, pos=None, summary=False, total=False)[source]¶
Write a request for element result output to the .fil or .dat file.
keys: a list of ELEMENT output identifiers
set: a single item or a list of items, where each item is either a property number or an element set name for which the results should be written
output is either
FILE
(for .fil output) orPRINT
(for .dat output)(Abaqus/Standard only)freq is the output frequency in increments (0 = no output)
Extra arguments:
pos: Position of the points in the elements at which the results are written. Should be one of:
‘INTEGRATION POINTS’ (default)
‘CENTROIDAL’
‘NODES’
‘AVERAGED AT NODES’
Non-default values are only available for ABAQUS/Standard.
Extra arguments for output=’PRINT’:
summary: if True, a summary with minimum and maximum is written
total: if True, sums the values for each key
Remark: the
kind
argument is not used, but is included so that we can easily call it with a Results dict as arguments
- plugins.fe_abq.writeFileOutput(fil, resfreq=1, timemarks=False)[source]¶
Write the FILE OUTPUT command for Abaqus/Explicit
- plugins.fe_abq.exportMesh(filename, mesh, eltype='ELTYPE', header='')[source]¶
Export a finite element mesh in Abaqus .inp format.
This is a convenience function to quickly export a mesh to Abaqus without having to go through the whole setup of a complete finite element model. It just writes the nodes and elements specified in the mesh to the file with the specified name. If the mesh has property numbers, the elements with the same property will be grouped in an element set. The resulting file can then be imported in Abaqus/CAE or manually be edited to create a full model.
- Parameters:
filename (path_like) – The filename to which to export. It should normally have a ‘.inp’ suffix
mesh (Mesh) – The Mesh to be exported.
eltype (str, optional.) – The element type for the exported elements. This will normally be a valid Abaqus element type compatible with the Mesh geometry. A default value ‘ELTYPE’ is provided which can later be edited int the output file.
Examples
>>> f = Path('test_filewrite.off') >>> M = Mesh(eltype='quad4').subdivide(2,2) >>> exportMesh(f, M, 'S4') >>> print(f.read_text()) ** Abaqus input file created by pyFormex ... ** pyFormex ... *NODE, NSET=Nall 1, 0.000000e+00, 0.000000e+00, 0.000000e+00 2, 5.000000e-01, 0.000000e+00, 0.000000e+00 3, 1.000000e+00, 0.000000e+00, 0.000000e+00 4, 0.000000e+00, 5.000000e-01, 0.000000e+00 5, 5.000000e-01, 5.000000e-01, 0.000000e+00 6, 1.000000e+00, 5.000000e-01, 0.000000e+00 7, 0.000000e+00, 1.000000e+00, 0.000000e+00 8, 5.000000e-01, 1.000000e+00, 0.000000e+00 9, 1.000000e+00, 1.000000e+00, 0.000000e+00 *ELEMENT, TYPE=S4, ELSET=ESET0 1, 1, 2, 5, 4 2, 2, 3, 6, 5 3, 4, 5, 8, 7 4, 5, 6, 9, 8 >>> f.remove()