Skip to content

Commit 692787f

Browse files
committed
BUG: Fix bug in CubicOps::getF1()
Also update getFspt() and getF7() methods to have similar code bases. These should really just be combined. Return 0 for the Hexagonal class implementations instead of throwing an exception. Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
1 parent c646932 commit 692787f

File tree

5 files changed

+112
-78
lines changed

5 files changed

+112
-78
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1515
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1616

1717
# set project's name
18-
project(EbsdLibProj VERSION 1.0.26)
18+
project(EbsdLibProj VERSION 1.0.28)
1919

2020
# ---------- Setup output Directories -------------------------
2121
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY

Source/EbsdLib/LaueOps/CubicOps.cpp

Lines changed: 55 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -948,16 +948,13 @@ void CubicOps::getSchmidFactorAndSS(double load[3], double plane[3], double dire
948948

949949
double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const
950950
{
951-
// double g1[3][3];
952-
// double g2[3][3];
953-
// double g1temp[3][3];
954-
// double g2temp[3][3];
955951
EbsdLib::Matrix3X1D hkl1;
956952
EbsdLib::Matrix3X1D uvw1;
957953
EbsdLib::Matrix3X1D hkl2;
958954
EbsdLib::Matrix3X1D uvw2;
959955
EbsdLib::Matrix3X1D slipDirection;
960956
EbsdLib::Matrix3X1D slipPlane;
957+
961958
double schmidFactor1 = 0, schmidFactor2 = 0, maxSchmidFactor = 0;
962959
double directionComponent1 = 0, planeComponent1 = 0;
963960
double directionComponent2 = 0, planeComponent2 = 0;
@@ -1047,10 +1044,6 @@ double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const
10471044

10481045
double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const
10491046
{
1050-
// double g1[3][3];
1051-
// double g2[3][3];
1052-
// double g1temp[3][3];
1053-
// double g2temp[3][3];
10541047
EbsdLib::Matrix3X1D hkl1;
10551048
EbsdLib::Matrix3X1D uvw1;
10561049
EbsdLib::Matrix3X1D hkl2;
@@ -1112,7 +1105,7 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
11121105
hkl2 = hkl2.normalize();
11131106
uvw2 = uvw2.normalize();
11141107

1115-
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw2.data(), uvw2.data()));
1108+
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data()));
11161109
totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment;
11171110
}
11181111
F1 = schmidFactor1 * directionComponent1 * totalDirectionMisalignment;
@@ -1134,24 +1127,25 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
11341127

11351128
double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const
11361129
{
1137-
double g1[3][3];
1138-
double g2[3][3];
1139-
double g1temp[3][3];
1140-
double g2temp[3][3];
1141-
double hkl1[3], uvw1[3];
1142-
double hkl2[3], uvw2[3];
1143-
double slipDirection[3], slipPlane[3];
1130+
EbsdLib::Matrix3X1D hkl1;
1131+
EbsdLib::Matrix3X1D uvw1;
1132+
EbsdLib::Matrix3X1D hkl2;
1133+
EbsdLib::Matrix3X1D uvw2;
1134+
EbsdLib::Matrix3X1D slipDirection;
1135+
EbsdLib::Matrix3X1D slipPlane;
1136+
11441137
double directionMisalignment = 0, totalDirectionMisalignment = 0;
11451138
double planeMisalignment = 0, totalPlaneMisalignment = 0;
11461139
double schmidFactor1 = 0, maxSchmidFactor = 0;
11471140
double directionComponent1 = 0, planeComponent1 = 0;
1148-
// s double directionComponent2 = 0, planeComponent2 = 0;
11491141
double maxF1spt = 0.0;
11501142
double F1spt = 0.0f;
1151-
OrientationTransformation::qu2om<QuatD, OrientationType>(q1).toGMatrix(g1temp);
1152-
OrientationTransformation::qu2om<QuatD, OrientationType>(q2).toGMatrix(g2temp);
1153-
EbsdMatrixMath::Transpose3x3(g1temp, g1);
1154-
EbsdMatrixMath::Transpose3x3(g2temp, g2);
1143+
1144+
EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om<QuatD, OrientationType>(q1).data());
1145+
EbsdLib::Matrix3X3D g1 = g.transpose();
1146+
1147+
g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om<QuatD, OrientationType>(q2).data());
1148+
EbsdLib::Matrix3X3D g2 = g.transpose();
11551149

11561150
EbsdMatrixMath::Normalize3x1(LD);
11571151

