Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdep fixes #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions t3/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,15 @@ def check_model(cls, value):
@validator('pdep')
def check_pdep_only_if_gas_phase(cls, value, values):
"""RMG.pdep validator"""
if value is not None and values['reactors'] is not None:
reactor_types = set([reactor['type'] for reactor in values['reactors']])
if value is not None and 'reactors' in values and values['reactors'] is not None:
reactor_types = set([reactor.type for reactor in values['reactors']])
if value is not None and not any(['gas' in reactor for reactor in reactor_types]):
raise ValueError(f'A pdep section can only be specified for gas phase reactors, got: {reactor_types}')
return value

@root_validator(pre=True)
def check_species_and_reactors(cls, values):
"""Check species and reactors"""
if 'reactors' in values and values['reactors'] is not None \
and 'species' in values and values['species'] is not None:
# check species attributes (balance, solvation) make sense
Expand Down Expand Up @@ -584,6 +585,19 @@ def check_qm(cls, value):
"""InputBase.qm validator"""
return value or dict()

@validator('rmg', always=True)
def check_rmg(cls, value):
"""InputBase.rmg validator"""
# Check the presence of at least one inert gas if PDep is requested
if value.species and value.pdep and value.pdep.method:
for species in value.species:
if not species.reactive:
break
else:
raise ValueError(f'Pressure Dependence calculations require at least one inert (non-reacting) '
f'species for the bath gas.')
return value

@root_validator(pre=True)
def validate_rmg_t3(cls, values):
"""InputBase.validate_rmg_t3"""
Expand Down
5 changes: 3 additions & 2 deletions t3/utils/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def write_rmg_input_file(rmg: dict,
)

# pressureDependence
pdep = rmg['pdep']
pdep = rmg['pdep'].copy()
if pdep is not None:
pdep_template = """
pressureDependence(
Expand All @@ -246,9 +246,10 @@ def write_rmg_input_file(rmg: dict,
maximumAtoms=${max_atoms},
)
"""
pdep['method'] = METHOD_MAP[pdep['method']]
pdep['method'] = pdep['method'] if pdep['method'] in list(METHOD_MAP.values()) else METHOD_MAP[pdep['method']]
pdep['T_min'], pdep['T_max'], pdep['T_count'] = pdep['T']
pdep['P_min'], pdep['P_max'], pdep['P_count'] = pdep['P']
pdep['T_count'], pdep['P_count'] = int(pdep['T_count']), int(pdep['P_count'])
del pdep['T']
del pdep['P']
if pdep['interpolation'] == 'PDepArrhenius':
Expand Down