Skip to content

Conversation

@santisoler
Copy link
Member

@santisoler santisoler commented Dec 1, 2025

Refactor the ellipsoid code to have a single Ellipsoid class that can represent any type of ellipsoid. Ditch the specific classes for each ellipsoid type. Update the forward modelling code for gravity and magnetics. Make use of an extra rotation matrix that aligns the x, y, z local coordinate system to the ellipsoid's semiaxes in decreasing order, so a >= b >= c. Modify the analytic solutions for oblate ellipsoids in such way that they are defined by a == b > c (instead of a < b = c as Takahashi et al. and Clark et al. do). Make rotation angles and center as optional arguments for the Ellipsoid class. Fix numerical instabilities of triaxial ellipsoids when they approximate prolate or oblate ellipsoids (when two semiaxes lengths are close enough to each other). Update the tests and add a few more for the new bits of code.

Relevant issues/PRs:

Part of #594

Start implementing gravity field with a permutation matrix to sort out
the semiaxes.
Update the elliptical integrals for oblates so they assume that
`a == b > c`. Simplify the permutation matrix since now we don't need to
take care of oblates as a special case.
Remove quite a lot of tests since we now have a single ellipsoid class.
It makes it more explicit about what's happening with the semiaxes. The
permutation matrix should match that sorting, but we can cover that in
tests.
Update the magnetic code to use the single `Ellipsoid` class, make use
of the permutation matrix, and update the internal demagnetization
tensor equations for the oblate ellipsoid defined as `a == b > c`.
Do this to differentiate it from just the rotation matrix, since it also
includes the permutation one.
@santisoler
Copy link
Member Author

santisoler commented Dec 1, 2025

TODO:

  • add tests for the get_permutation_matrix get_semiaxes_rotation_matrix function (fixed a bug on it)
  • test gravity and magnetic fields of triaxial ellipsoids vs oblates and prolates (when two of the semiaxes are similar to each other).

The permutation matrix used wasn't right: we need to apply a proper
rotation matrix (with 90 degrees) to ensure that the local coordinate
system is a right-handed one.
Test ellipsoids defined with semiaxes passed in arbitrary orders against
equivalent ellipsoids defined with ``a >= b >= c``, but with necessary
rotations.
After changing the definition of the oblate to `a == b > c`, we need to
change the condition for oblates in such function.
Fix the numerical instabilities of gravity fields produced by triaxial
ellipsoids that approximate a prolate and an oblate ellipsoid.
Fallback to the prolate and oblate solutions when two of the three
semiaxes are close enough to each other.
Fallback to the prolate and oblate solutions for the internal
demagnetization tensor when triaxial has two semiaxes close enough to
each other.
Use the ratio instead of a static delta, so we are sure we are comparing
the two different codes and not just triggering the numerical
instability fix that falls back to the spherical solutions.
Use the ratio instead of a static delta, so we are sure we are comparing
the two different codes and not just triggering the numerical
instability fix that falls back to the spherical solutions.
@santisoler santisoler force-pushed the single-ellipsoid-class branch from 2a93219 to d40d9fd Compare December 4, 2025 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant