From 692787f06f367402d3db50a19927556760af12ce Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 23 May 2024 14:21:49 -0400 Subject: [PATCH] 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 --- CMakeLists.txt | 2 +- Source/EbsdLib/LaueOps/CubicOps.cpp | 116 ++++++++++----------- Source/EbsdLib/LaueOps/CubicOps.h | 55 +++++++++- Source/EbsdLib/LaueOps/HexagonalLowOps.cpp | 5 +- Source/EbsdLib/LaueOps/HexagonalOps.cpp | 12 +-- 5 files changed, 112 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6e7a84..8494a20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Source/EbsdLib/LaueOps/CubicOps.cpp b/Source/EbsdLib/LaueOps/CubicOps.cpp index 2db4b49..233db5d 100644 --- a/Source/EbsdLib/LaueOps/CubicOps.cpp +++ b/Source/EbsdLib/LaueOps/CubicOps.cpp @@ -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; @@ -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; @@ -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; @@ -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(q1).toGMatrix(g1temp); - OrientationTransformation::qu2om(q2).toGMatrix(g2temp); - EbsdMatrixMath::Transpose3x3(g1temp, g1); - EbsdMatrixMath::Transpose3x3(g2temp, g2); + + EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om(q1).data()); + EbsdLib::Matrix3X3D g1 = g.transpose(); + + g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om(q2).data()); + EbsdLib::Matrix3X3D g2 = g.transpose(); EbsdMatrixMath::Normalize3x1(LD); @@ -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) { @@ -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; } @@ -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; @@ -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(q1).toGMatrix(g1temp); - OrientationTransformation::qu2om(q2).toGMatrix(g2temp); - EbsdMatrixMath::Transpose3x3(g1temp, g1); - EbsdMatrixMath::Transpose3x3(g2temp, g2); + EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om(q1).data()); + EbsdLib::Matrix3X3D g1 = g.transpose(); + + g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om(q2).data()); + EbsdLib::Matrix3X3D g2 = g.transpose(); EbsdMatrixMath::Normalize3x1(LD); @@ -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) { @@ -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; diff --git a/Source/EbsdLib/LaueOps/CubicOps.h b/Source/EbsdLib/LaueOps/CubicOps.h index cfbddef..1e3ba22 100644 --- a/Source/EbsdLib/LaueOps/CubicOps.h +++ b/Source/EbsdLib/LaueOps/CubicOps.h @@ -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 getNumSymmetry() const override; + std::array getNumSymmetry() const override; /** * @brief getMDFSize Returns the number of MDF bins @@ -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; @@ -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 getDefaultPoleFigureNames() const override; + std::array getDefaultPoleFigureNames() const override; /** * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. diff --git a/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp b/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp index 4a03491..3b2cd7b 100644 --- a/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp +++ b/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp @@ -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 @@ -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 @@ -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]; @@ -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]; diff --git a/Source/EbsdLib/LaueOps/HexagonalOps.cpp b/Source/EbsdLib/LaueOps/HexagonalOps.cpp index 7bfa5ff..a2d3d26 100644 --- a/Source/EbsdLib/LaueOps/HexagonalOps.cpp +++ b/Source/EbsdLib/LaueOps/HexagonalOps.cpp @@ -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 @@ -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 @@ -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]; @@ -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]; @@ -1068,7 +1065,6 @@ double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool } */ #endif - return 0.0; } // ----------------------------------------------------------------------------- //