NEML2 2.1.0
Loading...
Searching...
No Matches

Implicit exponential time integration for rotations. More...

Detailed Description

Implicit exponential time integration for rotations.

#include <WR2ImplicitExponentialTimeIntegration.h>

Inheritance diagram for WR2ImplicitExponentialTimeIntegration:

Public Member Functions

 WR2ImplicitExponentialTimeIntegration (const OptionSet &options)
void diagnose () const override
 Check for common problems.
Public Member Functions inherited from Model
 Model (const OptionSet &options)
 Construct a new Model object.
void setup () override
 Setup this object.
virtual bool defines_values () const
 Whether this model defines output values.
virtual bool defines_derivatives () const
 Whether this model defines first derivatives.
virtual bool defines_second_derivatives () const
 Whether this model defines second derivatives.
virtual bool is_jit_enabled () const
 Whether JIT is enabled.
virtual void to (const TensorOptions &options)
 Send model to a different device or dtype.
const std::vector< std::shared_ptr< Model > > & registered_models () const
 The models that may be used during the evaluation of this model.
std::shared_ptr< Modelregistered_model (const std::string &name) const
 Get a registered model by its name.
void register_nonlinear_parameter (const std::string &pname, const NonlinearParameter &param)
 Register a nonlinear parameter.
bool has_nl_param (bool recursive=false) const
 Whether this parameter store has any nonlinear parameter.
const VariableBasenl_param (const std::string &) const
 Query the existence of a nonlinear parameter.
virtual std::map< std::string, NonlinearParameternamed_nonlinear_parameters (bool recursive=false) const
 Get all nonlinear parameters.
std::set< VariableNameconsumed_items () const override
 The variables that this model depends on.
std::set< VariableNameprovided_items () const override
 The variables that this model defines as part of its output.
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.
void clear_input () override
void clear_output () override
void zero_undefined_input () override
 Fill undefined input variables with zeros.
void forward_maybe_jit (bool out, bool dout, bool d2out)
 Forward operator with jit.
std::string variable_name_lookup (const ATensor &var) const
 Look up the name of a variable in the traced graph.
virtual ValueMap value (const ValueMap &in)
 Convenient shortcut to construct and return the model value.
virtual std::tuple< ValueMap, DerivMapvalue_and_dvalue (const ValueMap &in)
 Convenient shortcut to construct and return the model value and its derivative.
virtual DerivMap dvalue (const ValueMap &in)
 Convenient shortcut to construct and return the derivative.
virtual std::tuple< ValueMap, DerivMap, SecDerivMapvalue_and_dvalue_and_d2value (const ValueMap &in)
 Convenient shortcut to construct and return the model's value, first and second derivative.
virtual SecDerivMap d2value (const ValueMap &in)
 Convenient shortcut to construct and return the model's second derivative.
virtual std::tuple< DerivMap, SecDerivMapdvalue_and_d2value (const ValueMap &in)
 Convenient shortcut to construct and return the model's first and second derivative.
Public Member Functions inherited from Data
 Data (const OptionSet &options)
 Construct a new Data object.
const std::vector< std::shared_ptr< Data > > & registered_data () const
 All the registered data objects.
Public Member Functions inherited from NEML2Object
 NEML2Object ()=delete
 NEML2Object (NEML2Object &&)=delete
 NEML2Object (const NEML2Object &)=delete
NEML2Objectoperator= (NEML2Object &&)=delete
NEML2Objectoperator= (const NEML2Object &)=delete
virtual ~NEML2Object ()=default
 NEML2Object (const OptionSet &options)
 Construct a new NEML2Object object.
const OptionSetinput_options () const
const std::string & name () const
 A readonly reference to the object's name.
const std::string & type () const
 A readonly reference to the object's type.
const std::string & path () const
 A readonly reference to the object's path.
const std::string & doc () const
 A readonly reference to the object's docstring.
Factoryfactory () const
 Get the factory that created this object.
const Settingssettings () const
 Settings.
template<typename T = NEML2Object>
const T * host () const
 Get a readonly pointer to the host.
template<typename T = NEML2Object>
T * host ()
 Get a writable pointer to the host.
template<typename T>
const T & resolve_tensor (const std::string &name)
 Resolve a TensorName to a Tensor.
template<class T>
std::shared_ptr< T > get_object (const std::string &section, const std::string &name)
template<class T = EquationSystem>
std::shared_ptr< T > get_es (const std::string &name)
 Get an equation system from the factory.
template<class T = Solver>
std::shared_ptr< T > get_solver (const std::string &name)
 Get a solver from the factory.
template<class T = Data>
std::shared_ptr< T > get_data (const std::string &name)
 Get a data from the factory.
template<class T = Model>
std::shared_ptr< T > get_model (const std::string &name)
 Get a model from the factory.
template<class T = Driver>
std::shared_ptr< T > get_driver (const std::string &name)
 Get a driver from the factory.
template<class T = WorkScheduler>
std::shared_ptr< T > get_scheduler (const std::string &name)
 Get a scheduler from the factory.
