API Reference¤
The public API of abaqus2py consists of two classes: AbaqusSimulator, the
standalone driver for running ABAQUS simulations, and F3DASMAbaqusSimulator,
an f3dasm.DataGenerator adapter that runs simulations over an
f3dasm.ExperimentData.
Simulator¤
abaqus2py.AbaqusSimulator
¤
Abaqus simulator class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_cpus
|
int
|
Number of CPUs to use for the simulation. |
1
|
delete_odb
|
bool
|
If True, the created ODB file is removed after post-processing. Can be used to save disk space, default is False. |
False
|
delete_temp_files
|
bool
|
If True, temporary files created by Abaqus are removed after the simulation, default is False. |
False
|
working_directory
|
Path
|
Working directory where subdirectories will be created for simulation results. Defaults to the current working directory. |
<factory>
|
max_waiting_time
|
int
|
Maximum time to wait in seconds after submitting a job, default is 60. This is a workaround to wait for the job to finish. |
60
|
delete_odb = False
class-attribute
¤
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
delete_temp_files = False
class-attribute
¤
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
max_waiting_time = 60
class-attribute
¤
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
num_cpus = 1
class-attribute
¤
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
postprocess(py_file: str, odb_files: Iterable[str] | str | Path, function_name: str = 'main') -> None
¤
Run a postprocessing procedure; where the odb file is read and the results are processed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
py_file
|
str
|
Path to the python file |
required |
odb_files
|
str | Path | list
|
Path to the odb file(s) |
required |
function_name
|
str
|
Name of the function to call, default is "main" |
'main'
|
preprocess(py_file: str, function_name: str = 'main', simulation_parameters: Optional[Iterable[dict[str, Any]] | dict[str, Any]] = None)
¤
Create the input files (.inp) for the simulation with a preprocessing script
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
py_file
|
str
|
Path to the python file |
required |
function_name
|
str
|
Name of the function to call, default is "main" |
'main'
|
simulation_parameters
|
dict | Iterable[dict]
|
Key-word arguments with the simulation parameters |
None
|
run(py_file: str, function_name: str = 'main', post_py_file: Optional[str] = None, simulation_parameters: Optional[Iterable[dict[str, Any]] | dict[str, Any]] = None, submit_job: bool = True, post_function_name: Optional[str] = None)
¤
Run the full simulation process
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
py_file
|
str
|
Path to the pre-processing python file to create the input file |
required |
function_name
|
str
|
Name of the pre-processing function to call, default is "main" |
'main'
|
post_py_file
|
str
|
Path to the postprocessing python file, optional |
None
|
simulation_parameters
|
dict | Iterable[dict]
|
Key-word arguments with the simulation parameters |
None
|
submit_job
|
bool
|
Whether to submit the job to Abaqus, default is True |
True
|
post_function_name
|
str
|
Name of the post-processing function to call. Defaults to
|
None
|
submit(inp_files: Iterable[str] | str | Path) -> None
¤
Submit the simulation to Abaqus
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inp_files
|
str | Path | list
|
Path to the input file(s) |
required |
f3dasm Adapter¤
abaqus2py.F3DASMAbaqusSimulator
¤
f3dasm :class:DataGenerator adapter around :class:AbaqusSimulator.
Wrap a pair of Abaqus pre- and post-processing Python scripts so they can
be evaluated over an :class:f3dasm.ExperimentData via the standard
:meth:DataGenerator.call entry point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
py_file
|
str
|
Path to the Python file containing the pre-processing function. |
required |
function_name
|
str
|
Name of the callable to invoke inside |
'main'
|
post_py_file
|
str
|
Path to the Python file containing the post-processing function. If None, no post-processing step is run. |
None
|
post_function_name
|
str
|
Name of the callable to invoke inside |
None
|
num_cpus
|
int
|
Number of CPUs to use for the simulation, by default 1. |
1
|
delete_odb
|
bool
|
Delete the ODB file after post-processing, by default False. |
False
|
delete_temp_files
|
bool
|
Delete Abaqus temporary files after the simulation, by default False. |
False
|
working_directory
|
str or Path
|
Working directory where the simulation will be executed. Defaults to the current working directory. |
None
|
max_waiting_time
|
int
|
Maximum waiting time (seconds) for the Abaqus job to finish, by default 60. |
60
|
Attributes:
| Name | Type | Description |
|---|---|---|
simulator |
AbaqusSimulator
|
Underlying Abaqus simulator instance configured from the init args. |
py_file |
str
|
Path to the pre-processing Python file. |
function_name |
str
|
Name of the entry-point function in |
post_py_file |
str or None
|
Path to the post-processing Python file, or None if not set. |
post_function_name |
str
|
Name of the entry-point function in |
Notes
Callers must pass pass_id=True to :meth:DataGenerator.call so that
the job index is forwarded into :meth:execute as the id keyword
argument; this index is used as the per-sample sub-directory name.
execute(experiment_sample: ExperimentSample, id: typing.Optional[int] = None, **kwargs) -> ExperimentSample
¤
Run the Abaqus simulation for a single experiment sample.
Builds the simulation parameter dictionary from the sample's input
data, uses the f3dasm-supplied job id as the sub-directory name,
runs the underlying :class:AbaqusSimulator, and loads the resulting
results.pkl back onto the experiment sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_sample
|
ExperimentSample
|
The sample whose input data drives the simulation and whose
outputs will be updated from |
required |
id
|
int
|
The job index of this sample, forwarded by f3dasm when
:meth: |
None
|
**kwargs
|
Additional keyword arguments merged into the simulation
parameters passed to |
required |
Returns:
| Type | Description |
|---|---|
ExperimentSample
|
The same sample, with simulation outputs stored via
:meth: |