feat: add dice input generation and player routines for NVT/NPT simulations
This commit is contained in:
@@ -1,56 +1,62 @@
|
||||
from diceplayer.config.dice_config import DiceConfig
|
||||
from diceplayer.config.gaussian_config import GaussianConfig
|
||||
from diceplayer.config.player_config import PlayerConfig
|
||||
from diceplayer.config.player_config import PlayerConfig, RoutineType
|
||||
|
||||
import pytest
|
||||
|
||||
from typing import Any
|
||||
|
||||
def get_config_dict():
|
||||
return {
|
||||
"opt": True,
|
||||
"mem": 12,
|
||||
"maxcyc": 100,
|
||||
"nprocs": 4,
|
||||
"ncores": 4,
|
||||
"dice": {
|
||||
|
||||
class TestPlayerConfig:
|
||||
@pytest.fixture
|
||||
def dice_payload(self) -> dict[str, Any]:
|
||||
return {
|
||||
"ljname": "test",
|
||||
"outname": "test",
|
||||
"dens": 1.0,
|
||||
"nmol": [1],
|
||||
"nstep": [1, 1],
|
||||
},
|
||||
"gaussian": {
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def gaussian_payload(self) -> dict[str, Any]:
|
||||
return {
|
||||
"level": "test",
|
||||
"qmprog": "g16",
|
||||
"keywords": "test",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class TestPlayerConfig:
|
||||
@pytest.fixture
|
||||
def dice_config(self):
|
||||
return DiceConfig(
|
||||
ljname="test",
|
||||
outname="test",
|
||||
dens=1.0,
|
||||
nmol=[1],
|
||||
nstep=[1, 1],
|
||||
)
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def gaussian_config(self):
|
||||
return GaussianConfig(
|
||||
level="test",
|
||||
qmprog="g16",
|
||||
keywords="test",
|
||||
)
|
||||
def player_payload(
|
||||
self, dice_payload: dict[str, Any], gaussian_payload: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"type": "both",
|
||||
"mem": 12,
|
||||
"max_cyc": 100,
|
||||
"switch_cyc": 50,
|
||||
"nprocs": 4,
|
||||
"ncores": 4,
|
||||
"dice": dice_payload,
|
||||
"gaussian": gaussian_payload,
|
||||
}
|
||||
|
||||
def test_class_instantiation(self, dice_config, gaussian_config):
|
||||
@pytest.fixture
|
||||
def dice_config(self, dice_payload: dict[str, Any]) -> DiceConfig:
|
||||
return DiceConfig.model_validate(dice_payload)
|
||||
|
||||
@pytest.fixture
|
||||
def gaussian_config(self, gaussian_payload: dict[str, Any]):
|
||||
return GaussianConfig.model_validate(gaussian_payload)
|
||||
|
||||
def test_class_instantiation(
|
||||
self, dice_config: DiceConfig, gaussian_config: GaussianConfig
|
||||
):
|
||||
player_dto = PlayerConfig(
|
||||
opt=True,
|
||||
type=RoutineType.BOTH,
|
||||
mem=12,
|
||||
maxcyc=100,
|
||||
max_cyc=100,
|
||||
switch_cyc=50,
|
||||
nprocs=4,
|
||||
ncores=4,
|
||||
dice=dice_config,
|
||||
@@ -61,22 +67,25 @@ class TestPlayerConfig:
|
||||
assert isinstance(player_dto.dice, DiceConfig)
|
||||
assert isinstance(player_dto.gaussian, GaussianConfig)
|
||||
|
||||
def test_min_altsteps(self, dice_config, gaussian_config):
|
||||
def test_min_altsteps(
|
||||
self, dice_config: DiceConfig, gaussian_config: GaussianConfig
|
||||
):
|
||||
player_dto = PlayerConfig(
|
||||
opt=True,
|
||||
type=RoutineType.BOTH,
|
||||
mem=12,
|
||||
maxcyc=100,
|
||||
max_cyc=100,
|
||||
switch_cyc=50,
|
||||
nprocs=4,
|
||||
ncores=4,
|
||||
altsteps=100,
|
||||
altsteps=0,
|
||||
dice=dice_config,
|
||||
gaussian=gaussian_config,
|
||||
)
|
||||
|
||||
assert player_dto.altsteps == 20000
|
||||
|
||||
def test_from_dict(self):
|
||||
player_dto = PlayerConfig.model_validate(get_config_dict())
|
||||
def test_from_dict(self, player_payload: dict[str, Any]):
|
||||
player_dto = PlayerConfig.model_validate(player_payload)
|
||||
|
||||
assert isinstance(player_dto, PlayerConfig)
|
||||
assert isinstance(player_dto.dice, DiceConfig)
|
||||
|
||||
Reference in New Issue
Block a user