Skip to content

Investigate rust/python test discrepancy hack #94

@mducle

Description

@mducle

In PR#83 to add the spin-spin correlation calculations, it was found that the test for consistency between the Python and Rust code was failing due to different values of the intensity (spin-spin correlation function) being computed for degenerate modes - physically this is because we cannot measure the intensity of each degenerate mode but only their sum; However, the test simply compares the exact values calculated in the two codes which can be inconsistent due to the numerics of the eigendecomposition calculations in numpy and in faer.

As a hack, the codes introduced a small delta value (around 1e-12 to the diagonal element of the matrix to be diagonalise which slightly lifts the degeneracy of the modes. This ensures that the eigenvectors computed by the eigendecomposition is unique and consistent between the Python and Rust. The difference in eigenvalues was found to be around 1e-7 - 1e-8 which may be small enough to be ignored.

However, it would be good to check if there is a better solution to checking the Python and Rust codes are consistent. The options could include:

  1. Changing the test to just compare the summed intensities for degenerate modes using a routine similar to sw_omegasum
  2. Changing the computation code to orthogonalise the eigenvectors within a manifold of degenerate eigenvalues, like in the eigorth function in the Matlab version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions