(*by Nasser M. Abbasi, verion sept 7, 2013*)
Manipulate[
Module[{g, p1, p2, p3, p4, p5, p6, p7, p8,
e = ee*10^9, \[Sigma]x = \[Sigma]xx*10^6, \[Sigma]y = \
\[Sigma]yy*10^6, \[Sigma]z = \[Sigma]zz*10^6, \[Tau]xy = \
\[Tau]xyxy*10^6, \[Tau]yz = \[Tau]yzyz*10^6, \[Tau]zx = \
\[Tau]zxzx*10^6},
g = e/(2 (1 + \[Nu]));
\[Epsilon]x = \[Sigma]x/e - \[Nu]/e (\[Sigma]y + \[Sigma]z);
\[Epsilon]y = \[Sigma]y/e - \[Nu]/e (\[Sigma]x + \[Sigma]z);
\[Epsilon]z = \[Sigma]z/e - \[Nu]/e (\[Sigma]y + \[Sigma]x);
\[Gamma]xy = \[Tau]xy/g;
\[Gamma]yz = \[Tau]yz/g;
\[Gamma]zx = \[Tau]zx/g;
{p1, p2, p3, p4, p5, p6, p7, p8} =
getCoordinates[
strainType, \[Epsilon]x, \[Epsilon]y, \[Epsilon]z, \[Gamma]xy, \
\[Gamma]yz, \[Gamma]zx, k];
Style[Framed@Graphics3D[
Rotate[
{
If[plotStyle == 1,
{
{EdgeForm[{Thick, Red}], FaceForm[Opacity[.3]],
Polygon[{ p1, p2, p3, p4}],
Polygon[{ p5, p6, p7, p8}],
Polygon[{ p4, p3, p7, p8}],
Polygon[{ p1, p2, p6, p5}],
Polygon[{ p2, p6, p7, p3}],
Polygon[{ p4, p8, p5, p1}]
}
},
{
{FaceForm[{Opacity[0.3]}, White],
Polygon[{ p1, p2, p3, p4}],
Polygon[{ p5, p6, p7, p8}],
Polygon[{ p4, p3, p7, p8}],
Polygon[{ p1, p2, p6, p5}],
Polygon[{ p2, p6, p7, p3}],
Polygon[{ p4, p8, p5, p1}]
}
}
],
If[showOriginal,
{Gray, Dashed,
Line[{{-1/2, -1/2, 1/2}, {1/2, -1/2,
1/2}, {1/2, -1/2, -1/2}, {-1/2, -1/2, -1/2}, {-1/2, -1/2,
1/2}}],
Line[{{-1/2, 1/2, 1/2}, {1/2, 1/2, 1/2}, {1/2,
1/2, -1/2}, {-1/2, 1/2, -1/2}, {-1/2, 1/2, 1/2}}],
Line[{{-1/2, -1/2, -1/2}, {-1/2, 1/2, -1/2}}],
Line[{{1/2, -1/2, -1/2}, {1/2, 1/2, -1/2}}],
Line[{{-1/2, -1/2, 1/2}, {-1/2, 1/2, 1/2}}],
Line[{{1/2, -1/2, 1/2}, {1/2, 1/2, 1/2}}]
},
{}
],
If[showAxes,
{
{Arrowheads[.02],
Arrow[{{0, 0, 0}, #}] & /@ {{.25, 0, 0}, {0, 0.25, 0}, {0,
0, 0.25 }}
}
,
{Text[
Style["x", Italic, FontSize -> Scaled[.04]], {.28, 0, 0}],
Text[Style["y", Italic, FontSize -> Scaled[.04]], {0, 0.28,
0}], Text[
Style["z", Italic, FontSize -> Scaled[.04]], {0, 0, .28}]
}
},
{}
]
}, 90 Degree, {1, 0, 0}
],
PlotRange -> {{-1.3, 1.3}, {-1.4, 1.4}, {-1.4, 1.4}},
Boxed -> False,
ImagePadding -> .1,
ImageMargins -> 0,
SphericalRegion -> True,
ViewPoint -> {4.86215, -27.5746, 5},
If[plotStyle == 1,
Lighting -> {{"Ambient", White}},
Lighting -> Automatic
],
ViewAngle -> 2*Pi/180,
PreserveImageOptions -> If[reset, reset = False; False, True],
ImageSize -> {280, 420}
], Antialiasing -> True]
],
Text@Grid[{
{Grid[{
{Spacer[39],
TraditionalForm@HoldForm[Subscript[\[Sigma], x]],
Control[{{\[Sigma]xx, 0, ""}, -500, 500, 1,
ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[\[Sigma]xx,
3, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True],
Spacer[3],
"MPa",
Button["zero", \[Sigma]xx = 0, Appearance -> "Palette",
Background -> LightBlue, ImageSize -> {45, 20}],
Spacer[47]
},
{
Spacer[1],
TraditionalForm@HoldForm[Subscript[\[Sigma], y]],
Control[{{\[Sigma]yy, 0, ""}, -500, 500, 1,
ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[\[Sigma]yy,
3, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True],
Spacer[3],
"MPa",
Button["zero", \[Sigma]yy = 0, Appearance -> "Palette",
Background -> LightBlue, ImageSize -> {45, 20}],
Spacer[1]
},
{
Spacer[1],
TraditionalForm@HoldForm[Subscript[\[Sigma], z]],
Control[{{\[Sigma]zz, 0, ""}, -500, 500, 1,
ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[\[Sigma]zz,
3, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True],
Spacer[3],
"MPa",
Button["zero", \[Sigma]zz = 0, Appearance -> "Palette",
Background -> LightBlue, ImageSize -> {45, 20}],
Spacer[1]
},
{
Spacer[1],
TraditionalForm@HoldForm[Subscript[\[Tau], x, y]],
Control[{{\[Tau]xyxy, 300, ""}, -500, 500, 1,
ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[\[Tau]xyxy,
3, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True],
Spacer[3],
"MPa",
Button["zero", \[Tau]xyxy = 0, Appearance -> "Palette",
Background -> LightBlue, ImageSize -> {45, 20}], Spacer[1]
},
{
Spacer[1],
TraditionalForm@HoldForm[Subscript[\[Tau], y, z]],
Control[{{\[Tau]yzyz, 0, ""}, -500, 500, 1,
ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[\[Tau]yzyz,
3, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True],
Spacer[3],
"MPa",
Button["zero", \[Tau]yzyz = 0, Appearance -> "Palette",
Background -> LightBlue, ImageSize -> {45, 20}], Spacer[1]
},
{
Spacer[1],
TraditionalForm@HoldForm[Subscript[\[Tau], z, x]],
Control[{{\[Tau]zxzx, 0, ""}, -500, 500, 1,
ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[\[Tau]zxzx,
3, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True],
Spacer[3],
"MPa",
Button["zero", \[Tau]zxzx = 0, Appearance -> "Palette",
Background -> LightBlue, ImageSize -> {45, 20}], Spacer[1]
}
}, Alignment -> Left, Spacings -> {.4, .2}, Frame -> False,
FrameStyle -> Directive[Thickness[.005], Gray]]
},
{
Grid[{
{Button["reset view", reset = True, ImageSize -> {95, 28}],
Spacer[3],
Button["reset stress", \[Sigma]xx = 0; \[Sigma]yy =
0; \[Sigma]zz = 0; \[Tau]xyxy = 0; \[Tau]yzyz =
0; \[Tau]zxzx = 0, ImageSize -> {95, 28}]}
}]
},
{
Grid[{
{Spacer[23], Style["shear strain type", 12],
RadioButtonBar[
Dynamic[strainType], {"cauchy" -> Style["Cauchy", 12],
"eng" -> Style["engineering", 12]}],
Spacer[22]
}
}, Alignment -> Left, Spacings -> {.5, .5}, Frame -> False,
FrameStyle -> Directive[Thickness[.005], Gray]]
},
{
Grid[{
{
Spacer[46],
Style["Young's modulus E", 11],
Control[{{ee, 90, ""}, 90, 260, 1, ImageSize -> Tiny}],
Spacer[3],
Dynamic@AccountingForm[ee,
3, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"},
SignPadding -> True],
Spacer[3],
"GPa",
Spacer[46]
},
{
Spacer[3],
Style["poisson ratio \[Nu]", 11],
Control[{{\[Nu], .3, ""}, .01, .5, .01, ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[\[Nu],
{2, 2}, NumberSigns -> {"", ""},
NumberPadding -> {"0", "0"}, SignPadding -> True],
SpanFromLeft
},
{
Spacer[3],
Style["exaggeration factor", 11],
Control[{{k, 25, ""}, 1, 35, 1, ImageSize -> Tiny}],
Spacer[1],
Dynamic@AccountingForm[k,
2, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"},
SignPadding -> True],
SpanFromLeft
}
}, Alignment -> Left, Spacings -> {0, .8}, Frame -> True,
FrameStyle -> Directive[Thickness[.005], Gray]
]
},
{
Grid[{
{Spacer[11], Style["stress tensor (MPa)", 11], Spacer[11]},
{
Style[
Row[{Text@
Style[TraditionalForm@
HoldForm[{{Subscript[\[Sigma], x], Subscript[\[Tau], x,
y], Subscript[\[Tau], x, z]}, {Subscript[\[Tau], y,
x], Subscript[\[Sigma], y], Subscript[\[Tau], y,
z]}, {Subscript[\[Tau], z, x], Subscript[\[Tau], z,
y], Subscript[\[Sigma], z]}}]], " = ",
Dynamic@TraditionalForm[{
{AccountingForm[\[Sigma]xx,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True],
AccountingForm[\[Tau]xyxy,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True],
AccountingForm[\[Tau]zxzx,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True]
},
{AccountingForm[\[Tau]xyxy,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True],
AccountingForm[\[Sigma]yy,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True],
AccountingForm[\[Tau]yzyz,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True]
},
{AccountingForm[\[Tau]zxzx,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True],
AccountingForm[\[Tau]yzyz,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True],
AccountingForm[\[Sigma]zz,
3, NumberSigns -> {"-", "+"},
NumberPadding -> {"0", "0"}, SignPadding -> True]
}
}]
}], 11], SpanFromLeft
}
}, Alignment -> Center, Spacings -> {6.5, .8}, Frame -> False,
FrameStyle -> Directive[Thickness[.005], Gray]]
},
{
Grid[{
{Style["strain tensor", 11]},
{
Style[Row[{Text@Style[TraditionalForm@HoldForm[{
{Subscript[\[Epsilon], x],
Dynamic@
If[strainType == "eng", Spacer[12],
Style["1/2", 8]] (Subscript[\[Gamma], x, y]),
Dynamic@
If[strainType == "eng", Spacer[12],
Style["1/2", 8]] Subscript[\[Gamma], x,
z]}, {Dynamic@
If[strainType == "eng", Spacer[12],
Style["1/2", 8]] Subscript[\[Gamma], y, x],
Subscript[\[Epsilon], y],
Dynamic@
If[strainType == "eng", Spacer[12],
Style["1/2", 8]] Subscript[\[Gamma], y,
z]}, {Dynamic@
If[strainType == "eng", Spacer[12],
Style["1/2", 8]] Subscript[\[Gamma], z, x],
Dynamic@
If[strainType == "eng", Spacer[12],
Style["1/2", 8]] Subscript[\[Gamma], z, y],
Subscript[\[Epsilon], z]}}]], " = ",
Dynamic@TraditionalForm[{
{padIt1[100*\[Epsilon]x, {5, 4}],
padIt1[180/Pi*
If[strainType == "eng", \[Gamma]xy, \[Gamma]xy/
2], {5, 4}]^Degree,
padIt1[180/Pi*\[Gamma]zx/
If[strainType == "eng", 1, 2], {5, 4}]^Degree
},
{padIt1[
180/Pi*\[Gamma]xy/If[strainType == "eng", 1, 2], {5,
4}]^Degree,
padIt1[100*\[Epsilon]y, {5, 4}],
padIt1[180/Pi*\[Gamma]yz/
If[strainType == "eng", 1, 2], {5, 4}]^Degree
},
{padIt1[
180/Pi*\[Gamma]zx/If[strainType == "eng", 1, 2], {5,
4}]^Degree,
padIt1[180/Pi*\[Gamma]yz/
If[strainType == "eng", 1, 2], {5, 4}]^Degree,
padIt1[100*\[Epsilon]z, {5, 4}]
}
}]
}], 11]
}
}, Alignment -> Center, Spacings -> {0.3, 1}, Frame -> False,
FrameStyle -> Directive[Thickness[.005], Gray]
]
},
{
Grid[{
{
Row[{Text@Style["show original", 12],
Control[{{showOriginal, True, ""}, {True, False}}]}],
Row[{Text@Style["show axes", 12],
Control[{{showAxes, True, ""}, {True, False}}]}],
Row[{Style["select 3D style", 12],
RadioButtonBar[Dynamic[plotStyle], {1, 2}]}]
}
}, Alignment -> Left, Spacings -> {1, .4}, Frame -> True,
FrameStyle -> Directive[Thickness[.005], Gray]
]
}
}, Alignment -> Center
],
{{strainType, "eng"}, None},
{{plotStyle, 2}, None},
{{reset, False}, None},
{{\[Epsilon]x, 0}, None},
{{\[Epsilon]y, 0}, None},
{{\[Epsilon]z, 0}, None},
{{\[Gamma]xy, 0}, None},
{{\[Gamma]yz, 0}, None},
{{\[Gamma]zx, 0}, None},
ControlPlacement -> Left,
SynchronousUpdating -> True,
SynchronousInitialization -> True,
ContinuousAction -> True,
Alignment -> Center,
ImageMargins -> 0,
FrameMargins -> 0,
Paneled -> True,
Frame -> False,
TrackedSymbols :> {\[Sigma]xx, \[Sigma]yy, \[Sigma]zz, \[Tau]xyxy, \
\[Tau]yzyz, \[Tau]zxzx, strainType, k, ee, \[Nu], reset, showOriginal,
showAxes, plotStyle},
Initialization :>
(
(*definitions used for parameter checking*)
integerStrictPositive = (IntegerQ[#] && # > 0 &);
integerPositive = (IntegerQ[#] && # >= 0 &);
numericStrictPositive = (Element[#, Reals] && # > 0 &);
numericPositive = (Element[#, Reals] && # >= 0 &);
numericStrictNegative = (Element[#, Reals] && # < 0 &);
numericNegative = (Element[#, Reals] && # <= 0 &);
bool = (Element[#, Booleans] &);
numeric = (Element[#, Reals] &);
integer = (Element[#, Integers] &);
(*--------------------------------------------*)
padIt1[v_?numeric, f_List] := AccountingForm[v,
f, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True];
(*--------------------------------------------*)
padIt1[v_?numeric, f_Integer] := AccountingForm[Chop[v],
f, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"},
SignPadding -> True];
(*--------------------------------------------*)
padIt2[v_?numeric, f_List] := AccountingForm[v,
f, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"},
SignPadding -> True];
(*--------------------------------------------*)
padIt2[v_?numeric, f_Integer] := AccountingForm[Chop[v],
f, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"},
SignPadding -> True];
(*--------------------------------------------*)
getCoordinates[
strainType_String, \[Epsilon]x_?numeric, \[Epsilon]y_?
numeric, \[Epsilon]z_?numeric, \[Gamma]xy_?numeric, \[Gamma]yz_?
numeric, \[Gamma]zx_?numeric, k_?integerStrictPositive] :=
Module[{p1, p2, p3, p4, p5, p6, p7, p8, a\[Tau]xy, a\[Tau]yz,
a\[Tau]zx},
a\[Tau]xy = Sin[\[Gamma]xy/2];
a\[Tau]yz = Sin[\[Gamma]yz/2];
a\[Tau]zx = Sin[\[Gamma]zx/2];
(*set coordinates of 8 corners of cube based on type of strain*)
If[strainType == "eng",
p1 = {-1/2 + k (-\[Epsilon]x/2 + a\[Tau]zx), -1/2 +
k (-\[Epsilon]y/2 - a\[Tau]xy),
1/2 + k (\[Epsilon]z/2 - a\[Tau]yz)};
p2 = {1/2 + k (\[Epsilon]x/2 + a\[Tau]zx), -1/2 +
k (-\[Epsilon]y/2 + a\[Tau]xy),
1/2 + k (\[Epsilon]z/2 - a\[Tau]yz)};
p3 = {1/2 + k (\[Epsilon]x/2 + a\[Tau]zx),
1/2 + k (\[Epsilon]y/2 + a\[Tau]xy),
1/2 + k (\[Epsilon]z/2 + a\[Tau]yz)};
p4 = {-1/2 + k (-\[Epsilon]x/2 + a\[Tau]zx),
1/2 + k (\[Epsilon]y/2 - a\[Tau]xy),
1/2 + k (\[Epsilon]z/2 + a\[Tau]yz)};
p5 = {-1/2 + k (-\[Epsilon]x/2 - a\[Tau]zx), -1/2 +
k (-\[Epsilon]y/2 - a\[Tau]xy), -1/2 +
k (-\[Epsilon]z/2 - a\[Tau]yz)};
p6 = {1/2 + k (\[Epsilon]x/2 - a\[Tau]zx), -1/2 +
k (-\[Epsilon]y/2 + a\[Tau]xy), -1/2 +
k (-\[Epsilon]z/2 - a\[Tau]yz)};
p7 = {1/2 + k (\[Epsilon]x/2 - a\[Tau]zx),
1/2 + k (\[Epsilon]y/2 + a\[Tau]xy), -1/2 +
k (-\[Epsilon]z/2 + a\[Tau]yz)};
p8 = {-1/2 + k (-\[Epsilon]x/2 - a\[Tau]zx),
1/2 + k (\[Epsilon]y/2 - a\[Tau]xy), -1/2 +
k (-\[Epsilon]z/2 + a\[Tau]yz)}
,
p1 = {-1/2 +
k (-\[Epsilon]x/2 - a\[Tau]xy/2 + a\[Tau]zx/2), -1/2 +
k (-\[Epsilon]y/2 - a\[Tau]xy/2 + a\[Tau]yz/2),
1/2 + k (\[Epsilon]z/2 - a\[Tau]yz/2 - a\[Tau]zx/2)};
p2 = {1/2 +
k (\[Epsilon]x/2 - a\[Tau]xy/2 + a\[Tau]zx/2), -1/2 +
k (-\[Epsilon]y/2 + a\[Tau]xy/2 + a\[Tau]yz/2),
1/2 + k (\[Epsilon]z/2 - a\[Tau]yz/2 + a\[Tau]zx/2)};
p3 = {1/2 + k (\[Epsilon]x/2 + a\[Tau]xy/2 + a\[Tau]zx/2),
1/2 + k (\[Epsilon]y/2 + a\[Tau]xy/2 + a\[Tau]yz/2),
1/2 + k (\[Epsilon]z/2 + a\[Tau]yz/2 + a\[Tau]zx/2)};
p4 = {-1/2 + k (-\[Epsilon]x/2 + a\[Tau]xy/2 + a\[Tau]zx/2),
1/2 + k (\[Epsilon]y/2 - a\[Tau]xy/2 + a\[Tau]yz/2),
1/2 + k (\[Epsilon]z/2 + a\[Tau]yz/2 - a\[Tau]zx/2)};
p5 = {-1/2 +
k (-\[Epsilon]x/2 - a\[Tau]xy/2 - a\[Tau]zx/2), -1/2 +
k (-\[Epsilon]y/2 - a\[Tau]xy/2 - a\[Tau]yz/2),
-1/2 + k (-\[Epsilon]z/2 - a\[Tau]yz/2 - a\[Tau]zx/2)};
p6 = {1/2 +
k (\[Epsilon]x/2 - a\[Tau]xy/2 - a\[Tau]zx/2), -1/2 +
k (-\[Epsilon]y/2 + a\[Tau]xy/2 - a\[Tau]yz/2),
-1/2 + k (-\[Epsilon]z/2 - a\[Tau]yz/2 + a\[Tau]zx/2)};
p7 = {1/2 + k (\[Epsilon]x/2 + a\[Tau]xy/2 - a\[Tau]zx/2),
1/2 + k (\[Epsilon]y/2 + a\[Tau]xy/2 - a\[Tau]yz/2),
-1/2 + k (-\[Epsilon]z/2 + a\[Tau]yz/2 + a\[Tau]zx/2)};
p8 = {-1/2 + k (-\[Epsilon]x/2 + a\[Tau]xy/2 - a\[Tau]zx/2),
1/2 + k (\[Epsilon]y/2 - a\[Tau]xy/2 - a\[Tau]yz/2),
-1/2 + k (-\[Epsilon]z/2 + a\[Tau]yz/2 - a\[Tau]zx/2)}
];
{p1, p2, p3, p4, p5, p6, p7, p8}
]
)
]