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

Fix ck2yaml problems with surface reactions / coverages #961

Merged
merged 4 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9' ]
os: ['macos-10.15', 'macos-11.0']
os: ['macos-10.15']
fail-fast: false
steps:
# Attempt to fix intermittent cloning errors. The error message says something like
Expand Down
44 changes: 21 additions & 23 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ else:
# InstallVersionedLib only fully functional in SCons >= 2.4.0
# SHLIBVERSION fails with MinGW: http://scons.tigris.org/issues/show_bug.cgi?id=3035
if (env['toolchain'] == 'mingw'
or StrictVersion(SCons.__version__) < StrictVersion('2.4.0')):
or parse_version(SCons.__version__) < parse_version('2.4.0')):
defaults.versionedSharedLibrary = False
else:
defaults.versionedSharedLibrary = True
Expand Down Expand Up @@ -719,12 +719,10 @@ for arg in ARGUMENTS:
print('Encountered unexpected command line argument: %r' % arg)
sys.exit(1)

# Require a StrictVersion-compatible version
env['cantera_version'] = "2.5.0b1"
ctversion = StrictVersion(env['cantera_version'])
# For use where pre-release tags are not permitted (MSI, sonames)
env['cantera_pure_version'] = '.'.join(str(x) for x in ctversion.version)
env['cantera_short_version'] = '.'.join(str(x) for x in ctversion.version[:2])
env['cantera_pure_version'] = re.match(r'(\d+\.\d+\.\d+)', env['cantera_version']).group(0)
env['cantera_short_version'] = re.match(r'(\d+\.\d+)', env['cantera_version']).group(0)

try:
env['git_commit'] = getCommandOutput('git', 'rev-parse', '--short', 'HEAD')
Expand Down Expand Up @@ -1125,17 +1123,17 @@ if env['system_sundials'] == 'y':

# Ignore the minor version, e.g. 2.4.x -> 2.4
env['sundials_version'] = '.'.join(sundials_version.split('.')[:2])
sundials_ver = LooseVersion(env['sundials_version'])
if sundials_ver < LooseVersion('2.4') or sundials_ver >= LooseVersion('6.0'):
sundials_ver = parse_version(env['sundials_version'])
if sundials_ver < parse_version('2.4') or sundials_ver >= parse_version('6.0'):
print("""ERROR: Sundials version %r is not supported.""" % env['sundials_version'])
sys.exit(1)
elif sundials_ver > LooseVersion('5.3'):
elif sundials_ver > parse_version('5.3'):
print("WARNING: Sundials version %r has not been tested." % env['sundials_version'])

print("""INFO: Using system installation of Sundials version %s.""" % sundials_version)

#Determine whether or not Sundials was built with BLAS/LAPACK
if sundials_ver < LooseVersion('2.6'):
if sundials_ver < parse_version('2.6'):
# In Sundials 2.4 / 2.5, SUNDIALS_BLAS_LAPACK is either 0 or 1
sundials_blas_lapack = get_expression_value(['"sundials/sundials_config.h"'],
'SUNDIALS_BLAS_LAPACK')
Expand Down Expand Up @@ -1228,19 +1226,19 @@ if env['VERBOSE']:
env['python_cmd_esc'] = quoted(env['python_cmd'])