@@ -1167,12 +1161,14 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m
11671161
slipPlane[0] = CubicHigh::SlipPlanes[i][0];
11681162
slipPlane[1] = CubicHigh::SlipPlanes[i][1];
11691163
slipPlane[2] = CubicHigh::SlipPlanes[i][2];
1170-
EbsdMatrixMath::Multiply3x3with3x1(g1, slipPlane, hkl1);
1171-
EbsdMatrixMath::Multiply3x3with3x1(g1, slipDirection, uvw1);
1172-
EbsdMatrixMath::Normalize3x1(hkl1);
1173-
EbsdMatrixMath::Normalize3x1(uvw1);
1174-
directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1));
1175-
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1));
1164+
hkl1 = g1 * slipPlane;
1165+
uvw1 = g1 * slipDirection;
1166+
1167+
hkl1 = hkl1.normalize();
1168+
uvw1 = uvw1.normalize();
1169+
1170+
directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data()));
1171+
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data()));
11761172
schmidFactor1 = directionComponent1 * planeComponent1;
11771173
if(schmidFactor1 > maxSchmidFactor || !maxSF)
11781174
{
@@ -1190,15 +1186,14 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m
11901186
slipPlane[0] = CubicHigh::SlipPlanes[j][0];
11911187
slipPlane[1] = CubicHigh::SlipPlanes[j][1];
11921188
slipPlane[2] = CubicHigh::SlipPlanes[j][2];
1193-
EbsdMatrixMath::Multiply3x3with3x1(g2, slipPlane, hkl2);
1194-
EbsdMatrixMath::Multiply3x3with3x1(g2, slipDirection, uvw2);
1195-
EbsdMatrixMath::Normalize3x1(hkl2);
1196-
EbsdMatrixMath::Normalize3x1(uvw2);
1197-
// directionComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, uvw2));
1198-
// planeComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, hkl2));
1199-
// schmidFactor2 = directionComponent2 * planeComponent2;
1200-
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1, uvw2));
1201-
planeMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(hkl1, hkl2));
1189+
1190+
hkl2 = g2 * slipPlane;
1191+
uvw2 = g2 * slipDirection;
1192+
hkl2 = hkl2.normalize();
1193+
uvw2 = uvw2.normalize();
1194+
1195+
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data()));
1196+
planeMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(hkl1.data(), hkl2.data()));
12021197
totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment;
12031198
totalPlaneMisalignment = totalPlaneMisalignment + planeMisalignment;
12041199
}
@@ -1221,13 +1216,13 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m
12211216

12221217
double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const
12231218
{
1224-
double g1[3][3];
1225-
double g2[3][3];
1226-
double g1temp[3][3];
1227-
double g2temp[3][3];
1228-
double hkl1[3], uvw1[3];
1229-
double hkl2[3], uvw2[3];
1230-
double slipDirection[3], slipPlane[3];
1219+
EbsdLib::Matrix3X1D hkl1;
1220+
EbsdLib::Matrix3X1D uvw1;
1221+
EbsdLib::Matrix3X1D hkl2;
1222+
EbsdLib::Matrix3X1D uvw2;
1223+
EbsdLib::Matrix3X1D slipDirection;
1224+
EbsdLib::Matrix3X1D slipPlane;
1225+
12311226
double directionMisalignment = 0, totalDirectionMisalignment = 0;
12321227
double schmidFactor1 = 0.0, maxSchmidFactor = 0.0;
12331228
double directionComponent1 = 0.0;
@@ -1237,10 +1232,11 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
12371232
double maxF7 = 0.0;
12381233
double F7 = 0.0f;
12391234

1240-
OrientationTransformation::qu2om<QuatD, OrientationType>(q1).toGMatrix(g1temp);
1241-
OrientationTransformation::qu2om<QuatD, OrientationType>(q2).toGMatrix(g2temp);
1242-
EbsdMatrixMath::Transpose3x3(g1temp, g1);
1243-
EbsdMatrixMath::Transpose3x3(g2temp, g2);
1235+
EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om<QuatD, OrientationType>(q1).data());
1236+
EbsdLib::Matrix3X3D g1 = g.transpose();
1237+
1238+
g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om<QuatD, OrientationType>(q2).data());
1239+
EbsdLib::Matrix3X3D g2 = g.transpose();
12441240

12451241
EbsdMatrixMath::Normalize3x1(LD);
12461242

