svexporter
SVExporter
Bases: UserList
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.constitutive.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:
-
Get the state variables by name, e.g.
exporter.sigimplemented bySVExporter.__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. -
Get the state variables by name or expression of the name or name with column index, e.g.,
exporter["sig"], implemented bySVExporter.__getitem__. -
Get the state variables by the above name with filters, implemented by the
SVExporter.getmethod. This method is used to determine the state variables to get in visualization methods such asVisualizationModel.plotand x/y axis of the experimentLine.The following filters are supported:
phase: load phase indexstep: step indexidx: integration point index, only valid for contact state variablescol: column index, only valid for vector state variables
You can use the filters by the keyword arguments.
Note
The above filters are applied with the following steps:
- If
phaseis 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.indexOfmethod. - 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.
FN11
instance-attribute
Fabric tensor of contact normal force component FN11, shape (steps,)
FN12
instance-attribute
Fabric tensor of contact normal force component FN12, shape (steps,)
FN13
instance-attribute
Fabric tensor of contact normal force component FN13, shape (steps,)
FN22
instance-attribute
Fabric tensor of contact normal force component FN22, shape (steps,)
FN23
instance-attribute
Fabric tensor of contact normal force component FN23, shape (steps,)
FN33
instance-attribute
Fabric tensor of contact normal force component FN33, shape (steps,)
FT11
instance-attribute
Fabric tensor of contact shear force component FT11, shape (steps,)
FT12
instance-attribute
Fabric tensor of contact shear force component FT12, shape (steps,)
FT13
instance-attribute
Fabric tensor of contact shear force component FT13, shape (steps,)
FT22
instance-attribute
Fabric tensor of contact shear force component FT22, shape (steps,)
FT23
instance-attribute
Fabric tensor of contact shear force component FT23, shape (steps,)
FT33
instance-attribute
Fabric tensor of contact shear force component FT33, shape (steps,)
an
instance-attribute
Degree of fabric anisotropy for the contact normal force, shape (steps,)
at
instance-attribute
Degree of fabric anisotropy for the contact shear force, shape (steps,)
disp
instance-attribute
Displacement for every integration point, shape (steps, size, 3)
dispp
instance-attribute
Plastic displacement for every integration point, shape (steps, size, 3)
dups
cached
property
Plastic shear displacement increment at the first direction, shape (steps, size)
dupt
cached
property
Plastic shear displacement increment at the second direction, shape (steps, size)
dus
cached
property
Shear displacement increment at the first direction, shape (steps, size)
dut
cached
property
Shear displacement increment at the second direction, shape (steps, size)
epspq
cached
property
Plastic strain exclude strain after the first phase, shape (steps,)
epspqa
cached
property
Axial plastic strain exclude strain after the first phase, shape (steps,)
epspqd
cached
property
General plastic shear strain exclude strain after the first phase, shape (steps,)
epspqv
cached
property
Volumetric plastic strain exclude strain after the first phase, shape (steps,)
epsqa
cached
property
Axial strain exclude strain after the first phase, shape (steps,)
epsqd
cached
property
General shear strain exclude strain after the first phase, shape (steps,)
epsqv
cached
property
Volumetric strain exclude strain after the first phase, shape (steps,)
fs
instance-attribute
Shear force at the first direction for every integration point, shape (steps, size)
ft
instance-attribute
Shear force at the second direction for every integration point, shape (steps, size)
p0
instance-attribute
Size of the yield surface for the SaniSand model, shape (steps, size)
un
instance-attribute
Normal displacement for every integration point, shape (steps, size)
upn
instance-attribute
Plastic normal displacement for every integration point, shape (steps, size)
upr
instance-attribute
Plastic shear displacement for every integration point, shape (steps, size)
ups
instance-attribute
Plastic shear displacement at the first direction for every integration point, shape (steps, size)
upt
instance-attribute
Plastic shear displacement at the second direction for every integration point, shape (steps, size)
ur
instance-attribute
Shear displacement for every integration point, shape (steps, size)
us
instance-attribute
Shear displacement at the first direction for every integration point, shape (steps, size)
ut
instance-attribute
Shear displacement at the second direction for every integration point, shape (steps, size)
__getattr__
cached
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:
|
| RETURNS | DESCRIPTION |
|---|---|
array
|
An array of the state variable
TYPE:
|
__getitem__
cached
Get state variables
| PARAMETER | DESCRIPTION |
|---|---|
item
|
A string specifies name or an expression of the state variable parsed by
TYPE:
|
| 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:
TYPE:
|
__hash__
Get the hash of the state variables exporter, which is the hash of the data and phase attributes.
abaqusStateVariableNames
classmethod
abaqusStateVariableNames(
contact_type: str | None = None, 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: Union[Iterable, str, PathLike],
contact_type: str | None = None,
*,
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),
smooth_variables: list[str] | None = None
) -> Union[ndarray, float]
Get state variables
| PARAMETER | DESCRIPTION |
|---|---|
var
|
A string specifies name or an expression of the state variable parsed by
TYPE:
|
phase
|
An integer or a slice indicates index of the phase.
TYPE:
|
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
TYPE:
|
idx
|
An integer or a slice indicates index of the integration point for contact variables.
TYPE:
|
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
TYPE:
|
smooth_variables
|
A list of state variable names to be smoothed, by default None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
array
|
An array or a float of the state variable
TYPE:
|
indexOf
Get the indices of the corresponding steps belonging to a phase or phases
isContactVariable
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
)
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:
|
excludes
|
An iterable of state variable names to be excluded, by default (), which means no state variable will be excluded.
TYPE:
|
phase
|
Filters for the state variables, see :meth:
TYPE:
|
step
|
Filters for the state variables, see :meth:
TYPE:
|
idx
|
Filters for the state variables, see :meth:
TYPE:
|
col
|
Filters for the state variables, see :meth:
TYPE:
|
set_columns
|
Set the column names of the DataFrame, by default False.
TYPE:
|
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:
|
includes
|
Arguments for :meth:
TYPE:
|
excludes
|
Arguments for :meth:
TYPE:
|
phase
|
Arguments for :meth:
TYPE:
|
step
|
Arguments for :meth:
TYPE:
|
idx
|
Arguments for :meth:
TYPE:
|
col
|
Arguments for :meth:
TYPE:
|
set_columns
|
Set the column names of the DataFrame, by default True.
TYPE:
|
kwargs
|
Other arguments for :meth:
DEFAULT:
|
StateVariableLabels
Bases: HashableBaseModelIO
Labels manager for the x/y labels of the figure.
defaults
class-attribute
instance-attribute
Default mapping of the key to another key if the key is not in the dictionary when calling get method.
get
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
defaultsis{"negp": "p"},get("negp")will return the label ofpwhenpis in the dictionary andnegpis not. - else return the key itself.