# Python Package Settings
python_min_version = LooseVersion('3.5')
python_min_version = parse_version('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_version = LooseVersion('1.12.0')
cython_min_version = parse_version('0.23')
numpy_min_version = parse_version('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')
ruamel_min_version = parse_version('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
Expand Down Expand Up @@ -1332,12 +1330,12 @@ if env['python_package'] != 'none':
warn_no_python = True
else:
warn_no_python = False
python_version = LooseVersion(info[0])
numpy_version = LooseVersion(info[1])
cython_version = LooseVersion(info[2])
python_version = parse_version(info[0])
numpy_version = parse_version(info[1])
cython_version = parse_version(info[2])
if check_for_ruamel_yaml:
ruamel_yaml_version = LooseVersion(info[3])
if ruamel_yaml_version == LooseVersion("0.0.0"):
ruamel_yaml_version = parse_version(info[3])
if ruamel_yaml_version == parse_version("0.0.0"):
print("ERROR: ruamel.yaml was not found. {} or newer is "
"required".format(ruamel_min_version))
sys.exit(1)
Expand Down Expand Up @@ -1377,17 +1375,17 @@ if env['python_package'] != 'none':
print('| ' + '\n| '.join(info[expected_output_lines:]))

warn_no_full_package = False
if python_version >= LooseVersion("3.8"):
if python_version >= parse_version("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
# can do about this, the changes in CPython are handled by Cython. This
# version bump is used to produce a more useful/actionable error message
# for users than the compilation errors that result from using
# Cython < 0.29.12.
cython_min_version = LooseVersion("0.29.12")
cython_min_version = parse_version("0.29.12")

if numpy_version == LooseVersion('0.0.0'):
if numpy_version == parse_version('0.0.0'):
print("NumPy not found.")
warn_no_full_package = True
elif numpy_version < numpy_min_version:
Expand All @@ -1398,7 +1396,7 @@ if env['python_package'] != 'none':
else:
print('INFO: Using NumPy version {0}.'.format(numpy_version))

if cython_version == LooseVersion('0.0.0'):
if cython_version == parse_version('0.0.0'):
print("Cython not found.")
warn_no_full_package = True
elif cython_version < cython_min_version:
Expand Down Expand Up @@ -1699,7 +1697,7 @@ linkSharedLibs = ['cantera_shared']

if env['system_sundials'] == 'y':
env['sundials_libs'] = ['sundials_cvodes', 'sundials_ida', 'sundials_nvecserial']
if env['use_lapack'] and sundials_ver >= LooseVersion('3.0'):
if env['use_lapack'] and sundials_ver >= parse_version('3.0'):
if env.get('has_sundials_lapack'):
env['sundials_libs'].extend(('sundials_sunlinsollapackdense',
'sundials_sunlinsollapackband'))
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if localenv['OS'] == 'Darwin':
# and causes the warnings to appear will be removed in Python 3.9 so no
# further warnings should be issued. Cython has already implemented a fix
# in versions higher than 0.29.14.
if py_version == LooseVersion("3.8"):
if py_version == parse_version("3.8"):
localenv.Append(CXXFLAGS='-Wno-deprecated-declarations')
elif localenv['OS'] == 'Windows':
localenv.Append(LIBPATH=prefix+'/libs')
Expand Down
8 changes: 4 additions & 4 deletions interfaces/cython/cantera/ck2yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def reduce(self, output):
# base reaction
if self.rate.Ea[1] != self.rate.parser.output_energy_units:
E = '{} {}'.format(E, self.rate.Ea[1])
covdeps[species] = FlowList([A, m, E])
covdeps[species] = FlowList([A, m, E])
output['coverage-dependencies'] = covdeps


Expand Down Expand Up @@ -1787,6 +1787,9 @@ def readline():
revReaction.line_number = line_number
reactions.append(revReaction)

for index, reaction in enumerate(reactions):
reaction.index = index + 1

elif tokens[0].upper().startswith('TRAN'):
inHeader = False
line, comment = readline()
Expand Down Expand Up @@ -1819,9 +1822,6 @@ def readline():
for h in header:
self.header_lines.append(h[indent:])

for index, reaction in enumerate(self.reactions):
reaction.index = index + 1

if transportLines:
self.parse_transport_data(transportLines, path, transport_start_line)

Expand Down
6 changes: 6 additions & 0 deletions interfaces/cython/cantera/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ def test_surface_mech2(self):
self.assertEqual(gas.n_reactions, 0)
self.assertEqual(surf.n_reactions, 15)

# Coverage dependencies
covdeps = surf.reaction(1).coverage_deps
self.assertIn('H_Pt', covdeps)
self.assertEqual(covdeps['OH_Pt'][1], 1.0)
self.assertNear(covdeps['H_Pt'][2], -6e6)

def test_third_body_plus_falloff_reactions(self):
self.convert('third_body_plus_falloff_reaction.inp')
gas = ct.Solution('third_body_plus_falloff_reaction' + self.ext)
Expand Down
2 changes: 1 addition & 1 deletion site_scons/buildutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import SCons.Errors
import SCons
import SCons.Node.FS
from distutils.version import LooseVersion, StrictVersion
from pkg_resources import parse_version
import distutils.sysconfig

try:
Expand Down