-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 335 float quantity in settings (#657)
* use FloatQuantity type annotation in Settings this is different to `unit.Quantity` as it then allows the coercion of strings to correct values through a pydantic validator will eventually aid in ingesting CLI inputs to Settings as strings can be passed directly onto Settings * tests for setting fields in Settings via strings --------- Co-authored-by: Mike Henry <11765982+mikemhenry@users.noreply.github.com>
- Loading branch information
1 parent
5ddaad2
commit a3b5305
Showing
3 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# This code is part of OpenFE and is licensed under the MIT license. | ||
# For details, see https://github.com/OpenFreeEnergy/openfe | ||
|
||
import pytest | ||
from openff.units import unit | ||
|
||
from openfe.protocols.openmm_rfe import equil_rfe_settings | ||
# afe settings currently have no FloatQuantity values | ||
from openfe.protocols.openmm_utils import omm_settings | ||
|
||
|
||
class TestOMMSettingsFromStrings: | ||
# checks that we can set Settings fields via strings | ||
def test_system_settings(self): | ||
s = omm_settings.SystemSettings() | ||
|
||
s.nonbonded_cutoff = '1.1 nm' | ||
|
||
assert s.nonbonded_cutoff == 1.1 * unit.nanometer | ||
|
||
def test_solvation_settings(self): | ||
s = omm_settings.SolvationSettings() | ||
|
||
s.solvent_padding = '1.1 nm' | ||
|
||
assert s.solvent_padding == 1.1 * unit.nanometer | ||
|
||
def test_alchemical_sampler_settings(self): | ||
# todo: online_analysis_target_error is in kT, how to pass this as string? | ||
pass | ||
|
||
def test_integator_settings(self): | ||
s = omm_settings.IntegratorSettings() | ||
|
||
s.timestep = '3 fs' | ||
|
||
assert s.timestep == 3.0 * unit.femtosecond | ||
|
||
s.collision_rate = '1.1 / ps' | ||
|
||
assert s.collision_rate == 1.1 / unit.picosecond | ||
|
||
# todo: nsteps, barostat frequency require IntQuantity | ||
|
||
def test_simulation_settings(self): | ||
s = omm_settings.SimulationSettings( | ||
equilibration_length=2.0 * unit.nanosecond, | ||
production_length=5.0 * unit.nanosecond, | ||
) | ||
|
||
s.equilibration_length = '2.5 ns' | ||
s.production_length = '10 ns' | ||
|
||
assert s.equilibration_length == 2.5 * unit.nanosecond | ||
assert s.production_length == 10.0 * unit.nanosecond | ||
|
||
# todo: checkpoint_interval IntQuantity | ||
|
||
|
||
class TestEquilRFESettingsFromString: | ||
def test_alchemical_settings(self): | ||
s = equil_rfe_settings.AlchemicalSettings() | ||
|
||
s.explicit_charge_correction_cutoff = '0.85 nm' | ||
|
||
assert s.explicit_charge_correction_cutoff == 0.85 * unit.nanometer | ||
|
||
|