Skip to content

Commit

Permalink
laromance grade 91 from type model implemented in NEML2.
Browse files Browse the repository at this point in the history
This is based on a grade 91 model from LANL on 2/1/2025.
The implementation uses a dummy inteprolation grid, values, and transforms and does not contain any real material data.
The actual grade 91 data is in Bison.
This implements multilinear interpolation.
There are 6 interpolation axes and 3 values at each node.
The interpolation axes and interpolated values are transformed.
This contains examples where the model only performs interpolation and a full example with radial return done in NEML2.
The radial return mapping requries a change to NEML2 in math.cxx that Gary is including in his neml2 udpate
closes #29774
  • Loading branch information
lynnmunday committed Feb 5, 2025
1 parent 4d0bbd6 commit e910ca3
Show file tree
Hide file tree
Showing 17 changed files with 1,220 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#pragma once

#include "neml2/models/Model.h"
#include "nlohmann/json.h"

namespace neml2
{
class Multilinear6DInterpolationModel : public Model
{
public:
Multilinear6DInterpolationModel(const OptionSet & options);

static OptionSet expected_options();

protected:
void set_value(bool, bool, bool) override;

/// grid for interpolation
Scalar _stress_grid;
Scalar _temperature_grid;
Scalar _plastic_strain_grid;
Scalar _cell_grid;
Scalar _wall_grid;
Scalar _env_grid;

/// grid values being interpolated
Scalar _grid_values;

/// Model input for interpolation
// @{
/// The von Mises stress
const Variable<Scalar> & _s;
/// Temperature
const Variable<Scalar> & _T;
/// The creep strain
const Variable<Scalar> & _ep;
/// cell dislocation density
const Variable<Scalar> & _cell_dd;
/// wall dislocation density
const Variable<Scalar> & _wall_dd;
/// environmental factor
const Variable<Scalar> & _env_fac;
// @}

/// Model output
// @{
/// output rate
Variable<Scalar> & _output_rate;
// @}

/// JSON object containing interpolation grid and values
nlohmann::json _json;

/// find index of input point
std::pair<Scalar, Scalar> findLeftIndexAndFraction(const Scalar & grid,
const Scalar & interp_points);

/// compute interpolated value and transform results
Scalar interpolate_and_transform();

/// transform output data
virtual Scalar transform(const Scalar & data) = 0;

/// read in json axes transform name
std::string json_to_string(std::string key);

/// read in json axes transform constants
std::vector<Real> json_to_vector(std::string key);

///read 6D grid date from json and store in Torch tensor
Scalar json_6Dvector_to_torch(std::string key);

private:
///read 1D vector of grid points from json and store in Torch tensor
Scalar json_vector_to_torch(std::string key);

/// compute interpolated value
Scalar compute_interpolation(const std::vector<std::pair<Scalar, Scalar>> index_and_fraction,
const Scalar grid_values);

std::string _stress_transform_name;
std::string _temperature_transform_name;
std::string _plastic_strain_transform_name;
std::string _cell_transform_name;
std::string _wall_transform_name;
std::string _env_transform_name;

std::vector<Real> _stress_transform_values;
std::vector<Real> _temperature_transform_values;
std::vector<Real> _plastic_strain_transform_values;
std::vector<Real> _cell_transform_values;
std::vector<Real> _wall_transform_values;
std::vector<Real> _env_transform_values;

/// LAROMANCE transforms for input axis
// @{
Scalar transform_compress(const Scalar & data, const std::vector<Real> & params) const;
Scalar transform_log10_bounded(const Scalar & data, const std::vector<Real> & params) const;
Scalar transform_min_max(const Scalar & data, const std::vector<Real> & params) const;
// @}
};
} // namespace neml2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "Multilinear6DInterpolationModel.h"

namespace neml2
{
class TabulatedDislocationDensity : public Multilinear6DInterpolationModel
{
public:
TabulatedDislocationDensity(const OptionSet & options);

static OptionSet expected_options();

protected:
void set_value(bool, bool, bool) override;
/// transform output data
virtual Scalar transform(const Scalar & data) override;

private:
/// Struct members from CompressTransform in lafleur struct
//@{
const Real _factor;
const Real _compressor;
const Real _original_min;
//@}
};
} // namespace neml2
30 changes: 30 additions & 0 deletions modules/solid_mechanics/neml2/include/TabulatedEffectiveStrain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "Multilinear6DInterpolationModel.h"

namespace neml2
{
class TabulatedEffectiveStrain : public Multilinear6DInterpolationModel
{
public:
TabulatedEffectiveStrain(const OptionSet & options);

static OptionSet expected_options();

protected:
void set_value(bool, bool, bool) override;

/// transform output data
virtual Scalar transform(const Scalar & data) override;

private:
/// Struct members from Log10Transform struct in laromance
//@{
const Real _factor;
const Real _lowerbound;
const Real _upperbound;
const Real _logmin;
const Real _logmax;
//@}
};
} // namespace neml2
Loading

0 comments on commit e910ca3

Please sign in to comment.