The OdbClient class#

class odbclient.OdbClient(odb_file, abaqus_bin=None, python_env_path=None)[source]#

Read Abaqus ODB result data through an Abaqus-side server.

OdbClient is the user-facing entry point of pylife-odbclient. It runs in a normal Python 3 interpreter, starts python -m odbserver with the Abaqus Python executable, and exchanges commands with that server. The split is necessary because Abaqus ODB access is only available inside the Abaqus Python environment, while pyLife analyses typically run in a modern Python process.

Parameters:
  • odb_file (str) – Path to the Abaqus ODB file to open.

  • abaqus_bin (str, optional) – Path to the Abaqus executable used to start the server. Default is None, which first reads ODBSERVER_ABAQUS_BIN and then tries known Abaqus installation paths.

  • python_env_path (str, optional) – Path to the Python environment that provides the odbserver package for Abaqus. Default is None, which first reads ODBSERVER_PYTHON_ENV_PATH and then tries common environment locations.

Raises:
  • ValueError – If the Abaqus executable or server Python environment cannot be guessed.

  • FileNotFoundError – If an explicitly selected executable or environment path does not exist.

  • OdbServerError – If the server process exits or does not announce readiness.

  • RuntimeError – If client and server package versions differ.

See also

odbclient.OdbClient.variable

Read field output values as a DataFrame.

odbclient.OdbClient.node_coordinates

Read nodal coordinates as a DataFrame.

Examples

The snippets below need an actual Abaqus installation and ODB file, so they are shown as a transcript rather than as executable doctests.

Open an ODB file and list the part instances it contains.

>>> import odbclient as CL
>>> client = CL.OdbClient("some_file.odb")
>>> client.instance_names()
['PART-1-1']

Query the node coordinates of an instance.

>>> client.node_coordinates('PART-1-1')
            x     y     z
node_id
1       -30.0  15.0  10.0
2       -30.0  25.0  10.0
3       -30.0  15.0   0.0
...

Query the steps, the frames of a step and the field variables written in a given frame.

>>> client.step_names()
['Load']
>>> client.frame_ids('Load')
[0, 1]
>>> client.variable_names('Load', 1)
['CF', 'COORD', 'E', 'EVOL', 'IVOL', 'RF', 'S', 'U']

Read the stress tensor of an instance for a given step and frame.

>>> client.variable('S', 'PART-1-1', 'Load', 1)
                          S11        S22  ...       S13       S23
node_id element_id                        ...
5       1          -38.617779   2.705118  ... -3.578981  1.355571
7       1          -38.617779   2.705118  ...  3.578981 -1.355571
3       1          -50.749348 -21.749729  ... -7.597347 -0.000003
1       1          -50.749348 -21.749729  ...  7.597347  0.000003
6       1           38.643414  -2.588303  ...  3.522046  1.446851
...                       ...        ...  ...       ...       ...

Oftentimes it is desirable to have the node coordinates and multiple field variables in one data frame. This is easily achieved by join() operations.

>>> node_coordinates = client.node_coordinates('PART-1-1')
>>> stress = client.variable('S', 'PART-1-1', 'Load', 1)
>>> strain = client.variable('E', 'PART-1-1', 'Load', 1)
>>> node_coordinates.join(stress).join(strain)
                       x     y     z  ...           E12           E13           E23
node_id element_id                    ...
5       1          -20.0  15.0  10.0  ... -2.741873e-11 -4.652675e-11  1.762242e-11
7       1          -20.0  15.0   0.0  ... -2.741873e-11  4.652675e-11 -1.762242e-11
3       1          -30.0  15.0   0.0  ... -2.599339e-11 -9.876550e-11 -3.946581e-17
1       1          -30.0  15.0  10.0  ... -2.599339e-11  9.876550e-11  3.946581e-17
...                  ...   ...   ...  ...           ...           ...           ...
element_connectivity(instance_name, elset_name='')[source]#

Read element connectivity for an instance or element set.

Parameters:
  • instance_name (str) – Name of the Abaqus part instance to query.

  • elset_name (str, optional) – Name of an element set that limits the query. Default is '', which returns all elements of instance_name.

Returns:

One column named connectivity containing lists of connected node IDs. The index is named element_id.

Return type:

pandas.DataFrame

element_ids(elset_name, instance_name='')[source]#

Read element IDs from an element set.

Parameters:
  • elset_name (str) – Name of the element set to query.

  • instance_name (str, optional) – Instance that owns the element set. Default is '', which queries an assembly-level element set.

Returns:

Element identifiers with name element_id and integer dtype.

Return type:

pandas.Index

elset_names(instance_name='')[source]#

Return element set names available in the ODB.

Parameters:

