Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Cantera/cantera into pdep_err
Browse files Browse the repository at this point in the history
  • Loading branch information
12Chao committed Sep 1, 2020
2 parents b3f2d32 + 54d1fd7 commit e5f4b7b
Show file tree
Hide file tree
Showing 49 changed files with 683 additions and 454 deletions.
51 changes: 45 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Upgrade pip
run: python3 -m pip install -U pip setuptools wheel
- name: Install Python dependencies
run: python3 -m pip install ruamel.yaml scons numpy cython h5py
run: python3 -m pip install ruamel.yaml scons numpy cython h5py pandas
- name: Build Cantera
run: python3 `which scons` build -j2
- name: Test Cantera
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Upgrade pip
run: python3 -m pip install -U pip setuptools wheel
- name: Install Python dependencies
run: python3 -m pip install ruamel.yaml scons numpy cython h5py
run: python3 -m pip install ruamel.yaml scons numpy cython h5py pandas
- name: Build Cantera
run: python3 `which scons` build -j2
- name: Test Cantera
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Upgrade pip
run: python3 -m pip install -U pip setuptools wheel
- name: Install Python dependencies
run: python3 -m pip install ruamel.yaml scons numpy cython h5py
run: python3 -m pip install ruamel.yaml scons numpy cython h5py pandas
- name: Build Cantera
run: |
python3 `which scons` build blas_lapack_libs=lapack,blas coverage=y \
Expand Down Expand Up @@ -166,13 +166,52 @@ jobs:
python3-pip python3-setuptools libsundials-serial-dev liblapack-dev \
libblas-dev
- name: Install Python dependencies
# Don't include Pandas here due to install errors
run: |
sudo -H /usr/bin/python3 -m pip install ruamel.yaml cython h5py
- name: Build Cantera
run: scons build python_cmd=/usr/bin/python3 blas_lapack_libs=lapack,blas -j2
- name: Test Cantera
run: scons test

run-examples:
name: Run the Python examples using bash
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
name: Checkout the repository
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: '3.8'
architecture: x64
- name: Install Apt dependencies
run: sudo apt-get install libboost-dev gfortran graphviz liblapack-dev libblas-dev
- name: Upgrade pip
run: python3 -m pip install -U pip setuptools wheel
- name: Install Python dependencies
run: python3 -m pip install ruamel.yaml scons numpy cython h5py pandas matplotlib scipy
- name: Build Cantera
run: python3 `which scons` build -j2
- name: Run the examples
# See https://unix.stackexchange.com/a/392973 for an explanation of the -exec part
run: |
find interfaces/cython/cantera/examples -type f -iname "*.py" \
-exec sh -c 'for n; do echo "$n" | tee -a results.txt && python3 "$n" >> results.txt || exit 1; done' sh {} +
env:
PYTHONPATH: build/python
PYTHONWARNINGS: error
MPLBACKEND: Agg
- name: Save the results file for inspection
uses: actions/upload-artifact@v2
with:
path: results.txt
# Run this step if the job was successful or failed, but not if it was cancelled
# Using always() would run this step if the job was cancelled as well.
if: failure() || success()

multiple-sundials:
name: Sundials ${{ matrix.sundials-ver }}
runs-on: ubuntu-latest
Expand All @@ -196,7 +235,7 @@ jobs:
shell: bash -l {0}
run: |
conda install -q sundials=${{ matrix.sundials-ver}} scons numpy ruamel_yaml \
cython libboost fmt eigen yaml-cpp h5py
cython libboost fmt eigen yaml-cpp h5py pandas
- name: Build Cantera
run: |
scons build extra_inc_dirs=$CONDA_PREFIX/include:$CONDA_PREFIX/include/eigen3 \
Expand Down Expand Up @@ -226,7 +265,7 @@ jobs:
run: python3 -m pip install -U pip setuptools wheel
- name: Install Python dependencies
run: |
python3 -m pip install ruamel.yaml scons numpy h5py;
python3 -m pip install ruamel.yaml scons numpy h5py pandas;
python3 -m pip install https://github.com/cython/cython/archive/master.zip --install-option='--no-cython-compile';
- name: Build Cantera
run: python3 `which scons` build blas_lapack_libs=lapack,blas python_package='full' -j2
Expand Down Expand Up @@ -270,7 +309,7 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install scons pypiwin32 numpy ruamel.yaml cython h5py
python -m pip install scons pypiwin32 numpy ruamel.yaml cython h5py pandas
- name: Build Cantera
run: |
scons build -j2 boost_inc_dir=%BOOST_ROOT_1_69_0% debug=n VERBOSE=y python_package=full ^
Expand Down
105 changes: 80 additions & 25 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1229,9 +1229,26 @@ env['python_cmd_esc'] = quoted(env['python_cmd'])

# Python Package Settings
python_min_version = LooseVersion('3.5')
# The string is used to set python_requires in setup.py.in
env['py_min_ver_str'] = str(python_min_version)
# Note: cython_min_version is redefined below if the Python version is 3.8 or higher
cython_min_version = LooseVersion('0.23')
numpy_min_test_version = LooseVersion('1.8.1')
numpy_min_version = LooseVersion('1.12.0')

# We choose ruamel.yaml 0.15.34 as the minimum version
# since it is the highest version available in the Ubuntu
# 18.04 repositories and seems to work. Older versions such as
# 0.13.14 on CentOS7 and 0.10.23 on Ubuntu 16.04 raise an exception
# that they are missing the RoundTripRepresenter
ruamel_min_version = LooseVersion('0.15.34')

# Check for the minimum ruamel.yaml version, 0.15.34, at install and test
# time. The check happens at install and test time because ruamel.yaml is
# only required to run the Python interface, not to build it.
check_for_ruamel_yaml = any(
target in COMMAND_LINE_TARGETS
for target in ["install", "test", "test-python-convert"]
)

# Handle the version-specific Python package options
python_options = (('package', 'default'),
Expand Down Expand Up @@ -1281,6 +1298,25 @@ if env['python_package'] != 'none':
if err:
print(err)
""")
expected_output_lines = 3
if check_for_ruamel_yaml:
ru_script = textwrap.dedent("""\
try:
import ruamel_yaml as yaml
print(yaml.__version__)
except ImportError as ru_err:
try:
from ruamel import yaml
print(yaml.__version__)
except ImportError as ru_err_2:
print('0.0.0')
err += str(ru_err) + '\\n'
err += str(ru_err_2) + '\\n'
""").splitlines()
s = script.splitlines()
s[-2:-2] = ru_script
script = "\n".join(s)
expected_output_lines = 4

try:
info = getCommandOutput(env['python_cmd'], '-c', script).splitlines()
Expand All @@ -1299,6 +1335,22 @@ if env['python_package'] != 'none':
python_version = LooseVersion(info[0])
numpy_version = LooseVersion(info[1])
cython_version = LooseVersion(info[2])
if check_for_ruamel_yaml:
ruamel_yaml_version = LooseVersion(info[3])
if ruamel_yaml_version == LooseVersion("0.0.0"):
print("ERROR: ruamel.yaml was not found. {} or newer is "
"required".format(ruamel_min_version))
sys.exit(1)
elif ruamel_yaml_version < ruamel_min_version:
print("ERROR: ruamel.yaml is an incompatible version: Found "
"{}, but {} or newer is required.".format(
ruamel_yaml_version, ruamel_min_version))
sys.exit(1)

if len(info) > expected_output_lines:
print("WARNING: Unexpected output while checking Python "
"dependency versions:")
print('| ' + '\n| '.join(info[expected_output_lines:]))

if warn_no_python:
if env['python_package'] == 'default':
Expand All @@ -1309,20 +1361,18 @@ if env['python_package'] != 'none':
print('ERROR: Could not execute the Python interpreter {!r}'.format(
env['python_cmd']))
sys.exit(1)
elif env['python_package'] == 'minimal':
print('INFO: Building the minimal Python package for Python {}'.format(python_version))
elif python_version < python_min_version:
msg = ("{}: Python version is incompatible. Found {} but {} "
"or newer is required")
if env["python_package"] in ("minimal", "full"):
print(msg.format("ERROR", python_version, python_min_version))
sys.exit(1)
elif env["python_package"] == "default":
print(msg.format("WARNING", python_version, python_min_version))
env["python_package"] = "none"
else:
warn_no_full_package = False
if len(info) > 3:
print("WARNING: Unexpected output while checking Python / Numpy / Cython versions:")
print('| ' + '\n| '.join(info[3:]))

if python_version < python_min_version:
print("WARNING: Python version is incompatible with the full Python module: "
"Found {0} but {1} or newer is required".format(
python_version, python_min_version))
warn_no_full_package = True
elif python_version >= LooseVersion("3.8"):
if python_version >= LooseVersion("3.8"):
# Reset the minimum Cython version if the Python version is 3.8 or higher
# Due to internal changes in the CPython API, more recent versions of
# Cython are necessary to build for Python 3.8. There is nothing Cantera
Expand All @@ -1335,10 +1385,11 @@ if env['python_package'] != 'none':
if numpy_version == LooseVersion('0.0.0'):
print("NumPy not found.")
warn_no_full_package = True
elif numpy_version < numpy_min_test_version:
print("WARNING: The installed version of Numpy is not tested and "
"support is not guaranteed. Found {0} but {1} or newer is preferred".format(
numpy_version, numpy_min_test_version))
elif numpy_version < numpy_min_version:
print("WARNING: NumPy is an incompatible version: "
"Found {0} but {1} or newer is required".format(
numpy_version, numpy_min_version))
warn_no_full_package = True
else:
print('INFO: Using NumPy version {0}.'.format(numpy_version))

Expand All @@ -1348,20 +1399,20 @@ if env['python_package'] != 'none':
elif cython_version < cython_min_version:
print("WARNING: Cython is an incompatible version: "
"Found {0} but {1} or newer is required.".format(
cython_version, cython_min_version))
cython_version, cython_min_version))
warn_no_full_package = True
else:
print('INFO: Using Cython version {0}.'.format(cython_version))

if warn_no_full_package:
msg = ('{}: Unable to build the full Python package because compatible '
'versions of Python, Numpy, and Cython could not be found.')
if env['python_package'] == 'default':
print('WARNING: Unable to build the full Python package because compatible '
'versions of Python, Numpy, and Cython could not be found.')
print(msg.format("WARNING"))
print('INFO: Building the minimal Python package for Python {}'.format(python_version))
env['python_package'] = 'minimal'
else:
print('ERROR: Unable to build the full Python package because compatible '
'versions of Python, Numpy, and Cython could not be found.')
print(msg.format("ERROR"))
sys.exit(1)
else:
print('INFO: Building the full Python package for Python {0}'.format(python_version))
Expand Down Expand Up @@ -1410,6 +1461,7 @@ env['debian'] = any(name.endswith('dist-packages') for name in sys.path)

# Directories where things will be after actually being installed. These
# variables are the ones that are used to populate header files, scripts, etc.
env['prefix'] = os.path.normpath(env['prefix'])
env['ct_installroot'] = env['prefix']
env['ct_libdir'] = pjoin(env['prefix'], env['libdirname'])
env['ct_bindir'] = pjoin(env['prefix'], 'bin')
Expand Down Expand Up @@ -1781,15 +1833,18 @@ def postInstallMessage(target, source, env):
""".format(**env_dict))

