Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
DislocationMobilityInterpolated.cpp
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef _model_DislocationMobilityInterpolated_cpp_
9#define _model_DislocationMobilityInterpolated_cpp_
10
12#include <cmath>
13#include <numbers>
14
15namespace model
16{
17
19 const std::shared_ptr<InterpolantBase>& interpolant_in,
20 const std::map<double,std::shared_ptr<DislocationMobilityBase>>& mobilityMap_in,
21 const bool& logSpace_in):
22 /* init */ DislocationMobility("DislocationMobilityInterpolated for "+material.materialName)
23 /* init */,interpolant(interpolant_in)
24 /* init */,mobilityMap(mobilityMap_in)
25 /* init */,logSpace(logSpace_in)
26 {
27 if(mobilityMap.size())
28 {
29 if(mobilityMap.begin()->first<0.0 && mobilityMap.rbegin()->first>std::numbers::pi)
30 {
31 throw std::runtime_error("DislocationMobilityInterpolated: breakpoints must be between 0 and 180 deg.");
32 }
33 }
34 else
35 {
36 throw std::runtime_error("DislocationMobilityInterpolated: mobilityMap is empty.");
37 }
38 }
39
40
42 const VectorDim& b,
43 const VectorDim& xi,
44 const VectorDim& n,
45 const double& T,
46 const double& dL,
47 const double& dt,
48 const std::shared_ptr<StochasticForceGenerator>& sfg) const
49 {
50
51 if(logSpace)
52 {
53 for(const auto& mob : mobilityMap)
54 {
55 const double v(mob.second->velocity(S,b,n,T,dL,dt,sfg));
56 if(v<0.0)
57 {
58 throw std::runtime_error("DislocationMobilityInterpolated: v<0.0 incompatible with logSpace interpolation.");
59 }
60 interpolant->at(mob.first)=std::log(v);
61 }
62 }
63 else
64 {
65 for(const auto& mob : mobilityMap)
66 {
67 interpolant->at(mob.first)=mob.second->velocity(S,b,n,T,dL,dt,sfg);
68 }
69 }
70
71
72
73 const VectorDim unitB(b.normalized());
74 const double angleRad(std::atan2(unitB.cross(xi).dot(n), unitB.dot(xi)));
75 return logSpace? std::exp(interpolant->f(angleRad)) : interpolant->f(angleRad);
76
77 }
78}
79#endif
the tangent vector S
b
Definition int_R.m:16
DislocationMobility(const std::string &name_in)
Eigen::Matrix< double, 3, 3 > MatrixDim
Eigen::Matrix< double, 3, 1 > VectorDim
DislocationMobilityInterpolated(const PolycrystallineMaterialBase &material, const std::shared_ptr< InterpolantBase > &interpolant_in, const std::map< double, std::shared_ptr< DislocationMobilityBase > > &mobilityMap_in, const bool &logSpace_in=false)
double velocity(const MatrixDim &S, const VectorDim &b, const VectorDim &xi, const VectorDim &n, const double &T, const double &dL, const double &dt, const std::shared_ptr< StochasticForceGenerator > &sfg) const override
const std::map< double, std::shared_ptr< DislocationMobilityBase > > mobilityMap
const std::shared_ptr< InterpolantBase > interpolant
REAL * xi
REAL v[4]