sxs-collaboration / spectre

SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gravitational physics.
https://spectre-code.org
Other
158 stars 187 forks source link

Primitive Recovery for 3d EOS could lead to floating point error #5488

Open jyoo1042 opened 12 months ago

jyoo1042 commented 12 months ago
        get(*specific_enthalpy)[s] = primitive_data.value().rho_h_w_squared /
                                     (primitive_data.value().lorentz_factor *
                                      primitive_data.value().lorentz_factor);
        get(*specific_internal_energy)[s] =
            (get(*specific_enthalpy)[s] -
             primitive_data.value().rest_mass_density -
             primitive_data.value().pressure) /
            primitive_data.value().rest_mass_density;

        get(*specific_enthalpy)[s] /= primitive_data.value().rest_mass_density;
      }

could lead to floating point error in Newtonian limit.

nilsdeppe commented 12 months ago

I have a fix for this and will submit a PR soon. There's another easy one that I also fix. Going to see if anything else pops out :)