From a3c20e6cf2e164a3756b2da0a06b28c1272e5993 Mon Sep 17 00:00:00 2001 From: Nick Wogan Date: Wed, 24 Apr 2024 08:18:31 -0700 Subject: [PATCH] Added 1 bar reference pressure to cantera conversion --- photochem/utils/_convert_cantera.py | 5 +++-- photochem/utils/_format.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/photochem/utils/_convert_cantera.py b/photochem/utils/_convert_cantera.py index 9a6c14e..6da838f 100644 --- a/photochem/utils/_convert_cantera.py +++ b/photochem/utils/_convert_cantera.py @@ -64,7 +64,8 @@ def photochem2cantera_main(data): # Cantera can't handle > 2 temperature ranges for thermodynamic data for i in range(len(data['species'])): - if len(data['species'][i]['thermo']['temperature-ranges']) > 3: + data['species'][i]['thermo']['reference-pressure'] = '1.0e6' # dynes/cm^2 + if len(data['species'][i]['thermo']['temperature-ranges']) > 3 and data['species'][i]['thermo']['model'] == 'Shomate': data['species'][i]['thermo']['temperature-ranges'] = data['species'][i]['thermo']['temperature-ranges'][:3] data['species'][i]['thermo']['data'] = data['species'][i]['thermo']['data'][:2] @@ -76,7 +77,7 @@ def photochem2cantera_main(data): phases[0]["species"] = blockseqtrue(species) phases[0]["kinetics"] = "gas" phases[0]["reactions"] = "all" - phases[0]["state"] = flowmap({"T": 300.0,"P":1.0e5}) + phases[0]["state"] = flowmap({"T": 300.0,"P": 1.0e5}) data = FormatReactions_main(data) data['units'] = units diff --git a/photochem/utils/_format.py b/photochem/utils/_format.py index 8a236d9..c4a688c 100644 --- a/photochem/utils/_format.py +++ b/photochem/utils/_format.py @@ -73,11 +73,12 @@ def FormatReactions_main(data): data['species'][i]['composition'] = flowmap(data['species'][i]['composition']) if 'thermo' in data['species'][i].keys(): - order = ['model','temperature-ranges','data','note'] + order = ['model', 'reference-pressure','temperature-ranges','data'] copy = data['species'][i]['thermo'].copy() data['species'][i]['thermo'].clear() - for key in copy: - data['species'][i]['thermo'][key] = copy[key] + for key in order: + if key in copy.keys(): + data['species'][i]['thermo'][key] = copy[key] data['species'][i]['thermo']['temperature-ranges'] = blockseqtrue(data['species'][i]['thermo']['temperature-ranges'])