@@ -1252,12 +1248,12 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
12521248
slipPlane[0] = CubicHigh::SlipPlanes[i][0];
12531249
slipPlane[1] = CubicHigh::SlipPlanes[i][1];
12541250
slipPlane[2] = CubicHigh::SlipPlanes[i][2];
1255-
EbsdMatrixMath::Multiply3x3with3x1(g1, slipPlane, hkl1);
1256-
EbsdMatrixMath::Multiply3x3with3x1(g1, slipDirection, uvw1);
1257-
EbsdMatrixMath::Normalize3x1(hkl1);
1258-
EbsdMatrixMath::Normalize3x1(uvw1);
1259-
directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1));
1260-
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1));
1251+
hkl1 = g1 * slipPlane;
1252+
uvw1 = g1 * slipDirection;
1253+
hkl1 = hkl1.normalize();
1254+
uvw1 = uvw1.normalize();
1255+
directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data()));
1256+
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data()));
12611257
schmidFactor1 = directionComponent1 * planeComponent1;
12621258
if(schmidFactor1 > maxSchmidFactor || !maxSF)
12631259
{
@@ -1274,14 +1270,12 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
12741270
slipPlane[0] = CubicHigh::SlipPlanes[j][0];
12751271
slipPlane[1] = CubicHigh::SlipPlanes[j][1];
12761272
slipPlane[2] = CubicHigh::SlipPlanes[j][2];
1277-
EbsdMatrixMath::Multiply3x3with3x1(g2, slipPlane, hkl2);
1278-
EbsdMatrixMath::Multiply3x3with3x1(g2, slipDirection, uvw2);
1279-
EbsdMatrixMath::Normalize3x1(hkl2);
1280-
EbsdMatrixMath::Normalize3x1(uvw2);
1281-
// directionComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, uvw2));
1282-
// planeComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, hkl2));
1283-
// schmidFactor2 = directionComponent2 * planeComponent2;
1284-
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1, uvw2));
1273+
hkl2 = g2 * slipPlane;
1274+
uvw2 = g2 * slipDirection;
1275+
hkl2 = hkl2.normalize();
1276+
uvw2 = uvw2.normalize();
1277+
1278+
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data()));
12851279
totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment;
12861280
}
12871281
F7 = directionComponent1 * directionComponent1 * totalDirectionMisalignment;

Source/EbsdLib/LaueOps/CubicOps.h

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ class EbsdLib_EXPORT CubicOps : public LaueOps
8181
*/
8282
bool getHasInversion() const override;
8383

84-
/**
84+
/**
8585
* @brief getODFSize Returns the number of ODF bins
8686
* @return
8787
*/
8888
int getODFSize() const override;
8989

90-
/**
90+
/**
9191
* @brief getNumSymmetry Returns the internal variables for symSize0, symSize1, symSize2
9292
* @return
9393
*/
94-
std::array<int32_t, 3> getNumSymmetry() const override;
94+
std::array<int32_t, 3> getNumSymmetry() const override;
9595

9696
/**
9797
* @brief getMDFSize Returns the number of MDF bins
@@ -167,9 +167,56 @@ class EbsdLib_EXPORT CubicOps : public LaueOps
167167
int getOdfBin(const OrientationType& rod) const override;
168168
void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override;
169169
void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override;
170+
171+
/**
172+
* @brief Compute the Luster-Morris parameter
173+
* @param q1
174+
* @param q2
175+
* @param LD
176+
* @return
177+
*/
170178
double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override;
179+
180+
/**
181+
* @brief Compute the Fracture Initiation Parameter F1 variation.
182+
*
183+
* [2] [D. Kumar, T. R. Bieler, P. Eisenlohr, D. E. Mason, M. A. Crimp, F. Roters, and D. Raabe. On Predicting Nucleation of Microcracks Due to Slip Twin Interactions at Grain Boundaries in Duplex
184+
* Near γ-TiAl. Journal of Engineering Materials and Technology, 130(2):021012–12, 2008. doi:10.1115/1.2841620.](https://doi.org/10.1115/1.2841620)
185+
*
186+
* @param q1
187+
* @param q2
188+
* @param LD
189+
* @param maxSF
190+
* @return
191+
*/
171192
double getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override;
193+
194+
/**
195+
* @brief Compute the Fracture Initiation Parameter F1spt variation.
196+
*
197+
* [2] [D. Kumar, T. R. Bieler, P. Eisenlohr, D. E. Mason, M. A. Crimp, F. Roters, and D. Raabe. On Predicting Nucleation of Microcracks Due to Slip Twin Interactions at Grain Boundaries in Duplex
198+
* Near γ-TiAl. Journal of Engineering Materials and Technology, 130(2):021012–12, 2008. doi:10.1115/1.2841620.](https://doi.org/10.1115/1.2841620)
199+
*
200+
* @param q1
201+
* @param q2
202+
* @param LD
203+
* @param maxSF
204+
* @return
205+
*/
172206
double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override;
207+
208+
/**
209+
* @brief Compute the Fracture Initiation Parameter F7 variation.
210+
*
211+
* [2] [D. Kumar, T. R. Bieler, P. Eisenlohr, D. E. Mason, M. A. Crimp, F. Roters, and D. Raabe. On Predicting Nucleation of Microcracks Due to Slip Twin Interactions at Grain Boundaries in Duplex
212+
* Near γ-TiAl. Journal of Engineering Materials and Technology, 130(2):021012–12, 2008. doi:10.1115/1.2841620.](https://doi.org/10.1115/1.2841620)
213+
*
214+
* @param q1
215+
* @param q2
216+
* @param LD
217+
* @param maxSF
218+
* @return
219+
*/
173220
double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override;
174221

