ReactionMechanismGenerator / RMG-Py

Python version of the amazing Reaction Mechanism Generator (RMG).
http://reactionmechanismgenerator.github.io/RMG-Py/
Other
381 stars 226 forks source link

AttributeError: 'rmgpy.thermo.nasa.NASA' object has no attribute 'is_all_zeros' #2115

Closed shikharnigam8 closed 3 years ago

shikharnigam8 commented 3 years ago

Bug Description

I am trying to simulate the mechanism for chlorinated carbon compounds. However, I encountered the following error during RMG simulation "AttributeError: 'rmgpy.thermo.nasa.NASA' object has no attribute 'is_all_zeros'"

How To Reproduce

The error message is attached.

Expected Behavior

No error in the simulation. All thermo data is correct.

Installation Information

Describe your installation method and system information.

Additional Context

For reaction generation 1 process is used.
Generating thermo for new species...
Traceback (most recent call last):
  File "/home/dr/RMG/RMG-Py/rmg.py", line 118, in <module>
    main()
  File "/home/dr/RMG/RMG-Py/rmg.py", line 112, in main
    rmg.execute(**kwargs)
  File "/home/dr/RMG/RMG-Py/rmgpy/rmg/main.py", line 922, in execute
    trimolecular_react=self.trimolecular_react)
  File "/home/dr/RMG/RMG-Py/rmgpy/rmg/model.py", line 614, in enlarge
    self.apply_thermo_to_species(procnum)
  File "/home/dr/RMG/RMG-Py/rmgpy/rmg/model.py", line 824, in apply_thermo_to_species
    self.generate_thermo(spc, rename=True)
  File "/home/dr/RMG/RMG-Py/rmgpy/rmg/model.py", line 831, in generate_thermo
    submit(spc, self.solvent_name)
  File "/home/dr/RMG/RMG-Py/rmgpy/thermo/thermoengine.py", line 175, in submit
    spc.thermo = evaluator(spc, solvent_name=solvent_name)
  File "/home/dr/RMG/RMG-Py/rmgpy/thermo/thermoengine.py", line 160, in evaluator
    thermo = generate_thermo_data(spc, solvent_name=solvent_name)
  File "/home/dr/RMG/RMG-Py/rmgpy/thermo/thermoengine.py", line 125, in generate_thermo_data
    thermo0 = thermodb.get_thermo_data(spc)
  File "/home/dr/RMG/RMG-Py/rmgpy/data/thermo.py", line 1311, in get_thermo_data
    tdata = self.estimate_radical_thermo_via_hbi(molecule, self.get_thermo_data_from_libraries)
  File "/home/dr/RMG/RMG-Py/rmgpy/data/thermo.py", line 1948, in estimate_radical_thermo_via_hbi
    self._add_group_thermo_data(thermo_data, self.groups['radical'], saturated_struct, {'*': atom})
  File "/home/dr/RMG/RMG-Py/rmgpy/data/thermo.py", line 2450, in _add_group_thermo_data
    if data.is_all_zeros():
AttributeError: 'rmgpy.thermo.nasa.NASA' object has no attribute 'is_all_zeros'
rwest commented 3 years ago

Could you confirm which version of RMG-Py and the database you're using? Looking at my versions, I can't see how to reproduce that error. For one thing, "RMG-Py/rmgpy/data/thermo.py", line 2450 is something else. And Perhaps your radical database is also different? (containing a NASA polynomial entry?)

shikharnigam8 commented 3 years ago

@rwest I am using latest version of RMG and RMG-database. However, I have slightly modified the radical.py file to incorporate Si and C atoms with four unpaired electrons. I have also modified the chlorinated_hydrocarbon thermo library with more accurate data. I have attached the input file and other required database to reproduce the same error. database.zip

mjohnson541 commented 3 years ago

