lumol-org / lumol

Universal extensible molecular simulation engine
http://lumol.org/
BSD 3-Clause "New" or "Revised" License
184 stars 18 forks source link

Error when using potentials with a too small cutoff #233

Closed Luthaf closed 6 years ago

Luthaf commented 6 years ago

Using potentials with a cutoff bigger than half the cell is not well defined with the current code, so this PR adds fatal_error in NPT MD integrator when resizing the cell to a small value, and when adding potentials to a system.

NPT MC integrator already call fatal_error.

See #232 for initial discussion on this.

We could return Result instead of panic!ing in System::add_pair_potential, but I am not really sure is it worth it: what could the user do with the Error case ?

g-bauer commented 6 years ago

That's a good addition. One minor thing:

Instead of writing

"Can not add a potential with a cutoff bigger than half of the
smallest cell size. Try increasing the cell size or decreasing
the cutoff."

I'd write "smallest cell length" when adding potentials. As for the error messages of the barostats, I think they are fine.

We could return Result instead of panic!ing in System::add_pair_potential, but I am not really sure is it worth it: what could the user do with the Error case ?

I think panicking is fine here.

Luthaf commented 6 years ago

I'd write "smallest cell length" when adding potentials. As for the error messages of the barostats, I think they are fine.

Done!