Fix handedness for bingham average - #7297
Open
Theo-Geo wants to merge 2 commits into
Open
Conversation
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this pull request i address problems with outputing the bingham average as euler angles.
In the cpo bingham average particle property if Use rotation matrix is set to false, the eigenvectors with the highest eigenvalue are combined as column vectors to form a 3x3 matrix. The problem here is that the bingham average is an antipodal average i.e. the eigenvectors can be either + or - and are still eigenvectors of the second order structure tensor.
When the principal eigenvectors are combined they can form a left-handed coordinate system. This corresponds to a rotation matrix that is not in the group of rotations as it does not preserve orientation. Similarly a reflection also does not preserve orientation and is therefore not in the group of rotations.
Euler angles are a parametrization of the group of rotations, but are not a parametrization of all orthogonal matrices, e.g. they can not parametrize a reflection. This has bad consequences if one wants to recover the principle eigenvector of the first axis also called the mean 100 axis or mean a-axis.
To see the issue i attached a .zip file with a "minimum" working example (it only contains a .prm).
euler_angle_handedness.zip
The parameter file runs a 2d convection box, the crystal preferred orientation plugin and the bingham average.
The steady state convection pattern and bingham average output before applying the changes (No Check for Handness) and after applying the changes (Check for Handedness) can be seen below.
In this figure the black lines indicate the bingham average a-axis. Usually one would expect that it aligns with the velocity direction in a steady state regime as is created in this convection box. To recreate the a-axis orientation from the euler angles in paraview one can use the calculator and put in:
( cos("cpo mineral 0 phi2")*cos("cpo mineral 0 phi1") - cos("cpo mineral 0 theta")*sin("cpo mineral 0 phi1")*sin("cpo mineral 0 phi2") )*iHat - ( cos("cpo mineral 0 phi2")*sin("cpo mineral 0 phi1") + cos("cpo mineral 0 theta")*cos("cpo mineral 0 phi1")*sin("cpo mineral 0 phi2") )*jHat - sin("cpo mineral 0 phi2")*sin("cpo mineral 0 theta")*kHat
The solution in the right panel was created by checking for handedness before orthogonalizing the rotation matrix.$h$ can be computed by taking the cross product between the first two vectors and multiplying it by the last vector,
The handedness
If h is smaller than 0,$\mathbf{v}^3$ approximately points in the opposite direction of $( \mathbf{v}^1 \times \mathbf{v}^2) $ . To ensure the correct handedness one can then multiply $\mathbf{v}^3$ by -1 before constructing the rotation matrix.
TODO I still need to update all tests where euler angles are output, but feel welcome to read and comment on the changes before i do this so i do not have to do it twice.
Before your first pull request:
For all pull requests:
For new features/models or changes of existing features: