This page describes the mtest
module
MaterialProperty
classThe MaterialProperty
class handles a material
property.
This class has the following core interface:
getVariablesNames
, which returns the names of the
arguments of material property.setVariableValue
which allows to set the value of an
argument of the material property.getValue
which evaluates the material property for the
values of the arguments set by the setVariableValue
method.getParametersNames
, which returns the names of the
parameters of material property.setParameter
which allows to change the value of a
parameter.As described in the next paragraph, several convenient methods and operators are also provided to simplify the usage of this class.
Here is an example of the usage of the MaterialProperty
class.
import mtest
= mtest.MaterialProperty(
young_modulus 'src/libCastemVanadium.so', 'VanadiumAlloy_YoungModulus_SRMA')
Note that the MaterialProperty
constructor automatically
detects the interface used to generate the material property and
instantiates the proper concrete implementation internally. In this
case, an instance of the CastemMaterialProperty
class is
instanciated.
The arguments of the material property can then be set and the material property can be evaluated:
'Temperature', 562)
young_modulus.setVariableValue(= young_modulus.getValue() E
Setting the variables’ values and evaluating the material property
can be tedious. To avoid this, overloaded versions of the
getValue
are available:
# using a dictionary
= young_modulus.getValue({'Temperature': 562})
E # for material properties with only one argument
= young_modulus.getValue(562) E
To make the code even more explicit, the call operator can also be used, as follows:
# using a dictionary
= young_modulus({'Temperature': 562})
E # for material properties with only one argument
= young_modulus(562) E
Behaviour
classThe Behaviour
class retrieves information in a shared
library about a behaviour specific implementation.
Contrary the tfel.system.ExternalBehaviourDescription
class, the information given by the Behaviour
class takes
into account the variables that are implicitly declared by the interface
to match its specific (internal) requirements.
For example, if a behaviour requires the stiffness tensor to be given
by the calling code (see the @RequireStiffnessTensor
MFront
’ keyword for details), additional material
properties are provided to the behaviour. The number of those additional
material properties may depend on the modelling hypothesis (mostly for
orthotropic behaviours): the calling code generally only not provides
the minimal number of material properties needed, in order to reduce the
cost of handling those extra material properties.
One can give some other examples:
@AsterSaveTangentOperator
is used in
MFront
, the consistent tangent operator will be saved as
additional state variables.@AbaqusOrthotropyManagementPolicy
is used to set
the orthotropy management policy to “MFront
” in
Abaqus/Standard
and Abaqus/Explicit
, the
definition of the orthotropic axes must be given in additional state
variables.StandardElasticity
brick). This variable is only defined
for this specific modelling hypothesis.import mtest
= mtest.Behaviour('aster','libAsterBehaviour.so','asterplasticity','PlaneStrain') b
The following methods are available:
getBehaviourType
: Return the behaviour type. The value
returned has the following meaning:
0
: general behaviour.1
: small strain behaviour.2
: finite strain behaviour.3
: cohesive zone model.getBehaviourKinematic
: Return the behaviour kinematic.
The value returned has the following meaning:
0
: undefined kinematic.1
: standard small strain behaviour kinematic.2
: cohesive zone model kinematic.3
: standard finite strain kinematic (F-Cauchy).4
: PTest
finite strain kinematic (eto-pk1)
(see [1]).getDrivingVariablesSize
: Return the size of a vector
able to contain all the components of the driving variables.getThermodynamicForcesSize
: Return the size of a vector
able to contain all the components of the thermodynamic forces.getStensorComponentsSuffixes
: Return the components
suffixes of a symmetric tensor.getVectorComponentsSuffixes
: Return the components
suffixes of a vector.getTensorComponentsSuffixes
: Return the components
suffixes of a tensor.getDrivingVariablesComponents
: Return the components of
the driving variables.getThermodynamicForcesComponents
: Return the components
of the thermodynamic forces.getDrivingVariableComponentPosition
: Return the
position of the component of a driving variable.getThermodynamicForceComponentPosition
: Return the
position of the component of a thermodynamic force.getSymmetryType
: Return the symmetry of the behaviour:
0
means that the behaviour is isotropic.1
means that the behaviour is orthotropic.getMaterialPropertiesNames
: return the names of the
material properties.getInternalStateVariablesNames
: Return the names of the
internal state variables.expandInternalStateVariablesNames
: Return the names of
the internal state variables, taking into account the suffixes for
vectors, symmetric tensors and tensors.getInternalStateVariablesSize
: Return the the size of
the array of internal variables.getInternalStateVariablesDescriptions
: Return the
descriptions the internal variables.getInternalStateVariableType
: Return the type of an
internal variable:
0
means that the internal state variable is a
scalar.1
means that the internal state variable is a symmetric
tensor.3
means that the internal state variable is a
tensor.getInternalStateVariablePosition
: Return the internal
state variable position.getExternalStateVariablesNames
: Return the names of the
external state variables.getParametersNames
: Return the names of the floating
point parameters.getIntegerParametersNames
: Return the names of the
integer parameters.getUnsignedShortParametersNames
: Return the names of
the unsigned short parameters.MTest
classHere is a first example of the MTest
class usage:
import std
import tfel.tests
from mtest import *
= MTest()
m
= 3.e-6
umax
setVerboseMode(VerboseLevel.VERBOSE_LEVEL2)
m.setPredictionPolicy(PredictionPolicy.LINEARPREDICTION)
"umat","src/libUmatBehaviour.so","umattvergaard")
m.setBehaviour('NormalStiffness',2.e16)
m.setMaterialProperty('TangentialStiffness',2.e16)
m.setMaterialProperty('MassDensity',0.)
m.setMaterialProperty('NormalThermalExpansion',0.)
m.setMaterialProperty('MaximumStress',200.e6)
m.setMaterialProperty('MaximumOpeningDisplacement',3.e-6)
m.setMaterialProperty(
"Temperature",293.15)
m.setExternalStateVariable('Un',{0.:0.,1800.:umax/2,
m.setImposedOpeningDisplacement(2400.:0.,2600:-1.e-8,3000:0.,
3600.:umax})
3.6*i for i in range(0,1001)])
m.setTimes(["castemtvergaard.res")
m.setOutputFileName( m.execute()
This example shows that there is almost a one to one mapping between
the keywords used in mtest
input file and the methods of
the MTest
class.
The last instruction will execute all the time steps defined the time
discretization defined using the setTimes
method.
This is not convenient and the mtest
module allows you
to precisely define and manage how the computations are performed.
The three last line are indeed equivalent to:
= MTestCurrentState()
s = MTestWorkSpace()
wk
"castemtvergaard.res")
m.setOutputFileName(
m.completeInitialisation()
m.initializeCurrentState(s)
m.initializeWorkSpace(wk)
= [3.6*i for i in range(0,1001)]
t # values at 0
0],s)
m.printOutput(t[
# do the job
for i in range(0,len(t)-1):
'Un',t[i+1],umax*t[i+1]/t[-1])
m.setEvolutionValue(+1])
m.execute(s,wk,t[i],t[i+1],s) m.printOutput(t[i
The previous example introduces two classes: the
MTestWorkSpace
class and the MTestCurrentState
class.
The MTestWorkSpace
is of no interest for the end-user.
It only manages to memory allocated to perform the computation: this
memory is allocated once when calling the
initializeWorkSpace
of the MTest class.
The MTestCurrentState
class will be discussed in depth
in the next section.
MTestCurrentState
classThe MTestCurrentState
is a wrapper class around the
StudyCurrentState
class discussed later.
It has been introduced for backward compatibility with previous
versions of TFEL
and have a simpler interface for studies
handled by the MTest
class (one structure, one integration
point..).
This structure contains the state of the (unique) integration point at the beginning and at the end of the time step.
MTestCurrentState
classThe MTestCurrentState
class provides the following
fields:
u_1
: values of the unknowns (driving variables and
lagrange multipliers) at the beginning of the previous time step. This
information is used for extrapolation the unknowns evolution over the
time step.u0
: values of the unknowns (driving variables and
lagrange multipliers) at the beginning of the current time step.u1
: values of the unknowns (driving variables and
lagrange multipliers) at the end of the current time step.s_1
: values of the forces (thermodynamic forces and
dual of the lagrange multipliers) at the beginning of the previous time
step.s1
: values of the forces (thermodynamic forces and dual
of the lagrange multipliers) at the beginning of the end time step.s0
: values of the forces (thermodynamic forces and dual
of the lagrange multipliers) at the beginning of the current time
step.e0
: values of the driving variables at the beginning of
the time step.e1
: values of the driving variables at the end of the
time step.e_th0
: values of the thermal strain for small strain
behaviours at the beginning of the current time step. Those values are
not null only if the thermal strain is handled by MTest
and
not by the behaviour.e_th1
: values of the thermal strain for small strain
behaviours at the end of the time step. Those values are not null only
if the thermal strain is handled by MTest
and not by the
behaviour.mprops1
: values of the material properties at the end
of the time step.iv_1
: values of the internal state variables at the
beginning of the previous time step.iv0
: values of the internal state variables at the
beginning of the current time step.iv1
: values of the internal state variables at the end
of the current time step.evs0
: values of the external state variables at the
beginning of the current time step.desv
: values of the increment of the external state
variables over the current time step.period
: total number of time steps done so far.iterations
: total number of iterations done so
far.subSteps
: total number of sub steps done so far.dt_1
: value of the previous time increment.Tref
: value of the reference temperature for the
thermal strain computation.The meaning of the driving variables depends on the type of behaviour treated:
The meaning of the thermodynamic forces also depends on the type of behaviour treated:
MTestCurrentState
classThe MTestCurrentState
class provide the
copy
method to get a deep copy of the structure. It is
mandatory to use such a copy in some advanced usage of the
MTest
class. This includes the following cases:
The MTestCurrentState
also provides
getInternalStateVariableValue
and
setInternalStateVariableValue
methods, which are described
more in depth below.
PipeTest
classHere is an example:
import std
import tfel.tests
from mtest import PipeTest,StudyCurrentState,SolverWorkSpace, \
setVerboseMode, VerboseLevel
setVerboseMode(VerboseLevel.VERBOSE_QUIET)
= PipeTest()
t # geometry and meshing
4.2e-3)
t.setInnerRadius(4.7e-3)
t.setOuterRadius(10)
t.setNumberOfElements('Linear')
t.setElementType(
# modelling hypothesis
'None')
t.setAxialLoading(
t.performSmallStrainAnalysis()
0,1])
t.setTimes([1.5e6)
t.setInnerPressureEvolution(0:1.5e6,1:10e6})
t.setOuterPressureEvolution({
'castem','../../src/libUmatBehaviour.so','umatelasticity')
t.setBehaviour('YoungModulus',150e9)
t.setMaterialProperty('PoissonRatio',0.3)
t.setMaterialProperty('Temperature',293.15)
t.setExternalStateVariable(
"pipe.res")
t.setOutputFileName(
t.execute()
StudyCurrentState
, StructureCurrentState
and
CurrentState
classesStudyCurrentState
classAs with the MTest
class, the user can have precise
control of how the computations are performed. The last instruction of
the previous example can be changed by the following code:
= StudyCurrentState()
s = SolverWorkSpace()
wk
t.completeInitialisation()
t.initializeCurrentState(s)
t.initializeWorkSpace(wk)
# values at 0
0,s)
t.printOutput(# resolution from 0 to 1
0.,1.)
t.execute(s,wk,# values at 1
1.,s) t.printOutput(
This code introduces two new classes: SolverWorkSpace
and StudyCurrentState
. Only the latter is interesting for
the end user.
The StudyCurrentState
has been designed to encapsulate
all the test cases handled by MTest
, in the current and
future versions of TFEL
.
The StudyCurrentState
provides the following fields:
u_1
: values of the unknowns (driving variables and
lagrange multipliers) at the beginning of the previous time step. This
information is used for extrapolation the unknowns evolution over the
time step.u0
: values of the unknowns (driving variables and
lagrange multipliers) at the beginning of the current time step.u1
: values of the unknowns (driving variables and
lagrange multipliers) at the end of the current time step.u10
: values of the unknowns (driving variables and
lagrange multipliers) at the previous iteration.period
: total number of time steps done so far.iterations
: total number of iterations done so
far.subSteps
: total number of sub steps done so far.dt_1
: value of the previous time increment.Some of those fields are the same than those described earlier when
discussing the MTestCurrentState
class. Indeed, the
MTestCurrentState
is just a wrapper around the
StudyCurrentState
.
In the case of pipes, the unknowns are the radial displacements of the nodes of the pipe mesh and the axial displacement. There are no Lagrange multipliers.
StructureCurrentState
classA study may contains one or several structures. The current state of
those structures are handled by the StructureCurrentState
class which can be retrieved from a StudyCurrentState
object using the getStructureCurrentState
method. This
latter method takes the name of the structure as argument.
In the case of pipes, only one unnamed structure is defined (See the example below).
The StructureCurrentState
has mostly one field:
istates
which contains CurrentState
objects
describing each integration points.
For a pipe, integration points in the istates
array are
ordered using their position from the closest to the inner radius of the
pipe to the closest to the outer radius of the pipe.
CurrentState
classThe CurrentState
class contains the values at
integration points. It contains the following fields:
s_1
: values of the forces (thermodynamic forces and
dual of the lagrange multipliers) at the beginning of the previous time
step.s1
: values of the forces (thermodynamic forces and dual
of the lagrange multipliers) at the beginning of the end time step.s0
: values of the forces (thermodynamic forces and dual
of the lagrange multipliers) at the beginning of the current time
step.e0
: values of the driving variables at the beginning of
the time step.e1
: values of the driving variables at the end of the
time step.e_th0
: values of the thermal strain for small strain
behaviours at the beginning of the current time step. Those values are
not null only if the thermal strain is handled by MTest
and
not by the behaviour.e_th1
: values of the thermal strain for small strain
behaviours at the end of the time step. Those values are not null only
if the thermal strain is handled by MTest
and not by the
behaviour.mprops1
: values of the material properties at the end
of the time step.iv_1
: values of the internal state variables at the
beginning of the previous time step.iv0
: values of the internal state variables at the
beginning of the current time step.iv1
: values of the internal state variables at the end
of the current time step.evs0
: values of the external state variables at the
beginning of the current time step.desv
: values of the increment of the external state
variables over the current time step.Those fields are the same than those of the
MTestCurrentState
which indeed acts as a proxy for the
unique integration point it handles.
Here is an example of use of the StudyCurrentState
class:
# get the structure current state
= s.getStructureCurrentState("")
scs # iterate of over the integration points
for cs in scs.istates:
#print the radial stress, the axial stress, the hoop stress
print(str(cs.s1[0])+" "+str(cs.s1[1])+" "+str(cs .s1[1]))
The internal state variables are stored in the iv_1
,
iv0
and iv1
fields. Beware that access to
those fields creates a copy of the underlying array of values.
The CurrentState
also provides a method called
getInternalStateVariableValue
which has two overloads.
The first one takes the name of a variable and returns its value at the end of the time step.
The second one has one more argument: the depth of the values to be accessed:
-1
means that we are modifying the internal state
variable value at the beginning of the previous time step0
means that we are modifying the internal state
variable value at the beginning of the current time step1
means that we are modifying the internal state
variable value at the end of the current time stepThe initial values of the internal state variables can be specified
by the setInternalStateVariableInitialValue
method of the
MTest
or PipeTest
class. This method takes the
name of internal state variable and a list
of
floats
(a float
is accepted for scalar
internal state variables).
The values are stored in the MTest
or
PipeTest
object and will be used every time the
initializeCurrentState
method is called.
Here is an example of use of the
getInternalStateVariableValue
method:
= s.getStructureCurrentState("")
scs # get the maximum of the equivalent plastic strain over the integration points
= max([cs.getInternalStateVariableValue('EquivalentPlasticStrain') for cs in scs.istates]) p
Sometimes, it can be useful to modify the values of the internal state variables during the computation. This can
The internal state variables are stored in the iv_1
,
iv0
and iv1
fields. Access to those variables
creates a copy of the underlying array of values. Thus, modifying those
values has no effect of the CurrentState
object.
To modify the values of a CurrentState
, one may of the
two overloads of the setInternalStateVariableValue
method:
list
of floats
(a
float
is accepted for scalar internal state variables). The
value given is affected to internal state variable values at the
beginning of the previous time step (iv_1
field), the
beginning of the current time step (iv0
field) and the end
of the current time step (iv1
field).-1
means that we are modifying the internal state
variable value at the beginning of the previous time step0
means that we are modifying the internal state
variable value at the beginning of the current time step1
means that we are modifying the internal state
variable value at the end of the current time stepHere is an example of use of the
setInternalStateVariableValue
method:
= s.getStructureCurrentState("")
scs # iterate of over the integration points
for cs in scs.istates:
# set the value of the equivalent plastic strain
'EquivalentPlasticStrain',2.e-2) cs.setInternalStateVariableValue(
PipeTest
classfrom mtest import PipeTest,StudyCurrentState,SolverWorkSpace, \
setVerboseMode, VerboseLevel
# no output
setVerboseMode(VerboseLevel.VERBOSE_QUIET)
= 4.18e-3
Re = 3.1415926*Re*Re*20e6
Fz
= PipeTest()
t
# geometric and meshing options
0)
t.setInnerRadius(
t.setOuterRadius(Re)1)
t.setNumberOfElements('Quadratic')
t.setElementType(
# Type of loading
'ImposedAxialForce')
t.setAxialLoading(
# no geometrical update
t.performSmallStrainAnalysis()
# by default, with the 'castem' interface, one does not use the
# consistent tangent operator. Using the acceleration algorithm
# is mandatory for convergence.
True)
t.setUseCastemAccelerationAlgorithm(
# axial loading
0.:0.,1.e-6 :Fz,3600:Fz})
t.setAxialForceEvolution({
# definition of the mechanical behaviour and the material properties
'castem','../../src/libUmatBehaviour.so','umatnorton')
t.setBehaviour('YoungModulus',150e9)
t.setMaterialProperty('PoissonRatio',0.3)
t.setMaterialProperty('A',8.e-67)
t.setMaterialProperty('E',8.2)
t.setMaterialProperty(
# temperature (mandatory)
'Temperature',293.15)
t.setExternalStateVariable(
# results file
'pipe4.res')
t.setOutputFileName(
= StudyCurrentState()
s = SolverWorkSpace()
wk
# complete initialisation of the problem
t.completeInitialisation()
t.initializeCurrentState(s)
t.initializeWorkSpace(wk)
# time discretization
= [0]+[1.e-6+((3600.-1.e-6)/20.)*i for i in range(21)];
times
# get the state of the pipe (unique structure defined)
= s.getStructureCurrentState("")
scs = max([cs.getInternalStateVariableValue("EquivalentViscoplasticStrain")
p for cs in scs.istates])
print(str(times[0])+" "+str(p))
# loop over the time steps
for i in range(0,len(times)-1):
# search the mechanical equilibrium at the end of the time step
+1])
t.execute(s,wk,times[i],times[i# write in the output file
+1],s)
t.printOutput(times[i# iterate of over the integration points
= max([cs.getInternalStateVariableValue("EquivalentViscoplasticStrain")
p for cs in scs.istates])
print(str(times[i+1])+" "+str(p))