instance_name (str, optional) – Instance whose element sets are requested. Default is '', which requests assembly-level element sets.

Returns:

Element set names visible at the selected scope.

Return type:

list of str

Raises:

KeyError – If instance_name is not available in the ODB.

frame_ids(step_name)[source]#

Return frame IDs available in an analysis step.

Parameters:

step_name (str) – Name of the Abaqus analysis step.

Returns:

Abaqus frame IDs contained in step_name.

Return type:

list of int

history_info()[source]#

Return a nested summary of all history output metadata.

Returns:

Mapping from history region descriptions to region names, output names, and steps in which the region occurs.

Return type:

dict

history_output_values(step_name, history_region_name, historyoutput_name)[source]#

Read one history output as a pandas Series.

Parameters:
  • step_name (str) – Name of the Abaqus analysis step.

  • history_region_name (str) – Name of the Abaqus history region.

  • historyoutput_name (str) – Name of the history output variable.

Returns:

History output values indexed by the time-like abscissa returned by Abaqus. The series name combines the region description and output name.

Return type:

pandas.Series

history_outputs(step_name, history_region_name)[source]#

Return history output names for a history region.

Parameters:
  • step_name (str) – Name of the Abaqus analysis step.

  • history_region_name (str) – Name of the Abaqus history region.

Returns:

History output names available in the selected region.

Return type:

list of str

history_region_description(step_name, history_region_name)[source]#

Return the descriptive text of a history region.

Parameters:
  • step_name (str) – Name of the Abaqus analysis step.

  • history_region_name (str) – Name of the Abaqus history region.

Returns:

Description stored by Abaqus for the selected history region.

Return type:

str

history_regions(step_name)[source]#

Return history region names for one analysis step.

Parameters:

step_name (str) – Name of the Abaqus analysis step.

Returns:

History region names available in step_name.

Return type:

list of str

instance_names()[source]#

Return the instance names stored in the ODB root assembly.

Returns:

Names of all part instances available for mesh and result queries.

Return type:

list of str

node_coordinates(instance_name, nset_name='')[source]#

Read node coordinates for an instance or node set.

Parameters:
  • instance_name (str) – Name of the Abaqus part instance to query.

  • nset_name (str, optional) – Name of a node set that limits the query. Default is '', which returns all nodes of instance_name.

Returns:

Node coordinates with columns x, y, and z and an index named node_id.

Return type:

pandas.DataFrame

Raises:

KeyError – If instance_name is not available in the ODB.

node_ids(nset_name, instance_name='')[source]#

Read node IDs from a node set.

Parameters:
  • nset_name (str) – Name of the node set to query.

  • instance_name (str, optional) – Instance that owns the node set. Default is '', which queries an assembly-level node set.

Returns:

Node identifiers with name node_id and integer dtype.

Return type:

pandas.Index

nset_names(instance_name='')[source]#

Return node set names available in the ODB.

Parameters:

instance_name (str, optional) – Instance whose node sets are requested. Default is '', which requests assembly-level node sets.

Returns:

Node set names visible at the selected scope.

Return type:

list of str

Raises:

KeyError – If instance_name is not available in the ODB.

step_names()[source]#

Return analysis step names stored in the ODB.

Returns:

Names of all Abaqus analysis steps.

Return type:

list of str

variable(variable_name, instance_name, step_name, frame_id, nset_name='', elset_name='', position=None)[source]#

Read a field output variable as a pandas DataFrame.

Parameters:
  • variable_name (str) – Abaqus field output variable name, for example S, E, or U.

  • instance_name (str) – Name of the Abaqus part instance to query.

  • step_name (str) – Name of the Abaqus analysis step.

  • frame_id (int) – Abaqus frame ID within step_name.

  • nset_name (str, optional) – Node set that limits the field output query. Default is '', which does not apply a node-set filter.

  • elset_name (str, optional) – Element set that limits the field output query. Default is '', which does not apply an element-set filter.

  • position (str, optional) – Abaqus output position in input-file terminology, such as INTEGRATION POINTS, CENTROIDAL, WHOLE ELEMENT, NODES, FACES, or AVERAGED AT NODES. Default is None, which uses the native ODB position except that integration-point data is requested as element-nodal data.

Returns:

Field values with one column per scalar component. The index is named node_id or element_id for single-location data and is a MultiIndex with labels such as node_id, element_id, ipoint_id, or face_id when Abaqus supplies multiple identifiers.

Return type:

pandas.DataFrame

variable_names(step_name, frame_id)[source]#

Return field output variable names for one frame.

Parameters:
  • step_name (str) – Name of the Abaqus analysis step.

  • frame_id (int) – Abaqus frame ID within step_name.

Returns:

Field output variable names, for example S or U.

Return type:

list of str