VlachosGroup / openmkm

Opensource software to model heterogeneous catalytic reactions. Based on Cantera
MIT License
14 stars 12 forks source link

Updated ctml_writer to clear global variables #9

Closed jonlym closed 4 years ago

jonlym commented 4 years ago

Hi Bharat,

When pMuTT writes OpenMKM's XML files, it uses ctml_writer.convert as shown by the following lines.

However, if a script is written to write multiple XML files, the following error occurs:

***** Error parsing input file *****

CH3CH2OH + PT(S) <=> CH3CH2OH(S) + PT(B)
A surface reaction may contain at most one surface phase.

Traceback (most recent call last):
  File "c:/Users/jonat/Dropbox (Personal)/UDel Documents (Dropbox)/UDel Research/C2H6_Heatmap/ethane_ODH_heatmap/gen_omkm_files.py", line 93, in <module>
    write_xml=True)
  File "c:\users\jonat\dropbox\udel documents (dropbox)\udel research\github\pmutt_development\pmutt\io\omkm.py", line 168, in write_cti
    convert(filename=filename, outName=xml_filename)
  File "c:\users\jonat\dropbox\udel documents (dropbox)\udel research\github\pmutt_development\pmutt\io\ctml_writer.py", line 3199, in convert
    write(outName)
  File "c:\users\jonat\dropbox\udel documents (dropbox)\udel research\github\pmutt_development\pmutt\io\ctml_writer.py", line 376, in write
    rx.build(r)
  File "c:\users\jonat\dropbox\udel documents (dropbox)\udel research\github\pmutt_development\pmutt\io\ctml_writer.py", line 1299, in build
    'one surface phase.')
pmutt.io.ctml_writer.CTI_Error: CH3CH2OH + PT(S) <=> CH3CH2OH(S) + PT(B)
A surface reaction may contain at most one surface phase.

I learned this was due to ctml_writer being imported once and global variables were not cleared when convert is called. To fix this, I suggest explicitly clearing the global variables whenever convert is called (see edits in pull request commit).

mbkumar commented 4 years ago

Thanks Jon for the fix.

jonlym commented 4 years ago

Hi Bharat, was this fix merged into the master branch? These changes aren't present in commit e1b750d