Skip to content

svexporter

labels module-attribute

labels = _read_labels()

SVExporter

State variables exporter to handle a list of state variables. The constructor of the SVExporter class accepts a list of StateVariable objects:

>>> from micromechanical.python.micromechanical.core.statevariable import StateVariable
>>> sv0, sv1 = StateVariable(37), StateVariable(37)
>>> sv0.phase, sv1.phase = 0, 1
>>> exporter = SVExporter([sv0] * 60 + [sv1] * 40)

There are three ways to get state variables:

  1. Get the state variables by name, e.g. exporter.sig implemented by SVExporter.__getattr__ method. the state variables will be cached. This method will collect a specific state variable from all the state variables in the list, and return a numpy array with the first dimension being the step index. The returned array can be a 1D array, a 2D array or a 3D array, depending on the shape of the state variable.

    >>> exporter.epsa.shape
    (100,)
    >>> exporter.sig.shape
    (100, 6)
    >>> exporter.disp.shape
    (100, 37, 3)
    
  2. Get the state variables by name or expression of the name or name with column index, e.g., exporter["sig"], implemented by SVExporter.__getitem__.

    >>> exporter["sig1"].shape
    (100,)
    >>> exporter["epsa * 100"].shape
    (100,)
    
  3. Get the state variables by the above name with filters, implemented by the SVExporter.get method. This method is used to determine the state variables to get in visualization methods such as VisualizationModel.plot and x/y axis of the experiment Line.

    The following filters are supported:

    • phase: load phase index
    • step: step index
    • idx: integration point index, only valid for contact state variables
    • col: column index, only valid for vector state variables

    You can use the filters by the keyword arguments.

    >>> exporter.get("disp", phase=0).shape
    (60, 37, 3)
    >>> exporter.get("disp", step=slice(80)).shape
    (80, 37, 3)
    >>> exporter.get("disp", step=slice(80, None)).shape
    (20, 37, 3)
    >>> exporter.get("disp", idx=slice(20)).shape
    (100, 20, 3)
    >>> exporter.get("disp", col=0).shape
    (100, 37)
    

Note

The above filters are applied with the following steps:

  • If phase is specified, the state variables will be filtered by the phase index first.
  • An array of the indices of the steps corresponding to the phase will be generated by the SVExporter.indexOf method.
  • An array of the state variable will be generated by the SVExporter.__getitem__ method, and then filtered by the indices of the steps.
  • If the array is a 3D array, it will be filtered by the step index, integration point index and column index in each dimension, i.e., array[step, idx, col].
  • If the array is a 2D array, depending on the name of the state variable, it will be filtered by the step index and integration point index if the state variable is a contact state variable (i.e., array[step, idx]), or filtered by the step index and column index otherwise (i.e., array[step, col]) .
  • If the array is a 1D array, it will be filtered by the step index, i.e., array[step].

Note

Property fabric tensors can be obtained by the name F_{prop} where {prop} is the property name.

You can also export the state variables to a pandas DataFrame by the SVExporter.toDataFrame method.

>>> df = exporter.toDataFrame(includes=["sig", "eps"])
Saving state variables to DataFrame
>>> df.head()
   eps1  eps2  eps3  eps4  eps5  eps6  sig1  sig2  sig3  sig4  sig5  sig6
...

Then it is possible to export the DataFrame to any file format supported by pandas, e.g., csv, excel, etc.

A instance-attribute

Fabric tensor, shape (steps, 6)

A11 instance-attribute

A11: ndarray

Fabric tensor component A11, shape (steps,)

A12 instance-attribute

A12: ndarray

Fabric tensor component A12, shape (steps,)

A13 instance-attribute

A13: ndarray

Fabric tensor component A13, shape (steps,)

A22 instance-attribute

A22: ndarray

Fabric tensor component A22, shape (steps,)

A23 instance-attribute

A23: ndarray

Fabric tensor component A23, shape (steps,)

A33 instance-attribute

A33: ndarray

Fabric tensor component A33, shape (steps,)

F instance-attribute

Fabric tensor, shape (steps, 6)

F11 instance-attribute

F11: ndarray

Fabric tensor component F11, shape (steps,)

F12 instance-attribute

F12: ndarray

Fabric tensor component F12, shape (steps,)

F13 instance-attribute

F13: ndarray

Fabric tensor component F13, shape (steps,)

F22 instance-attribute

F22: ndarray

Fabric tensor component F22, shape (steps,)

F23 instance-attribute

F23: ndarray

Fabric tensor component F23, shape (steps,)

F33 instance-attribute

F33: ndarray

Fabric tensor component F33, shape (steps,)

