|
NEML2 2.0.0
|
In the previous tutorial, we demonstrated the use of ImplicitUpdate to perform constitutive update by solving an implicit system of equations. In particular, we have addressed the constitutive update in the following form
\begin{align} \mathbf{s}_{n+1} = f(\mathbf{f}_{n+1}, \mathbf{s}_n, \mathbf{f}_n; \mathbf{p}). \label{form1} \end{align}
In other words, the constitutive update takes a recursive form: Given the state and external force of the system ( \(\mathbf{s}_n\) and \(\mathbf{f}_n\)) at time step \(n\), as well as the "forces" \(\mathbf{f}_{n+1}\) driving the system to advance to the next step \(n+1\), the model yields the state of the system for the next step \(\mathbf{s}_{n+1}\).
This form of constitutive update is oftentimes sufficient when coupling with external PDE solvers: The PDE solver calculates the external driving force \(\mathbf{f}_{n+1}\) and asks NEML2 to advance the state of system to \(\mathbf{s}_{n+1}\).
However, in many other applications such as parameter calibration, it is favorable to let NEML2 drive the constitutive update (recursively) to effectively simulate the transient response of the material. The corresponding initial-value problem can be formally written as:
Given initial conditions \(\mathbf{s}_0\) and \(\mathbf{f}_0\), find, \(\forall n \in [0, N-1]\),
\begin{align} \mathbf{s}_{n+1} = f(\mathbf{f}_{n+1}, \mathbf{s}_n, \mathbf{f}_n; \mathbf{p}), \label{form2} \end{align}
where \(N\) is the total number of steps used to discretize the "transient".
NEML2 models, including those composed from submodels, can only be used to describe the first form of constitutive \(\eqref{form1}\), i.e., a single step constitutive update. In order to simulate the initial-value problem defined in \(\eqref{form2}\), a neml2::TransientDriver can be used to perform the recursive constitutive update to obtain the transient response.
Reusing the viscoplasticity model defined in the previous tutorial, along with the Newton-Raphson solver, a predefined driver SDTSolidMechanicsDriver can be used to obtain the stress-strain curve.
with tensors defined as
The SDTSolidMechanicsDriver performs the recursive constitutive update using strain control, suitable for solid mechanics models using the small strain formulation. It asks the user to specify "prescribed_time" and "prescribed_strain" which define the discretization of the transient. Two predictors are implemented for all transient drivers:
The optional option "save_as" tells the driver to write the results into a file named "result.pt".
The following C++ code retrieves and executes the driver to obtain the stress-strain curve.
The results saved in "result.pt" can be used as a regular pickled TorchScript, which can be loaded using torch.jit.load. For example, the following Python script retrieves and plots the strain and stress values.