Skip to content

Commit

Permalink
BUG: Fix bug in CubicOps::getF1()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
imikejackson committed May 23, 2024
1 parent c646932 commit 692787f
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 78 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# set project's name
project(EbsdLibProj VERSION 1.0.26)
project(EbsdLibProj VERSION 1.0.28)

# ---------- Setup output Directories -------------------------
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
Expand Down
116 changes: 55 additions & 61 deletions Source/EbsdLib/LaueOps/CubicOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,16 +948,13 @@ void CubicOps::getSchmidFactorAndSS(double load[3], double plane[3], double dire

double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const
{
// double g1[3][3];
// double g2[3][3];
// double g1temp[3][3];
// double g2temp[3][3];
EbsdLib::Matrix3X1D hkl1;
EbsdLib::Matrix3X1D uvw1;
EbsdLib::Matrix3X1D hkl2;
EbsdLib::Matrix3X1D uvw2;
EbsdLib::Matrix3X1D slipDirection;
EbsdLib::Matrix3X1D slipPlane;

double schmidFactor1 = 0, schmidFactor2 = 0, maxSchmidFactor = 0;
double directionComponent1 = 0, planeComponent1 = 0;
double directionComponent2 = 0, planeComponent2 = 0;
Expand Down Expand Up @@ -1047,10 +1044,6 @@ double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const

double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const
{
// double g1[3][3];
// double g2[3][3];
// double g1temp[3][3];
// double g2temp[3][3];
EbsdLib::Matrix3X1D hkl1;
EbsdLib::Matrix3X1D uvw1;
EbsdLib::Matrix3X1D hkl2;
Expand Down Expand Up @@ -1112,7 +1105,7 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
hkl2 = hkl2.normalize();
uvw2 = uvw2.normalize();

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

double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const
{
double g1[3][3];
double g2[3][3];
double g1temp[3][3];
double g2temp[3][3];
double hkl1[3], uvw1[3];
double hkl2[3], uvw2[3];
double slipDirection[3], slipPlane[3];
EbsdLib::Matrix3X1D hkl1;
EbsdLib::Matrix3X1D uvw1;
EbsdLib::Matrix3X1D hkl2;
EbsdLib::Matrix3X1D uvw2;
EbsdLib::Matrix3X1D slipDirection;
EbsdLib::Matrix3X1D slipPlane;

double directionMisalignment = 0, totalDirectionMisalignment = 0;
double planeMisalignment = 0, totalPlaneMisalignment = 0;
double schmidFactor1 = 0, maxSchmidFactor = 0;
double directionComponent1 = 0, planeComponent1 = 0;
// s double directionComponent2 = 0, planeComponent2 = 0;
double maxF1spt = 0.0;
double F1spt = 0.0f;
OrientationTransformation::qu2om<QuatD, OrientationType>(q1).toGMatrix(g1temp);
OrientationTransformation::qu2om<QuatD, OrientationType>(q2).toGMatrix(g2temp);
EbsdMatrixMath::Transpose3x3(g1temp, g1);
EbsdMatrixMath::Transpose3x3(g2temp, g2);

EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om<QuatD, OrientationType>(q1).data());
EbsdLib::Matrix3X3D g1 = g.transpose();

g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om<QuatD, OrientationType>(q2).data());
EbsdLib::Matrix3X3D g2 = g.transpose();

EbsdMatrixMath::Normalize3x1(LD);

Expand All @@ -1167,12 +1161,14 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m
slipPlane[0] = CubicHigh::SlipPlanes[i][0];
slipPlane[1] = CubicHigh::SlipPlanes[i][1];
slipPlane[2] = CubicHigh::SlipPlanes[i][2];
EbsdMatrixMath::Multiply3x3with3x1(g1, slipPlane, hkl1);
EbsdMatrixMath::Multiply3x3with3x1(g1, slipDirection, uvw1);
EbsdMatrixMath::Normalize3x1(hkl1);
EbsdMatrixMath::Normalize3x1(uvw1);
directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1));
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1));
hkl1 = g1 * slipPlane;
uvw1 = g1 * slipDirection;

hkl1 = hkl1.normalize();
uvw1 = uvw1.normalize();

directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data()));
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data()));
schmidFactor1 = directionComponent1 * planeComponent1;
if(schmidFactor1 > maxSchmidFactor || !maxSF)
{
Expand All @@ -1190,15 +1186,14 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m
slipPlane[0] = CubicHigh::SlipPlanes[j][0];
slipPlane[1] = CubicHigh::SlipPlanes[j][1];
slipPlane[2] = CubicHigh::SlipPlanes[j][2];
EbsdMatrixMath::Multiply3x3with3x1(g2, slipPlane, hkl2);
EbsdMatrixMath::Multiply3x3with3x1(g2, slipDirection, uvw2);
EbsdMatrixMath::Normalize3x1(hkl2);
EbsdMatrixMath::Normalize3x1(uvw2);
// directionComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, uvw2));
// planeComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, hkl2));
// schmidFactor2 = directionComponent2 * planeComponent2;
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1, uvw2));
planeMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(hkl1, hkl2));

hkl2 = g2 * slipPlane;
uvw2 = g2 * slipDirection;
hkl2 = hkl2.normalize();
uvw2 = uvw2.normalize();

directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data()));
planeMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(hkl1.data(), hkl2.data()));
totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment;
totalPlaneMisalignment = totalPlaneMisalignment + planeMisalignment;
}
Expand All @@ -1221,13 +1216,13 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m

double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const
{
double g1[3][3];
double g2[3][3];
double g1temp[3][3];
double g2temp[3][3];
double hkl1[3], uvw1[3];
double hkl2[3], uvw2[3];
double slipDirection[3], slipPlane[3];
EbsdLib::Matrix3X1D hkl1;
EbsdLib::Matrix3X1D uvw1;
EbsdLib::Matrix3X1D hkl2;
EbsdLib::Matrix3X1D uvw2;
EbsdLib::Matrix3X1D slipDirection;
EbsdLib::Matrix3X1D slipPlane;

double directionMisalignment = 0, totalDirectionMisalignment = 0;
double schmidFactor1 = 0.0, maxSchmidFactor = 0.0;
double directionComponent1 = 0.0;
Expand All @@ -1237,10 +1232,11 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
double maxF7 = 0.0;
double F7 = 0.0f;

OrientationTransformation::qu2om<QuatD, OrientationType>(q1).toGMatrix(g1temp);
OrientationTransformation::qu2om<QuatD, OrientationType>(q2).toGMatrix(g2temp);
EbsdMatrixMath::Transpose3x3(g1temp, g1);
EbsdMatrixMath::Transpose3x3(g2temp, g2);
EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om<QuatD, OrientationType>(q1).data());
EbsdLib::Matrix3X3D g1 = g.transpose();

g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om<QuatD, OrientationType>(q2).data());
EbsdLib::Matrix3X3D g2 = g.transpose();

EbsdMatrixMath::Normalize3x1(LD);

Expand All @@ -1252,12 +1248,12 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
slipPlane[0] = CubicHigh::SlipPlanes[i][0];
slipPlane[1] = CubicHigh::SlipPlanes[i][1];
slipPlane[2] = CubicHigh::SlipPlanes[i][2];
EbsdMatrixMath::Multiply3x3with3x1(g1, slipPlane, hkl1);
EbsdMatrixMath::Multiply3x3with3x1(g1, slipDirection, uvw1);
EbsdMatrixMath::Normalize3x1(hkl1);
EbsdMatrixMath::Normalize3x1(uvw1);
directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1));
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1));
hkl1 = g1 * slipPlane;
uvw1 = g1 * slipDirection;
hkl1 = hkl1.normalize();
uvw1 = uvw1.normalize();
directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data()));
planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data()));
schmidFactor1 = directionComponent1 * planeComponent1;
if(schmidFactor1 > maxSchmidFactor || !maxSF)
{
Expand All @@ -1274,14 +1270,12 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS
slipPlane[0] = CubicHigh::SlipPlanes[j][0];
slipPlane[1] = CubicHigh::SlipPlanes[j][1];
slipPlane[2] = CubicHigh::SlipPlanes[j][2];
EbsdMatrixMath::Multiply3x3with3x1(g2, slipPlane, hkl2);
EbsdMatrixMath::Multiply3x3with3x1(g2, slipDirection, uvw2);
EbsdMatrixMath::Normalize3x1(hkl2);
EbsdMatrixMath::Normalize3x1(uvw2);
// directionComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, uvw2));
// planeComponent2 = std::fabs(GeometryMath::CosThetaBetweenVectors(LD, hkl2));
// schmidFactor2 = directionComponent2 * planeComponent2;
directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1, uvw2));
hkl2 = g2 * slipPlane;
uvw2 = g2 * slipDirection;
hkl2 = hkl2.normalize();
uvw2 = uvw2.normalize();

directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data()));
totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment;
}
F7 = directionComponent1 * directionComponent1 * totalDirectionMisalignment;
Expand Down
55 changes: 51 additions & 4 deletions Source/EbsdLib/LaueOps/CubicOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ class EbsdLib_EXPORT CubicOps : public LaueOps
*/
bool getHasInversion() const override;

/**
/**
* @brief getODFSize Returns the number of ODF bins
* @return
*/
int getODFSize() const override;

/**
/**
* @brief getNumSymmetry Returns the internal variables for symSize0, symSize1, symSize2
* @return
*/
std::array<int32_t, 3> getNumSymmetry() const override;
std::array<int32_t, 3> getNumSymmetry() const override;

/**
* @brief getMDFSize Returns the number of MDF bins
Expand Down Expand Up @@ -167,9 +167,56 @@ class EbsdLib_EXPORT CubicOps : public LaueOps
int getOdfBin(const OrientationType& rod) const override;
void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override;
void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override;

/**
* @brief Compute the Luster-Morris parameter
* @param q1
* @param q2
* @param LD
* @return
*/
double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override;

/**
* @brief Compute the Fracture Initiation Parameter F1 variation.
*
* [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
* 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)
*
* @param q1
* @param q2
* @param LD
* @param maxSF
* @return
*/
double getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override;

/**
* @brief Compute the Fracture Initiation Parameter F1spt variation.
*
* [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
* 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)
*
* @param q1
* @param q2
* @param LD
* @param maxSF
* @return
*/
double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override;

/**
* @brief Compute the Fracture Initiation Parameter F7 variation.
*
* [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
* 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)
*
* @param q1
* @param q2
* @param LD
* @param maxSF
* @return
*/
double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override;

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

/**
* @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps.
Expand Down
5 changes: 1 addition & 4 deletions Source/EbsdLib/LaueOps/HexagonalLowOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ void HexagonalLowOps::getSchmidFactorAndSS(double load[3], double plane[3], doub

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

double HexagonalLowOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
{
EBSD_METHOD_NOT_IMPLEMENTED()
return 0.0;
#if 0
/* I am asserting here because this code will simply give junk results and if someone uses it
Expand Down Expand Up @@ -893,7 +892,6 @@ double HexagonalLowOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bo
}
double HexagonalLowOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
{
EBSD_METHOD_NOT_IMPLEMENTED()
return 0.0;
#if 0
double g1[3][3];
Expand Down Expand Up @@ -971,7 +969,6 @@ double HexagonalLowOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3],

double HexagonalLowOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
{
EBSD_METHOD_NOT_IMPLEMENTED()
return 0.0;
#if 0
double g1[3][3];
Expand Down
12 changes: 4 additions & 8 deletions Source/EbsdLib/LaueOps/HexagonalOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ void HexagonalOps::getSchmidFactorAndSS(double load[3], double plane[3], double

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

double HexagonalOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
{
EBSD_METHOD_NOT_IMPLEMENTED()
return 0.0;
#if 0
/* I am asserting here because this code will simply give junk results and if someone uses it
* they could unknowningly get really bad results
Expand Down Expand Up @@ -922,11 +921,10 @@ double HexagonalOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool
}
*/
#endif
return 0.0;
}
double HexagonalOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
{
EBSD_METHOD_NOT_IMPLEMENTED()
return 0.0;
#if 0
double g1[3][3];
double g2[3][3];
Expand Down Expand Up @@ -999,12 +997,11 @@ double HexagonalOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bo
}
*/
#endif
return 0.0;
}

double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS) const
{
EBSD_METHOD_NOT_IMPLEMENTED()
return 0.0;
#if 0
double g1[3][3];
double g2[3][3];
Expand Down Expand Up @@ -1068,7 +1065,6 @@ double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool
}
*/
#endif
return 0.0;
}
// -----------------------------------------------------------------------------
//
Expand Down

0 comments on commit 692787f

Please sign in to comment.