FN11 instance-attribute

FN11: ndarray

Fabric tensor of contact normal force component FN11, shape (steps,)

FN12 instance-attribute

FN12: ndarray

Fabric tensor of contact normal force component FN12, shape (steps,)

FN13 instance-attribute

FN13: ndarray

Fabric tensor of contact normal force component FN13, shape (steps,)

FN22 instance-attribute

FN22: ndarray

Fabric tensor of contact normal force component FN22, shape (steps,)

FN23 instance-attribute

FN23: ndarray

Fabric tensor of contact normal force component FN23, shape (steps,)

FN33 instance-attribute

FN33: ndarray

Fabric tensor of contact normal force component FN33, shape (steps,)

FT11 instance-attribute

FT11: ndarray

Fabric tensor of contact shear force component FT11, shape (steps,)

FT12 instance-attribute

FT12: ndarray

Fabric tensor of contact shear force component FT12, shape (steps,)

FT13 instance-attribute

FT13: ndarray

Fabric tensor of contact shear force component FT13, shape (steps,)

FT22 instance-attribute

FT22: ndarray

Fabric tensor of contact shear force component FT22, shape (steps,)

FT23 instance-attribute

FT23: ndarray

Fabric tensor of contact shear force component FT23, shape (steps,)

FT33 instance-attribute

FT33: ndarray

Fabric tensor of contact shear force component FT33, shape (steps,)

I1 instance-attribute

I1: ndarray

First invariant of stress, shape (steps,)

I2 instance-attribute

I2: ndarray

Second invariant of stress, shape (steps,)

I3 instance-attribute

I3: ndarray

Third invariant of stress, shape (steps,)

J2 instance-attribute

J2: ndarray

Second invariant of deviatoric stress, shape (steps,)

J3 instance-attribute

J3: ndarray

Third invariant of deviatoric stress, shape (steps,)

_stateVars instance-attribute

_stateVars: List['StateVariable'] = stateVars

State variables

alpha instance-attribute

alpha: ndarray

Void ratio ratio, shape (steps, size, 3)

an instance-attribute

an: ndarray

Degree of fabric anisotropy for the contact normal force, shape (steps,)

ar instance-attribute

ar: ndarray

Degree of fabric anisotropy, shape (steps,)

at instance-attribute

at: ndarray

Degree of fabric anisotropy for the contact shear force, shape (steps,)

cached_num instance-attribute

cached_num: ndarray

cached number of integration points

chi instance-attribute

chi: ndarray

Bounding ratio, shape (steps, size)

contactVars cached property

contactVars: List[str]

Available contact variables

d2w cached property

d2w: ndarray

Second derivative of the work, shape (steps,)

d2wl cached property

d2wl: ndarray

Second derivative of the work of contacts, shape (steps, size)

ddisp cached property

ddisp: ndarray

Displacement increment, shape (steps, size, 3)

ddispp cached property

ddispp: ndarray

Plastic displacement increment, shape (steps, size, 3)

deps cached property

deps: ndarray

Strain increment, shape (steps, 6)

depsa cached property

depsa: ndarray

Axial strain increment, shape (steps,)

depsd cached property

depsd: ndarray

General shear strain increment, shape (steps,)

depsp cached property

depsp: ndarray

Plastic strain increment, shape (steps, 6)

depspa cached property

depspa: ndarray

Axial plastic strain increment, shape (steps,)

depspd cached property

depspd: ndarray

General shear plastic strain increment, shape (steps,)

depspu cached property

depspu: ndarray

Plastic strain increment from displacements, shape (steps, 6)

depspua cached property

depspua: ndarray

Axial plastic strain increment from displacements, shape (steps,)

depspud cached property

depspud: ndarray

General shear plastic strain increment from displacements, shape (steps,)

depspuv cached property

depspuv: ndarray

Volumetric plastic strain increment from displacements, shape (steps,)

depspv cached property

depspv: ndarray

Volumetric plastic strain increment, shape (steps,)

depsv cached property

depsv: ndarray

Volumetric strain increment, shape (steps,)

dfn cached property

dfn: ndarray

Normal force increment, shape (steps, size)

dforce cached property

dforce: ndarray

Force increment, shape (steps, size, 3)

dfr cached property

dfr: ndarray

Shear force increment, shape (steps, size)

dfs cached property

dfs: ndarray

Shear force increment at the first direction, shape (steps, size)

dft cached property

dft: ndarray

Shear force increment at the second direction, shape (steps, size)

disp instance-attribute

disp: ndarray

Displacement for every integration point, shape (steps, size, 3)

dispp instance-attribute

dispp: ndarray

