From 29d61521f233cd1840b6773d8c6c0633a2f3cf3b Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Wed, 26 Aug 2020 13:50:53 -0400 Subject: [PATCH 1/4] BugFix: In schema check_pdep_only_if_gas_phase(), reactor is an object not a dict. Note that it is a dict under `check_species_and_reactors()` which is a root_validator, on line 503. Cofusing, but crashes otherwise --- t3/schema.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t3/schema.py b/t3/schema.py index d2d9c646..7b9fd9cb 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 From c737c0bf37a1eacef3d6032276f980b9d1fc8959 Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Mon, 24 Aug 2020 11:13:57 -0400 Subject: [PATCH 2/4] Added a validator to schema checking for an inert species when running RMG with PDep --- t3/schema.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/t3/schema.py b/t3/schema.py index 7b9fd9cb..89879602 100644 --- a/t3/schema.py +++ b/t3/schema.py @@ -585,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""" From bd3e627b83afab72d497b7d66f7a8d65d24072a2 Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Mon, 24 Aug 2020 11:14:29 -0400 Subject: [PATCH 3/4] BugFix: T and P increments in RMG's PDep block must be integers --- t3/utils/writer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/t3/utils/writer.py b/t3/utils/writer.py index c5e6573c..f8e2a75e 100644 --- a/t3/utils/writer.py +++ b/t3/utils/writer.py @@ -249,6 +249,7 @@ def write_rmg_input_file(rmg: dict, pdep['method'] = 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': From 2382664578e0883990c1ac019e1de1174ae9be94 Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Mon, 24 Aug 2020 13:04:34 -0400 Subject: [PATCH 4/4] BugFix: Check the PDep method before using the METHOD_MAP dict The first iteration will assign the value from this dictionary to pdep['method', the T3 will crash at the second iteration, since the corresponding value is not a key in this dict. Here we first check whether the value is already correct, if not we use the mapping dict. --- t3/utils/writer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t3/utils/writer.py b/t3/utils/writer.py index f8e2a75e..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,7 +246,7 @@ 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'])