Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using metal attributes #2025

Merged
merged 24 commits into from Feb 8, 2021
Merged

Using metal attributes #2025

merged 24 commits into from Feb 8, 2021

Conversation

mazeau
Copy link
Contributor

@mazeau mazeau commented Sep 9, 2020

Motivation or Problem

Currently, RMG can only use surfaceThermoPt111 as it assumes the reference point is Pt111. We want to be able to:

  • use thermo from all sorts of different metals and use LSRs to scale to wherever
  • properly use kinetics training reactions that were on different metals (reverse reactions in particular)

This also adds a new metal database so users don't have to look up binding energies for specific metals of interest

Reviewer Tips

I just created this PR so we would have a place for discussion.
Sister database PR is #387

@mazeau
Copy link
Contributor Author

mazeau commented Sep 9, 2020

RMG currently (?):

reads in binding energies from input file
assumes user is only using sufraceThermoPt111
> hard coded Pt111 in as starting point in rmgpy/data/thermo.py, line 1378
...
calls set_delta_atomic_adsorption_energies to set delta_atomic_adsorption_energy ONCE
> this makes delta_atomic_adsorption_energy the difference between Pt111 point and binding energies specified in the input file
...
loads in the training reactions from specified families
if the reaction is reverse, the thermo is assumed to be on Pt111 and that is used to determine the reverse rate
...

is delta_atomic_adsorption_energy used anywhere else? during model generation?

RMG should (assuming it loads thermo first? not sure the order):

read in binding energies/metal from the input file
be able to load in multiple surface thermo libraries from different metals
> when loading in thermo entries, be able to read which metal each entry was calculated on
> use LSRs to scale from entry metal to binding energies/metal specified from input file
...
be able to load training reactions on different metals
> load in each training reaction entry
> read which metal kinetics entry came from
> scale thermo from whatever metal RMG has it on (either newly scaled thermo to the BEs from input file or their original metal) and scale to the training reaction entry metal to correctly determine reverse reaction rates

To do this:

  • delta_atomic_adsorption_energy should not be static?
    this may lead to other problems...

  • BEs from input file should be stored somewhere permanent, and not in delta_atomic_adsorption_energy

  • rmgpy/data/thermo.py, line 1444 is where it applies the lsr and the metal needs to be included somewhere here

  • rmgpy/data/thermo.py, line 1378 should have to do with the metal that the thermodata is coming from

  • I think correct_binding_energy should call set_delta_atomic_adsorption_energies instead of just delta_atomic_adsorption_energies

  • set_delta_atomic_adsorption_energies should require both BEs from the input file and the metal that either the thermodata was from?

  • rmgpy/data/kinetics/family.py get_training_set is maybe where it reverses training reactions to all be in the forward direction? or get_training_depository?

    • thermo database is none, but is probably what was specified in the input file?
      • when do we apply lsr corrections to the thermodata? before or after this?
      • if before, everything should already be on the BE from the input file, so I would assume that is not the case?
    • line 3914/3955 calls get_thermo_data, so each entry metal attribute should be passed through there (at the very end)
    • maybe get_thermo_data also needs to know which metal the thermo was on,
      • is this already stored in thermo0.metal?

Speculative ToDo List:

  • in rmgpy/data/thermo.py:
    • set_delta_atomic_adsorption_energies -> make a duplicate-like function to this that returns the delta_atomic_adsorption_energy2 when given BE1 (thermodata entry.metal), BE2 (input BEs)
      reference_binding_energies should be the metal the thermo is from
      rmgpy/rmg/main.py line 404 calls this
    • correct_binding_energy - > should know which metal thermo db came from and which metal to scale to
    • get_thermo_data ->
      metal will be the metal to scale to??
    • get_thermo_data_for_surface_species: does this need to be changed? how does it do adsorption corrections if it doesn't know what metal it's on? uses adsorptionpt111 group tree to do this

getting really confused as to which metal will refer to what... could either be
- original BEs/metal the model is being scaled to from the input file
- thermo db metal
- kinetics training reaction entry metal

NOTE: this does NOT change the thermo groups from using adsorption pt111 as a default/is currently hard-coded in
Adsorption corrections (thermo groups) may cause issues???

-- also, do we want to load in all the thermo libraries and scale to where (the BEs) we want the model generated on, and then use the already scaled thermo to scale the thermo for the kinetics training reactions (probably easiest) or use original, non-scaled thermo to scale from? it shouldn't matter either way....

Also need to update saving methods in rmgpy/data/kinetics.py for saving training reactions if there is a metal attribute and probably same with rmgpy/data/thermo.py

@codecov
Copy link

codecov bot commented Sep 9, 2020

Codecov Report

