Skip to content

Commit

Permalink
Merge branch 'main' into wsl_docs_addition
Browse files Browse the repository at this point in the history
  • Loading branch information
ntietje1 authored Jun 20, 2024
2 parents 558499e + 36bceb3 commit 08e45d4
Show file tree
Hide file tree
Showing 18 changed files with 606 additions and 134 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ env:

jobs:
build-osx:
runs-on: macos-latest
runs-on: macos-13
# skip scheduled runs from forks
if: ${{ !( github.repository != 'ReactionMechanismGenerator/RMG-Py' && github.event_name == 'schedule' ) }}
defaults:
Expand All @@ -63,7 +63,7 @@ jobs:

# configures the mamba environment manager and builds the environment
- name: Setup Mambaforge Python 3.7
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment.yml
miniforge-variant: Mambaforge
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:

# configures the mamba environment manager and builds the environment
- name: Setup Mambaforge Python 3.7
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment.yml
miniforge-variant: Mambaforge
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:
# Upload Regression Results as Failed if above step failed
- name: Upload Failed Results
if: ${{ failure() && steps.regression-execution.conclusion == 'failure' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failed_regression_results
path: |
Expand All @@ -195,7 +195,7 @@ jobs:
- name: Upload Results as Reference
# upload the results for scheduled CI (on main) and pushes to main
if: ${{ env.REFERENCE_JOB == 'true' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: stable_regression_results
path: |
Expand All @@ -204,7 +204,7 @@ jobs:
# Upload Regression Results as Dynamic if Push to non-main Branch
- name: Upload Results as Dynamic
if: ${{ env.REFERENCE_JOB == 'false' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dynamic_regression_results
path: |
Expand All @@ -215,23 +215,24 @@ jobs:
run: mkdir stable_regression_results

# Retrieve Stable Results for reference
# Will need to use this -> https://github.com/dawidd6/action-download-artifact
- name : Find ID of Reference Results
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
run_id=$(gh run list -R ReactionMechanismGenerator/RMG-Py --workflow="Continuous Integration" --branch main --limit 1 --json databaseId --jq '.[0].databaseId')
echo "CI_RUN_ID=$run_id" >> $GITHUB_ENV
- name: Retrieve Stable Regression Results
if: ${{ env.REFERENCE_JOB == 'false' }}
uses: dsnopek/action-download-artifact@91dda23aa09c68860977dd0ed11d93c0ed3795e7 # see https://github.com/ReactionMechanismGenerator/RMG-Py/pull/2459#issuecomment-1582850815
uses: actions/download-artifact@v4
with:
# this will search for the last successful execution of CI on main and download
# the stable regression results
workflow: CI.yml
workflow_conclusion: success
repo: ReactionMechanismGenerator/RMG-Py
branch: main
run-id: ${{ env.CI_RUN_ID }}
repository: ReactionMechanismGenerator/RMG-Py
github-token: ${{ secrets.GITHUB_TOKEN }}
name: stable_regression_results
path: stable_regression_results
search_artifacts: true # retrieves the last run result, either scheduled daily or on push to main
ensure_latest: true # ensures that the latest run is retrieved
# should result in a set of folders inside stable_regression_results
# each of which has the stable result for that example/test

# Regression Testing - Actual Comparisons
- name: Regression Tests - Compare to Baseline
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
################################################################################

CC=gcc
CXX=g++

.PHONY : all minimal main solver check pycheck arkane clean install decython documentation test q2dtor

all: pycheck main solver check
Expand Down
6 changes: 2 additions & 4 deletions arkane/ess/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import logging
import math
import os.path

import re
import numpy as np

import rmgpy.constants as constants
Expand Down Expand Up @@ -309,9 +309,8 @@ def load_energy(self, zpe_scale_factor=1.):
with open(self.path, 'r') as f:
line = f.readline()
while line != '':

if 'SCF Done:' in line:
e_elect = float(line.split()[4]) * constants.E_h * constants.Na
e_elect = float(re.findall(r"SCF Done: E\(.+\) \=\s+[^\s]+", line)[0].split()[-1]) * constants.E_h * constants.Na
elect_energy_source = 'SCF'
elif ' E2(' in line and ' E(' in line:
e_elect = float(line.split()[-1].replace('D', 'E')) * constants.E_h * constants.Na
Expand Down Expand Up @@ -351,7 +350,6 @@ def load_energy(self, zpe_scale_factor=1.):
# G4MP2 calculation without opt and freq calculation
# Keyword in Gaussian G4MP2(SP), No zero-point or thermal energies are included.
e_elect = float(line.split()[2]) * constants.E_h * constants.Na

# Read the ZPE from the "E(ZPE)=" line, as this is the scaled version.
# Gaussian defines the following as
# E (0 K) = Elec + E(ZPE),
Expand Down
21 changes: 19 additions & 2 deletions documentation/source/users/rmg/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ by Benson's method.

For example, if you wish to use the GRI-Mech 3.0 mechanism [GRIMech3.0]_ as a ThermoLibrary in your model, the syntax will be::

thermoLibraries = ['primaryThermoLibrary','GRI-Mech3.0']
thermoLibraries = ['primaryThermoLibrary', 'GRI-Mech3.0']

.. [GRIMech3.0] Gregory P. Smith, David M. Golden, Michael Frenklach, Nigel W. Moriarty, Boris Eiteneer, Mikhail Goldenberg, C. Thomas Bowman, Ronald K. Hanson, Soonho Song, William C. Gardiner, Jr., Vitali V. Lissianski, and Zhiwei Qin http://combustion.berkeley.edu/gri-mech/
Expand Down Expand Up @@ -78,7 +78,7 @@ In the following example, the user has created
a reaction library with a few additional reactions specific to n-butane, and these reactions
are to be used in addition to the Glarborg C3 library::

reactionLibraries = [('Glarborg/C3',False)],
reactionLibraries = [('Glarborg/C3', False)],

The keyword False/True permits user to append all unused reactions (= kept in the edge) from this library to the chemkin file.
True means those reactions will be appended. Using just the string inputs would lead to
Expand All @@ -104,6 +104,23 @@ given in each mechanism, the different mechanisms can have different units.
Library.


.. _externallib:

External Libraries
------------------
Users may direct RMG to use thermo and/or kinetic libraries which are not included in the RMG database,
e.g., a library a user created that was intentionally saved to a path different than the conventional
RMG-database location. In such cases, the user can specify the full path to the library in the input file::

thermoLibraries = ['path/to/your/thermo/library/file.py']

or::

reactionLibraries = [(path/to/your/kinetic/library/folder/']

Combinations in any order of RMG's legacy libraries and users' external libraries are allowed,
and the order in which the libraries are specified is the order in which they are loaded and given priority.

.. _seedmechanism:

Seed Mechanisms
Expand Down
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ dependencies:
- conda-forge::gprof2dot
- conda-forge::numdifftools
- conda-forge::quantities
- conda-forge::muq
- conda-forge::lpsolve55
- conda-forge::ringdecomposerlib-python

# packages we maintain
- rmg::lpsolve55
- rmg::muq2
- rmg::pydas >=1.0.3
- rmg::pydqed >=1.0.3
- rmg::pyrdl
- rmg::pyrms
- rmg::symmetry

Expand Down
146 changes: 101 additions & 45 deletions examples/rmg/minimal_surface/input.py
Original file line number Diff line number Diff line change
@@ -1,67 +1,123 @@
# Data sources
database(
thermoLibraries = ['primaryThermoLibrary'],
reactionLibraries = [],
thermoLibraries=['surfaceThermoPt111', 'primaryThermoLibrary', 'thermo_DFT_CCSDTF12_BAC','DFT_QCI_thermo'], # 'surfaceThermoPt' is the default. Thermo data is derived using bindingEnergies for other metals
reactionLibraries = [('Surface/CPOX_Pt/Deutschmann2006_adjusted', False)], # when Ni is used change the library to Surface/Deutschmann_Ni
seedMechanisms = [],
kineticsDepositories = ['training'],
kineticsFamilies = 'default',
kineticsFamilies = ['surface', 'default'],
kineticsEstimator = 'rate rules',
)

# List of species
catalystProperties(
bindingEnergies = {
'H': (-2.75368,'eV/molecule'),
'C': (-7.02516,'eV/molecule'),
'N': (-4.63225,'eV/molecule'),
'O': (-3.81153,'eV/molecule'),
},
surfaceSiteDensity=(2.483e-9, 'mol/cm^2'),
coverageDependence=False
)
species(
label='ethane',
label='CH4',
reactive=True,
structure=SMILES("CC"),
structure=SMILES("C"),
)

# Reaction systems
simpleReactor(
temperature=(1350,'K'),
pressure=(1.0,'bar'),
initialMoleFractions={
"ethane": 1.0,
},
terminationConversion={
'ethane': 0.9,
},
terminationTime=(1e6,'s'),
species(
label='O2',
reactive=True,
structure=adjacencyList(
"""
1 O u1 p2 c0 {2,S}
2 O u1 p2 c0 {1,S}
"""),
)

simpleReactor(
temperature=(1000,'K'),
pressure=(1.0,'bar'),
initialMoleFractions={
"ethane": 1.0,
species(
label='N2',
reactive=False,
structure=SMILES("N#N"),
)
species(
label='X',
reactive=True,
structure=adjacencyList("1 X u0"),
)
# added for training
species(
label='CO2X',
reactive=True,
structure=adjacencyList(
"""
1 O u0 p2 c0 {3,D}
2 O u0 p2 c0 {3,D}
3 C u0 p0 c0 {1,D} {2,D}
4 X u0 p0 c0
"""),
)
species(
label='COX',
reactive=True,
structure=adjacencyList(
"""
1 O u0 p2 c0 {2,D}
2 C u0 p0 c0 {1,D} {3,D}
3 X u0 p0 c0 {2,D}
"""),
)
species(
label='OX',
reactive=True,
structure=adjacencyList(
"""
1 O u0 p2 c0 {2,D}
2 X u0 p0 c0 {1,D}
"""),
)
# If you would like to forbid the bidentate form of absorbed CO2 from your model,
# use the following `CO2_bidentate` forbidden structure
# forbidden(
# label='CO2_bidentate',
# structure=SMILES("O=C(*)O*"),
# )
#----------
# Reaction systems
surfaceReactor(
temperature=(1000, 'K'),
initialPressure=(1.0, 'bar'),
initialGasMoleFractions={
"CH4": 0.15,
"O2": 0.15,
"N2": 0.7,
},
terminationConversion={
'ethane': 0.9,
initialSurfaceCoverages={
"X": 1.0,
},
terminationTime=(1e6,'s'),
surfaceVolumeRatio=(1.e5, 'm^-1'),
terminationConversion = { "CH4": 0.95,},
terminationTime=(0.1, 's'),
terminationRateRatio=0.01,
)



simulator(
atol=1e-16,
rtol=1e-8,
atol=1e-18,
rtol=1e-12,
)

model(
toleranceKeepInEdge=0.0,
toleranceMoveToCore=100.0,
toleranceInterruptSimulation=100.0,
toleranceMoveToCore=1e-1,
toleranceInterruptSimulation=0.1,
maximumEdgeSpecies=100000,
toleranceMoveEdgeReactionToSurface=1.0,
toleranceMoveSurfaceReactionToCore=2.0,
toleranceMoveSurfaceSpeciesToCore=.001,
dynamicsTimeScale=(1.0e-10,'sec'),
)

options(
units='si',
generateOutputHTML=True,
generatePlots=False,
saveEdgeSpecies=True,
saveSimulationProfiles=True,
generateOutputHTML=False,
generatePlots=False, # Enable to make plots of core and edge size etc. But takes a lot of the total runtime!
saveEdgeSpecies=False,
saveSimulationProfiles=False,
)
generatedSpeciesConstraints(
allowed=['input species','reaction libraries'],
maximumCarbonAtoms=2,
maximumOxygenAtoms=2,
maximumSurfaceSites=2,
)


14 changes: 9 additions & 5 deletions rmgpy/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,17 @@ def load(self, path, local_context=None, global_context=None):
local_context[key] = value

# Process the file
f = open(path, 'r')
with open(path, 'r') as f:
content = f.read()
try:
exec(f.read(), global_context, local_context)
except Exception:
logging.error('Error while reading database {0!r}.'.format(path))
exec(content, global_context, local_context)
except Exception as e:
logging.exception(f'Error while reading database file {path}.')
line_number = e.__traceback__.tb_next.tb_lineno
logging.error(f'Error occurred at or near line {line_number} of {path}.')
lines = content.splitlines()
logging.error(f'Line: {lines[line_number - 1]}')
raise
f.close()

# Extract the database metadata
self.name = local_context['name']
Expand Down
Loading

0 comments on commit 08e45d4

Please sign in to comment.