if os.name != 'nt':
env['setup_cantera'] = pjoin(env['ct_bindir'], 'setup_cantera')
env['setup_cantera_csh'] = pjoin(env['ct_bindir'], 'setup_cantera.csh')
install_message += textwrap.dedent("""
Setup scripts to configure the environment for Cantera are at:
setup script (bash) {ct_bindir!s}/setup_cantera
setup script (csh/tcsh) {ct_bindir!s}/setup_cantera.csh
setup script (bash) {setup_cantera!s}
setup script (csh/tcsh) {setup_cantera_csh!s}
It is recommended that you run the script for your shell by typing:
source {ct_bindir!s}/setup_cantera
source {setup_cantera!s}
before using Cantera, or else include its contents in your shell login script.
""".format(**env_dict))
Expand Down
28 changes: 14 additions & 14 deletions data/sofc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: |-
species thermochemistry ARE NOT REAL VALUES - they are chosen only
for the purposes of this example.
Defines bulk (i.e., 3D) phases - a gas, a metal, and an oxide.
Defines bulk (that is, 3D) phases - a gas, a metal, and an oxide.
The gas contains only the minimum number of species needed to model
operation on hydrogen. The species definitions are imported from
gri30.yaml. The initial composition is set to hydrogen + 5% water, but
Expand All @@ -26,22 +26,22 @@ description: |-
charge balances on the metal, then we would require a more complex
model. Note that there is no work function for this metal.
Note: the "const_cp" species thermo model is used throughout this
Note: the 'const_cp' species thermo model is used throughout this
file (with the exception of the gaseous species, which use NASA
polynomials imported from gri30.cti). The const_cp model assumes a
polynomials imported from gri30.yaml). The const_cp model assumes a
constant specific heat, which by default is zero. Parameters that
can be specified are cp0, t0, h0, and s0. If omitted, t0 = 300 K, h0
= 0, and s0 = 0. The thermo properties are computed as follows: h =
h0 + cp0*(t - t0), s = s0 + cp0*ln(t/t0). For work at a single
temperature, it is sufficient to specify only h0.
can be specified are cp0, t0, h0, and s0. If omitted, t0 = 300 K,
h0 = 0, and s0 = 0. The thermo properties are computed as follows:
h = h0 + cp0*(t - t0), s = s0 + cp0*ln(t/t0).
For work at a single temperature, it is sufficient to specify only h0.
The 'oxide_bulk' phase is a very simple model for the bulk phase. We only
consider the oxygen sublattice. The only species we define are a
lattice oxygen, and an oxygen vacancy. Again, the density is a
required input, but is not used here, so may be set arbitrarily.
The vacancy will be modeled as truly vacant - it contains no atoms,
has no charge, and has zero enthalpy and entropy. This is different
has no charge, and has zero enthalpy and entropy. This is different
from the usual convention in which the vacancy properties are are
expressed relative to the perfect crystal lattice. For example, in
the usual convention, an oxygen vacancy has charge +2. But the
Expand All @@ -65,7 +65,7 @@ description: |-
'mol' and 'cm' were specified in the units directive below as the
units for quantity and length, respectively.
2. The 'reactions' field specifies that all reaction entries in this file
that have are in the 'metal_surface-reactions' field are reactions belonging
that are in the 'metal_surface-reactions' field are reactions belonging
to this surface mechanism.
On the oxide surface, we consider four species:
Expand All @@ -74,11 +74,11 @@ description: |-
3. OH'(ox) - a surface hydroxyl with charge -1
4. H2O(ox) - physisorbed neutral water
The 'tpb' phase is th etriple phase boundary between the metal, oxide, and gas. A
single species is specified, but it is not used, since all reactions
only involve species on either side of the tpb. Note that the site
density is in mol/cm. But since no reactions involve TPB species,
this parameter is unused.
The triple phase boundary (TPB) between the metal, oxide, and gas is
specified in the 'tpb' phase. A single species is specified, but it
is not used, since all reactions only involve species on either side
of the TPB. Note that the site density is in mol/cm. But since no
reactions involve TPB species, this parameter is unused.
generator: cti2yaml
cantera-version: 2.5.0a3
Expand Down
4 changes: 2 additions & 2 deletions include/cantera/base/AnyMap.inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const T &AnyValue::as() const {
if (m_value->type() == typeid(void)) {
// Values that have not been set are of type 'void'
throw InputFileError("AnyValue::as", *this,
"Key '{}' not found", m_key);
"Key '{}' not found or contains no value", m_key);
} else {
throw InputFileError("AnyValue::as", *this,
"Key '{}' contains a '{}',\nnot a '{}'",
Expand All @@ -48,7 +48,7 @@ T &AnyValue::as() {
if (m_value->type() == typeid(void)) {
// Values that have not been set are of type 'void'
throw InputFileError("AnyValue::as", *this,
"Key '{}' not found", m_key);
"Key '{}' not found or contains no value", m_key);
} else {
throw InputFileError("AnyValue::as", *this,
"Key '{}' contains a '{}',\nnot a '{}'",
Expand Down
4 changes: 2 additions & 2 deletions include/cantera/kinetics/RateCoeffMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class Rate1

/**
* Update the concentration-dependent parts of the rate coefficient, if any.
* Used by class SurfaceArrhenius to compute coverage-dependent *
* Used by class SurfaceArrhenius to compute coverage-dependent
* modifications to the Arrhenius parameters. The array c should contain
* whatever data the particular rate coefficient class needs to update its
* rates. Note that this method does not return anything. To get the
* rates. Note that this method does not return anything. To get the
* updated rates, method update must be called after the call to update_C.
*/
void update_C(const doublereal* c) {
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/kinetics/RxnRates.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class SurfaceArrhenius
}

/**
* Update the value the rate constant.
* Update the value of the rate constant.
*
* This function returns the actual value of the rate constant. It can be
* safely called for negative values of the pre-exponential factor.
Expand Down
Loading

0 comments on commit e5f4b7b

Please sign in to comment.