Merging #2025 (c35c6ea) into master (94aa292) will increase coverage by 0.03%.
The diff coverage is 55.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2025      +/-   ##
==========================================
+ Coverage   47.54%   47.58%   +0.03%     
==========================================
  Files          88       89       +1     
  Lines       23304    23499     +195     
  Branches     6062     6105      +43     
==========================================
+ Hits        11080    11181     +101     
- Misses      11065    11146      +81     
- Partials     1159     1172      +13     
Impacted Files Coverage Δ
rmgpy/rmg/main.py 22.51% <0.00%> (ø)
rmgpy/rmg/input.py 41.26% <10.71%> (-0.76%) ⬇️
rmgpy/data/kinetics/family.py 48.70% <15.38%> (-0.14%) ⬇️
rmgpy/data/kinetics/common.py 67.98% <33.33%> (-1.06%) ⬇️
rmgpy/data/thermo.py 67.09% <50.90%> (-2.81%) ⬇️
rmgpy/data/surface.py 70.24% <70.24%> (ø)
rmgpy/data/base.py 48.94% <100.00%> (+0.13%) ⬆️
rmgpy/data/rmg.py 72.41% <100.00%> (+1.50%) ⬆️
arkane/kinetics.py 12.24% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94aa292...c35c6ea. Read the comment docs.

@rwest rwest self-assigned this Sep 9, 2020
@lgtm-com
Copy link

lgtm-com bot commented Sep 9, 2020

This pull request introduces 4 alerts when merging 34aa030 into 3c13a22 - view on LGTM.com

new alerts:

  • 4 for Unused import

@mazeau mazeau force-pushed the Metal_Attributes branch 4 times, most recently from 4ed71a9 to 44f02cb Compare September 10, 2020 16:32
@lgtm-com
Copy link

lgtm-com bot commented Sep 10, 2020

This pull request introduces 4 alerts when merging 44f02cb into 3c13a22 - view on LGTM.com

new alerts:

  • 4 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Sep 10, 2020

This pull request introduces 5 alerts and fixes 3 when merging 751af74 into 3c13a22 - view on LGTM.com

new alerts:

  • 4 for Unused import
  • 1 for Syntax error

fixed alerts:

  • 2 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Sep 21, 2020

This pull request introduces 5 alerts and fixes 3 when merging 82b6783 into 3c13a22 - view on LGTM.com

new alerts:

  • 4 for Unused import
  • 1 for Syntax error

fixed alerts:

  • 2 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Sep 21, 2020

This pull request introduces 5 alerts and fixes 3 when merging e344e20 into 3c13a22 - view on LGTM.com

new alerts:

  • 4 for Unused import
  • 1 for Syntax error

fixed alerts:

  • 2 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Sep 22, 2020

This pull request introduces 2 alerts when merging 0e857da into 3c13a22 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Except block handles 'BaseException'

@lgtm-com
Copy link

lgtm-com bot commented Sep 22, 2020

This pull request introduces 3 alerts when merging 3426502 into 3c13a22 - view on LGTM.com

new alerts:

  • 1 for Wrong name for an argument in a call
  • 1 for Unused local variable
  • 1 for Except block handles 'BaseException'

@lgtm-com
Copy link

lgtm-com bot commented Sep 29, 2020

This pull request introduces 2 alerts when merging 79a6263 into 3c13a22 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Except block handles 'BaseException'

@mazeau
Copy link
Contributor Author

mazeau commented Sep 30, 2020

Something to note: Katrin mentioned that the surfaceThermoPt111 things were calculated on binding energies from https://github.com/ReactionMechanismGenerator/RMG-Py/pull/1975/files the BEEF-vdW calculations from Karlsruhe - (2019 paper) so I just added them back in as hard coded, because these conflict with the new pt111 binding energies in the database.

@lgtm-com
Copy link

lgtm-com bot commented Oct 2, 2020

This pull request introduces 2 alerts when merging d644803 into 3c13a22 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Except block handles 'BaseException'

@mazeau
Copy link
Contributor Author

mazeau commented Oct 5, 2020

Current RMG-Py test failures:

======================================================================
ERROR: Test we can load all entries from the database on one metal
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surfaceTest.py", line 89, in test_load_all_entries_on_one_metal
    self.assertEqual(len(self.database.get_all_entries_on_metal("Pt")), 2)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 202, in get_all_entries_on_metal
    if entry.metal == metal_name:
AttributeError: 'str' object has no attribute 'metal'

======================================================================
ERROR: Test we can obtain metal parameters from a string
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 183, in get_binding_energies
    metal_data = self.libraries['surface'].get_binding_energies(metal_name)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 118, in get_binding_energies
    return self.entries[label].binding_energies