Public Member Functions inherited from BufferStore
 BufferStore (NEML2Object *object)
 BufferStore (const BufferStore &)=delete
 BufferStore (BufferStore &&)=delete
BufferStoreoperator= (const BufferStore &)=delete
BufferStoreoperator= (BufferStore &&)=delete
virtual ~BufferStore ()=default
const std::map< std::string, std::unique_ptr< TensorValueBase > > & named_buffers () const
std::map< std::string, std::unique_ptr< TensorValueBase > > & named_buffers ()
const TensorValueBaseget_buffer (const std::string &name) const
 }@
TensorValueBaseget_buffer (const std::string &name)
 Get a writable reference of a buffer.
Public Member Functions inherited from ParameterStore
 ParameterStore (NEML2Object *object)
 ParameterStore (const ParameterStore &)=delete
 ParameterStore (ParameterStore &&)=delete
ParameterStoreoperator= (const ParameterStore &)=delete
ParameterStoreoperator= (ParameterStore &&)=delete
virtual ~ParameterStore ()=default
const std::map< std::string, std::unique_ptr< TensorValueBase > > & named_parameters () const
std::map< std::string, std::unique_ptr< TensorValueBase > > & named_parameters ()
const TensorValueBaseget_parameter (const std::string &name) const
 }@
TensorValueBaseget_parameter (const std::string &name)
 Get a writable reference of a parameter.
void set_parameter (const std::string &, const Tensor &)
 Set the value for a parameter.
void set_parameters (const std::map< std::string, Tensor > &)
 Set values for parameters.
Public Member Functions inherited from VariableStore
 VariableStore (Model *object)
 VariableStore (const VariableStore &)=delete
 VariableStore (VariableStore &&)=delete
VariableStoreoperator= (const VariableStore &)=delete
VariableStoreoperator= (VariableStore &&)=delete
virtual ~VariableStore ()=default
LabeledAxisdeclare_axis (const std::string &name)
const TensorOptionsvariable_options () const
 Current tensor options for variables.
LabeledAxisinput_axis ()
const LabeledAxisinput_axis () const
LabeledAxisoutput_axis ()
const LabeledAxisoutput_axis () const
VariableStorageinput_variables ()
const VariableStorageinput_variables () const
VariableStorageoutput_variables ()
const VariableStorageoutput_variables () const
VariableBaseinput_variable (const VariableName &)
const VariableBaseinput_variable (const VariableName &) const
VariableBaseoutput_variable (const VariableName &)
const VariableBaseoutput_variable (const VariableName &) const
virtual void clear_derivatives ()
void cache_derivative_sparsity ()
void cache_second_derivative_sparsity ()
 Cache sparsity of second derivatives.
const std::optional< DerivSparsity > & derivative_sparsity () const
 Derivative sparsity.
const std::optional< SecDerivSparsity > & second_derivative_sparsity () const
 Second derivative sparsity.
void assign_input (const ValueMap &vals)
void assign_input (const std::vector< VariableName > &, const SparseTensorList &)
 Assign input variable values for the given variable names.
void assign_output (const ValueMap &vals)
 Assign output variable values.
void assign_output (const std::vector< VariableName > &, const SparseTensorList &)
 Assign output variable values for the given variable names.
void assign_output_derivatives (const DerivMap &derivs)
 Assign variable derivatives.
void assign_output_derivatives (const std::vector< VariableName > &, const std::vector< VariableName > &, const SparseTensorList &)
 Assign variable derivatives for the given variable names.
ValueMap collect_input () const
SparseTensorList collect_input (const std::vector< VariableName > &) const
 Collect input variable values for the given variable names.
ValueMap collect_output () const
 Collect output variable values.
SparseTensorList collect_output (const std::vector< VariableName > &) const
 Collect output variable values for the given variable names.
DerivMap collect_output_derivatives () const
 Collect variable derivatives.
SparseTensorList collect_output_derivatives (const std::vector< VariableName > &, const std::vector< VariableName > &) const
 Collect variable derivatives for the given variable names.
SecDerivMap collect_output_second_derivatives () const
 Collect variable second derivatives.
Public Member Functions inherited from DependencyDefinition< VariableName >
 DependencyDefinition ()=default
DependencyDefinitionoperator= (const DependencyDefinition &)=delete
virtual ~DependencyDefinition ()=default
Public Member Functions inherited from DiagnosticsInterface
 DiagnosticsInterface ()=delete
 DiagnosticsInterface (NEML2Object *object)
 DiagnosticsInterface (DiagnosticsInterface &&)=delete
 DiagnosticsInterface (const DiagnosticsInterface &)=delete
DiagnosticsInterfaceoperator= (const DiagnosticsInterface &)=delete
DiagnosticsInterfaceoperator= (DiagnosticsInterface &&)=delete
virtual ~DiagnosticsInterface ()=default
const NEML2Objectobject () const
 Get the object.

Static Public Member Functions

static OptionSet expected_options ()
Static Public Member Functions inherited from Model
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 ()

Protected Member Functions

void set_value (bool out, bool dout_din, bool d2out_din2) override
 Perform the update by defining the nonlinear residual and it's derivatives.