Plastic displacement for every integration point, shape (steps, size, 3)

dsig cached property

dsig: ndarray

Stress increment, shape (steps, 6)

dun cached property

dun: ndarray

Normal displacement increment, shape (steps, size)

dupn cached property

dupn: ndarray

Plastic normal displacement increment, shape (steps, size)

dupr cached property

dupr: ndarray

Plastic shear displacement increment, shape (steps, size)

dups cached property

dups: ndarray

Plastic shear displacement increment at the first direction, shape (steps, size)

dupt cached property

dupt: ndarray

Plastic shear displacement increment at the second direction, shape (steps, size)

dur cached property

dur: ndarray

Shear displacement increment, shape (steps, size)

dus cached property

dus: ndarray

Shear displacement increment at the first direction, shape (steps, size)

dut cached property

dut: ndarray

Shear displacement increment at the second direction, shape (steps, size)

e instance-attribute

Void ratio, shape (steps,)

ec instance-attribute

ec: ndarray

Critical void ratio, shape (steps,)

eps instance-attribute

eps: ndarray

Strain, shape (steps, 6)

epsa instance-attribute

epsa: ndarray

Axial strain, shape (steps,)

epsd instance-attribute

epsd: ndarray

General shear strain, shape (steps,)

epsi cached property

epsi: ndarray

Strain after the first phase, shape (steps, 6)

epspi cached property

epspi: ndarray

Plastic strain after the first phase, shape (steps, 6)

epspq cached property

epspq: ndarray

Plastic strain exclude strain after the first phase, shape (steps,)

epspqa cached property

epspqa: ndarray

Axial plastic strain exclude strain after the first phase, shape (steps,)

epspqd cached property

epspqd: ndarray

General plastic shear strain exclude strain after the first phase, shape (steps,)

epspqv cached property

epspqv: ndarray

Volumetric plastic strain exclude strain after the first phase, shape (steps,)

epspqva cached property

epspqva: ndarray

Volumetric plastic strain approximation exclude strain after the first phase, shape (steps,)

epspui cached property

epspui: ndarray

Plastic strain from displacements after the first phase, shape (steps, 6)

epspuq cached property

epspuq: ndarray

Plastic strain from displacements exclude strain after the first phase, shape (steps,)

epspuqa cached property

epspuqa: ndarray

Axial plastic strain from displacements exclude strain after the first phase, shape (steps,)

epspuqd cached property

epspuqd: ndarray

General plastic shear strain from displacements exclude strain after the first phase, shape (steps,)

epspuqv cached property

epspuqv: ndarray

Volumetric plastic strain from displacements exclude strain after the first phase, shape (steps,)

epspuqva cached property

epspuqva: ndarray

Volumetric plastic strain from displacements approximation exclude strain after the first phase, shape (steps,)

epsq cached property

epsq: ndarray

Strain exclude strain after the first phase, shape (steps,)

epsqa cached property

epsqa: ndarray

Axial strain exclude strain after the first phase, shape (steps,)

epsqd cached property

epsqd: ndarray

General shear strain exclude strain after the first phase, shape (steps,)

epsqv cached property

epsqv: ndarray

Volumetric strain exclude strain after the first phase, shape (steps,)

epsqva cached property

epsqva: ndarray

Volumetric strain approximation exclude strain after the first phase, shape (steps,)

epsv instance-attribute

epsv: ndarray

Volumetric strain, shape (steps,)

epsva instance-attribute

epsva: ndarray

Volumetric strain approximation, shape (steps,)

eta instance-attribute

eta: ndarray

Stress ratio, shape (steps,)

f instance-attribute

Yield function value, shape (steps, size)

fb instance-attribute

fb: ndarray

Bounding force, shape (steps, size)

fci instance-attribute

fci: ndarray

Intrinsic size of yield surface, shape (steps, size)

feta instance-attribute

feta: ndarray

Contact force ratio, shape (steps,)

fn instance-attribute

fn: ndarray

Normal force for every integration point, shape (steps, size)

fncri cached property

fncri: ndarray

Normal force series for the critical state line

force instance-attribute

force: ndarray

Force for every integration point, shape (steps, size, 3)

fr instance-attribute

fr: ndarray

Shear force for every integration point, shape (steps, size)

frcri cached property

frcri: ndarray

Shear force series for the critical state line

fs instance-attribute

fs: ndarray

Shear force at the first direction for every integration point, shape (steps, size)

ft instance-attribute

ft: ndarray

Shear force at the second direction for every integration point, shape (steps, size)

negp instance-attribute

negp: ndarray

Negative mean stress, shape (steps,)

nintegration cached property

