Implements Refactoring in Player Class and Initial Working Version

This commit is contained in:
2023-06-02 20:20:38 -03:00
parent b440a0f05d
commit 33612f2d7b
21 changed files with 1193 additions and 983 deletions

View File

@@ -6,7 +6,7 @@ from typing import List
@dataclass
class DiceDTO(Dataclass):
class DiceConfig(Dataclass):
"""
Data Transfer Object for the Dice configuration.
"""
@@ -53,4 +53,4 @@ class DiceDTO(Dataclass):
@classmethod
def from_dict(cls, param: dict):
return from_dict(DiceDTO, param)
return from_dict(DiceConfig, param)

View File

@@ -11,10 +11,11 @@ class GaussianDTO(Dataclass):
"""
level: str
qmprog: str
keywords: str
chgmult = [0, 1]
pop: str = 'chelpg'
chg_tol: float = 0.01
keywords: str = None
def __post_init__(self):
if self.qmprog not in ("g03", "g09", "g16"):

View File

@@ -0,0 +1,47 @@
from diceplayer.shared.utils.dataclass_protocol import Dataclass
from diceplayer.shared.config.gaussian_config import GaussianDTO
from diceplayer.shared.config.dice_config import DiceConfig
from dataclasses import dataclass
from dacite import from_dict
@dataclass
class PlayerConfig(Dataclass):
"""
Data Transfer Object for the player configuration.
"""
opt: bool
maxcyc: int
nprocs: int
ncores: int
dice: DiceConfig
gaussian: GaussianDTO
mem: int = None
switchcyc: int = 3
qmprog: str = 'g16'
altsteps: int = 20000
simulation_dir = 'simfiles'
def __post_init__(self):
MIN_STEP = 20000
# altsteps value is always the nearest multiple of 1000
self.altsteps = round(max(MIN_STEP, self.altsteps) / 1000) * 1000
@classmethod
def from_dict(cls, param: dict):
if param['dice'] is None:
raise ValueError(
"Error: 'dice' keyword not specified in config file."
)
param['dice'] = DiceConfig.from_dict(param['dice'])
if param['gaussian'] is None:
raise ValueError(
"Error: 'gaussian' keyword not specified in config file."
)
param['gaussian'] = GaussianDTO.from_dict(param['gaussian'])
return from_dict(PlayerConfig, param)

View File

@@ -1,28 +0,0 @@
from diceplayer.shared.utils.dataclass_protocol import Dataclass
from dataclasses import dataclass
from dacite import from_dict
@dataclass
class PlayerDTO(Dataclass):
"""
Data Transfer Object for the player configuration.
"""
opt: bool
maxcyc: int
nprocs: int
ncores: int
qmprog: str = 'g16'
altsteps: int = 20000
simulation_dir = 'simfiles'
def __post_init__(self):
MIN_STEP = 20000
# altsteps value is always the nearest multiple of 1000
self.altsteps = round(max(MIN_STEP, self.altsteps) / 1000) * 1000
@classmethod
def from_dict(cls, param: dict):
return from_dict(PlayerDTO, param)

View File

@@ -1,22 +0,0 @@
from diceplayer.shared.environment.molecule import Molecule
from diceplayer.shared.config.player_dto import PlayerDTO
from dataclasses import dataclass
from typing import List
@dataclass
class StepDTO:
"""
Data Transfer Object for the step configuration.
"""
ncores: int
nprocs: int
simulation_dir: str
altsteps: int
nmol: List[int] = None
molecule: List[Molecule] = None
charges: List[float] = None
position: List[float] = None