175222
void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const override;
@@ -220,7 +267,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps
220267
* @brief Returns the names for each of the three standard pole figures that are generated. For example
221268
*<001>, <011> and <111> for a cubic system
222269
*/
223-
std::array<std::string, 3> getDefaultPoleFigureNames() const override;
270+
std::array<std::string, 3> getDefaultPoleFigureNames() const override;
224271

225272
/**
226273
* @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps.

Source/EbsdLib/LaueOps/HexagonalLowOps.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ void HexagonalLowOps::getSchmidFactorAndSS(double load[3], double plane[3], doub
777777

778778
double HexagonalLowOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const
779779
{
780-
EBSD_METHOD_NOT_IMPLEMENTED()
780+
return 0.0;
781781
#if 0
782782
/* I am asserting here because this code will simply give junk results and if someone uses it
783783
* they could unknowningly get really bad results
@@ -817,7 +817,6 @@ double HexagonalLowOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]
817817

818818
double HexagonalLowOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
819819
{
820-
EBSD_METHOD_NOT_IMPLEMENTED()
821820
return 0.0;
822821
#if 0
823822
/* I am asserting here because this code will simply give junk results and if someone uses it
@@ -893,7 +892,6 @@ double HexagonalLowOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bo
893892
}
894893
double HexagonalLowOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
895894
{
896-
EBSD_METHOD_NOT_IMPLEMENTED()
897895
return 0.0;
898896
#if 0
899897
double g1[3][3];
@@ -971,7 +969,6 @@ double HexagonalLowOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3],
971969

972970
double HexagonalLowOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
973971
{
974-
EBSD_METHOD_NOT_IMPLEMENTED()
975972
return 0.0;
976973
#if 0
977974
double g1[3][3];

Source/EbsdLib/LaueOps/HexagonalOps.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ void HexagonalOps::getSchmidFactorAndSS(double load[3], double plane[3], double
810810

811811
double HexagonalOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const
812812
{
813-
EBSD_METHOD_NOT_IMPLEMENTED()
813+
return 0.0;
814814
#if 0
815815
/* I am asserting here because this code will simply give junk results and if someone uses it
816816
* they could unknowningly get really bad results
@@ -845,12 +845,11 @@ double HexagonalOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) c
845845
directionmisalignment = fabs((u1 * u2 + v1 * v2 + w1 * w2) / (denomuvw1 * denomuvw2));
846846
mPrime = planemisalignment * directionmisalignment;
847847
#endif
848-
return 0.0;
849848
}
850849

851850
double HexagonalOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
852851
{
853-
EBSD_METHOD_NOT_IMPLEMENTED()
852+
return 0.0;
854853
#if 0
855854
/* I am asserting here because this code will simply give junk results and if someone uses it
856855
* they could unknowningly get really bad results
@@ -922,11 +921,10 @@ double HexagonalOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool
922921
}
923922
*/
924923
#endif
925-
return 0.0;
926924
}
927925
double HexagonalOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
928926
{
929-
EBSD_METHOD_NOT_IMPLEMENTED()
927+
return 0.0;
930928
#if 0
931929
double g1[3][3];
932930
double g2[3][3];
@@ -999,12 +997,11 @@ double HexagonalOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bo
999997
}
1000998
*/
1001999
#endif
1002-
return 0.0;
10031000
}
10041001

10051002
double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
10061003
{
1007-
EBSD_METHOD_NOT_IMPLEMENTED()
1004+
return 0.0;
10081005
#if 0
10091006
double g1[3][3];
10101007
double g2[3][3];
@@ -1068,7 +1065,6 @@ double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool
10681065
}
10691066
*/
10701067
#endif
1071-
return 0.0;
10721068
}
10731069
// -----------------------------------------------------------------------------
10741070
//

0 commit comments

Comments
 (0)