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.
OdbClientis the user-facing entry point ofpylife-odbclient. It runs in a normal Python 3 interpreter, startspython -m odbserverwith 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 readsODBSERVER_ABAQUS_BINand then tries known Abaqus installation paths.python_env_path (str, optional) – Path to the Python environment that provides the
odbserverpackage for Abaqus. Default isNone, which first readsODBSERVER_PYTHON_ENV_PATHand 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.variableRead field output values as a DataFrame.
odbclient.OdbClient.node_coordinatesRead 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:
- Returns:
One column named
connectivitycontaining lists of connected node IDs. The index is namedelement_id.- Return type:
- element_ids(elset_name, instance_name='')[source]#
Read element IDs from an element set.
- Parameters:
- Returns:
Element identifiers with name
element_idand integer dtype.- Return type:
- 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:
- history_output_values(step_name, history_region_name, historyoutput_name)[source]#
Read one history output as a pandas Series.
- Parameters:
- 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:
- history_outputs(step_name, history_region_name)[source]#
Return history output names for a history region.
- history_region_description(step_name, history_region_name)[source]#
Return the descriptive text of a history region.
- node_coordinates(instance_name, nset_name='')[source]#
Read node coordinates for an instance or node set.
- Parameters:
- Returns:
Node coordinates with columns
x,y, andzand an index namednode_id.- Return type:
- Raises:
KeyError – If
instance_nameis not available in the ODB.
- node_ids(nset_name, instance_name='')[source]#
Read node IDs from a node set.
- Parameters:
- Returns:
Node identifiers with name
node_idand integer dtype.- Return type:
- 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, orU.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, orAVERAGED AT NODES. Default isNone, 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_idorelement_idfor single-location data and is a MultiIndex with labels such asnode_id,element_id,ipoint_id, orface_idwhen Abaqus supplies multiple identifiers.- Return type: