Skip to content

Commit 6d09086

Browse files
committed
Add all code
1 parent b5ebad9 commit 6d09086

14 files changed

+402
-0
lines changed

Elastic Formulae/cubic.wls

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
cubic = {{c11, c12, c12, 0, 0, 0}, {0, c11, c12, 0, 0, 0}, {0, 0, c11,
11+
0, 0, 0}, {0, 0, 0, c44, 0, 0}, {0, 0, 0, 0, c44, 0}, {0, 0, 0, 0, 0,
12+
c44}} // Symmetrise
13+
14+
f = ElasticEnergy[cubic]
15+
16+
cj = {c11, c12, c44};
17+
18+
(*Length[cj] == 3*)
19+
20+
s = S[f, cj];
21+
22+
s // MatrixForm
23+
24+
25+
Examine[s, cj, f]

Elastic Formulae/hexagonal.wls

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
hex = {{c11, c12, c13, 0, 0, 0}, {0, c11, c13, 0, 0, 0}, {0, 0, c33,
11+
0, 0, 0}, {0, 0, 0, c44, 0, 0}, {0, 0, 0, 0, c44, 0}, {0, 0, 0, 0, 0,
12+
(c11 - c12) / 2}} // Symmetrise
13+
14+
f = ElasticEnergy[hex]
15+
16+
cj = {c11, c33, c12, c13, c44};
17+
18+
(*Length[cj] == 5*)
19+
20+
s = S[f, cj];
21+
22+
s // MatrixForm
23+
24+
25+
Examine[s, cj, f]

Elastic Formulae/monoclinic.wls

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
mono = {{c11, c12, c13, 0, 0, c16}, {0, c22, c23, 0, 0, c26}, {0, 0,
11+
c33, 0, 0, c36}, {0, 0, 0, c44, c45, 0}, {0, 0, 0, 0, c55, 0}, {0, 0,
12+
0, 0, 0, c66}} // Symmetrise
13+
14+
f = ElasticEnergy[mono]
15+
16+
cj = {c11, c22, c33, c12, c13, c23, c44, c55, c66, c16, c26, c36, c45
17+
};
18+
19+
(*Length[cj] == 13*)
20+
21+
s = S[f, cj];
22+
23+
s // MatrixForm
24+
25+
26+
Examine[s, cj, f]

Elastic Formulae/monoclinic2.wls

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
mono = {{c11, c12, c13, 0, c15, 0}, {0, c22, c23, 0, c25, 0}, {0, 0,
11+
c33, 0, c35, 0}, {0, 0, 0, c44, 0, c46}, {0, 0, 0, 0, c55, 0}, {0, 0,
12+
0, 0, 0, c66}} // Symmetrise
13+
14+
f = ElasticEnergy[mono]
15+
16+
cj = {c11, c22, c33, c12, c13, c23, c44, c55, c66, c15, c25, c35, c46
17+
};
18+
19+
(*Length[cj] == 13*)
20+
21+
s = S[f, cj];
22+
23+
s // MatrixForm
24+
25+
26+
Examine[s, cj, f]

Elastic Formulae/orthorhombic.wls

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
orth = {{c11, c12, c13, 0, 0, 0}, {0, c22, c23, 0, 0, 0}, {0, 0, c33,
11+
0, 0, 0}, {0, 0, 0, c44, 0, 0}, {0, 0, 0, 0, c55, 0}, {0, 0, 0, 0, 0,
12+
c66}} // Symmetrise
13+
14+
cj = {c11, c22, c33, c12, c13, c23, c44, c55, c66};
15+
16+
f = ElasticEnergy[orth]
17+
18+
(*Length[cj] == 9*)
19+
20+
s = S[f, cj];
21+
22+
s // MatrixForm
23+
24+
25+
Examine[s, cj, f]

Elastic Formulae/sij.wl

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(* ::Package:: *)
2+
3+
BeginPackage["Sij`"]
4+
5+
Symmetrise::usage = "Construct a symmetric matrix from an upper triangular matrix."
6+
7+
ElasticEnergy::usage = "Calculate the free energy formula."
8+
9+
Sij::usage = "Calculate matrix element S[i, j]."
10+
11+
S::usage = "Calculate matrix S."
12+
13+
Examine::usage = "Examine whether the S matrix is correct."
14+
15+
Begin["`Private`"]
16+
17+
\[Epsilon] = {Global`\[Epsilon]1, Global`\[Epsilon]2, Global`\[Epsilon]3,
18+
Global`\[Epsilon]4, Global`\[Epsilon]5, Global`\[Epsilon]6};
19+
20+
Symmetrise[upperTriMatrix_] :=
21+
UpperTriangularize[upperTriMatrix, 1] + Transpose[upperTriMatrix]
22+
23+
ElasticEnergy[c_] :=
24+
\[Epsilon] . c . \[Epsilon] / 2 // Expand
25+
26+
Sij[f_, \[Epsilon]i_, cj_] :=
27+
D[f, \[Epsilon]i, cj]
28+
29+
S[f_, c_] :=
30+
Table[Sij[f, \[Epsilon][[i]], c[[j]]], {i, 1, 6}, {j, 1, Length[c
31+
]}] // Simplify
32+
33+
Examine[S_, c_, f_] := PossibleZeroQ[S . c . \[Epsilon] / 2 - f]
34+
35+
End[]
36+
37+
EndPackage[]

Elastic Formulae/tetragonal.wls

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
tet = {{c11, c12, c13, 0, 0, 0}, {0, c11, c13, 0, 0, 0}, {0, 0, c33,
11+
0, 0, 0}, {0, 0, 0, c44, 0, 0}, {0, 0, 0, 0, c44, 0}, {0, 0, 0, 0, 0,
12+
c66}} // Symmetrise
13+
14+
cj = {c11, c33, c12, c13, c44, c66};
15+
16+
f = ElasticEnergy[tet]
17+
18+
(*Length[cj] == 6*)
19+
20+
s = S[f, cj];
21+
22+
s // MatrixForm
23+
24+
25+
Examine[s, cj, f]

Elastic Formulae/tetragonal2.wls

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
tet = {{c11, c12, c13, 0, 0, c16}, {0, c11, c13, 0, 0, -c16}, {0, 0,
11+
c33, 0, 0, 0}, {0, 0, 0, c44, 0, 0}, {0, 0, 0, 0, c44, 0}, {0, 0, 0,
12+
0, 0, c66}} // Symmetrise
13+
14+
cj = {c11, c33, c12, c13, c16, c44, c66};
15+
16+
(*Length[cj] == 7*)
17+
18+
f = ElasticEnergy[tet]
19+
20+
s = S[f, cj];
21+
22+
s // MatrixForm
23+
24+
25+
Examine[s, cj, f]

Elastic Formulae/triclinic.wls

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
triclinic = {{c11, c12, c13, c14, c15, c16}, {0, c22, c23, c24, c25,
11+
c26}, {0, 0, c33, c34, c35, c36}, {0, 0, 0, c44, c45, c46}, {0, 0, 0,
12+
0, c55, c56}, {0, 0, 0, 0, 0, c66}} // Symmetrise
13+
14+
f = ElasticEnergy[triclinic]
15+
16+
cj = {c11, c12, c13, c14, c15, c16, c22, c23, c24, c25, c26, c33, c34,
17+
c35, c36, c44, c45, c46, c55, c56, c66};
18+
19+
(*Length[cj] == 21*)
20+
21+
s = S[f, cj];
22+
23+
s // MatrixForm
24+
25+
26+
Examine[s, cj, f]

Elastic Formulae/trigonal.wls

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
tri = {{c11, c12, c13, c14, 0, 0}, {0, c11, c13, -c14, 0, 0}, {0, 0,
11+
c33, 0, 0, 0}, {0, 0, 0, c44, 0, 0}, {0, 0, 0, 0, c44, c14}, {0, 0, 0,
12+
0, 0, (c11 - c12) / 2}} // Symmetrise
13+
14+
(*tri // SymmetricMatrixQ*)
15+
16+
cj = {c11, c33, c12, c13, c44, c14};
17+
18+
f = ElasticEnergy[tri]
19+
20+
(*Length[cj] == 6*)
21+
22+
s = S[f, cj];
23+
24+
s // MatrixForm
25+
26+
27+
Examine[s, cj, f]

Elastic Formulae/trigonal2.wls

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
SetDirectory[NotebookDirectory[]];
7+
8+
<<Sij`
9+
10+
tri = {{c11, c12, c13, c14, c15, 0}, {0, c11, c13, -c14, -c15, 0}, {0,
11+
0, c33, 0, 0, 0}, {0, 0, 0, c44, 0, -c15}, {0, 0, 0, 0, c44, c14}, {
12+
0, 0, 0, 0, 0, (c11 - c12) / 2}} // Symmetrise
13+
14+
(*tri // SymmetricMatrixQ*)
15+
16+
cj = {c11, c33, c12, c13, c44, c14, c15};
17+
18+
f = ElasticEnergy[tri]
19+
20+
(*Length[cj] == 7*)
21+
22+
s = S[f, cj];
23+
24+
s // MatrixForm
25+
26+
27+
Examine[s, cj, f]

Sound Velocity/Cubic.wls

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
GreenChristoffelEquations[{ qx_, qy_, qz_ }] := {{
7+
c11 qx ^ 2 + c44(qy ^ 2 + qz ^ 2), (c12 + c44) qx qy, (c12 + c44) qx qz
8+
}, {
9+
(c12 + c44) qx qy, c11 qy ^ 2 + c44(qz ^ 2 + qx ^ 2), (c12 + c44) qy qz
10+
}, {
11+
(c12 + c44) qx qz, (c12 + c44) qy qz, c11 qz ^ 2 + c44(qx ^ 2 + qy ^ 2)
12+
}}
13+
14+
qVectorOnDirection[{ a_, b_, c_ }] := q / Norm[{ a, b, c }] { a, b, c }
15+
16+
generateEquationsOnDirection[{ a_, b_, c_ }] := GreenChristoffelEquations[qVectorOnDirection[{ a, b, c }]]
17+
18+
phaseVelocity[{ a_, b_, c_ }] := Simplify[Sqrt[Eigenvalues[generateEquationsOnDirection[{ a, b, c }]] / \[Rho]] / q, Assumptions-> q > 0]
19+
20+
particleDisplacementDirections[{ a_, b_, c_ }] := Eigenvectors[generateEquationsOnDirection[{ a, b, c }]]
21+
22+
takePositiveSolutions[{ a_, b_, c_ }] := Module[{ v, indices },
23+
v = phaseVelocity[{ a, b, c }];
24+
indices = Simplify[v // Sign, Assumptions -> c11 > c12 && c11 + 2 c12 > 0 && c44 > 0 && \[Rho] > 0 && q > 0] // Position[#, 1] & // Flatten;
25+
Map[Part[v, #] &, indices]
26+
]
27+
28+
29+
takePositiveSolutions[{1,1,1}]
30+
particleDisplacementDirections[{1,1,1}]
31+
32+
33+
Simplify[((generateEquationsOnDirection[{1,1,1}]//Eigenvalues) / \[Rho] // Sqrt) /q,Assumptions->q>0]

Sound Velocity/Orthorhombic.wls

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env wolframscript
2+
(* ::Package:: *)
3+
4+
Clear["Global`*"]
5+
6+
indices := {{1,1,1,1},{1,1,2,2},{1,1,3,3},{2,2,1,1},{2,2,2,2},{2,2,3,3},{3,3,1,1},{3,3,2,2},{3,3,3,3},
7+
{2,3,2,3},{2,3,3,2},{3,2,3,2},{3,2,2,3},{1,3,1,3},{1,3,3,1},{3,1,3,1},{3,1,1,3},
8+
{1,2,1,2},{1,2,2,1},{2,1,2,1},{2,1,1,2}};
9+
10+
dict = <|{1,1}->1,{2,2}->2,{3,3}->3,{2,3}->4,{3,2}->4,{1,3}->5,{3,1}->5,{1,2}->6,{2,1}->6|>;
11+
12+
c[i_,j_,k_,l_] := c[dict[[Key[{i,j}]]],dict[[Key[{k,l}]]]]
13+
14+
c[i_,j_] := {{c11,c12,c13,0,0,0},{c12,c22,c23,0,0,0},{c13,c23,c33,0,0,0},{0,0,0,c44,0,0},{0,0,0,0,c55,0},{0,0,0,0,0,c66}}[[i,j]];
15+
16+
qs = {qx,qy,qz};
17+
18+
GreenChristoffelEquations[qs_] := Table[Sum[c[\[Alpha],\[Gamma],\[Beta],\[Delta]]qs[[\[Gamma]]]qs[[\[Delta]]],{\[Gamma],1,3},{\[Delta],1,3}],{\[Alpha],1,3},{\[Beta],1,3}]
19+
20+
21+
qVectorOnDirection[{ a_, b_, c_ }] := q / Norm[{ a, b, c }] { a, b, c }
22+
23+
generateEquationsOnDirection[{ a_, b_, c_ }] := GreenChristoffelEquations[qVectorOnDirection[{ a, b, c }]]
24+
25+
phaseVelocity[{ a_, b_, c_ }] := Simplify[Sqrt[Eigenvalues[generateEquationsOnDirection[{ a, b, c }]] / \[Rho]] / q, Assumptions-> q > 0]
26+
27+
particleDisplacementDirections[{ a_, b_, c_ }] := Eigenvectors[generateEquationsOnDirection[{ a, b, c }]]
28+
29+
takePositiveSolutions[{ a_, b_, c_ }] := Module[{ v, indices },
30+
v = phaseVelocity[{ a, b, c }];
31+
indices = Simplify[v // Sign, Assumptions -> c11 > 0 && c11 c22 > c12^2 && c11 c22 c33 + 2 c12 c13 c23 > c11 c23^2 + c22 c13^2 + c33 c12^2 && c44 > 0 && c55 > 0 && c66 > 0 && \[Rho] > 0 && q > 0] // Position[#, 1] & // Flatten;
32+
Map[Part[v, #] &, indices]
33+
]
34+
35+
36+
phaseVelocity[{0,1,1}]
37+
38+
39+
Simplify[((generateEquationsOnDirection[{1,1,1}]//Eigenvalues) / \[Rho] // Sqrt) /q,Assumptions->q>0]

0 commit comments

Comments
 (0)