Protected Member Functions inherited from Model
void diagnostic_assert_state (const VariableBase &v) const
void diagnostic_assert_old_state (const VariableBase &v) const
void diagnostic_assert_force (const VariableBase &v) const
void diagnostic_assert_old_force (const VariableBase &v) const
void diagnostic_assert_residual (const VariableBase &v) const
void diagnostic_check_input_variable (const VariableBase &v) const
void diagnostic_check_output_variable (const VariableBase &v) const
virtual void link_input_variables ()
virtual void link_input_variables (Model *submodel)
virtual void link_output_variables ()
virtual void link_output_variables (Model *submodel)
void check_precision () const
 Check the current default precision and warn if it's not double precision.
virtual std::string failed_graph_execution_hint () const
 Additional hint to include in the error message when an exception is encountered during execution of the traced graph.
virtual void request_AD ()
void forward (bool out, bool dout, bool d2out)
 Forward operator without jit.
template<typename T = Model, typename = typename std::enable_if_t<std::is_base_of_v<Model, T>>>
T & register_model (const std::string &name, bool merge_input=true)
 Register a model that the current model may use during its evaluation.
template<typename T = Model, typename = typename std::enable_if_t<std::is_base_of_v<Model, T>>>
void register_model (const std::shared_ptr< T > &model, bool merge_input=true)
 Register a model that the current model may use during its evaluation.
void assign_input_stack (jit::Stack &stack)
jit::Stack collect_input_stack () const
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)
virtual void send_buffers_to (const 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 TensorName< T > &tensorname)
 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.
void assign_buffer_stack (jit::Stack &stack)
 Assign stack to buffers.
jit::Stack collect_buffer_stack () const
 Collect stack from buffers.
virtual void send_parameters_to (const 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 TensorName< T > &tensorname, 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.
void assign_parameter_stack (jit::Stack &stack)
 Assign stack to parameters.
jit::Stack collect_parameter_stack () const
 Collect stack from parameters.
Protected Member Functions inherited from VariableStore
virtual void send_variables_to (const TensorOptions &options)
 Send padding variables to options.
template<typename T>
const Variable< T > & declare_input_variable (const char *name, bool allow_duplicate=false)
 Declare an input variable.
template<typename T>
const Variable< T > & declare_input_variable (const VariableName &name, bool allow_duplicate=false)
 Declare an input variable.
template<typename T>
Variable< T > & declare_output_variable (const char *name)
 Declare an output variable.
template<typename T>
Variable< T > & declare_output_variable (const VariableName &name)
 Declare an output variable.
const VariableBaseclone_input_variable (const VariableBase &var, const VariableName &new_name={})
 Clone a variable and put it on the input axis.
VariableBaseclone_output_variable (const VariableBase &var, const VariableName &new_name={})
 Clone a variable and put it on the output axis.
void assign_input_stack (jit::Stack &stack)
 Assign stack to input variables.
void assign_output_stack (jit::Stack &stack, bool out, bool dout, bool d2out)
 Assign stack to output variables and derivatives.
jit::Stack collect_input_stack () const
 Collect stack from input variables.
jit::Stack collect_output_stack (bool out, bool dout, bool d2out) const
 Collect stack from output variables and derivatives.

Protected Attributes

const Variable< Rot > & _s
 Current guess at next value.
const Variable< Rot > & _sn
 Previous value.
const Variable< WR2 > & _s_dot
 Current variable spin rate.
const Variable< Scalar > & _t
 Current time.
const Variable< Scalar > & _tn
 Previous time.
Variable< Rot > & _r
 Nonlinear residual.
Protected Attributes inherited from Model
std::vector< std::shared_ptr< Model > > _registered_models
 Models this model may use during its evaluation.
Protected Attributes inherited from Data
std::vector< std::shared_ptr< Data > > _registered_data
 Registered Data objects.

Additional Inherited Members

Public Types inherited from VariableStore
using VariableStorage = std::map<VariableName, std::unique_ptr<VariableBase>>
using DerivSparsity = std::vector<std::pair<VariableBase *, const VariableBase *>>
using SecDerivSparsity

Constructor & Destructor Documentation

◆ WR2ImplicitExponentialTimeIntegration()

WR2ImplicitExponentialTimeIntegration ( const OptionSet & options)

Member Function Documentation

◆ diagnose()

void diagnose ( ) const
overridevirtual

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.

Reimplemented from Model.

◆ expected_options()

OptionSet expected_options ( )
static

◆ set_value()

void set_value ( bool out,
bool dout_din,
bool d2out_din2 )
overrideprotectedvirtual

Perform the update by defining the nonlinear residual and it's derivatives.

Implements Model.

Member Data Documentation

◆ _r

Variable<Rot>& _r
protected

Nonlinear residual.

◆ _s

const Variable<Rot>& _s
protected

Current guess at next value.

◆ _s_dot

const Variable<WR2>& _s_dot
protected

Current variable spin rate.

◆ _sn

const Variable<Rot>& _sn
protected

Previous value.

◆ _t

const Variable<Scalar>& _t
protected

Current time.

◆ _tn

const Variable<Scalar>& _tn
protected

Previous time.