LibtorchModel
This is a custom NEML2 object for solid_mechanics. To enable it, configure MOOSE with libtorch and initialize the NEML2 submodule.
The documentation is for a NEML2 (Hu et al., 2024; Messner and Hu, 2023) material for evaluating pretrained libtorch models in .pt format, such as neural networks. This allows evaluating models with an arbitrary number of inputs and mapping them to an arbitrary number of outputs.
Example Input File
Running NEML2 models using MOOSE requires a separate NEML2 input file that builds the material. An example input for a NEML2 LibtorchModel is shown below. The inputs to the libtorch model are provided using inputs = 'forces/T', and the model outputs are mapped to outputs = 'state/k_T'. The scaling of inputs and outputs is built into the libtorch model during training.
[Models]
[rom]
type = LibtorchModel
inputs = 'forces/T'
outputs = 'state/k_T'
file_path = 'solid_mechanics:libtorch/test/thermal_conductivity_model.pt'
[]
[](moose/modules/solid_mechanics/test/tests/neml2/models/libtorch_model.i)The evaluated NEML2 variable value state/k_T can then be mapped back to a MOOSE material property as shown in the following input file. The NEML2 input file is specified inside the NEML2 block. We specify which NEML2 model to use (model = 'rom'), and specify that we want to map the non-linear T variable in MOOSE to the forces/T NEML2 variable, and the state/k_T NEML2 variable is mapped back to the k_T MOOSE material property (which is automatically generated by the action). NEML2 also uses automatic differenciation on the libtorch model to provide arbitrary derivatives of the outputs in relation to the inputs. Here we specify that we want to calculate to populate the Jacobian in a heat conduction example problem.
[NEML2<<<{"href": "../../../syntax/NEML2/index.html"}>>>]
input<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: Path to the NEML2 input file containing the NEML2 model(s).)"}>>> = 'models/libtorch_model.i'
[thermal_conductivity_model]
model<<<{"description": "Name of the NEML2 model, i.e., the string inside the brackets [] in the NEML2 input file that corresponds to the model you want to use."}>>> = 'rom'
moose_input_types<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: Type of each MOOSE data to be used as NEML2 input variable)"}>>> = 'VARIABLE'
moose_inputs<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: List of MOOSE data to be used as inputs of the material model.)"}>>> = 'T'
neml2_inputs<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: List of NEML2 input variables corresponding to each MOOSE data.)"}>>> = 'forces/T'
neml2_outputs<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: List of NEML2 output variables corresponding to each MOOSE data.)"}>>> = 'state/k_T'
moose_outputs<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: List of MOOSE data used to hold the output of the material model.)"}>>> = 'k_T'
moose_output_types<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: MOOSE types used to hold the NEML2 output variables)"}>>> = 'MATERIAL'
neml2_derivatives<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: List of pairs of NEML2 variables to take derivatives (i.e., first in the pair w.r.t. the second in the pair).)"}>>> = 'state/k_T forces/T'
moose_derivatives<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: List of MOOSE data used to hold the derivative of the material model.)"}>>> = 'dk_T/dT'
moose_derivative_types<<<{"description": "The `NEML2` library is required but not enabled. Refer to the documentation for guidance on how to enable it. (Original description: MOOSE types used to hold the NEML2 variable derivatives)"}>>> = 'MATERIAL'
export_outputs<<<{"description": "List of MOOSE material properties to export which correspond to NEML2 output variables or output derivatives. Each material property's export targets can be specified by export_output_targets. The default export target is 'none'."}>>> = 'k_T dk_T/dT'
export_output_targets<<<{"description": "The export targets corresponding to each MOOSE material property specified in export_outputs."}>>> = 'exodus;exodus'
[]
[](moose/modules/solid_mechanics/test/tests/neml2/heat_conduction.i)References
- Tianchen Hu, Mark C. Messner, Daniel Schwen, Lynn B. Munday, and Dewen Yushu.
Neml2: a high performance library for constitutive modeling.
Technical Report, Argonne National Laboratory (ANL), Argonne, IL (United States); Idaho National Laboratory (INL), Idaho Falls, ID (United States), 09 2024.
URL: https://www.osti.gov/biblio/2440430, doi:10.2172/2440430.[BibTeX]
- Mark Messner and Tianchen Hu.
NEML2 - The New Engineering Material Model Library, version 2.
Technical Report, Argonne National Lab.(ANL), Argonne, IL (United States), 2023.[BibTeX]