glotzerlab / hoomd-blue

Molecular dynamics and Monte Carlo soft matter simulation on GPUs.
http://glotzerlab.engin.umich.edu/hoomd-blue
BSD 3-Clause "New" or "Revised" License
324 stars 127 forks source link

Add error when ellipsoid axis is zero #1785

Closed janbridley closed 1 month ago

janbridley commented 2 months ago

Description

A check was added to verify values are within the expected range. ~I set the minimum allowed value to ELLIPSOID_OVERLAP_PRECISION (1e-6), which may or may not be the correct choice. We could do FLT_EPSILON from as well, but that may not be consistent if HOOMD_SHORTREAL_SIZE==64.~ I am open to suggestions about the correct value to assign.

Errors occur then any semimajor axis is less than 0.0f.

Motivation and context

Overlap checks do not work for ellipsoids with any semimajor axis less than zero. This error (on the c++ level) prevents users from inadvertently encountering this issue.

Resolves #1762

How has this been tested?

A new test has been added that attempts to set invalid parameters. This tests values at zero, slightly above zero, and well below it.

Change log

- Provide an error message for invalid Ellipsoid shape params.

Checklist:

joaander commented 2 months ago

I think a check against 0 is correct here. ELLIPSOID_OVERLAP_PRECISION is a relative tolerance. If users would like to work in a system of units where typical particle diameters are 1e-50, they we should allow that.

janbridley commented 1 month ago

pre-commit.ci autofix