nintegration: int

Number of integration points

nsteps cached property

nsteps: int

Number of steps

p instance-attribute

Mean stress, shape (steps,)

p0 instance-attribute

p0: ndarray

Size of the yield surface for the SaniSand model, shape (steps, size)

pcri cached property

pcri: ndarray

Mean stress series for the critical state line

phase instance-attribute

phase: ndarray

load phase index

q instance-attribute

Deviatoric stress, shape (steps,)

qcri cached property

qcri: ndarray

Deviatoric stress series for the critical state line

sig instance-attribute

sig: ndarray

Stress, shape (steps, 6)

step cached property

step: ndarray

Step number

un instance-attribute

un: ndarray

Normal displacement for every integration point, shape (steps, size)

upn instance-attribute

upn: ndarray

Plastic normal displacement for every integration point, shape (steps, size)

upr instance-attribute

upr: ndarray

Plastic shear displacement for every integration point, shape (steps, size)

ups instance-attribute

ups: ndarray

Plastic shear displacement at the first direction for every integration point, shape (steps, size)

upt instance-attribute

upt: ndarray

Plastic shear displacement at the second direction for every integration point, shape (steps, size)

ur instance-attribute

ur: ndarray

Shear displacement for every integration point, shape (steps, size)

us instance-attribute

us: ndarray

Shear displacement at the first direction for every integration point, shape (steps, size)

ut instance-attribute

ut: ndarray

Shear displacement at the second direction for every integration point, shape (steps, size)

w instance-attribute

Work, shape (steps, size)

__contains__ cached

__contains__(item) -> bool

Check if a state variable is available

__getattr__ cached

__getattr__(name: str) -> ndarray

Get state variables

PARAMETER DESCRIPTION
name

A string specifies name of the state variable. It can end with a column number (1, 2, 3, 4, 5, 6) to specify the column of the state variable when it is a vector.

TYPE: str

RETURNS DESCRIPTION
array

An array of the state variable

TYPE: ndarray

__getitem__ cached

__getitem__(item: str) -> ndarray

Get state variables

PARAMETER DESCRIPTION
item

A string specifies name or an expression of the state variable parsed by sympy. The expression can contain any of the available state variables, and it can end with a column number (1, 2, 3, 4, 5, 6) to specify the column of the state variable when it is a vector.

TYPE: str

RETURNS DESCRIPTION
array

An array of the state variable, the shape of the array depends on the type of the state variable and the arguments specified in the name and index:

  • 1D array (shape (steps,)): the state variable is a scalar; the state variable is a vector, is not a contact variable, and the column number is specified in the name.
  • 2D array (shape (steps, ndim)): the state variable is a vector, is not a contact variable, and the column number is not specified in the name.
  • 2D array (shape (steps, integration size)): the state variable is a contact variable (force, disp), the column number is specified in the name.
  • 3D array (shape (steps, integration size, ndim)): the state variable is a contact variable (force, disp), the column number is not specified in the name.

TYPE: ndarray

__init__

__init__(stateVars: List['StateVariable'])

Initialize state variables exporter

PARAMETER DESCRIPTION
stateVars

State variables

TYPE: List[StateVariable]

abaqusStateVariableNames classmethod

abaqusStateVariableNames(
    contact_type: str, size: int = 37, reverse: bool = False
) -> dict[str, str]

The state variable names for the Abaqus subroutine, a dictionary of ("SDV{i}", name) pairs. If reverse is True, the dictionary is reversed to {name: "SDV{i}"} pairs.

fromAbaqusStateVariables classmethod

fromAbaqusStateVariables(
    data: "DataFrame" | str | PathLike,
    contact_type: str,
    *,
    size: int = 37,
    phase_column: str = "Step"
) -> "SVExporter"

Create state variables exporter by a data file exported from an Abaqus output database, data is a pandas DataFrame or a csv file with columns of names like SDV{i}. A column with name Step is required to specify the load phase or any other column name specified by phase_column, if the column is not available, the phase will be set to 0.

get

get(
    var: str,
    *,
    phase: int | slice | Iterable[int] = slice(None),
    step: int | slice | Iterable[int] = slice(None),
    idx: int | slice | Iterable[int] = slice(None),
    col: int | slice | Iterable[int] = slice(None)
) -> Union[ndarray, float]

Get state variables

PARAMETER DESCRIPTION
var

A string specifies name or an expression of the state variable parsed by sympy. The expression can contain any of the available state variables, and it can end with a column number (1, 2, 3, 4, 5, 6) to specify the column of the state variable when it is a vector.

TYPE: str

phase

An integer or a slice indicates index of the phase.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

step

An integer or a slice indicates index of the step, noted that the step index is the relative step index to the phase if phase is specified.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

idx

An integer or a slice indicates index of the integration point for contact variables.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

col

An integer or a slice indicates index of the column for variables with multiple columns, this argument will be ignored if the variable has only one column or the column index is already specified in var.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

RETURNS DESCRIPTION
array

An array or a float of the state variable

TYPE: ndarray or float

indexOf

indexOf(
    phase: int | slice | Iterable[int] = slice(None),
) -> Union[ndarray, int, slice]

Get the indices of the corresponding steps belonging to a phase or phases

isContactVariable

isContactVariable(var: str) -> bool

Check if a state variable is a contact variable

toDataFrame

toDataFrame(
    includes: Iterable[str] | None = None,
    excludes: Iterable[str] = (),
    *,
    phase: int | slice | Iterable[int] = slice(None),
    step: int | slice | Iterable[int] = slice(None),
    idx: int | slice | Iterable[int] = slice(None),
    col: int | slice | Iterable[int] = slice(None),
    set_columns: bool = False
) -> "DataFrame"

Convert state variables to a pandas DataFrame

PARAMETER DESCRIPTION
includes

An iterable of state variable names to be included, by default None, which means only stress and strain state variables will be included.

TYPE: Iterable[str] DEFAULT: None

excludes

An iterable of state variable names to be excluded, by default (), which means no state variable will be excluded.

TYPE: Iterable[str] DEFAULT: ()

phase

Filters for the state variables, see :meth:get for details.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

step

Filters for the state variables, see :meth:get for details.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

idx

Filters for the state variables, see :meth:get for details.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

col

Filters for the state variables, see :meth:get for details.

TYPE: int | slice | Iterable[int] DEFAULT: slice(None)

set_columns

Set the column names of the DataFrame, by default False.

TYPE: bool DEFAULT: False

to_csv

to_csv(
    filename: PathLike | str,
    includes: Iterable[str] | None = None,
    excludes: Iterable[str] = (),
    *,
    phase: int | slice | Iterable[int] = slice(None),
    step: int | slice | Iterable[int] = slice(None),
    idx: int | slice | Iterable[int] = slice(None),
    col: int | slice | Iterable[int] = slice(None),
    set_columns: bool = False,
    **kwargs
)

Save state variables to a csv file

PARAMETER DESCRIPTION
filename

The filename to save the state variables.

TYPE: PathLike or str

includes

Arguments for :meth:toDataFrame.

TYPE: Iterable[str] | None DEFAULT: None

excludes

Arguments for :meth:toDataFrame.

TYPE: Iterable[str] | None DEFAULT: None

phase

Arguments for :meth:toDataFrame.

TYPE: Iterable[str] | None DEFAULT: None

step

Arguments for :meth:toDataFrame.

TYPE: Iterable[str] | None DEFAULT: None

idx

Arguments for :meth:toDataFrame.

TYPE: Iterable[str] | None DEFAULT: None

col

Arguments for :meth:toDataFrame.

TYPE: Iterable[str] | None DEFAULT: None

set_columns

Set the column names of the DataFrame, by default True.

TYPE: bool DEFAULT: False

kwargs

Other arguments for :meth:pandas.DataFrame.to_csv.

DEFAULT: {}

StateVariableLabels

Bases: HashableBaseModelIO

Labels manager for the x/y labels of the figure.

defaults class-attribute instance-attribute

defaults: Dict[str, str] = {}

Default mapping of the key to another key if the key is not in the dictionary when calling get method.

labels class-attribute instance-attribute

labels: Dict[str, str] = {}

__contains__

__contains__(key: str) -> bool

__delitem__

__delitem__(key: str)

__getitem__

__getitem__(key: str) -> str

__setitem__

__setitem__(key: str, value: str)

get

get(key: str, default: str = None)

Get the label of the key, the following rules are applied:

  • if the key is in the dictionary, return the value of the key.
  • else if the default is not None, return the default.
  • else if the key is a sympy expression with only one symbol, return the label of the symbol in the expression.
  • else if the key is in the defaults, return the label of the default of the key. For example, if defaults is {"negp": "p"}, get("negp") will return the label of p when p is in the dictionary and negp is not.
  • else return the key itself.

_getattr cached

_getattr(stateVar: 'StateVariable', name: str) -> Union[ndarray, float]

Get attribute from the attributes/scalars/vectors of a state variable

_hasattr cached

_hasattr(stateVar: 'StateVariable', name: str) -> bool

Check if the state variables have the attribute

_read_labels

_read_labels()

Read the labels from the configuration files.