www.mooseframework.org
ADLAROMANCEStressUpdateBase.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
13 
14 #define usingADLAROMANCEStressUpdateBase \
15  usingRadialReturnCreepStressUpdateBaseMembers; \
16  using ADLAROMANCEStressUpdateBase<compute_stage>::getTransform; \
17  using ADLAROMANCEStressUpdateBase<compute_stage>::getTransformCoefs; \
18  using ADLAROMANCEStressUpdateBase<compute_stage>::getInputLimits; \
19  using ADLAROMANCEStressUpdateBase<compute_stage>::getCoefs
20 
21 template <ComputeStage>
23 
25 
27 {
28  LINEAR,
29  LOG,
30  EXP
31 };
32 
33 template <ComputeStage compute_stage>
35 {
36 public:
37  static InputParameters validParams();
38 
39  ADLAROMANCEStressUpdateBase(const InputParameters & parameters);
40 
41 protected:
42  virtual void initialSetup() override;
43 
44  virtual void initQpStatefulProperties() override;
45 
46  virtual ADReal computeResidual(const ADReal & effective_trial_stress,
47  const ADReal & scalar) override;
48 
49  virtual ADReal computeDerivative(const ADReal & /*effective_trial_stress*/,
50  const ADReal & /*scalar*/) override
51  {
52  return _derivative;
53  }
54 
55  virtual void computeStressFinalize(const ADRankTwoTensor & plastic_strain_increment) override;
56 
62  virtual Real computeTimeStepLimit() override;
63 
80  void computeROMStrainRate(const Real dt,
81  const Real & mobile_dislocations_old,
82  const Real & immobile_dislocations_old,
83  const ADReal & trial_stress,
84  const Real & effective_strain_old,
85  const ADReal & temperature,
86  const ADReal & environmental,
87  ADReal & mobile_dislocation_increment,
88  ADReal & immobile_dislocation_increment,
89  ADReal & rom_effective_strain,
90  ADReal & rom_effective_strain_derivative);
91 
96  void checkInputWindows(std::vector<ADReal> & input);
97 
105  void convertInput(const std::vector<ADReal> & input,
106  std::vector<std::vector<ADReal>> & converted,
107  std::vector<std::vector<ADReal>> & dconverted);
108 
118  void buildPolynomials(const std::vector<std::vector<ADReal>> & rom_inputs,
119  const std::vector<std::vector<ADReal>> & drom_inputs,
120  std::vector<std::vector<std::vector<ADReal>>> & polynomial_inputs,
121  std::vector<std::vector<std::vector<ADReal>>> & dpolynomial_inputs);
122 
134  void computeValues(const std::vector<std::vector<Real>> & coefs,
135  const std::vector<std::vector<std::vector<ADReal>>> & polynomial_inputs,
136  const std::vector<std::vector<std::vector<ADReal>>> & dpolynomial_inputs,
137  std::vector<ADReal> & rom_outputs,
138  std::vector<ADReal> & drom_outputs);
139 
151  void convertOutput(const Real dt,
152  const std::vector<ADReal> & old_input_values,
153  const std::vector<ADReal> & rom_outputs,
154  const std::vector<ADReal> & drom_outputs,
155  std::vector<ADReal> & input_value_increments,
156  std::vector<ADReal> & dinput_value_increments);
157 
165  ADReal
166  computePolynomial(const ADReal & value, const unsigned int degree, const bool derivative = false);
167 
168  /*
169  * Calculates and returns the transformed limits for the ROM calculations
170  * @return Multi-dimentional vector of transformed limits
171  */
172  std::vector<std::vector<std::vector<Real>>> getTransformedLimits() const;
173 
174  /*
175  * Calculates and returns vector utilized in assign values
176  * @return Multi-dimentional vector that preallocates calculations for polynomial calculation
177  */
178  std::vector<std::vector<unsigned int>> getMakeFrameHelper() const;
179 
180  /*
181  * Returns vector of the functions to use for the conversion of input variables.
182  * @return vector of the functions to use for the conversion of input variables.
183  */
184  virtual std::vector<std::vector<ROMInputTransform>> getTransform() = 0;
185 
186  /*
187  * Returns factors for the functions for the conversion functions given in getTransform
188  * @return factors for the functions for the conversion functions given in getTransform
189  */
190  virtual std::vector<std::vector<Real>> getTransformCoefs() = 0;
191 
192  /* Returns human-readable limits for the inputs. Inputs ordering is
193  * 0: mobile_old
194  * 1: immobile_old
195  * 2: trial stress,
196  * 3: effective strain old,
197  * 4: temperature
198  * 5: environmental factor (optional)
199  * @return human-readable limits for the inputs
200  */
201  virtual std::vector<std::vector<Real>> getInputLimits() = 0;
202 
203  /*
204  * Material specific coefficients multiplied by the Legendre polynomials for each of the input
205  * variables
206  * @return Legendre polynomial coefficients
207  */
208  virtual std::vector<std::vector<Real>> getCoefs() = 0;
209 
211  const ADVariableValue & _temperature;
212 
214  const ADVariableValue & _environmental;
215 
217  const Real _window;
218 
221 
224 
226  const bool _verbose;
227 
229  ADMaterialProperty(Real) & _mobile_dislocations;
230  const MaterialProperty<Real> & _mobile_dislocations_old;
232 
235 
238 
240  const Function * const _mobile_function;
241 
244 
247 
249  ADMaterialProperty(Real) & _immobile_dislocations;
250  const MaterialProperty<Real> & _immobile_dislocations_old;
252 
255 
258 
260  const Function * const _immobile_function;
261 
264 
267 
269  const unsigned int _stress_index;
270 
272  const Function * const _creep_strain_old_forcing_function;
273 
275  unsigned int _num_inputs;
276 
278  unsigned int _num_outputs;
279 
281  unsigned int _degree;
282 
284  unsigned int _num_coefs;
285 
287  std::vector<std::vector<ROMInputTransform>> _transform;
288 
290  std::vector<std::vector<Real>> _transform_coefs;
291 
293  std::vector<std::vector<Real>> _input_limits;
294 
296  std::vector<std::vector<Real>> _coefs;
297 
299  bool _use_env;
300 
302  std::vector<std::vector<std::vector<Real>>> _transformed_limits;
303 
305  std::vector<std::vector<unsigned int>> _makeframe_helper;
306 
308  ADMaterialProperty(Real) & _creep_rate;
309 
311  MaterialProperty<Real> & _failed;
312 
314  ADReal _derivative;
315 
317 };
ADLAROMANCEStressUpdateBase::computeROMStrainRate
void computeROMStrainRate(const Real dt, const Real &mobile_dislocations_old, const Real &immobile_dislocations_old, const ADReal &trial_stress, const Real &effective_strain_old, const ADReal &temperature, const ADReal &environmental, ADReal &mobile_dislocation_increment, ADReal &immobile_dislocation_increment, ADReal &rom_effective_strain, ADReal &rom_effective_strain_derivative)
Computes the ROM Strain rate.
Definition: ADLAROMANCEStressUpdateBase.C:301
ADLAROMANCEStressUpdateBase::_window
const Real _window
Window applied to input maximum and minimum values.
Definition: ADLAROMANCEStressUpdateBase.h:217
ADLAROMANCEStressUpdateBase::_immobile_dislocation_increment
ADReal _immobile_dislocation_increment
Container for immobile dislocation increment.
Definition: ADLAROMANCEStressUpdateBase.h:263
ADLAROMANCEStressUpdateBase::checkInputWindows
void checkInputWindows(std::vector< ADReal > &input)
Function to check input values against applicability windows set by ROM data set.
Definition: ADLAROMANCEStressUpdateBase.C:360
ADLAROMANCEStressUpdateBase::_initial_mobile_dislocations
const Real _initial_mobile_dislocations
Initial mobile dislocation value.
Definition: ADLAROMANCEStressUpdateBase.h:234
ADLAROMANCEStressUpdateBase::WindowFailure::ERROR
declareADValidParams
declareADValidParams(ADLAROMANCEStressUpdateBase)
ADLAROMANCEStressUpdateBase::_immobile_old
Real _immobile_old
Container for old immobile dislocation value.
Definition: ADLAROMANCEStressUpdateBase.h:266
ADLAROMANCEStressUpdateBase::_mobile_old
Real _mobile_old
Container for old mobile dislocation value.
Definition: ADLAROMANCEStressUpdateBase.h:246
ADLAROMANCEStressUpdateBase::computeResidual
virtual ADReal computeResidual(const ADReal &effective_trial_stress, const ADReal &scalar) override
Compute the residual for a predicted value of the scalar.
Definition: ADLAROMANCEStressUpdateBase.C:180
ADLAROMANCEStressUpdateBase::_mobile_dislocation_increment
ADReal _mobile_dislocation_increment
Container for mobile dislocation increment.
Definition: ADLAROMANCEStressUpdateBase.h:243
ADLAROMANCEStressUpdateBase::_environmental
const ADVariableValue & _environmental
Optionally coupled environmental factor.
Definition: ADLAROMANCEStressUpdateBase.h:214
ROMInputTransform::EXP
ADLAROMANCEStressUpdateBase::_extrapolate_stress
const bool _extrapolate_stress
Flag to optinoally allow model extrapolation to zero stress.
Definition: ADLAROMANCEStressUpdateBase.h:223
ADLAROMANCEStressUpdateBase::_temperature
const ADVariableValue & _temperature
Coupled temperature variable.
Definition: ADLAROMANCEStressUpdateBase.h:211
ADLAROMANCEStressUpdateBase::WindowFailure
WindowFailure
Enum to error, warn, or ignore checks that ensure ROM input is within applicability window.
Definition: ADLAROMANCEStressUpdateBase.h:220
ADLAROMANCEStressUpdateBase::_transform_coefs
std::vector< std::vector< Real > > _transform_coefs
Transform coefficients defined by the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:290
ADLAROMANCEStressUpdateBase::_max_immobile_increment
const Real _max_immobile_increment
Maximum immobile dislocation increment.
Definition: ADLAROMANCEStressUpdateBase.h:257
ADLAROMANCEStressUpdateBase::getInputLimits
virtual std::vector< std::vector< Real > > getInputLimits()=0
ADLAROMANCEStressUpdateBase::ADMaterialProperty
ADMaterialProperty(Real) &_mobile_dislocations
Material properties for mobile (glissile) dislocation densities (1/m^2)
ADLAROMANCEStressUpdateBase::convertOutput
void convertOutput(const Real dt, const std::vector< ADReal > &old_input_values, const std::vector< ADReal > &rom_outputs, const std::vector< ADReal > &drom_outputs, std::vector< ADReal > &input_value_increments, std::vector< ADReal > &dinput_value_increments)
Computes the output variable increments from the ROM predictions by bringing out of the normalized ma...
Definition: ADLAROMANCEStressUpdateBase.C:510
ADLAROMANCEStressUpdateBase::_window_failure
enum ADLAROMANCEStressUpdateBase::WindowFailure _window_failure
ADLAROMANCEStressUpdateBase::_mobile_dislocations_old
const MaterialProperty< Real > & _mobile_dislocations_old
Definition: ADLAROMANCEStressUpdateBase.h:230
ADLAROMANCEStressUpdateBase::_max_mobile_increment
const Real _max_mobile_increment
Maximum mobile dislocation increment.
Definition: ADLAROMANCEStressUpdateBase.h:237
ADLAROMANCEStressUpdateBase::initQpStatefulProperties
virtual void initQpStatefulProperties() override
Definition: ADLAROMANCEStressUpdateBase.C:170
ADLAROMANCEStressUpdateBase::_mobile_function
const Function *const _mobile_function
Optional mobile dislocation forcing function.
Definition: ADLAROMANCEStressUpdateBase.h:240
ADLAROMANCEStressUpdateBase::_derivative
ADReal _derivative
Container for derivative of creep rate with respect to strain.
Definition: ADLAROMANCEStressUpdateBase.h:314
ADLAROMANCEStressUpdateBase::getTransform
virtual std::vector< std::vector< ROMInputTransform > > getTransform()=0
ADLAROMANCEStressUpdateBase::_use_env
bool _use_env
Flag that checks if environmental factor is included in ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:299
ADLAROMANCEStressUpdateBase::_immobile_dislocations_old
const MaterialProperty< Real > & _immobile_dislocations_old
Definition: ADLAROMANCEStressUpdateBase.h:250
ADLAROMANCEStressUpdateBase::computeDerivative
virtual ADReal computeDerivative(const ADReal &, const ADReal &) override
Compute the derivative of the residual as a function of the scalar variable.
Definition: ADLAROMANCEStressUpdateBase.h:49
ADLAROMANCEStressUpdateBase::initialSetup
virtual void initialSetup() override
Definition: ADLAROMANCEStressUpdateBase.C:129
ADLAROMANCEStressUpdateBase::WindowFailure::WARN
ADLAROMANCEStressUpdateBase::_transform
std::vector< std::vector< ROMInputTransform > > _transform
Transform rules defined by the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:287
ADLAROMANCEStressUpdateBase::_creep_strain_old_forcing_function
const Function *const _creep_strain_old_forcing_function
Optional old creep strain forcing function.
Definition: ADLAROMANCEStressUpdateBase.h:272
ADLAROMANCEStressUpdateBase::_degree
unsigned int _degree
Legendre polynomial degree for the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:281
ADLAROMANCEStressUpdateBase::ADLAROMANCEStressUpdateBase
ADLAROMANCEStressUpdateBase(const InputParameters &parameters)
Definition: ADLAROMANCEStressUpdateBase.C:86
ADLAROMANCEStressUpdateBase::computeValues
void computeValues(const std::vector< std::vector< Real >> &coefs, const std::vector< std::vector< std::vector< ADReal >>> &polynomial_inputs, const std::vector< std::vector< std::vector< ADReal >>> &dpolynomial_inputs, std::vector< ADReal > &rom_outputs, std::vector< ADReal > &drom_outputs)
Arranges the calculated Legendre polynomials into the order expected by the ROM coefficients and ulti...
Definition: ADLAROMANCEStressUpdateBase.C:481
ADLAROMANCEStressUpdateBase::usingRadialReturnCreepStressUpdateBaseMembers
usingRadialReturnCreepStressUpdateBaseMembers
Definition: ADLAROMANCEStressUpdateBase.h:316
ADLAROMANCEStressUpdateBase::getMakeFrameHelper
std::vector< std::vector< unsigned int > > getMakeFrameHelper() const
Definition: ADLAROMANCEStressUpdateBase.C:593
ADLAROMANCEStressUpdateBase::buildPolynomials
void buildPolynomials(const std::vector< std::vector< ADReal >> &rom_inputs, const std::vector< std::vector< ADReal >> &drom_inputs, std::vector< std::vector< std::vector< ADReal >>> &polynomial_inputs, std::vector< std::vector< std::vector< ADReal >>> &dpolynomial_inputs)
Assemble the array of Legendre polynomials to be multiplied by the ROM coefficients.
Definition: ADLAROMANCEStressUpdateBase.C:451
ADLAROMANCEStressUpdateBase::_input_limits
std::vector< std::vector< Real > > _input_limits
Input limits defined by the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:293
ADLAROMANCEStressUpdateBase::computeTimeStepLimit
virtual Real computeTimeStepLimit() override
Compute the limiting value of the time step for this material.
Definition: ADLAROMANCEStressUpdateBase.C:283
ROMInputTransform::LOG
ADRadialReturnCreepStressUpdateBase
This class provides baseline functionallity for creep models based on the stress update material in a...
Definition: ADRadialReturnCreepStressUpdateBase.h:21
ADLAROMANCEStressUpdateBase::getTransformCoefs
virtual std::vector< std::vector< Real > > getTransformCoefs()=0
ADLAROMANCEStressUpdateBase::_makeframe_helper
std::vector< std::vector< unsigned int > > _makeframe_helper
Helper container defined by the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:305
ADLAROMANCEStressUpdateBase::getCoefs
virtual std::vector< std::vector< Real > > getCoefs()=0
ADLAROMANCEStressUpdateBase::computePolynomial
ADReal computePolynomial(const ADReal &value, const unsigned int degree, const bool derivative=false)
Calculate the value or derivative of Legendre polynomial up to 3rd order.
Definition: ADLAROMANCEStressUpdateBase.C:535
ADLAROMANCEStressUpdateBase::getTransformedLimits
std::vector< std::vector< std::vector< Real > > > getTransformedLimits() const
Definition: ADLAROMANCEStressUpdateBase.C:567
ADLAROMANCEStressUpdateBase::_stress_index
const unsigned int _stress_index
Index corresponding to the position for the stress in the input vector.
Definition: ADLAROMANCEStressUpdateBase.h:269
ADLAROMANCEStressUpdateBase::_coefs
std::vector< std::vector< Real > > _coefs
Coefficients used with Legendre polynomials defined by the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:296
ADLAROMANCEStressUpdateBase::WindowFailure::IGNORE
ADRadialReturnCreepStressUpdateBase.h
NS::temperature
const std::string temperature
Definition: NS.h:26
ADLAROMANCEStressUpdateBase::_immobile_function
const Function *const _immobile_function
Optional immobile dislocation forcing function.
Definition: ADLAROMANCEStressUpdateBase.h:260
ADLAROMANCEStressUpdateBase::_num_outputs
unsigned int _num_outputs
Number of inputs to the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:278
ADLAROMANCEStressUpdateBase::computeStressFinalize
virtual void computeStressFinalize(const ADRankTwoTensor &plastic_strain_increment) override
Perform any necessary steps to finalize state after return mapping iterations.
Definition: ADLAROMANCEStressUpdateBase.C:256
ADLAROMANCEStressUpdateBase::_num_coefs
unsigned int _num_coefs
Total number of Legendre polynomial coefficients for the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:284
ADLAROMANCEStressUpdateBase
Definition: ADLAROMANCEStressUpdateBase.h:22
ADLAROMANCEStressUpdateBase::convertInput
void convertInput(const std::vector< ADReal > &input, std::vector< std::vector< ADReal >> &converted, std::vector< std::vector< ADReal >> &dconverted)
Convert the input variables into the form expected by the ROM Legendre polynomials to have a normaliz...
Definition: ADLAROMANCEStressUpdateBase.C:416
ADLAROMANCEStressUpdateBase::_transformed_limits
std::vector< std::vector< std::vector< Real > > > _transformed_limits
Limits transformed from readabile input to ROM readable limits.
Definition: ADLAROMANCEStressUpdateBase.h:302
ADLAROMANCEStressUpdateBase::_failed
MaterialProperty< Real > & _failed
Material property to indicate if material point is outside of input limits.
Definition: ADLAROMANCEStressUpdateBase.h:311
ROMInputTransform
ROMInputTransform
Definition: ADLAROMANCEStressUpdateBase.h:26
ADLAROMANCEStressUpdateBase::_verbose
const bool _verbose
Flag to output verbose infromation.
Definition: ADLAROMANCEStressUpdateBase.h:226
ADLAROMANCEStressUpdateBase::validParams
static InputParameters validParams()
Definition: ADLAROMANCEStressUpdateBase.C:19
ADLAROMANCEStressUpdateBase::_num_inputs
unsigned int _num_inputs
Number of inputs for the ROM data set.
Definition: ADLAROMANCEStressUpdateBase.h:275
ROMInputTransform::LINEAR
ADLAROMANCEStressUpdateBase::_initial_immobile_dislocations
const Real _initial_immobile_dislocations
Initial immobile dislocation value.
Definition: ADLAROMANCEStressUpdateBase.h:254