Essentially what's happening is that a NASA object (that doesn't have the is_all_zeros function) is getting pulled out of the groups for "Si(Q)" instead of a ThermoData object (that has the is_all_zeros function) all of the group data objects have to be ThermoData objects.

alongd commented 3 years ago

@shikharnigam8, following @mjohnson541's insight, if you added thermo for Si(Q), make sure it looks like a ThemoData object rather than a NASA object. Try adding Si(Q) to a thermo library, and make sure that allowed=['input species','seed mechanisms','reaction libraries'] is specified under the species constraints block of the input file.

rwest commented 3 years ago

In your posted radical.py you have this

entry(
    index = 2093,
    label = "Si(Q)",
    group =
"""
1 Si u4 p0 c0
""",
    thermo = NASA(
        polynomials = [
            NASAPolynomial(coeffs=[0.25003271E+01, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00 ,0.00000000E+00,0.53382660E+05 ,0.38328969E+01], Tmin = (298,'K'), Tmax=(1500,'K')),
            NASAPolynomial(coeffs=[0.25003271E+01, 0.00000000E+00, 0.00000000E+00,0.00000000E+00 ,0.00000000E+00 ,0.53382656E+05, 0.38328967E+01], Tmin = (1500,'K'), Tmax=(3000,'K')),
        ],
        Tmin = (298,'K'),
        Tmax = (3000,'K')
    ),
    shortDesc = u"""""",
    longDesc =
u"""
H298: ATcT version 1.110
level of theory energy: CCSD(T)F12A/cc-pVQZ-F12//CCSD(T)/cc-pVQZ
level of theory frequency: B3LYP/6-311++g(d,p)//B3LYP/6-311++g(d,p)
""",
)

You could convert it as Alon suggests, like this:

In [1]: from rmgpy.thermo import *

In [2]:     thermo = NASA(
    ...:         polynomials = [
    ...:             NASAPolynomial(coeffs=[0.25003271E+01, 0.00000000E+00, 0.00000000E+00, 0.00000000E+00 ,0.0000
    ...: 0000E+00,0.53382660E+05 ,0.38328969E+01], Tmin = (298,'K'), Tmax=(1500,'K')),
    ...: ^I^I^INASAPolynomial(coeffs=[0.25003271E+01, 0.00000000E+00, 0.00000000E+00,0.00000000E+00 ,0.00000000E+0
    ...: 0 ,0.53382656E+05, 0.38328967E+01], Tmin = (1500,'K'), Tmax=(3000,'K')),
    ...:         ],
    ...:         Tmin = (298,'K'),
    ...:         Tmax = (3000,'K')
    ...:     )

In [3]: thermo.to_thermo_data()
Out[3]: ThermoData(Tdata=([300,400,500,600,800,1000,1500],'K'), 
            Cpdata=([20.7889,20.7889,20.7889,20.7889,20.7889,20.7889,20.7889],'J/(mol*K)'), 
            H298=(450.044,'kJ/mol'), 
            S298=(150.305,'J/(mol*K)'))

In doing this conversion I notice that you end up with H298=(450.044,'kJ/mol'), S298=(150.305,'J/(mol*K)') which is close to the NASA webbook values making me think the data is for an Si atom itself. The radical.py file contains radical corrections that are applied using the Hydrogen Bond Increment approach. If you want to just include the thermochemistry of atomic Si directly, put it in a thermo library, not this radical.py file. To see what I mean, once you've got this to load correctly, evaluate the thermochemistry of an Si atom. It will probably come out strange. Putting something here would be helpful, to stop RMG crashing if it comes across Si not in a library, but you'll need to derive the necessary correction.

Also, I strongly encourage you to update the metadata such as the longDesc to keep track of where this came from, even if you think nobody but your future self will ever see it. It seems you copied and pasted this from another entry without changing it. (I guess this because it says "H298: ATcT version 1.110" and I think Si isn't in the ATcT)

shikharnigam8 commented 3 years ago

Thank you @rwest. It is working fine.