vancesteven / PlanetProfile

Construct 1D interior structure models based on planetary properties. Self-consistent thermodynamics are used for fluid, rock, and mineral phases. Sound speeds, attenuation, and electrical conductivities are computed as outputs.
https://vancesteven.github.io/PlanetProfile/
Other
18 stars 13 forks source link

try block for testing whether Pb was found is problematic #22

Open itsmoosh opened 4 years ago

itsmoosh commented 4 years ago

https://github.com/vancesteven/PlanetProfile/blob/05197dd1769575a2094e45a1fd2c2f1d3ddd137d/PlanetProfile.m#L227

The try/catch block entered at the line above in PlanetProfile.m is used to determine if errors were encountered in finding Pb, the pressure at the ice--ocean interface. Any statement causing an error in the try block could trigger an error though, so this block should be shrunk or redesigned to better handle the expected outcomes.

itsmoosh commented 4 years ago

The same thing is being done in getRhoIce and getCpIce to test if the range of inputs is valid for SeaFreeze. The parameters need to be checked directly, not indirectly, as this can mask problems with the physics or programming. https://github.com/vancesteven/PlanetProfile/blob/05197dd1769575a2094e45a1fd2c2f1d3ddd137d/PlanetProfile.m#L2800 https://github.com/vancesteven/PlanetProfile/blob/05197dd1769575a2094e45a1fd2c2f1d3ddd137d/PlanetProfile.m#L2850

itsmoosh commented 2 years ago

This is still true. In the Python version, I have added a lot more descriptive checks and error messages that help the user identify where and why things are breaking. Most often, failing to find Pb happens because Tb_K is too high and the zero-crossing algorithm used to find the melting temp fails, due to the start and end points for the search region having the same sign (no obvious zero-crossing between). Similar checks should be added in the Matlab version.