feat: add dice input generation and player routines for NVT/NPT simulations
This commit is contained in:
0
tests/dice/__init__.py
Normal file
0
tests/dice/__init__.py
Normal file
65
tests/dice/test_dice_input.py
Normal file
65
tests/dice/test_dice_input.py
Normal file
@@ -0,0 +1,65 @@
|
||||
from pathlib import Path
|
||||
|
||||
from diceplayer.config import PlayerConfig
|
||||
from diceplayer.dice.dice_input import NVTEqConfig, NVTTerConfig, NPTTerConfig, NPTEqConfig
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestDiceInput:
|
||||
@pytest.fixture
|
||||
def player_config(self) -> PlayerConfig:
|
||||
return PlayerConfig.model_validate(
|
||||
{
|
||||
"type": "both",
|
||||
"mem": 12,
|
||||
"max_cyc": 100,
|
||||
"switch_cyc": 50,
|
||||
"nprocs": 4,
|
||||
"ncores": 4,
|
||||
"dice": {
|
||||
"ljname": "test",
|
||||
"outname": "test",
|
||||
"dens": 1.0,
|
||||
"nmol": [1],
|
||||
"nstep": [1, 1],
|
||||
},
|
||||
"gaussian": {
|
||||
"level": "test",
|
||||
"qmprog": "g16",
|
||||
"keywords": "test",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
def test_generate_nvt_ter_input(self, player_config: PlayerConfig):
|
||||
dice_input = NVTTerConfig.from_config(player_config)
|
||||
|
||||
assert isinstance(dice_input, NVTTerConfig)
|
||||
|
||||
def test_generate_nvt_eq_input(self, player_config: PlayerConfig):
|
||||
dice_input = NVTEqConfig.from_config(player_config)
|
||||
|
||||
assert isinstance(dice_input, NVTEqConfig)
|
||||
|
||||
def test_generate_npt_ter_input(self, player_config: PlayerConfig):
|
||||
dice_input = NPTTerConfig.from_config(player_config)
|
||||
|
||||
assert isinstance(dice_input, NPTTerConfig)
|
||||
|
||||
def test_generate_npt_eq_input(self, player_config: PlayerConfig):
|
||||
dice_input = NPTEqConfig.from_config(player_config)
|
||||
|
||||
assert isinstance(dice_input, NPTEqConfig)
|
||||
|
||||
def test_write_dice_config(self, player_config: PlayerConfig, tmp_path: Path):
|
||||
dice_input = NVTTerConfig.from_config(player_config)
|
||||
|
||||
output_file = tmp_path / "nvt_ter.inp"
|
||||
|
||||
with open(output_file, "w") as file:
|
||||
dice_input.write_dice_config(file)
|
||||
|
||||
assert output_file.exists()
|
||||
|
||||
print(output_file.read_text())
|
||||
Reference in New Issue
Block a user