NEML2 2.0.0
|
The base class for all constitutive models. More...
The base class for all constitutive models.
A model maps some input to output. The forward operator (and its derivative) is defined in the method Model::set_value
. All concrete models must provide the implementation of the forward operator by overriding the Model::set_value
method.
#include <Model.h>
Inherits enable_shared_from_this< Model >, Data, ParameterStore, VariableStore, NonlinearSystem, DependencyDefinition< VariableName >, and DiagnosticsInterface.
Inherited by ElasticityInterface< Model, 2 >, NonlinearParameter< Scalar >, NonlinearParameter< SSR4 >, AssociativeJ2FlowDirection, BackwardEulerTimeIntegration< T >, ComposedModel, CopyVariable< T >, CrystalMean< T >, Eigenstrain, ElasticStrainRate, Elasticity, FixOrientation, FlowRule, ForwardEulerTimeIntegration< T >, GTNYieldFunction, GursonCavitation, ImplicitUpdate, IsotropicHardening, IsotropicHardeningStaticRecovery, KinematicHardening, KinematicHardeningStaticRecovery, KocksMeckingActivationEnergy, KocksMeckingFlowSwitch, LinearCombination< T >, MandelStress, MixedControlSetup, NonlinearParameter< T >, Normality, OlevskySinteringStress, OrientationRate, PlasticDeformationRate, PlasticFlowRate, PlasticVorticity, RateIndependentPlasticFlowConstraint, ResolvedShear, RotationMatrix, SR2Invariant, SingleSlipHardeningRule, SlipRule, SlipStrengthMap, SumSlipRates, TwoStageThermalAnnealing< T >, VariableRate< T >, WR2ExplicitExponentialTimeIntegration, WR2ImplicitExponentialTimeIntegration, and YieldFunction.
Static Public Member Functions | |
static OptionSet | expected_options () |
Static Public Member Functions inherited from Data | |
static OptionSet | expected_options () |
Static Public Member Functions inherited from NEML2Object | |
static OptionSet | expected_options () |
Static Public Member Functions inherited from NonlinearSystem | |
static OptionSet | expected_options () |
static void | disable_automatic_scaling (OptionSet &options) |
static void | enable_automatic_scaling (OptionSet &options) |
Protected Member Functions | |
void | setup () override |
Setup this object. | |
virtual void | link_input_variables () |
virtual void | link_input_variables (Model *submodel) |
virtual void | link_output_variables () |
virtual void | link_output_variables (Model *submodel) |
virtual void | request_AD () |
void | diagnose_nl_sys (std::vector< Diagnosis > &diagnoses) const |
Additional diagnostics for a nonlinear system. | |
virtual void | set_value (bool out, bool dout_din, bool d2out_din2)=0 |
The map between input -> output, and optionally its derivatives. | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<Model, T>>> | |
T & | register_model (const std::string &name, bool nonlinear=false, bool merge_input=true) |
Register a model that the current model may use during its evaluation. | |
void | set_guess (const Sol< false > &) override |
Set the unscaled current guess. | |
void | assemble (Res< false > *, Jac< false > *) override |
Compute the unscaled residual and Jacobian. | |
Protected Member Functions inherited from Data | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<Data, T>>> | |
T & | register_data (const std::string &name) |
Protected Member Functions inherited from BufferStore | |
virtual void | send_buffers_to (const torch::TensorOptions &options) |
Send all buffers to options . | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_buffer (const std::string &name, const T &rawval) |
Declare a buffer. | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_buffer (const std::string &name, const CrossRef< T > &crossref) |
Declare a buffer. | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_buffer (const std::string &name, const std::string &input_option_name) |
Declare a buffer. | |
Protected Member Functions inherited from ParameterStore | |
virtual void | send_parameters_to (const torch::TensorOptions &options) |
Send parameters to options. | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_parameter (const std::string &name, const T &rawval) |
Declare a parameter. | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_parameter (const std::string &name, const CrossRef< T > &crossref, bool allow_nonlinear) |
Declare a parameter. | |
template<typename T , typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>> | |
const T & | declare_parameter (const std::string &name, const std::string &input_option_name, bool allow_nonlinear=false) |
Declare a parameter. | |
Protected Member Functions inherited from VariableStore | |
template<typename T , typename S > | |
const Variable< T > & | declare_input_variable (S &&name, TensorShapeRef list_shape={}, TensorShapeRef base_shape={}) |
Declare an input variable. | |
template<typename T , typename S > | |
Variable< T > & | declare_output_variable (S &&name, TensorShapeRef list_shape={}, TensorShapeRef base_shape={}) |
Declare an output variable. | |
const VariableBase * | clone_input_variable (const VariableBase &var, const VariableName &new_name={}) |
Clone a variable and put it on the input axis. | |
VariableBase * | clone_output_variable (const VariableBase &var, const VariableName &new_name={}) |
Clone a variable and put it on the output axis. | |
Protected Attributes | |
std::vector< Model * > | _registered_models |
Models this model may use during its evaluation. | |
Protected Attributes inherited from Data | |
std::vector< Data * > | _registered_data |
Registered Data objects. | |
Protected Attributes inherited from ParameterStore | |
std::map< std::string, const VariableBase * > | _nl_params |
Map from nonlinear parameter names to their corresponding variable views. | |
std::map< std::string, Model * > | _nl_param_models |
Map from nonlinear parameter names to models which evaluate them. | |
Protected Attributes inherited from NonlinearSystem | |
const bool | _autoscale |
If true, do automatic scaling. | |
const Real | _autoscale_tol |
Tolerance for convergence check of the iterative automatic scaling algorithm. | |
const unsigned int | _autoscale_miter |
Maximum number of iterations allowed for the iterative automatic scaling algorithm. | |
bool | _scaling_matrices_initialized |
Flag to indicate whether scaling matrices have been computed. | |
Tensor | _row_scaling |
Row scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals. | |
Tensor | _col_scaling |
Column scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals. | |
Friends | |
class | ParameterStore |
Declaration of nonlinear parameters may require manipulation of input. | |
class | ComposedModel |
ComposedModel's set_value need to call submodel's set_value. | |
Construct a new Model object.
options | The options extracted from the input file |
Compute the unscaled residual and Jacobian.
r | Pointer to the residual vector – nullptr if not requested |
J | Pointer to the Jacobian matrix – nullptr if not requested |
Implements NonlinearSystem.
|
overridevirtual |
Release allocated tensor
Reimplemented from VariableStore.
|
overridevirtual |
Reimplemented from VariableStore.
|
overridevirtual |
The variables that this model depends on.
Implements DependencyDefinition< VariableName >.
|
virtual |
Evalute the second derivatives.
|
virtual |
Convenient shortcut to construct and return the model's second derivative.
Check for common problems.
This method serves as the entry point for diagnosing common problems in object setup. The idea behind this method is that while some errors could be detected at construction time, i.e., when the object's constructor is called, it doesn't hinder other objects' creation. We therefore would like to defer the detection of errors until after all objects have been created, collect all errors at once, and present the user with a complete understanding of all errors encountered.
Note, however, if an error could interfere with other objects' creation, it should be raised right away inside the constructor, instead of inside this method.
diagnoses | A vector of exceptions of type Diagnosis for each of the detected problem. |
Implements DiagnosticsInterface.
Reimplemented in VariableRate< T >, WR2ExplicitExponentialTimeIntegration, and WR2ImplicitExponentialTimeIntegration.
Additional diagnostics for a nonlinear system.
|
virtual |
Evalute the derivative.
Convenient shortcut to construct and return the derivative.
|
virtual |
Evalute the first and second derivatives.
|
virtual |
Convenient shortcut to construct and return the model's first and second derivative.
|
static |
Whether this model defines one or more nonlinear equations to be solved.
|
protectedvirtual |
Reimplemented in ComposedModel.
|
protectedvirtual |
Reimplemented in ImplicitUpdate.
Reimplemented in ComposedModel.
|
overridevirtual |
The variables that this model defines as part of its output.
Implements DependencyDefinition< VariableName >.
|
inlineprotected |
Register a model that the current model may use during its evaluation.
If merge_input
is set to true, this model will also consume the consumed variables of model
, which will affect dependency resolution inside a ComposedModel.
name | The model to register |
nonlinear | Set to true if the registered model defines a nonlinear system to be solved |
merge_input | Whether to merge the input axis of the registered model into this model's input axis. This will make sure that the input variables of the registered model are "ready" by the time this model is evaluated. |
The models that may be used during the evaluation of this model.
Request the use of automatic differentiation to compute variable derivatives
Model implementations which require automatic differentiation to compute variable derivatives shall override this method and mark variable derivatives. Variable derivatives are marked as,
void request_AD | ( | VariableBase & | y, |
const VariableBase & | u ) |
Request to use AD to compute the first derivative of a variable.
void request_AD | ( | VariableBase & | y, |
const VariableBase & | u1, | ||
const VariableBase & | u2 ) |
Request to use AD to compute the second derivative of a variable.
Set the unscaled current guess.
Implements NonlinearSystem.
The map between input -> output, and optionally its derivatives.
Implemented in ArrheniusParameter, BackwardEulerTimeIntegration< T >, ConstantParameter< T >, CopyVariable< T >, ForwardEulerTimeIntegration< T >, ImplicitUpdate, InputParameter< T >, LinearCombination< T >, LinearInterpolation< T >, RotationMatrix, AssociativeIsotropicPlasticHardening, AssociativeKinematicPlasticHardening, AssociativePlasticFlow, ChabochePlasticHardening, CrystalMean< T >, ElasticStrainRate, FixOrientation, LinearSingleSlipHardeningRule, OrientationRate, PlasticDeformationRate, PlasticVorticity, PowerLawSlipRule, ResolvedShear, SingleSlipStrengthMap, SumSlipRates, VoceSingleSlipHardeningRule, CubicElasticityTensor, GeneralElasticity, IsotropicElasticityTensor, LinearIsotropicElasticity, FredrickArmstrongPlasticHardening, GTNYieldFunction, GursonCavitation, IsotropicMandelStress, KocksMeckingActivationEnergy, KocksMeckingFlowSwitch, KocksMeckingFlowViscosity, KocksMeckingIntercept, KocksMeckingRateSensitivity, KocksMeckingYieldStress, LinearIsotropicElasticJ2TrialStressUpdate, LinearIsotropicHardening, LinearKinematicHardening, MixedControlSetup, Normality, OlevskySinteringStress, PerzynaPlasticFlowRate, PowerLawIsotropicHardeningStaticRecovery, PowerLawKinematicHardeningStaticRecovery, RateIndependentPlasticFlowConstraint, SlopeSaturationVoceIsotropicHardening, TwoStageThermalAnnealing< T >, VoceIsotropicHardening, YieldFunction, SR2Invariant, VariableRate< T >, WR2ExplicitExponentialTimeIntegration, WR2ImplicitExponentialTimeIntegration, ComposedModel, AssociativeJ2FlowDirection, and ThermalEigenstrain.
|
overrideprotectedvirtual |
Setup this object.
This method is called automatically if you use the Factory method get_object or get_object_ptr, right after construction. This serves as the entry point for things that are not convenient/possible to do at construction time, but are necessary before this object can be used (by others).
Reimplemented from NEML2Object.
|
virtual |
Evalute the model.
Convenient shortcut to construct and return the model value.
|
virtual |
Evalute the model and compute its derivative.
Convenient shortcut to construct and return the model value and its derivative.
|
virtual |
Evalute the model and compute its first and second derivatives.
|
virtual |
Convenient shortcut to construct and return the model's value, first and second derivative.
|
overridevirtual |
Zero variable values
Reimplemented from VariableStore.
|
overridevirtual |
Reimplemented from VariableStore.
|
friend |
ComposedModel's set_value need to call submodel's set_value.
|
friend |
Declaration of nonlinear parameters may require manipulation of input.
|
protected |
Models this model may use during its evaluation.