1 #ifndef HPP_CONTINUUM_H 5 #define HPP_CONTINUUM_H 30 std::vector<U> D_comps(3);
31 D_comps[0] = std::sqrt(2.0/3.0)*std::cos(theta-M_PI/3.0);
32 D_comps[1] = std::sqrt(2.0/3.0)*std::cos(theta+M_PI/3.0);
33 D_comps[2] = -std::sqrt(2.0/3.0)*std::cos(theta);
36 std::vector<std::vector<U>> basis(3);
37 for (
int i=0; i<3; i++) {
38 basis[i] = std::vector<U>(3);
44 for (
int i=0; i<3; i++) {
45 std::vector<U> e_i = basis[i];
46 D_0 += D_comps[i]*
outer(e_i, e_i);
75 std::valarray<T> Devals;
80 if (decomp.
evecs.det() < 0) {
81 std::swap(Devals[0], Devals[1]);
82 for (
int i=0; i<3; i++) {
83 std::swap(decomp.
evecs(i,0), decomp.
evecs(i,1));
86 if (!decomp.
evecs.isRotationMatrix()) {
88 std::cerr <<
"R*R^T = " << product << std::endl;
89 throw std::runtime_error(
"The transformation to the stretching tensor frame is not a rotation.");
94 for (
int i=0; i<3; i++) {
95 DPrincipal(i,i) = Devals[i];
102 std::valarray<T> D0evals = Devals/decomp.
DNorm;
104 for (
unsigned int i=0; i<D0evals.size(); i++) {
105 D0evalsMag += std::pow(D0evals[i],2.0);
107 D0evalsMag = std::sqrt(D0evalsMag);
108 D0evals /= D0evalsMag;
109 T E1 = D0evals[0]/std::sqrt(2.0/3.0);
110 T E2 = D0evals[1]/std::sqrt(2.0/3.0);
111 T E3 = D0evals[2]/std::sqrt(2.0/3.0);
114 T theta1 = std::acos(-E3);
115 T theta2 = 2.0*M_PI - std::acos(-E3);
116 T theta3 = std::acos(E1) + M_PI/3.0;
118 T theta5 = std::acos(E2) - M_PI/3.0;
119 T theta6 = 5.0*M_PI/3.0 - std::acos(E2);
123 T equiv = std::numeric_limits<T>::epsilon()*10000.0;
124 if (
std::abs(theta1-theta3)<equiv) {
133 if (minError > equiv) {
134 std::string errorMsg = std::string(
"Could not correctly determine theta. Error = ");
135 errorMsg += std::to_string(minError);
136 throw std::runtime_error(errorMsg);
150 template <
typename U>
153 L = 2*mu*identityTensor4<U>(3) ;
154 L += ((U)(kappa-(2.0/3)*mu))*outer<U>(identityTensor2<U>(3), identityTensor2<U>(3));
165 template <
typename U>
168 U cbar = c11-c12-2*c44;
169 for (
int i=0; i<3; i++) {
170 for (
int j=0; j<3; j++) {
171 for (
int k=0; k<3; k++) {
172 for (
int l=0; l<3; l++) {
173 L(i,j,k,l) = c12*(i==j)*(k==l);
174 L(i,j,k,l) += c44*((i==k)*(j==l)+(i==l)*(j==k));
175 for (
int r=0; r<3; r++) {
176 L(i,j,k,l) += cbar*(i==r)*(j==r)*(k==r)*(l==r);
191 template <
typename U>
194 unsigned int nT = tVec.size();
195 unsigned int nV = vVec.size();
197 throw std::runtime_error(
"Different number of stiffness tensors and volumes.");
203 for (
unsigned int i=1; i<nT; i++) {
213 template <
typename U>
215 U mu = c11 - c12 - 2.0*c44;
216 U a = mu*(c11+c12)/(c11*c44);
217 U b = std::pow(mu, 2.0)*(c11+2*c12+c44)/(c11*std::pow(c44,2.0));
225 A0(0,0,0,0) = (1.0/3.0)*c11;
226 A1(0,0,0,0) = (2*m/3.0)*c11*c44;
229 A1(0,0,1,1) = -(p/3.0)*c11*c44;
230 A2(0,0,1,1) = -p*mu/(c11*std::pow(c44,2.0));
231 A0(0,1,0,1) = (1.0/6.0)*c44;
232 A1(0,1,0,1) = a*(mu-2.0*c44)/(12.0*mu*c44);
233 A2(0,1,0,1) = (1.0/2.0)*(a/(2.0*c44)-b/mu);
240 E(1,0,0,1) = E(0,1,0,1);
243 E(0,1,1,0) = E(0,1,0,1);
245 std::cout <<
"E = " << E << std::endl;
250 std::cout <<
"C = " << C << std::endl;
264 template <
typename U>
267 unsigned int nC = cVec.size();
268 unsigned int nV = vVec.size();
270 throw std::runtime_error(
"Different number of stiffness tensors and volumes.");
276 for (
unsigned int i=0; i<cVec.size(); i++) {
277 cTot += cVec[i]*vVec[i];
291 template <
typename U>
294 unsigned int nC = cVec.size();
295 unsigned int nV = vVec.size();
297 throw std::runtime_error(
"Different number of stiffness tensors and volumes.");
301 U cTol = 1.0e2*std::numeric_limits<U>::epsilon();
307 for (
const auto& v : vVec) {
322 bool converged =
false;
323 for (
unsigned int i=0; i<maxIters; i++) {
331 cBarTot = (U)0.0*cBar;
332 for (
unsigned int r=0; r<nC; r++) {
333 Ar =
contract((cVec[r]+cTilde).inv(), cBarPrev+cTilde);
334 cBarTot +=
contract(cVec[r], Ar)*vVec[r];
339 cDiff = cBar-cBarPrev;
341 if (relDiff < cTol) {
348 throw std::runtime_error(
"ELSC homogenization failed to converge.");
T frobeniusNorm() const
Definition: tensor.cpp:776
Tensor2< T > outer(const std::vector< T > &A, const std::vector< T > &B)
Definition: tensor.h:640
Definition: casesUtils.cpp:4
Tensor4< U > volumeAverage(const std::vector< Tensor4< U >> &tVec, const std::vector< U > &vVec)
Volume average fourth order tensors.
Definition: continuum.h:192
T frobeniusNorm() const
Definition: tensor.cpp:1005
Tensor2< U > deformationGradFromVelGrad(U t_init, const Tensor2< U > &F_init, const Tensor2< U > &L, U t)
Definition: continuum.h:21
T theta
Definition: continuum.h:56
Header file for tensor classes.
Definition: continuum.h:55
void evecDecomposition(std::valarray< T > &evals, Tensor2< T > &evecs)
Definition: tensor.cpp:707
Tensor4< U > getHomogenizedStiffnessELSC(const std::vector< Tensor4< U >> &cVec, const std::vector< U > &vVec, const Tensor4< U > &S)
Get the homogenized stiffness tensor using the elastic self-consistent method.
Definition: continuum.h:292
std::vector< T > abs(const std::vector< T > &vec)
Definition: tensor.h:89
T DNorm
Definition: continuum.h:57
T contract(const Tensor2< T > &A, const Tensor2< T > &B)
Definition: tensor.h:950
Tensor2< T > trans() const
The transpose of the tensor.
Definition: tensor.cpp:536
Tensor4< U > getHomogenizedStiffnessVolumeAverage(const std::vector< Tensor4< U >> &cVec, const std::vector< U > &vVec)
Get the homogenized stiffness tensor using a volume average.
Definition: continuum.h:265
Tensor4< U > cubeSymmetricElasticityTensor(U c11, U c12, U c44)
Construct a fourth order elasticity tensor accounting for cubic symmetry.
Definition: continuum.h:166
Tensor2< T > evecs
Definition: continuum.h:58
Tensor4< U > isotropicElasticityTensor(U mu, U kappa)
Construct a fourth order isotropic elasticity tensor.
Definition: continuum.h:151
Tensor2< U > stretchingVelocityGradient(U theta, U eDot)
Definition: continuum.h:28
T min(const std::vector< T > &vec)
Definition: tensor.h:98
Tensor4< T > inv() const
Definition: tensor.cpp:998
Tensor4< U > getEshelbyTensorCubicMaterialSphericalInclusion(U c11, U c12, U c44, U I0, U I1, U I2)
Definition: continuum.h:214
StretchingTensorDecomposition< T > getStretchingTensorDecomposition(const Tensor2< T > &L)
Definition: continuum.h:67