KeyError: 'Pt000'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surfaceTest.py", line 84, in test_load_from_label
    self.assertRaises(DatabaseError, self.database.get_binding_energies(test_noexistent))
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 185, in get_binding_energies
    raise DatabaseError('Metal {0!r} not found in database'.format(metal_name))
rmgpy.exceptions.DatabaseError: Metal 'Pt000' not found in database

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH2XCH2X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 674, in test_adsorbate_thermo_generation_bidentate
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1406, in correct_binding_energy
    metal_to_scale_to_binding_energies = metal_db.find_binding_energies(metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 217, in find_binding_energies
    metal_binding_energies = rmgpy.rmg.binding_energies
AttributeError: module 'rmgpy.rmg' has no attribute 'binding_energies'

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate [C]#[C]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 724, in test_adsorbate_thermo_generation_bidentate_C2
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1406, in correct_binding_energy
    metal_to_scale_to_binding_energies = metal_db.find_binding_energies(metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 217, in find_binding_energies
    metal_binding_energies = rmgpy.rmg.binding_energies
AttributeError: module 'rmgpy.rmg' has no attribute 'binding_energies'

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH=XCH2X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 782, in test_adsorbate_thermo_generation_bidentate_asymmetric
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1406, in correct_binding_energy
    metal_to_scale_to_binding_energies = metal_db.find_binding_energies(metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 217, in find_binding_energies
    metal_binding_energies = rmgpy.rmg.binding_energies
AttributeError: module 'rmgpy.rmg' has no attribute 'binding_energies'

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH=XCH=X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 700, in test_adsorbate_thermo_generation_bidentate_double
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1406, in correct_binding_energy
    metal_to_scale_to_binding_energies = metal_db.find_binding_energies(metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 217, in find_binding_energies
    metal_binding_energies = rmgpy.rmg.binding_energies
AttributeError: module 'rmgpy.rmg' has no attribute 'binding_energies'

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH2X-CH2-CH2X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 811, in test_adsorbate_thermo_generation_bidentate_nonadjacent
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1406, in correct_binding_energy
    metal_to_scale_to_binding_energies = metal_db.find_binding_energies(metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 217, in find_binding_energies
    metal_binding_energies = rmgpy.rmg.binding_energies
AttributeError: module 'rmgpy.rmg' has no attribute 'binding_energies'

======================================================================
ERROR: Test thermo generation for adsorbate from Group Additivity value.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 629, in test_adsorbate_thermo_generation_gav
    thermo = self.databaseWithoutLibraries.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1406, in correct_binding_energy
    metal_to_scale_to_binding_energies = metal_db.find_binding_energies(metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 217, in find_binding_energies
    metal_binding_energies = rmgpy.rmg.binding_energies
AttributeError: module 'rmgpy.rmg' has no attribute 'binding_energies'

======================================================================
ERROR: Test thermo generation for adsorbate from gas phase library value.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 648, in test_adsorbate_thermo_generation_library
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1406, in correct_binding_energy
    metal_to_scale_to_binding_energies = metal_db.find_binding_energies(metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/surface.py", line 217, in find_binding_energies
    metal_binding_energies = rmgpy.rmg.binding_energies
AttributeError: module 'rmgpy.rmg' has no attribute 'binding_energies'

@lgtm-com
Copy link

lgtm-com bot commented Oct 5, 2020

This pull request introduces 1 alert when merging 6702156 into 3c13a22 - view on LGTM.com

new alerts:

  • 1 for Except block handles 'BaseException'

@mazeau
Copy link
Contributor Author

mazeau commented Oct 5, 2020

All old failures fixed, now I have these:

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH2XCH2X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 674, in test_adsorbate_thermo_generation_bidentate
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1424, in correct_binding_energy
    deltaEnergy.value_si = metal_to_scale_to_binding_energies[element].value_si - metal_to_scale_from_binding_energies[element].value_si
UnboundLocalError: local variable 'metal_to_scale_from_binding_energies' referenced before assignment

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate [C]#[C]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 724, in test_adsorbate_thermo_generation_bidentate_C2
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1424, in correct_binding_energy
    deltaEnergy.value_si = metal_to_scale_to_binding_energies[element].value_si - metal_to_scale_from_binding_energies[element].value_si
UnboundLocalError: local variable 'metal_to_scale_from_binding_energies' referenced before assignment

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH=XCH2X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 782, in test_adsorbate_thermo_generation_bidentate_asymmetric
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1424, in correct_binding_energy
    deltaEnergy.value_si = metal_to_scale_to_binding_energies[element].value_si - metal_to_scale_from_binding_energies[element].value_si
UnboundLocalError: local variable 'metal_to_scale_from_binding_energies' referenced before assignment

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH=XCH=X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 700, in test_adsorbate_thermo_generation_bidentate_double
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1424, in correct_binding_energy
    deltaEnergy.value_si = metal_to_scale_to_binding_energies[element].value_si - metal_to_scale_from_binding_energies[element].value_si
UnboundLocalError: local variable 'metal_to_scale_from_binding_energies' referenced before assignment

======================================================================
ERROR: Test thermo generation for a bidentate adsorbate, CH2X-CH2-CH2X
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 811, in test_adsorbate_thermo_generation_bidentate_nonadjacent
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1424, in correct_binding_energy
    deltaEnergy.value_si = metal_to_scale_to_binding_energies[element].value_si - metal_to_scale_from_binding_energies[element].value_si
UnboundLocalError: local variable 'metal_to_scale_from_binding_energies' referenced before assignment

======================================================================
ERROR: Test thermo generation for adsorbate from Group Additivity value.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 629, in test_adsorbate_thermo_generation_gav
    thermo = self.databaseWithoutLibraries.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1424, in correct_binding_energy
    deltaEnergy.value_si = metal_to_scale_to_binding_energies[element].value_si - metal_to_scale_from_binding_energies[element].value_si
UnboundLocalError: local variable 'metal_to_scale_from_binding_energies' referenced before assignment

======================================================================
ERROR: Test thermo generation for adsorbate from gas phase library value.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermoTest.py", line 648, in test_adsorbate_thermo_generation_library
    thermo = self.database.get_thermo_data(spec)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1231, in get_thermo_data
    thermo0 = self.correct_binding_energy(thermo0, species, metal_to_scale_to=metal_to_scale_to)
  File "/Users/emilymazeau/Code/RMG-Py/rmgpy/data/thermo.py", line 1424, in correct_binding_energy
    deltaEnergy.value_si = metal_to_scale_to_binding_energies[element].value_si - metal_to_scale_from_binding_energies[element].value_si
UnboundLocalError: local variable 'metal_to_scale_from_binding_energies' referenced before assignment```

@lgtm-com
Copy link

lgtm-com bot commented Oct 5, 2020

This pull request introduces 1 alert when merging c760868 into 3c13a22 - view on LGTM.com

new alerts:

  • 1 for Except block handles 'BaseException'

@lgtm-com
Copy link

lgtm-com bot commented Oct 5, 2020

This pull request introduces 1 alert when merging 0283e3d into 3c13a22 - view on LGTM.com

new alerts:

  • 1 for Except block handles 'BaseException'

mazeau and others added 21 commits February 8, 2021 13:34
get_training_set: adding metal entry attribute

trying to pass training reaction metal attribute to thermo calculations

add_rules_from_training: adding metal entry attribute

passing through metal training entry attribute during reverse rate thermo calculations

FIXUP: if there is no facet, change NoneType to an empty string

FIXUP: family.py, condensing code to fix string and None adding error
The Pt111 values in the metal database are not the same as the binding energies used to calculate the Pt111 surface thermo library, so they are hard coded in here

FIXUP: thermo.py now correctly passes metal into correct_binding_energy

FIXUP: thermo.py all tests pass now!
…e example.

This commit generalizes the test and makes it also test the write-read loop for
a surface mechanism (which was copied from RMG-database/input/kinetics/libraries/Surface/Example.

The test however is not good enough, as it doesn't actually enforce the written library
is the same as the input. For example, the `metal` attribute in the original is not
duplicated in the copy, and yet the test still passes. 
This may indicate a problem with a __repr__ method somewhere as well as the saving.
Load it once and refer to it.

Fixup initializing ThermoDatabase: At this point there's no help in calling
set_binding_energies, and the metals database hasn't even been loaded yet.
When generating a model on Ni, we should preferentially use the Ni thermo
data when it exists. Fall back to the Pt because there's not much Ni.

This Metal Attributes branch should take care of scaling the thermo
so they both end up on the right metal (Ni).
forgot to update some of the many save entries
tests to make sure that metal attributes are always strings
In a unit test that we can save a database library, we need a blank folder
to put it in. Previously, it would fail if that folder existed. Now it just
wipes it.
@rwest rwest closed this in 6146e3e Feb 8, 2021
@rwest rwest merged commit 6146e3e into master Feb 8, 2021
@rwest rwest deleted the Metal_Attributes branch February 8, 2021 19:05
rwest added a commit to ReactionMechanismGenerator/RMG-database that referenced this pull request Feb 8, 2021
Thanks @mazeau and @kblondal for this contribution,
and David and all the other reviewers.

Requires an update to RMG-Py, which was pull request
ReactionMechanismGenerator/RMG-Py#2025
merged in 6146e3e1c90b583bcc3b15d0afea98947e1bd1ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants