Coverage for tests/test_npt_atomic_code.py: 95%
21 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
1def test_npt_atomic() -> None:
2 import numpy as np
3 import gamdpy as gp
5 from object_lib import configuration_SC as configuration
7 # Test init
8 itg = gp.integrators.NPT_Atomic(temperature=2.0, tau=0.4, pressure=4.7, tau_p=20, dt=0.001)
9 assert itg.temperature==2.0 , "Integrator NPT_Atomic: error with temperature input"
10 assert itg.tau==0.4 , "Integrator NPT_Atomic: error with temperature relax time tau input"
11 assert itg.pressure==4.7 , "Integrator NPT_Atomic: error with pressure input"
12 assert itg.tau_p==20 , "Integrator NPT_Atomic: error with pressure relax time tau_p input"
13 assert itg.dt==0.001 , "Integrator NPT_Atomic: error with timestep dt input"
14 # Check initialization of barostat and thermostat state
15 assert np.all(itg.thermostat_state == np.array([0,0])), "Integrator NPT_Atomic: error with thermostat_state initialization"
16 assert np.all(itg.barostat_state == np.array([0,0,0])), "Integrator NPT_Atomic: error with barostat_state initialization"
17 assert isinstance(itg.get_params(configuration, ()), tuple), "Integrator NPT_Atomic: error with get_params"
19 # Test get_kernel
20 itg.get_kernel(configuration=configuration,
21 compute_plan = gp.get_default_compute_plan(configuration),
22 compute_flags = gp.get_default_compute_flags(),
23 interactions_kernel = None,
24 verbose=True)
26 # Test init for callable temperatures and pressures
27 temperature = gp.make_function_ramp(2.0, 100, 3.0, 400)
28 pressure = gp.make_function_ramp(4.0, 100, 5.0, 400)
29 itg = gp.integrators.NPT_Atomic(temperature=temperature, tau=0.4, pressure=pressure, tau_p=20, dt=0.001)
31 # Test get_kernel
32 itg.get_kernel(configuration=configuration,
33 compute_plan = gp.get_default_compute_plan(configuration),
34 compute_flags = gp.get_default_compute_flags(),
35 interactions_kernel = None,
36 verbose=True)
37 return
39if __name__ == '__main__':
40 test_npt_atomic()