Skip to content

Commit 1d198f9

Browse files
authored
Merge pull request #106 from tsherwen/dev
Minor updates for automated KPP tagging
2 parents 0fd420c + a12dbeb commit 1d198f9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

AC_tools/KPP.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,11 +1616,13 @@ def calc_fam_loss_by_route(wd=None, fam='LOx', ref_spec='O3',
16161616
if rtn_by_fam:
16171617
return dfFam
16181618

1619+
16191620
def add_tags4strs2mech(rxn_dicts, tagged_rxns={},
16201621
search_strs=None, counter=0,
16211622
search_reactants=False,
16221623
search_products=False,
1623-
tag_prefix='T'):
1624+
tag_prefix='T',
1625+
debug=False):
16241626
"""
16251627
Tag reactions in provided string found in KPP reaction string
16261628
@@ -1649,7 +1651,7 @@ def add_tags4strs2mech(rxn_dicts, tagged_rxns={},
16491651
re5 = '(\\s+)' # White Space 2
16501652
rg = re.compile(re1+re2+re3+re4, re.IGNORECASE | re.DOTALL)
16511653
# ( Or just all reactions that contain a species of interest )
1652-
current_tag = '{}{}'.format(tag_prefix, counter)
1654+
current_tag = '{}{:0>3}'.format(tag_prefix, counter)
16531655
for search_str in search_strs:
16541656
for key_ in list(rxn_dicts.keys()):
16551657
df = rxn_dicts[key_]
@@ -1667,6 +1669,8 @@ def add_tags4strs2mech(rxn_dicts, tagged_rxns={},
16671669
if search_str in str2search4search_str:
16681670
# Update the counter (NOTE: counter starts from 1)
16691671
counter += 1
1672+
if debug:
1673+
print( counter, current_tag )
16701674
# Check if rxn already tagged, if so just use that tag.
16711675
m = rg.search(rxn_str)
16721676
if m:

scripts/KPP_mk_tagged_GC_Mechanism.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ def main(folder=None, print_formatted_KPP_file=True, GC_version=None,
155155
# Add tags for halogen families
156156
rxn_dicts, tagged_rxns = AC.add_tags4strs2mech(rxn_dicts, counter=counter,
157157
search_strs=search_strs,
158-
tagged_rxns=tagged_rxns, )
158+
tagged_rxns=tagged_rxns,
159+
# debug=debug
160+
)
159161
counter = max(tagged_rxns.keys())
160162
current_tag = '{}{}'.format(tag_prefix, counter)
161163

@@ -201,7 +203,6 @@ def main(folder=None, print_formatted_KPP_file=True, GC_version=None,
201203
counter = max(tagged_rxns.keys())
202204
current_tag = '{}{}'.format(tag_prefix, counter)
203205

204-
205206
# - Add the species to the species_df
206207
# Number of reactions tagged
207208
alltags = [tagged_rxns[i]['tag'] for i in list(tagged_rxns.keys())]

0 commit comments

Comments
 (0)