diff --git a/t3/schema.py b/t3/schema.py index d2d9c646..89879602 100644 --- a/t3/schema.py +++ b/t3/schema.py @@ -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 @@ -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""" diff --git a/t3/utils/writer.py b/t3/utils/writer.py index c5e6573c..11c8bd30 100644 --- a/t3/utils/writer.py +++ b/t3/utils/writer.py @@ -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( @@ -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':