-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Scalar trial stress update (#173) * Modify the input file slightly so that the gold file can be reused * Add unit tests for the two new objects --------- Co-authored-by: Gary Hu <[email protected]>
- Loading branch information
1 parent
4b342de
commit 53b7035
Showing
9 changed files
with
452 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
include/neml2/models/solid_mechanics/LinearIsotropicElasticJ2TrialStressUpdate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2024, UChicago Argonne, LLC | ||
// All Rights Reserved | ||
// Software Name: NEML2 -- the New Engineering material Model Library, version 2 | ||
// By: Argonne National Laboratory | ||
// OPEN SOURCE LICENSE (MIT) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#pragma once | ||
|
||
#include "neml2/models/Model.h" | ||
|
||
namespace neml2 | ||
{ | ||
/** | ||
* @brief Update the trial stress under the assumptions of J2 plasticity and isotropic linear | ||
* elasticity | ||
* | ||
* This allows the construction of fully scalar return mapping models for | ||
* isotropic materials. | ||
*/ | ||
class LinearIsotropicElasticJ2TrialStressUpdate : public Model | ||
{ | ||
public: | ||
static OptionSet expected_options(); | ||
|
||
LinearIsotropicElasticJ2TrialStressUpdate(const OptionSet & options); | ||
|
||
protected: | ||
/// compute updated trial stress | ||
virtual void set_value(bool out, bool dout_din, bool d2out_din2) override; | ||
|
||
/// input trial stress (i.e., assuming a purely elastic step) | ||
const Variable<Scalar> & _elastic_trial_stress; | ||
|
||
/// input inelastic strain | ||
const Variable<Scalar> & _inelastic_strain; | ||
|
||
/// input old inelastic strain | ||
const Variable<Scalar> & _inelastic_strain_old; | ||
|
||
/// output (updated) trial stress | ||
Variable<Scalar> & _updated_trial_stress; | ||
|
||
/// Young's modulus | ||
const Scalar & _E; | ||
|
||
/// Poisson's ratio | ||
const Scalar & _nu; | ||
}; | ||
} // namespace neml2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/neml2/models/solid_mechanics/LinearIsotropicElasticJ2TrialStressUpdate.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright 2024, UChicago Argonne, LLC | ||
// All Rights Reserved | ||
// Software Name: NEML2 -- the New Engineering material Model Library, version 2 | ||
// By: Argonne National Laboratory | ||
// OPEN SOURCE LICENSE (MIT) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#include "neml2/models/solid_mechanics/LinearIsotropicElasticJ2TrialStressUpdate.h" | ||
|
||
namespace neml2 | ||
{ | ||
register_NEML2_object(LinearIsotropicElasticJ2TrialStressUpdate); | ||
|
||
OptionSet | ||
LinearIsotropicElasticJ2TrialStressUpdate::expected_options() | ||
{ | ||
OptionSet options = Model::expected_options(); | ||
|
||
options.doc() = "Update the trial stress under the assumptions of J2 plasticity and isotropic " | ||
"linear elasticity"; | ||
|
||
options.set_input("elastic_trial_stress") = VariableName("forces", "s"); | ||
options.set("elastic_trial_stress").doc() = "Initial trial stress assuming a purely elastic step"; | ||
|
||
options.set_input("equivalent_plastic_strain") = VariableName("state", "ep"); | ||
options.set("equivalent_plastic_strain").doc() = | ||
"Current guess for the equivalent plastic strain"; | ||
|
||
options.set_output("updated_trial_stress") = VariableName("state", "s"); | ||
options.set("updated_trial_stress").doc() = | ||
"Trial stress corrected for the current increment of plastic deformation"; | ||
|
||
options.set_parameter<CrossRef<Scalar>>("youngs_modulus"); | ||
options.set("youngs_modulus").doc() = "Young's modulus"; | ||
|
||
options.set_parameter<CrossRef<Scalar>>("poisson_ratio"); | ||
options.set("poisson_ratio").doc() = "Poisson's ratio"; | ||
|
||
return options; | ||
} | ||
|
||
LinearIsotropicElasticJ2TrialStressUpdate::LinearIsotropicElasticJ2TrialStressUpdate( | ||
const OptionSet & options) | ||
: Model(options), | ||
_elastic_trial_stress(declare_input_variable<Scalar>("elastic_trial_stress")), | ||
_inelastic_strain(declare_input_variable<Scalar>("equivalent_plastic_strain")), | ||
_inelastic_strain_old(declare_input_variable<Scalar>(_inelastic_strain.name().old())), | ||
_updated_trial_stress(declare_output_variable<Scalar>("updated_trial_stress")), | ||
_E(declare_parameter<Scalar>("E", "youngs_modulus", /*allow_nonlinear=*/false)), | ||
_nu(declare_parameter<Scalar>("nu", "poisson_ratio", /*allow_nonlinear=*/false)) | ||
{ | ||
} | ||
|
||
void | ||
LinearIsotropicElasticJ2TrialStressUpdate::set_value(bool out, bool dout_din, bool d2out_din2) | ||
{ | ||
const auto three_shear = 3.0 * _E / (2.0 * (1.0 + _nu)); | ||
|
||
if (out) | ||
_updated_trial_stress = | ||
_elastic_trial_stress - three_shear * (_inelastic_strain - _inelastic_strain_old); | ||
|
||
if (dout_din) | ||
{ | ||
if (_elastic_trial_stress.is_dependent()) | ||
_updated_trial_stress.d(_elastic_trial_stress) = Scalar::identity_map(options()); | ||
|
||
if (_inelastic_strain.is_dependent()) | ||
_updated_trial_stress.d(_inelastic_strain) = -three_shear; | ||
|
||
if (_inelastic_strain_old.is_dependent()) | ||
_updated_trial_stress.d(_inelastic_strain_old) = three_shear; | ||
} | ||
|
||
if (d2out_din2) | ||
{ | ||
// zero | ||
} | ||
} | ||
} // namespace neml2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.