Closed Tingchenlee closed 3 years ago
This issue is probably addressed by: ReactionMechanismGenerator/RMG-database#445
Made a PR here to the RMG database to correct this issue
I think that PR addresses #2038 not this one.
After trying https://github.com/ReactionMechanismGenerator/RMG-database/pull/445, I received the error messages:
Error: Could not update atomtypes for this molecule:
multiplicity 1
1 O u0 p2 c0 {2,S} {4,S}
2 N u1 p0 c0 {1,S} {3,T}
3 N u2 p0 c0 {2,T}
4 H u0 p0 c0 {1,S}
Error: Error attempting to get thermo for species ON(N=[Pt])[Pt](43) with structure
1 O u0 p2 c0 {2,S} {4,S}
2 N u0 p1 c0 {1,S} {3,S} {5,S}
3 N u0 p1 c0 {2,S} {6,D}
4 H u0 p0 c0 {1,S}
5 X u0 p0 c0 {2,S}
6 X u0 p0 c0 {3,D}
Traceback (most recent call last):
File "/Users/lee.ting/Code/RMG-Py/rmg.py", line 118, in <module>
main()
File "/Users/lee.ting/Code/RMG-Py/rmg.py", line 112, in main
rmg.execute(**kwargs)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/main.py", line 922, in execute
trimolecular_react=self.trimolecular_react)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/model.py", line 614, in enlarge
self.apply_thermo_to_species(procnum)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/model.py", line 824, in apply_thermo_to_species
self.generate_thermo(spc, rename=True)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/model.py", line 831, in generate_thermo
submit(spc, self.solvent_name)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/thermo/thermoengine.py", line 175, in submit
spc.thermo = evaluator(spc, solvent_name=solvent_name)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/thermo/thermoengine.py", line 160, in evaluator
thermo = generate_thermo_data(spc, solvent_name=solvent_name)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/thermo/thermoengine.py", line 125, in generate_thermo_data
thermo0 = thermodb.get_thermo_data(spc)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/data/thermo.py", line 1223, in get_thermo_data
thermo0 = self.get_thermo_data_for_surface_species(species)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/data/thermo.py", line 1546, in get_thermo_data_for_surface_species
dummy_molecule.update()
File "rmgpy/molecule/molecule.py", line 1130, in rmgpy.molecule.molecule.Molecule.update
File "rmgpy/molecule/molecule.py", line 1355, in rmgpy.molecule.molecule.Molecule.update_atomtypes
File "rmgpy/molecule/molecule.py", line 1350, in rmgpy.molecule.molecule.Molecule.update_atomtypes
File "rmgpy/molecule/atomtype.py", line 729, in rmgpy.molecule.atomtype.get_atomtype
File "rmgpy/molecule/atomtype.py", line 757, in rmgpy.molecule.atomtype.get_atomtype
rmgpy.exceptions.AtomTypeError: Unable to determine atom type for atom N., which has 1 single bonds, 0 double bonds (0 to O, 0 to S, 0 others), 1 triple bonds, 0 quadruple bonds, 0 benzene bonds, 0 lone pairs, and +0 charge.
I think it's trying to get the thermo for the bidentate
Error: Error attempting to get thermo for species ON(N=[Pt])[Pt](43) with structure
1 O u0 p2 c0 {2,S} {4,S}
2 N u0 p1 c0 {1,S} {3,S} {5,S}
3 N u0 p1 c0 {2,S} {6,D}
4 H u0 p0 c0 {1,S}
5 X u0 p0 c0 {2,S}
6 X u0 p0 c0 {3,D}
but to do so creates the gas phase counterpart, and it comes up with
multiplicity 1
1 O u0 p2 c0 {2,S} {4,S}
2 N u1 p0 c0 {1,S} {3,T}
3 N u2 p0 c0 {2,T}
4 H u0 p0 c0 {1,S}
which as @mazeau pointed out, has two unpaired electrons on atom 3. Maybe the thermo estimation of bidentate adsorption things is the problem? (But the title of this issue is Surface_Bidentate_Dissociation )
Should we discuss this in other issues? I encountered another problem species when I was testing my new library(metal=Ru):
Error: Could not update atomtypes for this molecule:
multiplicity 1
1 N u1 p0 c0 {2,S} {3,T}
2 N u0 p1 c0 {1,S} {4,D}
3 N u2 p0 c0 {1,T}
4 N u0 p1 c0 {2,D} {5,S}
5 H u0 p0 c0 {4,S}
Error: Error attempting to get thermo for species N=NN(N=[Pt])[Pt](43) with structure
1 N u0 p1 c0 {2,S} {3,S} {6,S}
2 N u0 p1 c0 {1,S} {4,D}
3 N u0 p1 c0 {1,S} {7,D}
4 N u0 p1 c0 {2,D} {5,S}
5 H u0 p0 c0 {4,S}
6 X u0 p0 c0 {1,S}
7 X u0 p0 c0 {3,D}
Traceback (most recent call last):
File "/Users/lee.ting/Code/RMG-Py/rmg.py", line 118, in <module>
main()
File "/Users/lee.ting/Code/RMG-Py/rmg.py", line 112, in main
rmg.execute(**kwargs)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/main.py", line 922, in execute
trimolecular_react=self.trimolecular_react)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/model.py", line 614, in enlarge
self.apply_thermo_to_species(procnum)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/model.py", line 824, in apply_thermo_to_species
self.generate_thermo(spc, rename=True)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/rmg/model.py", line 831, in generate_thermo
submit(spc, self.solvent_name)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/thermo/thermoengine.py", line 175, in submit
spc.thermo = evaluator(spc, solvent_name=solvent_name)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/thermo/thermoengine.py", line 160, in evaluator
thermo = generate_thermo_data(spc, solvent_name=solvent_name)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/thermo/thermoengine.py", line 125, in generate_thermo_data
thermo0 = thermodb.get_thermo_data(spc)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/data/thermo.py", line 1223, in get_thermo_data
thermo0 = self.get_thermo_data_for_surface_species(species)
File "/Users/lee.ting/Code/RMG-Py/rmgpy/data/thermo.py", line 1546, in get_thermo_data_for_surface_species
dummy_molecule.update()
File "rmgpy/molecule/molecule.py", line 1130, in rmgpy.molecule.molecule.Molecule.update
File "rmgpy/molecule/molecule.py", line 1355, in rmgpy.molecule.molecule.Molecule.update_atomtypes
File "rmgpy/molecule/molecule.py", line 1350, in rmgpy.molecule.molecule.Molecule.update_atomtypes
File "rmgpy/molecule/atomtype.py", line 729, in rmgpy.molecule.atomtype.get_atomtype
File "rmgpy/molecule/atomtype.py", line 757, in rmgpy.molecule.atomtype.get_atomtype
rmgpy.exceptions.AtomTypeError: Unable to determine atom type for atom N., which has 1 single bonds, 0 double bonds (0 to O, 0 to S, 0 others), 1 triple bonds, 0 quadruple bonds, 0 benzene bonds, 0 lone pairs, and +0 charge.
Katrin referred that it looks like RMG isn't updating the bonds and lone pairs correctly when removing it from the surface, like the #2034 Other testings of Rh and Pd surface have the same problem of species:
Error: Error attempting to get thermo for species ON(N=[Pt])[Pt](48) with structure
1 O u0 p2 c0 {2,S} {4,S}
2 N u0 p1 c0 {1,S} {3,S} {5,S}
3 N u0 p1 c0 {2,S} {6,D}
4 H u0 p0 c0 {1,S}
5 X u0 p0 c0 {2,S}
6 X u0 p0 c0 {3,D}
Hello there, I was a facing a similar scenario with the thermo of the bidentate adsorbate for adsorption of [O][O] over Ni:
For reaction generation 1 process is used.
Generating thermo for new species...
Error: Could not update atomtypes for this molecule:
1 O u0 p1 c+1 {2,T}
2 O u0 p2 c-1 {1,T}
Error: Error attempting to get thermo for species [Pt]OO[Pt](18) with structure
1 O u0 p2 c0 {2,S} {3,S}
2 O u0 p2 c0 {1,S} {4,S}
3 X u0 p0 c0 {1,S}
4 X u0 p0 c0 {2,S}
Traceback (most recent call last):
File "/mnt/c/users/josefedupe/RMG-Py/rmg.py", line 118, in <module>
main()
File "/mnt/c/users/josefedupe/RMG-Py/rmg.py", line 112, in main
rmg.execute(**kwargs)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/rmg/main.py", line 922, in execute
trimolecular_react=self.trimolecular_react)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/rmg/model.py", line 610, in enlarge
self.apply_thermo_to_species(procnum)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/rmg/model.py", line 820, in apply_thermo_to_species
self.generate_thermo(spc, rename=True)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/rmg/model.py", line 827, in generate_thermo
submit(spc, self.solvent_name)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/thermo/thermoengine.py", line 175, in submit
spc.thermo = evaluator(spc, solvent_name=solvent_name)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/thermo/thermoengine.py", line 160, in evaluator
thermo = generate_thermo_data(spc, solvent_name=solvent_name)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/thermo/thermoengine.py", line 125, in generate_thermo_data
thermo0 = thermodb.get_thermo_data(spc)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/data/thermo.py", line 1229, in get_thermo_data
thermo0 = self.get_thermo_data_for_surface_species(species)
File "/mnt/c/users/josefedupe/RMG-Py/rmgpy/data/thermo.py", line 1562, in get_thermo_data_for_surface_species
dummy_molecule.update()
File "rmgpy/molecule/molecule.py", line 1130, in rmgpy.molecule.molecule.Molecule.update
File "rmgpy/molecule/molecule.py", line 1355, in rmgpy.molecule.molecule.Molecule.update_atomtypes
File "rmgpy/molecule/molecule.py", line 1350, in rmgpy.molecule.molecule.Molecule.update_atomtypes
File "rmgpy/molecule/atomtype.py", line 729, in rmgpy.molecule.atomtype.get_atomtype
File "rmgpy/molecule/atomtype.py", line 757, in rmgpy.molecule.atomtype.get_atomtype
rmgpy.exceptions.AtomTypeError: Unable to determine atom type for atom O-, which has 0 single bonds, 0 double bonds (0 to O, 0 to S, 0 others), 1 triple bonds, 0 quadruple bonds, 0 benzene bonds, 2 lone pairs, and -1 charge.
I think, it was result of the treatment of thermo.py for bidentate adsorption where the bidentate adsorption of CO, X-C=O-X, requires to generate C[-1]#O[+1]. With this in mind, I add the following “try: - except:” to treat [Pt]OO[Pt] and generate [O][O]:
dummy_molecule_old = dummy_molecule.copy(deep=True)
try:
dummy_molecule.update()
except rmgpy.exceptions.AtomTypeError:
dummy_molecule = dummy_molecule_old
logging.exception("The above molecule was reestructured to: \n{0}".format(dummy_molecule.to_adjacency_list()))
pass
it worked for me, but I think there could be a more elegant way to avoid the formation of O[-1]#O[+1]. It allows [O][O] to be the counterpart of [Pt]OO[Pt] in gas phase, and apparentely will not interfere on the treatment of CO and C#C. The section of the code with the modifications is as follows:
if len(adsorbed_atoms) == 2:
# Bidentate adsorption.
# Conserve the old molecular structure after sites removal in case
# of generate an invalid molecule, i.e. O[-1]#O[+1]
dummy_molecule_old = dummy_molecule.copy(deep=True)
# Try to turn adjacent biradical into a bond.
try:
bond = adsorbed_atoms[0].bonds[adsorbed_atoms[1]]
except KeyError:
pass # the two adsorbed atoms are not bonded to each other
else:
if bond.order < 3:
bond.increment_order()
adsorbed_atoms[0].decrement_radical()
adsorbed_atoms[1].decrement_radical()
if (adsorbed_atoms[0].radical_electrons and
adsorbed_atoms[1].radical_electrons and
bond.order < 3):
# There are still spare adjacenct radicals, so do it again
bond.increment_order()
adsorbed_atoms[0].decrement_radical()
adsorbed_atoms[1].decrement_radical()
if (adsorbed_atoms[0].lone_pairs and
adsorbed_atoms[1].lone_pairs and
bond.order < 3):
# X#C-C#X will end up with .:C-C:. in gas phase
# and we want to get to .C#C. but not :C=C:
bond.increment_order()
adsorbed_atoms[0].decrement_lone_pairs()
adsorbed_atoms[0].increment_radical()
adsorbed_atoms[1].decrement_lone_pairs()
adsorbed_atoms[1].increment_radical()
#For bidentate CO because we want C[-1]#O[+1] but not .C#O.
#and for bidentate OO we want [O][O] but not O[-1]#O[+1], see
#line 1556
if (bond.order == 3 and adsorbed_atoms[0].radical_electrons and
adsorbed_atoms[1].radical_electrons and
(adsorbed_atoms[0].lone_pairs or adsorbed_atoms[1].lone_pairs)):
adsorbed_atoms[0].decrement_radical()
adsorbed_atoms[1].decrement_radical()
if adsorbed_atoms[0].lone_pairs:
adsorbed_atoms[1].increment_lone_pairs()
else:
adsorbed_atoms[0].increment_lone_pairs()
try:
dummy_molecule.update()
except rmgpy.exceptions.AtomTypeError:
dummy_molecule = dummy_molecule_old
logging.exception("The above molecule was reestructured to: \n{0}".format(dummy_molecule.to_adjacency_list()))
pass
dummy_molecule.update_connectivity_values()
dummy_molecule.update()
Hmm. This is getting complicated. Seems we want
C*O*
to become C[-1]#O[+1]
O*O*
to become [O][O]
C*C*
to become [C]#[C]
N*N*O
to become N#N=O
(the middle Nitrogen has valence 5)
etc...
Do we treat CO and OO as special known cases, and then everything else, a more generic arroach like: generate everything feasible, try them all, and use the lowest energy that doesn't fail?
Starting with
1 O u0 p2 c0 {2,S} {4,S}
2 N u0 p1 c0 {1,S} {3,S} {5,S}
3 N u0 p1 c0 {2,S} {6,D}
4 H u0 p0 c0 {1,S}
5 X u0 p0 c0 {2,S}
6 X u0 p0 c0 {3,D}
it first creates the gas phase counterpart
multiplicity 1
1 O u0 p2 c0 {2,S} {4,S}
2 N u1 p1 c0 {1,S} {3,S}
3 N u2 p1 c0 {2,S}
4 H u0 p0 c0 {1,S}
note the three unpaired electrons total then it turns two of them into a double bond
if bond.order < 3:
bond.increment_order()
adsorbed_atoms[0].decrement_radical()
adsorbed_atoms[1].decrement_radical()
to get
multiplicity 1
1 O u0 p2 c0 {2,S} {4,S}
2 N u0 p1 c0 {1,S} {3,D}
3 N u1 p1 c0 {2,D}
4 H u0 p0 c0 {1,S}
then it tries to turn the lone pair into another bond
if (adsorbed_atoms[0].lone_pairs and
adsorbed_atoms[1].lone_pairs and
bond.order < 3):
# X#C-C#X will end up with .:C-C:. in gas phase
# and we want to get to .C#C. but not :C=C:
bond.increment_order()
adsorbed_atoms[0].decrement_lone_pairs()
adsorbed_atoms[0].increment_radical()
adsorbed_atoms[1].decrement_lone_pairs()
adsorbed_atoms[1].increment_radical()
and gets
multiplicity 1
1 O u0 p2 c0 {2,S} {4,S}
2 N u1 p0 c+1 {1,S} {3,T}
3 N u2 p0 c+1 {2,T}
4 H u0 p0 c0 {1,S}
Yes, I think the problem would be to decide which molecular structure for the gas phase counterpart should be used. A practical solution could be to test after each “if” statement the molecular structure, if it does not have “AtomTypeError”. But if the last is applied the final gas phase counter part of [Pt]OO[Pt] will be O=O, which, by default is set to not be allowed in the field “generatedSpeciesConstrains” of the “input.py” file. Then, it could be tested the H0 of each molecular structure, and select the one with lower H0 and without “AtomTypeErrors”. With that in mind, may be the lines to be added could be as follows,
if len(adsorbed_atoms) == 2:
# Bidentate adsorption.
# Conserve the old molecular structure after sites removal in case
# of generate an invalid molecule, i.e. O[-1]#O[+1]
#print('here')
dummy_molecule_old = dummy_molecule.copy(deep=True)
dummy_molecule_old.update_connectivity_values()
dummy_molecule_old.update()
dummy_species_old = Species()
dummy_species_old.molecule.append(dummy_molecule_old)
dummy_species_old.generate_resonance_structures()
H298_old = []
H298_old.append(self.get_thermo_data(dummy_species_old).get_enthalpy(298.))
molecule_test = []
molecule_test.append(dummy_molecule_old.to_smiles())
# Try to turn adjacent biradical into a bond.
try:
bond = adsorbed_atoms[0].bonds[adsorbed_atoms[1]]
except KeyError:
pass # the two adsorbed atoms are not bonded to each other
else:
if bond.order < 3:
#print('in here 1533')
bond.increment_order()
adsorbed_atoms[0].decrement_radical()
adsorbed_atoms[1].decrement_radical()
try:
dummy_molecule.update_connectivity_values()
dummy_molecule.update()
dummy_species_old = Species()
dummy_species_old.molecule.append(dummy_molecule)
dummy_species_old.generate_resonance_structures()
molecule_test.append(dummy_molecule.to_smiles())
H298_old.append(self.get_thermo_data(dummy_species_old).get_enthalpy(298.))
# print(dummy_species_old)
except rmgpy.exceptions.AtomTypeError:
#dummy_molecule = dummy_molecule_old
#logging.exception("The above molecule was reestructured to: \n{0}".format(dummy_molecule_old.to_adjacency_list()))
pass
if (adsorbed_atoms[0].radical_electrons and
adsorbed_atoms[1].radical_electrons and
bond.order < 3):
# There are still spare adjacenct radicals, so do it again
print('in here 1551')
bond.increment_order()
adsorbed_atoms[0].decrement_radical()
adsorbed_atoms[1].decrement_radical()
try:
dummy_molecule.update_connectivity_values()
dummy_molecule.update()
dummy_species_old = Species()
dummy_species_old.molecule.append(dummy_molecule)
dummy_species_old.generate_resonance_structures()
molecule_test.append(dummy_molecule.to_smiles())
H298_old.append(self.get_thermo_data(dummy_species_old).get_enthalpy(298.))
except rmgpy.exceptions.AtomTypeError:
#print('exception 1563')
pass
if (adsorbed_atoms[0].lone_pairs and
adsorbed_atoms[1].lone_pairs and
bond.order < 3):
# X#C-C#X will end up with .:C-C:. in gas phase
# and we want to get to .C#C. but not :C=C:
#print('in here 1571')
bond.increment_order()
adsorbed_atoms[0].decrement_lone_pairs()
adsorbed_atoms[0].increment_radical()
adsorbed_atoms[1].decrement_lone_pairs()
adsorbed_atoms[1].increment_radical()
try:
dummy_molecule.update_connectivity_values()
dummy_molecule.update()
dummy_species_old = Species()
dummy_species_old.molecule.append(dummy_molecule)
dummy_species_old.generate_resonance_structures()
molecule_test.append(dummy_molecule.to_smiles())
H298_old.append(self.get_thermo_data(dummy_species_old).get_enthalpy(298.))
except rmgpy.exceptions.AtomTypeError or rmgpy.exceptions.ResonanceError:
#print('exception 1585')
pass
#For bidentate CO because we want C[-1]#O[+1] but not .C#O.
#and for bidentate OO we want [O][O] but not O[-1]#O[+1], see
#line 1556
if (bond.order == 3 and adsorbed_atoms[0].radical_electrons and
adsorbed_atoms[1].radical_electrons and
(adsorbed_atoms[0].lone_pairs or adsorbed_atoms[1].lone_pairs)):
#print('in here 1594')
adsorbed_atoms[0].decrement_radical()
adsorbed_atoms[1].decrement_radical()
if adsorbed_atoms[0].lone_pairs:
adsorbed_atoms[1].increment_lone_pairs()
else:
adsorbed_atoms[0].increment_lone_pairs()
try:
dummy_molecule.update_connectivity_values()
dummy_molecule.update()
dummy_species_old = Species()
dummy_species_old.molecule.append(dummy_molecule)
dummy_species_old.generate_resonance_structures()
molecule_test.append(dummy_molecule.to_smiles())
H298_old.append(self.get_thermo_data(dummy_species_old).get_enthalpy(298.))
except rmgpy.exceptions.AtomTypeError or rmgpy.exceptions.ResonanceError:
#print('in here 1619')
index_min_H298 = min(range(len(H298_old)), key=H298_old.__getitem__)
dummy_molecule.from_smiles(molecule_test[index_min_H298])
logging.exception("The above molecule was reestructured to: \n{0}".format(dummy_molecule_old.to_adjacency_list()))
pass
I think it is just the idea, I am not sure if it could work generally. And sorry about my awkward way to program, I am new in python.
Thanks for the help, @josefedupe! Maybe you could help us review pull request #2045, see if it works for your scenarios.
Thanks to you @rwest, RMG-CAT is an amazing code! The scenario was presented in #2045. And sorry for the late response!
Bug Description
This minimal input file below leads to this crash caused by the reaction family Surface_Bidentate_Dissociation:
How To Reproduce
Try this input file:
Expected Behavior
It wouldn't crash.
Installation Information