Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
StraightDislocationSegment.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_StraightDislocationSegment_cpp_
9#define model_StraightDislocationSegment_cpp_
10
11#ifndef _MODEL_NON_SINGULAR_DD_
12#define _MODEL_NON_SINGULAR_DD_ 1
13#endif
14
15#include <cfloat>
16#include <math.h>
18
19namespace model
20{
21
22 template <int dim>
23 typename StraightDislocationSegment<dim>::MatrixDim StraightDislocationSegment<dim>::nonSymmStress_kernel(const VectorDim& r) const
24 {
25#if _MODEL_NON_SINGULAR_DD_ == 0
26 /* Devincre, B., & Condat, M. (1992). Model validation of a 3D
27 * simulation of dislocation dynamics: Discretization and line tension
28 * effects. Acta Metallurgica Et Materialia, 40(10), 2629–2637.
29 */
30
31 static_assert(0,"THERE IS NO CONSISTENT REGULARIZATION OF THIS EXPRESSION. USE _MODEL_NON_SINGULAR_DD_=1");
32
33// const Scalar L(r.dot(t));
34// const Scalar R(r.norm()+DislocationFieldBase<dim>::a);
35// const VectorDim rho(r-L*t); // distance vector to the line
36// const VectorDim Y((L+R)*t+rho); // = R*t + r
37// // Y2=R^2+R^2+2R*(r*t)=2R*(R+L)
43//
44//
46// const Scalar f1(1.0/(R*(R+L))); // =2/Y2=2/(2R*(R+L))
47//
50// const Scalar f2(material.C1*f1);
51// const Scalar bDotYcrosst(b.dot(Y.cross(t)));
52// const Scalar f3(bDotYcrosst*f1*f1);
53// const Scalar f4(0.5*f1*bDotYcrosst);
54// const Scalar f5(f4*f1*L/R);
55// // const Scalar f5(0.5*f3*L/R);
56//
57// return f2*b.cross(Y)*t.transpose()
58// /* */ -f1*b.cross(t)*Y.transpose()
59// /* */ -f3*rho*Y.transpose()
60// /* */ -f4*(MatrixDim::Identity()+t*t.transpose())
61// /* */ -f5*Y*Y.transpose();
62
63// const Scalar R(r.norm());
64 const Scalar Ra(sqrt(r.squaredNorm()+DislocationFieldBase<dim>::a2));
65 const VectorDim Y(r+Ra*t);
66 const Scalar Yt(Y.dot(t));
67// const Scalar Yta(Yt+DislocationFieldBase<dim>::a);
68 const Scalar Yta(sqrt(Yt*Yt+DislocationFieldBase<dim>::a2));
69 const Scalar Y2(Y.squaredNorm()+DislocationFieldBase<dim>::a2);
70 const Scalar bYt(b.cross(Y).dot(t));
71
72
73 const Scalar f1(2.0/Y2);
74// const Scalar f1(EwaldLength>FLT_EPSILON? 2.0*erfc(Y2/EwaldLength/EwaldLength)/Y2 : 2.0/Y2);
75// const Scalar f1(EwaldLength>FLT_EPSILON? 2.0*erfc(Ra/EwaldLength)/Y2 : 2.0/Y2);
76// const Scalar f1(EwaldLength>FLT_EPSILON? 2.0*erfc(sqrt(Y2)/EwaldLength)/Y2 : 2.0/Y2);
77
78
79 return f1*material.C1*t*(b.cross(Y)).transpose()
80 /* */-f1*Y*bCt.transpose()
81 /* */-f1*bYt/Yta*t*r.transpose()
82 /* */-0.5*f1*bYt*MatrixDim::Identity()
83 /* */-f1*bYt*(R+Yt)/Ra/Y2*r*r.transpose()
84 /* */-0.5*f1*bYt*R/Yta*t*t.transpose();
85
86
87#elif _MODEL_NON_SINGULAR_DD_ == 1 /* Cai's non-singular theory */
88
89 const Scalar Ra2=r.squaredNorm()+DislocationFieldBase<dim>::a2;
90 const Scalar Ra(sqrt(Ra2));
91 const VectorDim Ya(r+Ra*t);
92 const Scalar Yat(Ya.dot(t));
93 const Scalar Ya2a2(Ya.squaredNorm()+DislocationFieldBase<dim>::a2);
94 const VectorDim bYa(b.cross(Ya));
95 const Scalar bYat(bYa.dot(t));
96
97
98// THIS MUST USE Ya, not Ra, otherwise code goes crazy
99 const Scalar f1(2.0/Ya2a2);
100// const Scalar f1(EwaldLength>FLT_EPSILON? 2.0*erfc(Ya2a2/EwaldLength/EwaldLength)/Ya2a2 : 2.0/Ya2a2);
101// const Scalar f1(EwaldLength>FLT_EPSILON? 2.0*erfc(Ra/EwaldLength)/Ya2a2 : 2.0/Ya2a2);
102// const Scalar f1(EwaldLength>FLT_EPSILON? 2.0*erfc(sqrt(Ya2a2)/EwaldLength)/Ya2a2 : 2.0/Ya2a2);
103// std::cout<<"f1="<<f1<<", 2.0/Ya2a2="<<2.0/Ya2a2<<std::endl;
104
105
106 return f1*material.C1*(1.0+DislocationFieldBase<dim>::a2/Ya2a2)*t*bYa.transpose()
107 /* */+f1*material.C1*0.5*DislocationFieldBase<dim>::a2/Ra2*t*b.cross(r).transpose()
108 /* */-f1*Ya*bCt.transpose()
109 /* */-f1*bYat/Yat*t*r.transpose()
110 /* */-0.5*f1*bYat*(1.0+2.0*DislocationFieldBase<dim>::a2/Ya2a2+DislocationFieldBase<dim>::a2/Ra2)*MatrixDim::Identity()
111 /* */-f1*bYat*(Ra+Yat)/Ra/Ya2a2*r*r.transpose()
112 /* */-0.5*f1*bYat*Ra/Yat*t*t.transpose();
113
114#elif _MODEL_NON_SINGULAR_DD_ == 2 /* Lazar's non-singular theory */
115 static_assert(0,"NOT IMPLEMENTED. USE _MODEL_NON_SINGULAR_DD_=1");
116#else
117#error Unsupported choice of field regularization
118#endif
119 }
120
121 template <int dim>
122 typename StraightDislocationSegment<dim>::VectorDim StraightDislocationSegment<dim>::displacement_kernel(const VectorDim& r) const
123 {
124 const Scalar Ra(sqrt(r.squaredNorm()+DislocationFieldBase<dim>::a2));
125 const VectorDim Ya(r+Ra*t);
126 const Scalar Yat(Ya.dot(t));
127 return -(2.0-0.5/material.C1+(2.0-1.0/material.C1)*log(Yat)-DislocationFieldBase<dim>::a2/Ra/Yat)/8.0/M_PI*bCt
128 /* */ +bCt.dot(r)/Yat/Ra/material.C1/8.0/M_PI*Ya;
129 }
130
131 template <int dim>
132 double StraightDislocationSegment<dim>::elasticInteractionEnergy_kernel(const VectorDim& z,const VectorDim& tA,const VectorDim& bA) const
133 {
134 const Scalar za(sqrt(z.squaredNorm()+DislocationFieldBase<dim>::a2));
135 const VectorDim Ya(z+za*t);
136 const Scalar Yat(Ya.dot(t));
137 const Scalar logYat(log(Yat));
138 const Scalar zaYat(za*Yat);
139
140 const Scalar bAtA(bA.dot(tA));
141 const Scalar bt(b.dot(t));
142 const Scalar bAt(bA.dot(t));
143 const Scalar btA(b.dot(tA));
144 const Scalar bAb(bA.dot(b));
145 const Scalar tAt(tA.dot(t));
146 const Scalar zt(z.dot(t));
147 const Scalar zb(z.dot(b));
148 const Scalar zbA(z.dot(bA));
149 const double energyInf((0.5*material.C1*bAtA*bt+material.nu*bAt*btA)*(2.0+2.0*logYat-DislocationFieldBase<dim>::a2/zaYat)
150 /* */-bAb*tAt*(1.5+logYat-DislocationFieldBase<dim>::a2/zaYat)
151 /* */-bAt*bt*tAt*(0.5+logYat+zt/Yat)
152 /* */+tAt/Yat*(zbA*zb/za+bAt*zb+bt*zbA));
153// return EwaldLength>FLT_EPSILON? erfc(za/EwaldLength)*energyInf : energyInf;
154 return energyInf;
155 }
156
157 template <int dim>
159 const VectorDim& _P0,
160 const VectorDim& _P1,
161 const VectorDim& _b,
162 const double& _length,
163 const VectorDim& _t,
164 const double& EwaldLength_in) :
165 /* init */ material(mat)
166 /* init */,P0(_P0)
167 /* init */,P1(_P1)
168 /* init */,b(_b)
169 /* init */,length(_length)
170 /* init */,t(_t)
171 /* init */,EwaldLength(EwaldLength_in)
172 /* init */,bCt(b.cross(t))
173 {
177 }
178
179 template <int dim>
181 {
182 bCt=b.cross(t);
183 }
184
185 template <int dim>
186 typename StraightDislocationSegment<dim>::MatrixDim StraightDislocationSegment<dim>::nonSymmStress(const VectorDim& x) const
187 {
188 return length>FLT_EPSILON? nonSymmStress_kernel(P1-x)-nonSymmStress_kernel(P0-x) : MatrixDim::Zero().eval();
189 }
190
191 template <int dim>
192 typename StraightDislocationSegment<dim>::MatrixDim StraightDislocationSegment<dim>::stress(const VectorDim& x) const
193 {
194 const MatrixDim temp = nonSymmStress(x);
195// std::cout<<"stress="<<material.C2*(temp+temp.transpose())<<std::endl;
196 const double EwaldFactor(EwaldLength>FLT_EPSILON? erfc((0.5*(P0+P1)-x).norm()/EwaldLength) : 1.0);
197 return material.C2*EwaldFactor*(temp+temp.transpose());
198// const Eigen::Matrix<float,dim,dim> tempF((material.C2*(temp+temp.transpose())).template cast<float>());
199// return tempF.template cast<double>();
200 }
201
202 template <int dim>
203 typename StraightDislocationSegment<dim>::VectorDim StraightDislocationSegment<dim>::displacement(const VectorDim& x) const
204 {
207 return length>FLT_EPSILON? (displacement_kernel(P1-x)-displacement_kernel(P0-x)).eval() : VectorDim::Zero();
208 }
209
210 template <int dim>
211 double StraightDislocationSegment<dim>::elasticInteractionEnergy(const VectorDim& xA,const VectorDim& tA,const VectorDim& bA) const
212 {
213 const double EwaldFactor(EwaldLength>FLT_EPSILON? erfc((0.5*(P0+P1)-xA).norm()/EwaldLength) : 1.0);
214 return -0.5*material.C2*EwaldFactor*(elasticInteractionEnergy_kernel(P1-xA,tA,bA)-elasticInteractionEnergy_kernel(P0-xA,tA,bA));
215 }
216
217
218template class StraightDislocationSegment<3>;
219
220}
221#endif
222
VectorDim displacement(const VectorDim &x) const
const PolycrystallineMaterialBase & material
StraightDislocationSegment(const PolycrystallineMaterialBase &mat, const VectorDim &_P0, const VectorDim &_P1, const VectorDim &_b, const double &_length, const VectorDim &_t, const double &EwaldLength_in)
MatrixDim nonSymmStress(const VectorDim &x) const
MatrixDim stress(const VectorDim &x) const
double elasticInteractionEnergy(const VectorDim &xA, const VectorDim &tA, const VectorDim &bA) const
id z()
final point of the source segment t
b
Definition int_R.m:16
x
Definition int_R.m:12
auto eval(const std::shared_ptr< T > &t)
float r
Definition plotLoops.py:41
static double a2
Dislocation core size squared.
vertex temp