Page MenuHomec4science

material_stochastic_plasticity.hh
No OneTemporary

File Metadata

Created
Fri, May 17, 18:39

material_stochastic_plasticity.hh

/**
* @file material_stochastic_plasticity.hh
*
* @author Richard Leute <richard.leute@imtek.uni-freiburg.de>
*
* @date 24 Jan 2019
*
* @brief material for stochastic plasticity as described in Z. Budrikis et al.
* Nature Comm. 8:15928, 2017. It only works together with "python
* -script", which performes the avalanche loop. This makes the material
* slower but more easy to modify and test.
* (copied from material_linear_elastic4.hh)
*
* Copyright © 2019 Till Junge, Richard Leute
*
* µSpectre is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3, or (at
* your option) any later version.
*
* µSpectre is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with µSpectre; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Additional permission under GNU GPL version 3 section 7
*
* If you modify this Program, or any covered work, by linking or combining it
* with proprietary FFT implementations or numerical libraries, containing parts
* covered by the terms of those libraries' licenses, the licensors of this
* Program grant you additional permission to convey the resulting work.
*/
#ifndef SRC_MATERIALS_MATERIAL_STOCHASTIC_PLASTICITY_HH_
#define SRC_MATERIALS_MATERIAL_STOCHASTIC_PLASTICITY_HH_
#include "materials/material_linear_elastic1.hh"
#include "common/field.hh"
#include "common/tensor_algebra.hh"
#include <Eigen/Dense>
namespace muSpectre {
template <Dim_t DimS, Dim_t DimM>
class MaterialStochasticPlasticity;
/**
* traits for stochastic plasticity with eigenstrain
*/
template <Dim_t DimS, Dim_t DimM>
struct MaterialMuSpectre_traits<MaterialStochasticPlasticity<DimS, DimM>> {
//! global field collection
using GFieldCollection_t =
typename MaterialBase<DimS, DimM>::GFieldCollection_t;
//! expected map type for strain fields
using StrainMap_t =
MatrixFieldMap<GFieldCollection_t, Real, DimM, DimM, true>;
//! expected map type for stress fields
using StressMap_t = MatrixFieldMap<GFieldCollection_t, Real, DimM, DimM>;
//! expected map type for tangent stiffness fields
using TangentMap_t = T4MatrixFieldMap<GFieldCollection_t, Real, DimM>;
//! declare what type of strain measure your law takes as input
constexpr static auto strain_measure{StrainMeasure::GreenLagrange};
//! declare what type of stress measure your law yields as output
constexpr static auto stress_measure{StressMeasure::PK2};
//! local field_collections used for internals
using LFieldColl_t = LocalFieldCollection<DimS>;
//! local Lame constant, plastic increment, stress threshold type
using ScalarMap_t = ScalarFieldMap<LFieldColl_t, Real, true>;
//! storage type for eigen strain (is updated from outside)
using EigenStrainMap_t =
MatrixFieldMap<LFieldColl_t, Real, DimM, DimM>;
//! storage type for an overloaded pixel vector
using Pixel_Vector_t = std::vector<Ccoord_t<DimS>>;
//! stochastic plasticity internal variables (Lame 1, Lame 2, eigen strain,
//! overloaded_pixels)
using InternalVariables =
std::tuple<ScalarMap_t, ScalarMap_t, EigenStrainMap_t>;
};
/**
* implements stochastic plasticity with an eigenstrain, Lameconstants and
* plastic flow per pixel.
*/
template <Dim_t DimS, Dim_t DimM>
class MaterialStochasticPlasticity
: public MaterialMuSpectre<MaterialStochasticPlasticity<DimS, DimM>, DimS,
DimM> {
public:
//! base class
using Parent = MaterialMuSpectre<MaterialStochasticPlasticity, DimS, DimM>;
/**
* type used to determine whether the
* `muSpectre::MaterialMuSpectre::iterable_proxy` evaluate only
* stresses or also tangent stiffnesses
*/
using NeedTangent = typename Parent::NeedTangent;
//! global field collection
//! Full type for stress fields
using StressField_t =
TensorField<GlobalFieldCollection<DimS>, Real, secondOrder, DimM>;
using Stiffness_t =
Eigen::TensorFixedSize<Real, Eigen::Sizes<DimM, DimM, DimM, DimM>>;
using EigenStrainArg_t =
Eigen::Map<Eigen::Matrix<Real, DimM, DimM>>;
//! traits of this material
using traits = MaterialMuSpectre_traits<MaterialStochasticPlasticity>;
//! Type of container used for storing eigenstrain
using InternalVariables = typename traits::InternalVariables;
//! Hooke's law implementation
using Hooke =
typename MatTB::Hooke<DimM, typename traits::StrainMap_t::reference,
typename traits::TangentMap_t::reference>;
//! Default constructor
MaterialStochasticPlasticity() = delete;
//! Construct by name
explicit MaterialStochasticPlasticity(std::string name);
//! Copy constructor
MaterialStochasticPlasticity(const MaterialStochasticPlasticity & other) =
delete;
//! Move constructor
MaterialStochasticPlasticity(MaterialStochasticPlasticity && other) =
delete;
//! Destructor
virtual ~MaterialStochasticPlasticity() = default;
//! Copy assignment operator
MaterialStochasticPlasticity &
operator=(const MaterialStochasticPlasticity & other) = delete;
//! Move assignment operator
MaterialStochasticPlasticity &
operator=(MaterialStochasticPlasticity && other) = delete;
/**
* evaluates second Piola-Kirchhoff stress given the Green-Lagrange
* strain (or Cauchy stress if called with a small strain tensor), the first
* Lame constant (lambda) and the second Lame constant (shear modulus/mu).
*/
template <class s_t>
inline decltype(auto)
evaluate_stress(s_t && E, const Real & lambda, const Real & mu,
const EigenStrainArg_t & eigen_strain);
/**
* evaluates both second Piola-Kirchhoff stress and stiffness given
* the Green-Lagrange strain (or Cauchy stress and stiffness if
* called with a small strain tensor), the first Lame constant (lambda) and
* the second Lame constant (shear modulus/mu).
*/
template <class s_t>
inline decltype(auto)
evaluate_stress_tangent(s_t && E, const Real & lambda, const Real & mu,
const EigenStrainArg_t & eigen_strain);
/**
* return the empty internals tuple
*/
InternalVariables & get_internals() { return this->internal_variables; }
/**
* overload add_pixel to write into loacal stiffness tensor
*/
void add_pixel(const Ccoord_t<DimS> & pixel) final;
/**
* overload add_pixel to write into local stiffness tensor
*/
void add_pixel(const Ccoord_t<DimS> & pixel, const Real & Youngs_modulus,
const Real & Poisson_ratio, const Real & plastic_increment,
const Real & stress_threshold,
const Eigen::Ref<const Eigen::Matrix<
Real, Eigen::Dynamic, Eigen::Dynamic>> & eigen_strain);
/**
* evaluate how many pixels have a higher stress than their stress threshold
*/
inline std::vector<Ccoord_t<DimS>> &
identify_overloaded_pixels(StressField_t & stress_field);
protected:
//! storage for first Lame constant 'lambda',
//! second Lame constant(shear modulus) 'mu',
//! plastic strain epsilon_p,
//! and a vector of overloaded (stress>stress_threshold) pixel coordinates
using Field_t = ScalarField<LocalFieldCollection<DimS>, Real>;
using Tensor_Field_t =
TensorField<LocalFieldCollection<DimS>, Real, secondOrder, DimM>;
Field_t & lambda_field;
Field_t & mu_field;
Field_t & plastic_increment_field;
Field_t & stress_threshold_field;
Tensor_Field_t & eigen_strain_field;
std::vector<Ccoord_t<DimS>> overloaded_pixels;
//! tuple for iterable eigen_field
InternalVariables internal_variables;
private:
};
/* ---------------------------------------------------------------------- */
template <Dim_t DimS, Dim_t DimM>
template <class s_t>
auto MaterialStochasticPlasticity<DimS, DimM>::evaluate_stress(
s_t && E, const Real & lambda, const Real & mu,
const EigenStrainArg_t & eigen_strain) -> decltype(auto) {
return Hooke::evaluate_stress(lambda, mu, E - eigen_strain);
}
/* ---------------------------------------------------------------------- */
template <Dim_t DimS, Dim_t DimM>
template <class s_t>
auto MaterialStochasticPlasticity<DimS, DimM>::evaluate_stress_tangent(
s_t && E, const Real & lambda, const Real & mu,
const EigenStrainArg_t & eigen_strain) -> decltype(auto) {
T4Mat<Real, DimM> C = Hooke::compute_C_T4(lambda, mu);
return std::make_tuple(
this->evaluate_stress(std::forward<s_t>(E), lambda, mu, eigen_strain),
C);
}
/* ---------------------------------------------------------------------- */
template <Dim_t DimS, Dim_t DimM>
std::vector<Ccoord_t<DimS>> &
MaterialStochasticPlasticity<DimS, DimM>::identify_overloaded_pixels(
StressField_t & stress_field) {
auto threshold_map{this->stress_threshold_field.get_map()};
auto stress_map{stress_field.get_map()};
std::vector<Ccoord_t<DimS>> & overloaded_pixels_ref{
this->overloaded_pixels};
// loop over all pixels and check if stress overcomes the threshold or not
for (const auto && pixel_threshold : threshold_map.enumerate()) {
const auto & pixel{std::get<0>(pixel_threshold)};
const Real & threshold{std::get<1>(pixel_threshold)};
const auto & stress{stress_map[pixel]};
// check if stress is larger than threshold
std::cout << stress << threshold << std::endl;
// return & to Ccoord vector with pixels which overcome the threshold,
}
return overloaded_pixels_ref;
}
// relax_overloaded_pixels() //vector leeren
} // namespace muSpectre
#endif // SRC_MATERIALS_MATERIAL_STOCHASTIC_PLASTICITY_HH_

Event Timeline