Compare commits

...

52 commits

Author SHA1 Message Date
Ray Speth
92d17b5feb [Doc] Update branch in git checkout instructions to 2.2 2016-01-28 15:37:38 -05:00
Ray Speth
d7b1216f56 [Reactor] Fix null pointer dereference in FlowDevice::install
Taking the address of a dereferenced null pointer is still undefined
behavior. This was causing the test TestReactor.test_valve_errors to fail on
some versions of OS X.
2016-01-28 15:26:36 -05:00
Ray Speth
d35f6ab6f2 Bump version to 2.2.1 2016-01-26 14:09:51 -05:00
Ray Speth
3043a5d872 Fix indexing error in ImplicitSurfChem::eval
This method was not working in the case where there was more than one surface
phase, since 'loc' was always set to zero.
2016-01-25 18:39:47 -05:00
Ray Speth
e805d4d9ad Fix LD_LIBRARY_PATH order when running tests
build/lib needs to be first in case LD_LIBRARY_PATH contains another Cantera
installation.

Resolves #310.
2016-01-25 18:39:29 -05:00
Bryan W. Weber
8d1f374fc7 [Doc] Add link to Working with Input Files section 2016-01-25 18:39:16 -05:00
Bryan W. Weber
2b2b0947ec [Doc] Update docs for ck2cti
Update documentation to give short tutorial and reflect most recent
version. Add notes for common errors encountered. Remove old ck2cti
docs from Matlab and Cython interface documentation, prefering
cti/input-files.rst. Resolves #295.
2016-01-25 18:39:01 -05:00
Ray Speth
4c23fc2d1d [Python] Fix full-state (e.g. TPX) properties of PureFluid
The implementations which come from ThermoPhase expect "X" to mean mole
fractions, but for PureFluid "X" means vapor fraction. No setter is provided
since all three properties cannot be specified simultaneously.

Resolves #307
2016-01-25 18:35:35 -05:00
Bryan W. Weber
8b5271e6ea [SCons] Fix Cantera.mak cannot be written if extra_inc_dirs or extra_lib_dirs is specified 2016-01-25 18:35:03 -05:00
Bryan W. Weber
f51bb43f96 [Doc] Recommend to use pip to install optional Python packages on Ubuntu 2016-01-25 18:33:53 -05:00
Bryan W. Weber
e2fc2ce6f2 [Doc] Update Homebrew install instructions.
Update the Homebrew install instructions with a recommendation on how to install the Matlab toolbox and add additional options that are supported during the install process.
2016-01-25 18:33:03 -05:00
Ray Speth
3334a5ffb5 [Transport] Fix segfault when species transport data is missing
Resolves #312.
2015-11-23 10:59:11 -05:00
Ivan Mitrichev
163e4e638a Cython minimum version is 0.19
Resolves #302.
2015-10-25 14:19:51 -04:00
Ray Speth
2402505ffb [Doc] Mention IPython and Matplotlib in installation instructions 2015-10-24 20:36:04 -04:00
Ray Speth
ccb07ef853 [Doc] Mention '--with-python3' option for Homebrew installer 2015-10-24 20:35:57 -04:00
Bryan W. Weber
cc8ada13f4 [Doc] Correct docs for setState_*sat in Matlab
Correct the documentation to clarify that a vector must be passed in to
these functions, not a single value.
2015-10-24 20:35:51 -04:00
Bryan W. Weber
7489c2f1f7 [Matlab] Fix setState_sat*.m functions
Fix the setState_satLiquid and setState_satVapor functions so that they call the main set
method instead of the underlying C++ layer. Resolves #299.
2015-10-24 20:35:42 -04:00
Ray Speth
000cdb3934 [Doc] Add link to guidelines for creating good examples for bug reports 2015-10-24 20:33:13 -04:00
Ray Speth
99b3e7ea1b [Python] Fix handling of bad input to 'stringify'
Cases where a string is required but a non-string is provided will now generate
an exception instead of substituting the empty string.
2015-10-24 20:32:42 -04:00
Ray Speth
7308491654 [Test] Fix csv test comparisons to work with Numpy 1.10
Drop support for Numpy 1.3 (which lacks the skip_header argument to genfromtxt).
2015-10-24 20:30:55 -04:00
Ray Speth
051b9d1f51 [Test] Fix deprecation warnings in Python tests
This also fixes support for Numpy 1.10, which removes the 'skiprows' keyword.
2015-10-24 20:30:19 -04:00
Ray Speth
035c6d4ca1 [Doc] Add Doxygen docstrings for wrapper classes
Without at least a basic docstring, these classes are excluded from the Doxygen
documentation.
2015-10-24 20:26:12 -04:00
Ray Speth
4d643d05dc Bump version number to 2.2.1b1 for in-progress maintenance release
Leave documentation marked as 2.2.0 so we can continue to post minor updates
before 2.2.1 is finalized.
2015-10-24 20:16:25 -04:00
Ray Speth
e6dce9d80e [Matlab] Fix error handling for nAtoms to avoid false positives
Species can have negative "atoms" of an "element" in the case where the element
is an electron and the species is a positive ion.
2015-09-09 18:59:19 -04:00
Ray Speth
240079cb64 [Test] Fix compilation errors with VS2015 2015-09-09 18:59:19 -04:00
Ray Speth
9149089e08 Fix a compilation error when using '-std=c++11' 2015-09-09 18:59:19 -04:00
Ray Speth
2d2ad00777 [Test] Fix error in test comparison when numbers disappear 2015-09-09 18:59:19 -04:00
Ray Speth
205d073399 [Thermo] Prevent setting thermodynamic state variables to NaN
Throwing an exception when a state variable is being set to NaN transforms some
reactor network integration errors from unrecoverable errors into recoverable
errors.
2015-09-09 18:59:19 -04:00
Ray Speth
3662ccdacf [Python] Prevent renaming of Python extension module
In Cygwin, some versions of SCons append a 'cyg' prefix to DLL names, which
breaks the Python extension module that is supposed to be named just
'_cantera.dll'.
2015-09-09 18:59:19 -04:00
Ray Speth
a116ef675e [Thermo] Fix IdealGasPhase constructor from XML_Node 2015-09-09 18:59:19 -04:00
Ray Speth
ffb703ecfd Fix multiprocessing example when using Python 3
In Python 3, 'map' returns an object which evalutes the function as it is
consumed, not when 'map' is called. Therefore, the correct comparison to
pool.map(...) is list(map(...)).
2015-09-09 18:59:19 -04:00
Ray Speth
a79ee8e07a Fix multiprocessing example to actually get the indicated property 2015-09-09 18:59:19 -04:00
Bryan W. Weber
7d2e3813eb Fix syntax error in a Python example 2015-09-09 18:59:19 -04:00
Ray Speth
6d4540435e Fix pointer logic errors in initThermoXML
Affects DebyeHuckel and HMWSoln
2015-09-09 18:59:19 -04:00
Ray Speth
c0772d236a [Doc] Fix typos in NASA polynomial formulas 2015-09-09 18:59:19 -04:00
Ray Speth
4b7e058b43 [Reactor] Cannot add sensitivity reactions to initialized ReactorNet
Before, the attempt to add the reaction was silently ignored. Now, this raises
an exception.
2015-09-09 18:59:18 -04:00
Ray Speth
2044446bc3 [Samples] Fix compilation errors and warnings in the C++ examples 2015-09-09 18:59:18 -04:00
Ray Speth
6e77e3417f Fix incorrect index check in GeneralSpeciesThermo::reportParams
The SpeciesThermoInterpType no longer knows the species index, so
it isn't actually returned by the reportParameters function.
2015-09-09 18:59:18 -04:00
Ray Speth
c69889b4bc Remove link to old dev list 2015-09-09 18:59:18 -04:00
Ray Speth
832cf99927 Fix definition of elemental mole fraction
The elemental mole fractions should be invariant under composition changes which
conserve atoms.
2015-09-09 18:59:18 -04:00
Ray Speth
479a9da0bd [Python/1D] Fix FlameBase.write_csv
Also add a test for this method
2015-09-09 18:59:18 -04:00
Ray Speth
07257443e3 Fix race condition when Python 2 and Python 3 tests run in parallel 2015-09-09 18:59:18 -04:00
Ray Speth
774ec21d97 [Reactor] Add bounds check on sensitivity parameter index 2015-09-09 16:32:31 -04:00
Ray Speth
98c2aa82e7 [SCons] Fix include order when compiling Cython module 2015-09-09 16:32:02 -04:00
Ray Speth
5597d1e374 [Doc] Fix typo in Planck constant units
Fixes #280.
2015-07-01 12:04:58 -04:00
Ray Speth
4dc4a14467 [Doc] Update list of SCons options shown in Sphinx docs 2015-07-01 00:16:28 -04:00
Ray Speth
5a23dab3b8 Fix user-provided BLAS/LAPACK dir in Cantera.mak
Fixes an error introduced in 5720d7cf90.
2015-06-30 23:26:18 -04:00
Ray Speth
bd927d438a [SCons] Fix BLAS/LAPACK-related variables in Cantera.mak
* Fix logic for when BLAS/LAPACK libraries need to be explicitly listed
* ctlapack and ctblas are no longer separate libraries
2015-06-22 17:33:17 -04:00
Ray Speth
d0c62ada84 [Kinetics] Fix handling of integral, explicit reaction orders
If any of the reaction orders differ from the corresponding stoichiometric
coefficients, the reaction needs to be handled as the general case, instead of
just when the orders are non-integral.
2015-06-22 12:11:42 -04:00
Ray Speth
2aec189ddc [Reactor] Check for Reactor contents before installing FlowDevice
Fixes #279.
2015-06-22 12:11:29 -04:00
Ray Speth
c5bc4d3412 [Reactor] Fix segfaults in updateMassFlowRate due to unset parameters
The downstream and upstream Reactors, the "master" flow controller, and the
coefficient arrays were being read without checking that they had been
initialized.

Fixes #278.
2015-06-22 12:11:09 -04:00
Ray Speth
02a5409732 Add build script for Travis CI 2015-06-10 19:43:23 -04:00
89 changed files with 808 additions and 302 deletions

7
.travis.yml Normal file
View file

@ -0,0 +1,7 @@
language: cpp
before_script:
- sudo apt-get update -qq
- sudo apt-get install -y python-dev python-numpy-dev cython gfortran libsundials-serial-dev liblapack-dev libblas-dev libboost-thread-dev python3-dev python3-numpy-dev
script:
- scons build VERBOSE=y blas_lapack_libs=lapack,blas build_thread_safe=y boost_thread_lib=boost_thread optimize=n
- scons test

View file

@ -3,7 +3,7 @@
CANTERA
*******
Version 2.2.0 (stable)
Version 2.2.1 (stable)
License Information
===================
@ -45,9 +45,3 @@ Web Resources
http://groups.google.com/group/cantera-users
This site has a message board for discussions amongst Cantera users.
5. *The Cantera Developers Group*
http://groups.google.com/group/cantera-dev
Limited access site where developers can discuss development ideas.

View file

@ -590,7 +590,7 @@ config_options = [
with a prefix like '/opt/cantera'. 'debian' installs to the stage
directory in a layout used for generating Debian packages.""",
defaults.fsLayout, ('standard','compact','debian')),
('cantera_version', '', '2.2.0')
('cantera_version', '', '2.2.1')
]
opts.AddVariables(*config_options)
@ -929,7 +929,7 @@ if env['VERBOSE']:
env['python_cmd_esc'] = quoted(env['python_cmd'])
# Python 2 Package Settings
cython_min_version = LooseVersion('0.17')
cython_min_version = LooseVersion('0.19')
env['install_python2_action'] = ''
if env['python_package'] == 'new':
env['python_package'] = 'full' # Allow 'new' as a synonym for 'full'

View file

@ -34,7 +34,7 @@ PROJECT_NAME = Cantera
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 2.2
PROJECT_NUMBER = 2.2.1
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

View file

@ -42,7 +42,7 @@ Linux
* Checking out the source code from version control requires Git (install
``git``).
* The minimum compatible Cython version is 0.17. If your distribution does not
* The minimum compatible Cython version is 0.19. If your distribution does not
contain a suitable version, you may be able to install a more recent version
using `easy_install` or `pip`.
@ -94,7 +94,7 @@ OS X
and agree to the Xcode license agreement
* If you don't have numpy version >= 1.3, you can install a recent version with::
* If you don't have numpy version >= 1.4, you can install a recent version with::
sudo easy_install -U numpy
@ -126,7 +126,7 @@ Stable Release
git clone https://github.com/Cantera/cantera.git
cd cantera
git checkout 2.1
git checkout 2.2
Development Version
-------------------
@ -437,13 +437,12 @@ Optional Programs
* Required to build the Cantera Python module, and to run significant portions
of the test suite.
* http://sourceforge.net/projects/numpy/
* Known to work with versions 1.7 and 1.8; Expected to work with version >= 1.3
* Known to work with versions 1.7-1.9; Expected to work with version >= 1.4
* `Cython <http://cython.org/>`_
* Required to build the Python module
* Known to work with versions 0.19 and 0.20. Expected to work with
versions >= 0.17.
* Required version >=0.19 to build the Python module
* Known to work with versions 0.19 and 0.20.
* Tested with Python 2.7, 3.3, and 3.4. Expected to work with versions 2.6 and
3.1+ as well.

View file

@ -86,7 +86,7 @@ copyright = u'2012, Cantera Developers'
# The short X.Y version.
version = '2.2'
# The full version, including alpha/beta/rc tags.
release = '2.2.0'
release = '2.2.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View file

@ -487,3 +487,221 @@ importing any species that contain undeclared elements, instead of flagging them
as errors. You can also specify that reactions containing undeclared species
(also usually an error) should be skipped. This allows you to very easily
extract a portion of a large reaction mechanism, as described in :ref:`sec-phase-options`.
.. _sec-ck-format-conversion:
Converting CK-format files
--------------------------
Many existing reaction mechanism files are in "CK format," by which we mean
the input file format developed for use with the Chemkin-II software package
as specified in the report describing the Chemkin software [SAND89]_.
Cantera comes with a converter utility program ``ck2cti`` (or ``ck2cti.py``)
that converts CK format into Cantera format. This program should be run from
the command line first to convert any CK files you plan to use into Cantera
format (CTI format).
Usage::
ck2cti [--input=<filename>]
[--thermo=<filename>]
[--transport=<filename>]
[--id=<phase-id>]
[--output=<filename>]
[--permissive]
[-d | --debug]
Each of the terms in square brackets is an option that can be passed on the
command line to ``ck2cti``. ``--input`` is the chemistry input file, containing
a list of all the element names that are used, a list of all the species names,
and a list of all the reactions to be considered between the species. This file
can also optionally contain thermodynamic information for the species. If the
``--input`` file does not contain the thermodynamic data, a separate file
containing this information must be specified to the `--thermo`` option. Finally,
the ``--input`` file can also optionally contain transport information for the
species. If it does not, and the user wishes to use a part of Cantera that relies
on some transport properties, the ``--transport`` option must be used to specify
the file containing all the transport data for the species.
Example::
ck2cti --input=chem.inp --thermo=therm.dat --transport=tran.dat
If the output file name is not given, an output file with the same name as the
input file, with the extension changed to '.cti'.
An input file containing only species definitions (which can be referenced from
phase definitions in other input files) can be created by specifying only a
thermo file.
Many existing CK format files cause errors in ``ck2cti`` when they are
processed. Some of these errors may be avoided by specifying the
``--permissive`` option. This option allows certain recoverable parsing errors
(e.g. duplicate transport or thermodynamic data) to be ignored. Other errors
may be caused by incorrect formatting of lines in one or more of the input files.
Debugging common errors in CK files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When ``ck2cti`` encounters an error, it attempts to print the surrounding
information to help you to locate the error. Many of the most common errors
are due to an inconsistency of the input files from their standard, as defined
in the report for Chemkin referenced above. These errors include:
* Each section of the input files must be started with a keyword representing that
section and ending with the keyword ``END``. Keywords that may begin a section
include:
- ``ELEMENTS`` or ``ELEM``
- ``SPECIES`` or ``SPEC``
- ``THERMO`` or ``THERMO ALL``
- ``REACTIONS`` or ``REAC``
- ``TRANSPORT``
* The thermodynamic data is read in a fixed format. This means that each
column of the input has a particular meaning. *Many common errors are
generated because information is missing or in the wrong column. Check
thoroughly for extraneous or missing spaces.* The format for each
thermodynamic entry should be as follows::
N2 N 2 G200.000 6000.000 1000.00 1
2.95258000E+00 1.39690000E-03-4.92632000E-07 7.86010000E-11-4.60755000E-15 2
-9.23949000E+02 5.87189000E+00 3.53101000E+00-1.23661000E-04-5.02999000E-07 3
2.43531000E-09-1.40881000E-12-1.04698000E+03 2.96747000E+00 4
The following table is adapted from the Chemkin manual [SAND89]_ to describe the
column positioning of each required part of the entry. Empty columns should be
filled with spaces.
+---------+-------------------------------------+--------+
|Line No. | Contents | Column |
+=========+=====================================+========+
| 1 | Species Name | 1--18 |
+---------+-------------------------------------+--------+
| 1 | Date (Optional) | 19--24 |
+---------+-------------------------------------+--------+
| 1 | Atomic Symbols and formula | 25--44 |
+---------+-------------------------------------+--------+
| 1 | Phase of species (S, L, G) | 45 |
+---------+-------------------------------------+--------+
| 1 | Low temperature | 46--55 |
+---------+-------------------------------------+--------+
| 1 | High temperature | 56--65 |
+---------+-------------------------------------+--------+
| 1 | Common temperature | 66--73 |
+---------+-------------------------------------+--------+
| 1 | Additional Atomic Symbols | 74--78 |
+---------+-------------------------------------+--------+
| 1 | The integer ``1`` | 80 |
+---------+-------------------------------------+--------+
| 2 | Coefficients :math:`a_1` | 1--75 |
| | to :math:`a_5` for the upper | |
| | temperature interval | |
+---------+-------------------------------------+--------+
| 2 | The integer ``2`` | 80 |
+---------+-------------------------------------+--------+
| 3 | Coefficients :math:`a_6,\ a_7` | 1--75 |
| | for the upper temperature interval, | |
| | and :math:`a_1,\ a_2,\ a_3` for | |
| | the lower temperature interval | |
+---------+-------------------------------------+--------+
| 3 | The integer ``3`` | 80 |
+---------+-------------------------------------+--------+
| 4 | Coefficients :math:`a_4` through | 1--60 |
| | :math:`a_7` for the lower | |
| | temperature interval | |
+---------+-------------------------------------+--------+
| 4 | The integer ``4`` | 80 |
+---------+-------------------------------------+--------+
The first 18 columns are reserved for the species name. The name assigned
to the species in the thermodynamic data must be the same as the species
name defined in the ``SPECIES`` section. If the species name is shorter
than 18 characters, the rest of the characters should be filled by spaces.
The next six columns (columns 19--24) are typically used to write a date;
they are not used further. The next 20 columns (25--44) are used to
specify the elemental composition of the species. In column 45, the phase
of the species (``S``, ``L``, or ``G`` for solid, liquid, or gas
respectively) should be specified. The next 28 columns are reserved for
the temperatures that delimit the ranges of the polynomials specified on
the next several lines. The first two temperatures have a width of 10
columns each (46--55 and 56--65), and represent the lowest temperature and
highest temperature for which the polynomials are valid. The last
temperature has a width of 8 columns (66--73) and is the "common"
temperature, where the switch from low to high occurs. The next 5 columns
(74--78) are reserved for atomic symbols and are usually left blank for
the default behavior. Column 79 is blank and finally, the row is ended in
column 80 with the integer ``1``.
The next three lines of the thermodynamic entry have a similar format.
They contain the coefficients of the polynomial described in
:ref:`sec-thermo-models` for the NASA 7-coefficient polynomial formulation.
The second row of the thermo entry (the first after the information row)
contains the first five coefficients that apply the the temperature range
between the midpoint and the upper limit. 15 columns are alloted for each
coefficient (for a total of 75 columns), with no spaces between them.
Although the entry above shows spaces between positive coefficients, it is
to be noted that this is done only for formatting consistency with other
lines that contain negative numbers. After the coefficients, four spaces
in columns 76--79 are followed by the integer ``2`` in column 80. On the
next line, the last two coefficients for the upper temperature range and
the first three coefficients for the lower temperature range are
specified. Once again, this takes up the first 75 columns, columns 76--79
are blank, and the integer ``3`` is in column 80. Finally, on the last
line of a particular entry, the last four coefficients of the lower
temperature range are specified in columns 1--60, 19 blank spaces are
present, and the integer ``4`` is in column 80. The 19 blank spaces in the
last line are part of the standard. However, since the original Chemkin
interpreter ignored those spaces, researchers began using that space to
store additional information that was not necessary for the input file.
Although these numbers create an error in ``ck2cti`` if present, they are
harmless and can be ignored by using the ``--permissive`` option.
* It may be the case that scientific formatted numbers are missing the ``E``.
In this case, numbers often show up as ``1.1+01``, when they should be
``1.1E+01``. You can fix this with a simple Regular Expression find and
replace::
Find: (\d+\.\d+)([+-]\d+)
Replace: \1E\2
* The transport data file also has a specified format, as described in
[SAND98]_, although the format is not as strict as for the thermodynamic
entries. In particular, the first 15 columns of a line are reserved for
the species name. *One common source of errors is a species that is present
in the transport data file, but not in the thermodynamic data or in
the species list; or a species that is present in the species list but
not the transport data file.* The rest of the columns on a given line have
no particular format, but must be present in the following order:
+------------------+------------------------------------------------------+
| Parameter Number | Parameter Name |
+==================+======================================================+
| 1 | An integer with value 0, 1, or 2 indicating |
| | monatomic, linear, or non-linear molecular geometry. |
+------------------+------------------------------------------------------+
| 2 | The Lennerd-Jones potential well depth |
| | :math:`\varepsilon/k_B` in Kelvin |
+------------------+------------------------------------------------------+
| 3 | The Lennerd-Jones collision diameter :math:`\sigma` |
| | in Angstrom |
+------------------+------------------------------------------------------+
| 4 | The dipole moment :math:`\mu` in Debye |
+------------------+------------------------------------------------------+
| 5 | The polarizability :math:`\alpha` in Angstrom |
+------------------+------------------------------------------------------+
| 6 | The rotational relaxation collision number |
| | :math:`Z_{rot}` at 298 K |
+------------------+------------------------------------------------------+
Another common error is if all 6 of these numbers are not present for every
species.
.. [SAND89] See R. J. Kee, F. M. Rupley, and J. A. Miller, Sandia National
Laboratories Report SAND89-8009 (1989).
http://www.osti.gov/scitech/biblio/5681118
.. [SAND98] See R. J. Kee, G. Dixon-Lewis, J. Warnatz, M. E. Coltrin, J. A. Miller,
H. K. Moffat, Sandia National Laboratories Report SAND86-8246B (1998).

View file

@ -141,9 +141,9 @@ polynomial:
\frac{c_p^0(T)}{R} = a_0 + a_1 T + a_2 T^2 + a_3 T^3 + a_4 T^4
\frac{h^0(T)}{RT} = a_0 + \frac{a1}{2}T + \frac{a_2}{3} T^2 +
\frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + a_5
\frac{a_3}{4} T^3 + \frac{a_4}{5} T^4 + \frac{a_5}{T}
\frac{s^0(T)}{R} = a_o \ln T + a_1 T + \frac{a_2}{2} T^2 + \frac{a_3}{3} T^3 +
\frac{s^0(T)}{R} = a_0 \ln T + a_1 T + \frac{a_2}{2} T^2 + \frac{a_3}{3} T^3 +
\frac{a_4}{4} T^4 + a_6
Note that this is the "old" NASA polynomial form, used in the original NASA

View file

@ -23,7 +23,7 @@ These values are the same as those in the Cantera C++ header file ct_defs.h.
.. data:: planck
Planck constant (J/s)
Planck constant (J-s)
.. data:: stefan_boltzmann

View file

@ -227,19 +227,7 @@ surface reactions must also be passed as arguments to `Interface`.
Converting CK-format files
~~~~~~~~~~~~~~~~~~~~~~~~~~
Many existing reaction mechanism files are in "CK format," by which we mean
the input file format developed for use with the Chemkin-II software package.
[See R. J. Kee, F. M. Rupley, and J. A. Miller, Sandia National Laboratories
Report SAND89-8009 (1989).]
Cantera comes with a converter utility program ``ck2cti`` (or ``ck2cti.py``)
that converts CK format into Cantera format. This program should be run from
the command line first to convert any CK files you plan to use into Cantera
format. Here's an example of how to use it. The command::
$python ck2cti.py --input=mech.inp --thermo=therm.dat --transport=tran.dat
will produce the file ``mech.cti`` in the current directory.
See :ref:`sec-ck-format-conversion` in the :ref:`sec-input-files` documentation.
Getting Help

View file

@ -97,7 +97,7 @@ General
David G. Goodwin, Harry K. Moffat, and Raymond L. Speth. *Cantera: An object-
oriented software toolkit for chemical kinetics, thermodynamics, and
transport processes*. http://www.cantera.org, 2015. Version 2.2.0.
transport processes*. http://www.cantera.org, 2016. Version 2.2.1.
The following BibTeX entry may also be used::
@ -105,8 +105,8 @@ General
author = "David G. Goodwin and Harry K. Moffat and Raymond L. Speth",
title = "Cantera: An Object-oriented Software Toolkit for Chemical
Kinetics, Thermodynamics, and Transport Processes",
year = 2015,
note = "Version 2.2.0",
year = 2016,
note = "Version 2.2.1",
howpublished = "\url{http://www.cantera.org}"
}
@ -124,8 +124,8 @@ Support and Bug Reporting
- Check the `Issue Tracker
<https://github.com/Cantera/cantera/issues>`_ to see if the issue
has already been reported.
- Try to generate a complete, minimal example that demonstrates the
observed bug.
- Try to generate a `minimal, complete, and verifiable example
<http://stackoverflow.com/help/mcve>`_ that demonstrates the observed bug.
- Create a new issue on the tracker. Include as much information as
possible about your system configuration (operating system, compiler
versions, Python versions, installation method, etc.)

View file

@ -14,7 +14,7 @@ Windows
=======
Windows installers are provided for stable versions of Cantera. These
installation instructions are for Cantera 2.2.0.
installation instructions are for Cantera 2.2.1.
1. **Choose your Python version and architecture**
@ -68,14 +68,14 @@ installation instructions are for Cantera 2.2.0.
c:\python34\python.exe "%USERPROFILE%\Downloads\get-pip.py"
4. **Install Numpy**
4. **Install Numpy and optional Python packages**
- Go to the `Unofficial Windows Binaries for Python Extension Packages page
<http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy>`_.
- Download the most recent release (distributed as a "wheel" archive) of the
1.x series for Python *X.Y* that matches your Python architecture. The
binaries for Cantera 2.2.0 require Numpy 1.8.0 or newer, e.g. In the
binaries for Cantera 2.2.1 require Numpy 1.8.0 or newer, e.g. In the
filename, the digits after "cp" indicate the Python version, e.g.
``numpy1.8.2+mklcp34nonewin_amd64.whl`` is the installer for 64-bit
Python 3.4.
@ -85,6 +85,12 @@ installation instructions are for Cantera 2.2.0.
c:\python34\scripts\pip.exe install "%USERPROFILE%\Downloads\numpy1.8.2+mklcp34nonewin_amd64.whl"
- If you plan on using Cantera from Python, you may also want to install
IPython (an advanced interactive Python interpreter) and Matplotlib (a
plotting library), which are also available from the above link (note that
you may also need to download additional dependencies for each of these
packages). Matplotlib is required to run some of the Python examples.
5. **Remove old versions of Cantera**
- Use The Windows "Add/Remove Programs" interface
@ -98,10 +104,10 @@ installation instructions are for Cantera 2.2.0.
- Go to the `Cantera Releases <https://github.com/Cantera/cantera/releases>`_
page.
- *64-bit*: Download **Cantera-2.2.0-x64.msi** and
**Cantera-Python-2.2.0-x64-pyX.Y.msi**.
- *32-bit*: Download **Cantera-2.2.0-x86.msi** and
**Cantera-Python-2.2.0-x86-pyX.Y.msi**.
- *64-bit*: Download **Cantera-2.2.1-x64.msi** and
**Cantera-Python-2.2.1-x64-pyX.Y.msi**.
- *32-bit*: Download **Cantera-2.2.1-x86.msi** and
**Cantera-Python-2.2.1-x86-pyX.Y.msi**.
- If you are only using the Python module, you do not need to download and
install the base package.
@ -207,11 +213,22 @@ you can skip any steps which have already been completed.
Note that these packages are required even if you do not plan on using the
Cantera Python 2 module.
- If you plan on using Cantera from Python, you may also want to install
IPython (an advanced interactive Python interpreter) and Matplotlib (a
plotting library). Matplotlib is required to run some of the Python
examples::
pip install ipython matplotlib
- If you want to build the Cantera Python 3 module, run::
brew install python3
pip3 install numpy cython
and, optionally::
pip3 install ipython matplotlib
3. **Compile and install Cantera**
* To compile and install Cantera using the default configuration, run::
@ -223,14 +240,31 @@ you can skip any steps which have already been completed.
``--HEAD``
Installs the current development version of Cantera.
``--with-python3``
Install the Python 3 module.
``--with-matlab=/Applications/MATLAB_R2014a.app/``
Installs the Matlab toolbox (with the path modified to match your
installed Matlab version)
``--without-sundials``
Do not use an external SUNDIALS version to build Cantera. Users
choosing this option will not be able to run sensitivity analysis
of Reactor Networks, but it may prevent errors when installing
the Matlab toolbox.
``--without-check``
NOT RECOMMENDED! Disable automatic testing of Cantera during the
installation process.
* These options are specified as additional arguments to the ``brew install``
command, e.g.::
brew install cantera --HEAD --with-matlab=/Applications/MATLAB_R2014a.app/
brew install cantera --HEAD --with-python3
* If you are installing the Matlab toolbox, the recommended command is::
brew install cantera --with-matlab=/Applications/MATLAB_R2014a.app/ --without-sundials
* If something goes wrong with the Homebrew install, re-run the command with
the ``-v`` flag to get more verbose output that may help identify the
@ -303,7 +337,7 @@ Ubuntu
======
Ubuntu packages are provided for recent versions of Ubuntu using a Personal
Package Archive (PPA). As of Cantera 2.2.0, packages are available for Ubuntu
Package Archive (PPA). As of Cantera 2.2.1, packages are available for Ubuntu
Ubuntu 14.04 LTS (Trusty Tahr), Ubuntu 14.10 (Utopic Unicorn), and Ubuntu 15.04
(Vivid Vervet). To see which Ubuntu releases and Cantera versions are currently
available, visit https://launchpad.net/~speth/+archive/ubuntu/cantera
@ -328,3 +362,30 @@ To install all of the Cantera packages::
sudo aptitude install cantera-python cantera-python3 cantera-dev
or install whichever subset you need by adjusting the above command.
If you plan on using Cantera from Python, you may also want to install IPython
(an advanced interactive Python interpreter) and Matplotlib (a plotting
library), which are also available from the above link. Matplotlib is required
to run some of the Python examples. For Python 2, these packages can be
installed with::
pip2 install ipython matplotlib
And for Python 3, these packages can be installed with::
pip3 install ipython matplotlib
You may need to install ``pip`` first; instructions can be found on the
`pip installation instructions.
<https://pip.pypa.io/en/latest/installing.html#install-pip>`_
You may need to have superuser access to install packages into the system
directories. Alternatively, you can add ``--user`` after ``pip install`` but
before the package names to install into your local user directory. An
alternative method is to use the Ubuntu repositories, but these tend to
be very out of date. For Python 2, the command is::
sudo aptitude install ipython python-matplotlib
And for Python 3, these packages can be installed with::
sudo aptitude install ipython3 python3-matplotlib

View file

@ -59,17 +59,4 @@ must also be passed as arguments to importInterface.
Converting CK-format files
--------------------------
Many existing reaction mechanism files are in "CK format," by which we mean the
input file format developed for use with the Chemkin-II software package. [See
R. J. Kee, F. M. Rupley, and J. A. Miller, Sandia National Laboratories Report
SAND89-8009 (1989).]
Cantera comes with a converter utility program ``ck2cti`` (or ``ck2cti.exe``)
that converts CK format into Cantera format. This program should be run from the
command line first to convert any CK files you plan to use into Cantera format.
Here's an example of how to use it:
.. code-block:: bash
ck2cti -i mech.inp -t therm.dat -tr tran.dat -id mymech > mech.cti
See :ref:`sec-ck-format-conversion` in the :ref:`sec-input-files` documentation.

View file

@ -1,5 +1,3 @@
scons: Reading SConscript files ...
**************************************************
* Configuration options for building Cantera *
**************************************************
@ -9,11 +7,10 @@ build process. They should be given in the form:
scons build option1=value1 option2=value2
Variables set in this way will be stored in the 'cantera.conf' file
and reused automatically on subsequent invocations of
scons. Alternatively, the configuration options can be entered
directly into 'cantera.conf' before running 'scons build'. The format
of this file is:
Variables set in this way will be stored in the 'cantera.conf' file and reused
automatically on subsequent invocations of scons. Alternatively, the
configuration options can be entered directly into 'cantera.conf' before
running 'scons build'. The format of this file is:
option1 = 'value1'
option2 = 'value2'
@ -21,13 +18,15 @@ of this file is:
**************************************************
* msvc_version: [ string ]
Version of Visual Studio to use. The default is the same version
that was used to compile the installed version of Python.
- default: '9.0'
Version of Visual Studio to use. The default is the newest installed
version. Specify '9.0' for Visual Studio 2008; '10.0' for Visual
Studio 2010; '11.0' for Visual Studio 2012; or '12.0' for Visual
Studio 2013.
- default: ''
* target_arch: [ string ]
Target architecture. The default is the same architecture as the
installed version of Python
installed version of Python.
- default: 'amd64'
* toolchain: [ msvc | mingw | intel ]
@ -36,16 +35,15 @@ of this file is:
* CXX: [ string ]
The C++ compiler to use.
- default: 'g++'
- default: '$CC'
* CC: [ string ]
The C compiler to use. This is only used to compile CVODE and the
Python extension module.
- default: 'gcc'
The C compiler to use. This is only used to compile CVODE.
- default: 'cl'
* prefix: [ /path/to/prefix ]
Set this to the directory where Cantera should be installed.
- default: '/usr/local'
- default: 'C:\\Program Files\\Cantera'
* python_package: [ new | full | minimal | none | default ]
If you plan to work in Python, or you want to use the graphical
@ -53,7 +51,7 @@ of this file is:
Package. If, on the other hand, you will only use Cantera from some
other language (e.g. MATLAB or Fortran 90/95) and only need Python
to process .cti files, then you only need a 'minimal' subset of the
package (actually, only one file). The default behavior is to build
package (actually, only two files). The default behavior is to build
the Python package if the required prerequisites (numpy) are
installed.
- default: 'default'
@ -62,7 +60,7 @@ of this file is:
Cantera needs to know where to find the Python interpreter. If
PYTHON_CMD is not set, then the configuration process will use the
same Python interpreter being used by SCons.
- default: '/usr/bin/python'
- default: 'c:\\Python27\\python.exe'
* python_array_home: [ /path/to/python_array_home ]
If numpy was installed using the --home option, set this to the home
@ -74,13 +72,14 @@ of this file is:
an alternate location. On Unix-like systems, the default is the same
as the $prefix option. If this option is set to the empty string
(the default on Windows), then the Package will be installed to the
system default 'site-packages' directory.
- default: '$prefix'
system default 'site-packages' directory. To install to the current
user's site-packages directory, use 'python_prefix=USER'.
- default: ''
* python3_package: [ y | n | default ]
Controls whether or not the Python 3 module will be built. By
default, the module will be built if the Python 3 interpreter can be
found
found.
- default: 'default'
* python3_cmd: [ /path/to/python3_cmd ]
@ -90,7 +89,7 @@ of this file is:
* python3_array_home: [ /path/to/python3_array_home ]
"If numpy was installed to a custom location (e.g. using the --home
option, set this to the directory for numpy
option, set this to the directory for numpy.
- default: ''
* python3_prefix: [ /path/to/python3_prefix ]
@ -98,8 +97,9 @@ of this file is:
to an alternate location. On Unix-like systems, the default is the
same as the $prefix option. If this option is set to the empty
string (the default on Windows), then the Package will be installed
to the system default 'site-packages' directory.
- default: '$prefix'
to the system default 'site-packages' directory. To install to the
current user's site-packages directory, use 'python3_prefix=USER'.
- default: ''
* matlab_toolbox: [ y | n | default ]
This variable controls whether the Matlab toolbox will be built. If
@ -123,13 +123,13 @@ of this file is:
if one is found.
- default: 'default'
* F90: [ /path/to/F90 ]
The Fortran 90 compiler. If unspecified, the builder will look for a
compatible compiler (gfortran, ifort, g95) in the $PATH.
* FORTRAN: [ /path/to/FORTRAN ]
The Fortran (90) compiler. If unspecified, the builder will look for
a compatible compiler (gfortran, ifort, g95) in the $PATH.
- default: ''
* F90FLAGS: [ string ]
Compilation options for the Fortran 90 compiler.
* FORTRANFLAGS: [ string ]
Compilation options for the Fortran (90) compiler.
- default: '-O3'
* debug_verbose: [ yes | no ]
@ -143,33 +143,17 @@ of this file is:
- default: 'no'
* doxygen_docs: [ yes | no ]
Build HTML documentation for the C++ interface using Doxygen
Build HTML documentation for the C++ interface using Doxygen.
- default: 'no'
* sphinx_docs: [ yes | no ]
Build HTML documentation for the Python module using Sphinx
Build HTML documentation for the Python module using Sphinx.
- default: 'no'
* with_lattice_solid: [ yes | no ]
Include thermodynamic model for lattice solids in the Cantera
kernel.
- default: 'yes'
* sphinx_cmd: [ /path/to/sphinx_cmd ]
Command to use for building the Sphinx documentation
Command to use for building the Sphinx documentation.
- default: 'sphinx-build'
* with_h298modify_capability: [ yes | no ]
Enable changing the 298K heats of formation directly via the C++
layer.
- default: 'no'
* with_html_log_files: [ yes | no ]
write HTML log files. Some multiphase equilibrium procedures can
write copious diagnostic log messages. Set this to 'n' to disable
this capability. (results in slightly faster equilibrium
calculations)
- default: 'yes'
* use_sundials: [ default | y | n ]
Cantera uses the CVODE or CVODES ODE integrator to time-integrate
reactor network ODE's and for various other purposes. An older
@ -182,8 +166,9 @@ of this file is:
will be used if you have it, and if not the older CVODE will be
used. Or set USE_SUNDIALS to 'y' or 'n' to force using it or not.
Note that sensitivity analysis with Cantera requires use of
sundials. See: http://www.llnl.gov/CASC/sundials
sundials. See: http://www.llnl.gov/CASC/sundials.
- default: 'default'
- actual: 'y'
* sundials_include: [ /path/to/sundials_include ]
The directory where the Sundials header files are installed. This
@ -198,6 +183,16 @@ of this file is:
/usr/lib.
- default: ''
* sundials_license: [ /path/to/sundials_license ]
Path to the sundials LICENSE file. Needed so that it can be included
when bundling Sundials.
- default: ''
* install_sundials: [ yes | no ]
Determines whether Sundials library and header files are installed
alongside Cantera. Intended for use when installing on Windows.
- default: 'yes'
* blas_lapack_libs: [ string ]
Cantera comes with Fortran (or C) versions of those parts of BLAS
and LAPACK it requires. But performance may be better if you use a
@ -226,37 +221,37 @@ of this file is:
* env_vars: [ string ]
Environment variables to propagate through to SCons. Either the
string "all" or a comma separated list of variable names, e.g.
'LD_LIBRARY_PATH,HOME'
- default: ''
'LD_LIBRARY_PATH,HOME'.
- default: 'LD_LIBRARY_PATH,PYTHONPATH'
* cxx_flags: [ string ]
Compiler flags passed to the C++ compiler only.
- default: '-ftemplate-depth-128'
- default: '/EHsc'
* cc_flags: [ string ]
Compiler flags passed to both the C and C++ compilers, regardless of
optimization level
- default: '-Wall -Wno-deprecated-declarations'
- default: '/MD /nologo /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS'
* thread_flags: [ string ]
Compiler and linker flags for POSIX multithreading support
- default: '-pthread'
Compiler and linker flags for POSIX multithreading support.
- default: ''
* optimize: [ yes | no ]
Enable extra compiler optimizations specified by the
"optimize_flags" variable, instead of the flags specified by the
"debug_flags" variable
"debug_flags" variable.
- default: 'yes'
* optimize_flags: [ string ]
Additional compiler flags passed to the C/C++ compiler when
optimize=yes.
- default: '-O3 -DNDEBUG -finline-functions -Wno-inline'
- default: '/O2'
* no_optimize_flags: [ string ]
Additional compiler flags passed to the C/C++ compiler when
optimize=no.
- default: '-O0 -fno-inline'
- default: '/Od /Ob0'
* debug: [ yes | no ]
Enable compiler debugging symbols.
@ -265,7 +260,8 @@ of this file is:
* debug_flags: [ string ]
Additional compiler flags passed to the C/C++ compiler when
debug=yes.
- default: '-g'
- default: '/Zi /Fd${TARGET}.pdb'
- actual: '/Zi /Fd.pdb'
* no_debug_flags: [ string ]
Additional compiler flags passed to the C/C++ compiler when
@ -273,11 +269,27 @@ of this file is:
- default: ''
* debug_linker_flags: [ string ]
Additional options passed to the linker when debug=yes
- default: ''
Additional options passed to the linker when debug=yes.
- default: '/DEBUG'
* no_debug_linker_flags: [ string ]
Additional options passed to the linker when debug=yes
Additional options passed to the linker when debug=no.
- default: ''
* warning_flags: [ string ]
Additional compiler flags passed to the C/C++ compiler to enable
extra warnings. Used only when compiling source code that part of
Cantera (e.g. excluding code in the 'ext' directory).
- default: '/W3'
* extra_inc_dirs: [ string ]
Additional directories to search for header files (colon-separated
list).
- default: ''
* extra_lib_dirs: [ string ]
Additional directories to search for libraries (colon-separated
list).
- default: ''
* build_thread_safe: [ yes | no ]
@ -289,16 +301,23 @@ of this file is:
- default: 'no'
* boost_inc_dir: [ /path/to/boost_inc_dir ]
Location of the Boost header files
- default: '/usr/include'
Location of the Boost header files.
- default: ''
* boost_lib_dir: [ /path/to/boost_lib_dir ]
Directory containing the Boost.Thread library
- default: '/usr/lib'
Directory containing the Boost.Thread library.
- default: ''
* boost_thread_lib: [ string ]
The name of the Boost.Thread library.
- default: 'boost_thread'
A comma-separated list containing the names of the libraries needed
to link to Boost.Thread.
- default: ''
* boost_windows_libs: [ string ]
Comma-separated list containing the names of the Boost libraries
required to link Cantera programs on Windows. These libraries will
be copied to the Cantera installation directory.
- default: 'thread,system,date_time,chrono'
* build_with_f2c: [ yes | no ]
For external procedures written in Fortran 77, both the original F77
@ -309,7 +328,7 @@ of this file is:
* F77: [ string ]
Compiler used to build the external Fortran 77 procedures from the
Fortran source code
Fortran source code.
- default: 'gfortran'
* F77FLAGS: [ string ]
@ -325,6 +344,29 @@ of this file is:
of installing into the local filesystem.
- default: ''
* cantera_version: [ string ]
- default: '2.0.0b1'
* VERBOSE: [ yes | no ]
Create verbose output about what scons is doing.
- default: 'no'
* renamed_shared_libraries: [ yes | no ]
If this option is turned on, the shared libraries that are created
will be renamed to have a "_shared" extension added to their base
name. If not, the base names will be the same as the static
libraries. In some cases this simplifies subsequent linking
environments with static libraries and avoids a bug with using
valgrind with the -static linking flag.
- default: 'yes'
* layout: [ standard | compact | debian ]
The layout of the directory structure. 'standard' installs files to
several subdirectories under 'prefix', e.g. $prefix/bin,
$prefix/include/cantera, $prefix/lib. This layout is best used in
conjunction with 'prefix'='/usr/local'. 'compact' puts all installed
files in the subdirectory define by 'prefix'. This layout is best
for with a prefix like '/opt/cantera'. 'debian' installs to the
stage directory in a layout used for generating Debian packages.
- default: 'compact'
* cantera_version: [ string ]
- default: '2.2.1'

View file

@ -9,6 +9,7 @@
namespace Cantera
{
//! Convenience class which inherits from both EdgePhase and EdgeKinetics
class Edge :
public EdgePhase, public EdgeKinetics
{

View file

@ -10,6 +10,7 @@
namespace Cantera
{
//! Convenience class which inherits from both IdealGasPhase and GasKinetics
class IdealGasMix :
public IdealGasPhase,
public GasKinetics

View file

@ -8,6 +8,7 @@
namespace Cantera
{
//! Wrapper for ConstDensityThermo with constructor from file
class IncompressibleSolid : public ConstDensityThermo
{
public:

View file

@ -8,6 +8,7 @@
namespace Cantera
{
//! Wrapper for MetalPhase with constructor from file
class Metal : public MetalPhase
{
public:

View file

@ -8,6 +8,7 @@
namespace Cantera
{
//! Wrapper for PureFluidPhase with constructor from file
class PureFluid : public PureFluidPhase
{
public:

View file

@ -771,7 +771,7 @@ public:
}
bool frac = false;
for (size_t n = 0; n < stoich.size(); n++) {
if (fmod(stoich[n], 1.0) || fmod(order[n], 1.0)) {
if (fmod(stoich[n], 1.0) || stoich[n] != order[n]) {
frac = true;
break;
}

View file

@ -548,12 +548,16 @@ public:
//! Elemental mole fraction of element m
/*!
* The elemental mole fraction \f$Z_{\mathrm{mole},m}\f$ of element \f$m\f$
* is defined as
* is the number of atoms of element *m* divided by the total number of
* atoms. It is defined as:
*
* \f[
* Z_{\mathrm{mole},m} = \sum_k \frac{a_{m,k}}{\sum_j a_{j,k}} X_k
* Z_{\mathrm{mole},m} = \frac{\sum_k a_{m,k} X_k}
* {\sum_k \sum_j a_{j,k} X_k}
* \f]
* with \f$a_{m,k}\f$ being the number of atoms of element \f$m\f$ in
* species \f$k\f$and \f$X_k\f$ the mole fraction of species \f$k\f$.
* species \f$k\f$, \f$\sum_j\f$ being a sum over all elements, and
* \f$X_k\f$ being the mole fraction of species \f$k\f$.
*
* @param[in] m Index of the element within the phase. If m is outside the
* valid range, an exception will be thrown.
@ -617,10 +621,12 @@ public:
//! Note the density of a phase is an independent variable.
//! @param[in] density_ density (kg/m^3).
virtual void setDensity(const doublereal density_) {
if (density_ <= 0.0) {
throw CanteraError("Phase::setDensity()", "density must be positive");
if (density_ > 0.0) {
m_dens = density_;
} else {
throw CanteraError("Phase::setDensity()",
"density must be positive");
}
m_dens = density_;
}
//! Set the internally stored molar density (kmol/m^3) of the phase.
@ -630,11 +636,12 @@ public:
//! Set the internally stored temperature of the phase (K).
//! @param temp Temperature in Kelvin
virtual void setTemperature(const doublereal temp) {
if (temp <= 0) {
if (temp > 0) {
m_temp = temp;
} else {
throw CanteraError("Phase::setTemperature",
"temperature must be positive");
}
m_temp = temp;
}
//@}

View file

@ -133,10 +133,18 @@ public:
//! return a reference to the contents.
thermo_t& contents() {
if (!m_thermo) {
throw CanteraError("ReactorBase::contents",
"Reactor contents not defined.");
}
return *m_thermo;
}
const thermo_t& contents() const {
if (!m_thermo) {
throw CanteraError("ReactorBase::contents",
"Reactor contents not defined.");
}
return *m_thermo;
}

View file

@ -167,6 +167,10 @@ public:
if (!m_init) {
initialize();
}
if (p >= m_sensIndex.size()) {
throw IndexError("ReactorNet::sensitivity",
"m_sensIndex", p, m_sensIndex.size()-1);
}
return m_integ->sensitivity(k, m_sensIndex[p])/m_integ->solution(k);
}

View file

@ -54,7 +54,7 @@ public:
}
virtual bool ready() {
return FlowDevice::ready() && m_master != 0;
return FlowDevice::ready() && m_master != 0 && m_coeffs.size() == 1;
}
void setMaster(FlowDevice* master) {
@ -62,6 +62,10 @@ public:
}
virtual void updateMassFlowRate(doublereal time) {
if (!ready()) {
throw CanteraError("PressureController::updateMassFlowRate",
"Device is not ready; some parameters have not been set.");
}
doublereal master_mdot = m_master->massFlowRate(time);
m_mdot = master_mdot + m_coeffs[0]*(in().pressure() -
out().pressure());
@ -72,7 +76,8 @@ protected:
FlowDevice* m_master;
};
//! Supply a mass flow rate that is a function of the pressure drop across the valve.
//! Supply a mass flow rate that is a function of the pressure drop across the
//! valve.
/*!
* The default behavior is a linearly proportional to the pressure difference.
* Note that real valves do not have this behavior, so this class does not
@ -86,11 +91,15 @@ public:
}
virtual bool ready() {
return FlowDevice::ready() && m_coeffs.size() >= 1;
return FlowDevice::ready() && (m_coeffs.size() == 1 || m_func);
}
/// Compute the currrent mass flow rate, based on the pressure difference.
virtual void updateMassFlowRate(doublereal time) {
if (!ready()) {
throw CanteraError("Valve::updateMassFlowRate",
"Device is not ready; some parameters have not been set.");
}
double delta_P = in().pressure() - out().pressure();
if (m_func) {
m_mdot = m_func->eval(delta_P);

View file

@ -18,7 +18,7 @@ def configure_python(env, python_command):
"print(numpy.get_include())"))
info = getCommandOutput(python_command, '-c', script)
module_ext, inc, pylib, prefix, py_version, numpy_include = info.splitlines()[-6:]
env.Append(CPPPATH=[inc, numpy_include, Dir('#include')])
env.Prepend(CPPPATH=[Dir('#include'), inc, numpy_include])
env.Prepend(LIBS=env['cantera_libs'])
if env['OS'] == 'Darwin':
env.Append(LINKFLAGS='-undefined dynamic_lookup')
@ -137,7 +137,7 @@ if localenv['python3_package'] == 'y':
obj = py3env.SharedObject('#build/temp-py/_cantera3', 'cantera/_cantera.cpp')
ext = py3env.LoadableModule('#build/python3/cantera/_cantera%s' % module_ext,
obj, LIBPREFIX='', SHLIBSUFFIX=module_ext,
LIBSUFFIXES=[module_ext])
SHLIBPREFIX='', LIBSUFFIXES=[module_ext])
py3env['py_extension'] = ext[0].name
py3env.SubstFile('setup3.py', 'setup.py.in')
@ -161,7 +161,7 @@ if localenv['python_package'] == 'full':
obj = py2env.SharedObject('#build/temp-py/_cantera2', 'cantera/_cantera.cpp')
ext = py2env.LoadableModule('#build/python2/cantera/_cantera%s' % module_ext,
obj, LIBPREFIX='', SHLIBSUFFIX=module_ext,
LIBSUFFIXES=[module_ext])
SHLIBPREFIX='', LIBSUFFIXES=[module_ext])
py2env['py_extension'] = ext[0].name
py2env.SubstFile('setup2.py', 'setup.py.in')
build_cmd = ('cd interfaces/cython &&'

View file

@ -512,8 +512,8 @@ cdef extern from "cantera/zeroD/Wall.h":
cdef extern from "cantera/zeroD/flowControllers.h":
cdef cppclass CxxFlowDevice "Cantera::FlowDevice":
CxxFlowDevice()
double massFlowRate(double)
cbool install(CxxReactorBase&, CxxReactorBase&)
double massFlowRate(double) except +
cbool install(CxxReactorBase&, CxxReactorBase&) except +
void setFunction(CxxFunc1*)
void setParameters(int, double*)
@ -977,7 +977,7 @@ cdef class ReactionPathDiagram:
cdef CxxStringStream* _log
# free functions
cdef string stringify(x)
cdef string stringify(x) except *
cdef pystr(string x)
cdef np.ndarray get_species_array(Kinetics kin, kineticsMethod1d method)
cdef np.ndarray get_reaction_array(Kinetics kin, kineticsMethod1d method)

View file

@ -70,16 +70,17 @@ if sys.version_info[0] == 2:
def strip_nonascii(s):
return s.decode('ascii', 'ignore')
def open(filename, *args):
return _open(filename, *args)
def open(filename, mode, *args):
return _open(filename, mode, *args)
else:
string_types = (str,)
def strip_nonascii(s):
return s.encode('ascii', 'ignore').decode()
def open(filename, *args):
return _open(filename, *args, errors='ignore')
def open(filename, mode, *args):
mode = mode.replace('U', '')
return _open(filename, mode, *args, errors='ignore')
def compatible_quantities(quantity_basis, units):

View file

@ -38,7 +38,7 @@ print('Species: {0}'.format(', '.join(S.name for S in species)))
all_reactions = ct.Reaction.listFromFile('gri30.xml')
reactions = []
print '\nReactions:'
print('\nReactions:')
for R in all_reactions:
if not all(reactant in species_names for reactant in R.reactants):
continue

View file

@ -40,7 +40,7 @@ def get_viscosity(args):
mech, T, P, X = args
gas = gases[mech]
gas.TPX = T, P, X
return gas.enthalpy_mass
return gas.viscosity
def parallel(mech, predicate, nProcs, nTemps):
"""
@ -64,13 +64,13 @@ def serial(mech, predicate, nTemps):
P = ct.one_atm
X = 'CH4:1.0, O2:1.0, N2:3.76'
init_process(mech)
y = map(predicate,
zip(itertools.repeat(mech),
np.linspace(300, 900, nTemps),
itertools.repeat(P),
itertools.repeat(X)))
y = list(map(predicate,
zip(itertools.repeat(mech),
np.linspace(300, 900, nTemps),
itertools.repeat(P),
itertools.repeat(X))))
return y
if __name__ == '__main__':
# For functions where the work done in each subprocess is substantial,
# significant speedup can be obtained using the multiprocessing module.

View file

@ -1,5 +1,6 @@
import numpy as np
from ._cantera import *
import csv as _csv
try:
# Python 2.7 or 3.2+
@ -265,7 +266,7 @@ class FlameBase(Sim1D):
V = self.V
csvfile = open(filename, 'w')
writer = csv.writer(csvfile)
writer = _csv.writer(csvfile)
writer.writerow(['z (m)', 'u (m/s)', 'V (1/s)',
'T (K)', 'rho (kg/m3)'] + self.gas.species_names)
for n in range(self.flame.n_points):

View file

@ -426,8 +426,8 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
def test_irreversibility(self):
# Reactions are irreversible
Rr = self.gas.reverse_rate_constants
self.assertEqual(Rr[0], 0.0)
self.assertEqual(Rr[1], 0.0)
for i in range(3):
self.assertEqual(Rr[i], 0.0)
def test_rateConstants(self):
# species order: [H, AR, R1A, R1B, P1]
@ -436,6 +436,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
kf = self.gas.forward_rate_constants
self.assertNear(Rf[0], kf[0] * C[2]**1.5 * C[3]**0.5)
self.assertNear(Rf[1], kf[1] * C[0]**1.0 * C[4]**0.2)
self.assertNear(Rf[2], kf[2] * C[2]**3.0)
def test_ratio1(self):
rop1 = self.gas.forward_rates_of_progress
@ -445,6 +446,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
ratio = rop2/rop1
self.assertNear(ratio[0], 2**1.5) # order of R1A is 1.5
self.assertNear(ratio[1], 2**1.0) # order of H is 1.0
self.assertNear(ratio[2], 2**3) # order of R1A is 3
def test_ratio2(self):
rop1 = self.gas.forward_rates_of_progress
@ -454,6 +456,7 @@ class ExplicitForwardOrderTest(utilities.CanteraTest):
ratio = rop2/rop1
self.assertNear(ratio[0], 2**0.5) # order of R1B is 0.5
self.assertNear(ratio[1], 2**0.2) # order of P1 is 1.0
self.assertNear(ratio[2], 2**0.0) # order of R1B is 0
class TestSofcKinetics(utilities.CanteraTest):

View file

@ -241,7 +241,7 @@ class TestFreeFlame(utilities.CanteraTest):
self.create_sim(p, Tin, reactants)
self.solve_fixed_T()
filename = 'onedim-fixed-T.xml'
filename = 'onedim-fixed-T{0}.xml'.format(utilities.python_version)
if os.path.exists(filename):
os.remove(filename)
@ -302,7 +302,7 @@ class TestFreeFlame(utilities.CanteraTest):
p = 2 * ct.one_atm
Tin = 400
filename = 'onedim-add-species.xml'
filename = 'onedim-add-species{0}.xml'.format(utilities.python_version)
if os.path.exists(filename):
os.remove(filename)
@ -330,7 +330,7 @@ class TestFreeFlame(utilities.CanteraTest):
p = 2 * ct.one_atm
Tin = 400
filename = 'onedim-add-species.xml'
filename = 'onedim-add-species{0}.xml'.format(utilities.python_version)
if os.path.exists(filename):
os.remove(filename)
@ -353,6 +353,19 @@ class TestFreeFlame(utilities.CanteraTest):
k1 = gas1.species_index(species)
self.assertArrayNear(Y1[k1], Y2[k2])
def test_write_csv(self):
filename = 'onedim-write_csv{0}.csv'.format(utilities.python_version)
if os.path.exists(filename):
os.remove(filename)
self.create_sim(2e5, 350, 'H2:1.0, O2:2.0', mech='h2o2.xml')
self.sim.write_csv(filename)
data = np.genfromtxt(filename, delimiter=',', skip_header=1)
self.assertArrayNear(data[:,0], self.sim.grid)
self.assertArrayNear(data[:,3], self.sim.T)
k = self.gas.species_index('H2')
self.assertArrayNear(data[:,5+k], self.sim.X[k,:])
def test_refine_criteria_boundscheck(self):
self.create_sim(ct.one_atm, 300.0, 'H2:1.1, O2:1, AR:5')
good = [3.0, 0.1, 0.2, 0.05]

View file

@ -76,6 +76,14 @@ class TestPureFluid(utilities.CanteraTest):
self.check_fd_properties(self.water.max_temp*(1-1e-5), 101325,
self.water.max_temp*(1-1e-4), 101325, 1e-2)
def test_TPX(self):
self.water.TX = 400, 0.8
T,P,X = self.water.TPX
self.assertNear(T, 400)
self.assertNear(X, 0.8)
with self.assertRaises(AttributeError):
self.water.TPX = 500, 101325, 0.3
# To minimize errors when transcribing tabulated data, the input units here are:
# T: K, P: MPa, rho: kg/m3, v: m3/kg, (u,h): kJ/kg, s: kJ/kg-K

View file

@ -433,6 +433,19 @@ class TestReactor(utilities.CanteraTest):
self.assertNear(speciesMass(kAr), mAr)
self.assertNear(speciesMass(kO2), mO2)
def test_valve_errors(self):
self.make_reactors()
res = ct.Reservoir()
with self.assertRaises(RuntimeError):
# Must assign contents of both reactors before creating Valve
v = ct.Valve(self.r1, res)
v = ct.Valve(self.r1, self.r2)
with self.assertRaises(RuntimeError):
# inlet and outlet cannot be reassigned
v._install(self.r2, self.r1)
def test_pressure_controller(self):
self.make_reactors(n_reactors=1)
g = ct.Solution('h2o2.xml')
@ -456,6 +469,25 @@ class TestReactor(utilities.CanteraTest):
dP = self.r1.thermo.P - outlet_reservoir.thermo.P
self.assertNear(mdot(t) + 1e-5 * dP, pc.mdot(t))
def test_pressure_controller_errors(self):
self.make_reactors()
res = ct.Reservoir(self.gas1)
mfc = ct.MassFlowController(res, self.r1, mdot=0.6)
p = ct.PressureController(self.r1, self.r2, master=mfc, K=0.5)
with self.assertRaises(RuntimeError):
p = ct.PressureController(self.r1, self.r2, K=0.5)
p.mdot(0.0)
with self.assertRaises(RuntimeError):
p = ct.PressureController(self.r1, self.r2, master=mfc)
p.mdot(0.0)
with self.assertRaises(RuntimeError):
p = ct.PressureController(self.r1, self.r2)
p.mdot(0.0)
def test_set_initial_time(self):
self.make_reactors(P1=10*ct.one_atm, X1='AR:1.0', X2='O2:1.0')
self.net.rtol = 1e-12

View file

@ -65,8 +65,8 @@ class TestThermoPhase(utilities.CanteraTest):
mO = self.phase.element_index('O')
self.assertEqual(Zo, self.phase.elemental_mole_fraction(mO))
self.assertNear(Zo, 0.5/3 + 0.5)
self.assertNear(Zh, 0.5*2/3)
self.assertNear(Zo, (0.5 + 1) / (0.5*3 + 0.5*2))
self.assertNear(Zh, (2*0.5) / (0.5*3 + 0.5*2))
self.assertEqual(Zar, 0.0)
with self.assertRaises(ValueError):
@ -74,6 +74,22 @@ class TestThermoPhase(utilities.CanteraTest):
with self.assertRaises(ValueError):
self.phase.elemental_mole_fraction(5)
def test_elemental_mass_mole_fraction(self):
# expected relationship between elmental mass and mole fractions
comps = ['H2O:0.5, O2:0.5', 'H2:0.1, O2:0.4, H2O2:0.3, AR:0.2',
'O2:0.1, H2:0.9']
for comp in comps:
self.phase.X = comp
denom = sum(self.phase.elemental_mole_fraction(i)
* self.phase.atomic_weight(i)
for i in range(self.phase.n_elements))
for i in range(self.phase.n_elements):
self.assertNear(self.phase.elemental_mass_fraction(i),
self.phase.elemental_mole_fraction(i)
* self.phase.atomic_weight(i) / denom)
def test_weights(self):
atomic_weights = self.phase.atomic_weights
molecular_weights = self.phase.molecular_weights

View file

@ -4,6 +4,8 @@ import os
import warnings
_ver = sys.version_info[:2]
python_version = str(_ver[0])
if _ver < (2,7) or (3,0) <= _ver < (3,2):
# unittest2 is a backport of the new features added to the unittest
# testing framework in Python 2.7 and Python 3.2. See

View file

@ -557,13 +557,15 @@ cdef class ThermoPhase(_SolutionBase):
def elemental_mole_fraction(self, m):
r"""
Get the elemental mole fraction :math:`Z_{\mathrm{mole},m}` of element
:math:`m` as defined by:
:math:`m` (the number of atoms of element m divided by the total number
of atoms) as defined by:
.. math:: Z_{\mathrm{mole},m} = \sum_k \frac{a_{m,k}}{\sum_j a_{j,k}} X_k
.. math:: Z_{\mathrm{mole},m} = \frac{\sum_k a_{m,k} X_k}
{\sum_k \sum_j a_{j,k} X_k}
with :math:`a_{m,k}` being the number of atoms of element :math:`m` in
species :math:`k` and :math:`X_k` the mole fraction of species
:math:`k`.
species :math:`k`, :math:`\sum_j` being a sum over all elements, and
:math:`X_k` being the mole fraction of species :math:`k`.
:param m:
Base element, may be specified by name or by index.
@ -1200,3 +1202,51 @@ cdef class PureFluid(ThermoPhase):
P = values[0] if values[0] is not None else self.P
X = values[1] if values[1] is not None else self.X
self.thermo.setState_Psat(P, X)
property TDX:
"""
Get the temperature [K], density [kg/m^3 or kmol/m^3], and vapor
fraction.
"""
def __get__(self):
return self.T, self.density, self.X
property TPX:
"""Get the temperature [K], pressure [Pa], and vapor fraction."""
def __get__(self):
return self.T, self.P, self.X
property UVX:
"""
Get the internal energy [J/kg or J/kmol], specific volume
[m^3/kg or m^3/kmol], and vapor fraction.
"""
def __get__(self):
return self.u, self.v, self.X
property DPX:
"""Get the density [kg/m^3], pressure [Pa], and vapor fraction."""
def __get__(self):
return self.density, self.P, self.X
property HPX:
"""
Get the enthalpy [J/kg or J/kmol], pressure [Pa] and vapor fraction.
"""
def __get__(self):
return self.h, self.P, self.X
property SPX:
"""
Get the entropy [J/kg/K or J/kmol/K], pressure [Pa], and vapor fraction.
"""
def __get__(self):
return self.s, self.P, self.X
property SVX:
"""
Get the entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or
m^3/kmol], and vapor fraction.
"""
def __get__(self):
return self.s, self.v, self.X

View file

@ -4,7 +4,7 @@ cdef int _pythonMajorVersion = sys.version_info[0]
cdef CxxPythonLogger* _logger = new CxxPythonLogger()
CxxSetLogger(_logger)
cdef string stringify(x):
cdef string stringify(x) except *:
""" Converts Python strings to std::string. """
# This method works with both Python 2.x and 3.x.
if isinstance(x, bytes):

View file

@ -1,10 +1,15 @@
function setState_Psat(tp, px)
% SETSTATE_PSAT Set the fluid to a saturated state at a given pressure.
% SETSTATE_PSAT Set the fluid state using the given pressure and quality.
% setState_Psat(tp,px)
% The fluid state will be set to a saturated liquid-vapor state using the
% input pressure and vapor fraction (quality) as the independent,
% intensive variables.
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% class derived from ThermoPhase)
% :param px:
% Pressure. Units: Pa
% Vector of length 2 containing the desired values for the pressure (Pa)
% and the vapor fraction
%
thermo_set(tp.tp_id, 24, px);

View file

@ -1,11 +1,15 @@
function setState_Tsat(tp, tx)
% SETSTATE_TSAT Set the fluid to a saturated state at a given temperature.
% SETSTATE_TSAT Set the fluid state using the given temperature and quality.
% setState_Tsat(tp,tx)
% The fluid state will be set to a saturated liquid-vapor state using the
% input temperature and vapor fraction (quality) as the independent,
% intensive variables.
% :param tp:
% Instance of class :mat:func:`ThermoPhase` (or another
% class derived from ThermoPhase)
% :param tx:
% Temperature. Units: K
% Vector of length 2 containing the desired values for the temperature (K)
% and the vapor fraction (quality)
%
thermo_set(tp.tp_id, 25, tx);

View file

@ -6,4 +6,4 @@ function setState_satLiquid(tp)
% class derived from ThermoPhase)
%
thermo_set(tp.tp_id, 2, 0);
set(tp, 'T', temperature(tp), 'Liquid', 1.0)

View file

@ -6,4 +6,4 @@ function setState_satVapor(tp)
% class derived from ThermoPhase)
%
thermo_set(tp.tp_id, 3, 0);
set(tp, 'T', temperature(tp), 'Vapor', 1.0)

View file

@ -64,15 +64,7 @@ CANTERA_SUNDIALS_LIBS=@mak_sundials_libdir@ @mak_sundials_libs@
# BLAS LAPACK LINKAGE
###############################################################################
CANTERA_have_blas_lapack_dir=@mak_have_blas_lapack_dir@
ifeq ($(CANTERA_have_blas_lapack_dir), 1)
CANTERA_BLAS_LAPACK_LIBS=@blas_lapack_dir@ @mak_blas_lapack_libs@
CANTERA_BLAS_LAPACK_LIBS_DEP= @mak_blas_lapack_libs_dep@
else
CANTERA_BLAS_LAPACK_LIBS=@mak_blas_lapack_libs@
CANTERA_BLAS_LAPACK_LIBS_DEP=$(CANTERA_INSTALL_DIR)/lib/libctlapack.a $(CANTERA_INSTALL_DIR)/lib/libctblas.a
endif
CANTERA_BLAS_LAPACK_LIBS=-L@blas_lapack_dir@ @mak_blas_lapack_libs@
###############################################################################
# COMBINATIONS OF INCLUDES AND LIBS
@ -94,9 +86,7 @@ CANTERA_LIBS=$(CANTERA_CORE_LIBS) \
CANTERA_TOTAL_LIBS=$(CANTERA_LIBS)
CANTERA_TOTAL_LIBS_DEP= $(CANTERA_CORE_LIBS_DEP) \
$(CANTERA_SUNDIALS_LIBS_DEP) \
$(CANTERA_BLAS_LAPACK_LIBS_DEP)
$(CANTERA_SUNDIALS_LIBS_DEP)
CANTERA_FORTRAN_LIBS=$(CANTERA_CORE_FTN) \
$(CANTERA_EXTRA_LIBDIRS) $(CANTERA_SUNDIALS_LIBS) \

View file

@ -32,10 +32,10 @@ pc_cflags = []
localenv['mak_corelibs'] = '-lcantera'
localenv['mak_extra_includes'] = ['-I%s' % s for s in localenv['extra_inc_dirs']]
localenv['mak_extra_includes'] = ' '.join('-I%s' % s for s in localenv['extra_inc_dirs'])
pc_incdirs.extend(localenv['extra_inc_dirs'])
localenv['mak_extra_libdirs'] = ['-L%s' % s for s in localenv['extra_lib_dirs']]
localenv['mak_extra_libdirs'] = ' '.join('-L%s' % s for s in localenv['extra_lib_dirs'])
pc_libdirs.extend(localenv['extra_lib_dirs'])
if env['use_sundials'] == 'n':
@ -74,14 +74,7 @@ localenv['mak_boost_libs'] = ' '.join('-l%s' % s for s in localenv['boost_libs']
pc_libs += localenv['boost_libs']
# Handle BLAS/LAPACK linkage
localenv['mak_have_blas_lapack_dir'] = '1' if localenv['blas_lapack_dir'] else '0'
if localenv['blas_lapack_dir']:
localenv['mak_blas_lapack_libs'] = ' '.join('-l%s' % s for s in localenv['blas_lapack_libs'])
localenv['mak_blas_lapack_libs_dep'] = ''
else:
localenv['mak_blas_lapack_libs'] = ''
localenv['mak_blas_lapack_libs_dep'] = ''
localenv['mak_blas_lapack_libs'] = ' '.join('-l%s' % s for s in localenv['blas_lapack_libs'])
if 'Accelerate' in localenv['FRAMEWORKS']:
localenv['mak_blas_lapack_libs'] += ' -framework Accelerate'

View file

@ -6,6 +6,7 @@
#define BVP_H
#include "cantera/onedim.h"
#include <fstream>
/// Namespace for the boundary value problem package.
namespace BVP
@ -113,18 +114,19 @@ public:
* @param n Component number.
* @param c Component parameter values
*/
void setComponent(int n, Component& c) {
void setComponent(size_t n, Component& c) {
if (m_sim == 0) {
start();
}
if (n < 0 || n >= m_nv) {
if (n >= m_nv) {
throw Cantera::CanteraError("BoundaryValueProblem::setComponent",
"Illegal solution component number");
}
// set the upper and lower bounds for this component
setBounds(n, c.lower, c.upper);
// set the error tolerances
setTolerances(n, c.rtol, c.atol);
setSteadyTolerances(c.rtol, c.atol, n);
setTransientTolerances(c.rtol, c.atol, n);
// specify whether this component should be considered in
// refining the grid
m_refiner->setActive(n, c.refine);
@ -209,7 +211,7 @@ protected:
* True if n is the index of the left-most grid point (zero),
* false otherwise.
*/
bool isLeft(int n) const {
bool isLeft(size_t n) const {
return (n == 0);
}
@ -217,7 +219,7 @@ protected:
* True if \a n is the index of the right-most grid point, false
* otherwise.
*/
bool isRight(int n) const {
bool isRight(size_t n) const {
return (n == nPoints() - 1);
}

View file

@ -19,7 +19,6 @@ void runexample()
// use reaction mechanism GRI-Mech 3.0
IdealGasMix gas("gri30.cti", "gri30");
int nsp = gas.nSpecies();
// create a reservoir for the fuel inlet, and set to pure methane.
Reservoir fuel_in;
@ -105,7 +104,6 @@ void runexample()
double tfinal = 1.0;
double tnow = 0.0;
double tres;
int k;
std::ofstream f("combustor_cxx.csv");
std::vector<size_t> k_out;

View file

@ -13,6 +13,7 @@
#include "cantera/IdealGasMix.h" // defines class IdealGasMix
#include "cantera/transport.h" // transport properties
#include <cstdio>
// All Cantera kernel names are in namespace Cantera. You can either
// reference everything as Cantera::<name>, or include the following

View file

@ -48,7 +48,7 @@ int kinetics1(int np, void* p)
// create a container object to run the simulation
// and add the reactor to it
ReactorNet sim;
sim.addReactor(&r);
sim.addReactor(r);
// main loop
clock_t t0 = clock(); // save start time

View file

@ -235,15 +235,20 @@ def compareTextFiles(env, file1, file2):
# String representations match, so replacement is unnecessary
continue
delta = max(getPrecision(floats1[j][1]), getPrecision(floats2[j][1]))
num1 = float(floats1[j][1])
num2 = float(floats2[j][1])
abserr = abs(num1-num2)
relerr = abserr / (0.5 * abs(num1 + num2) + atol)
if abserr > (1.1*delta + atol) and relerr > rtol:
print 'Values differ: {0: 14g} {1: 14g}; rel. err = {2:.3e}; abs. err = {3:.3e}'.format(num1, num2, relerr, abserr)
allMatch = False
break
try:
delta = max(getPrecision(floats1[j][1]), getPrecision(floats2[j][1]))
num1 = float(floats1[j][1])
num2 = float(floats2[j][1])
abserr = abs(num1-num2)
relerr = abserr / (0.5 * abs(num1 + num2) + atol)
if abserr > (1.1*delta + atol) and relerr > rtol:
print 'Values differ: {0: 14g} {1: 14g}; rel. err = {2:.3e}; abs. err = {3:.3e}'.format(num1, num2, relerr, abserr)
allMatch = False
break
except Exception as e:
# Something went wrong -- one of the strings isn't actually a number,
# so just ignore this line and let the test fail
pass
# All the values are sufficiently close, so replace the string
# so that the diff of this line will succeed
@ -307,7 +312,6 @@ def compareCsvFiles(env, file1, file2):
"""
try:
import numpy as np
hasSkipHeader = tuple(np.version.version.split('.')[:2]) >= ('1','4')
except ImportError:
print 'WARNING: skipping .csv diff because numpy is not installed'
return 0
@ -323,12 +327,8 @@ def compareCsvFiles(env, file1, file2):
break
try:
if hasSkipHeader:
data1 = np.genfromtxt(file1, skip_header=headerRows, delimiter=',')
data2 = np.genfromtxt(file2, skip_header=headerRows, delimiter=',')
else:
data1 = np.genfromtxt(file1, skiprows=headerRows, delimiter=',')
data2 = np.genfromtxt(file2, skiprows=headerRows, delimiter=',')
data1 = np.genfromtxt(file1, skip_header=headerRows, delimiter=',')
data2 = np.genfromtxt(file2, skip_header=headerRows, delimiter=',')
except (IOError, StopIteration) as e:
print e
return 1

View file

@ -76,7 +76,7 @@ class WxsGenerator(object):
UpgradeCode='2340BEE1-279D-11E1-A4AA-001FBC085391',
Language='1033',
Codepage='1252',
Version='2.2.0',
Version='2.2.1',
Manufacturer='Cantera Developers'))
fields = {'Platform': 'x64'} if self.x64 else {}

View file

@ -28,14 +28,14 @@
#include <float.h>
#define isnan(x) _isnan(x)
#define finite(x) _finite(x)
#elif defined(USE_STD_ISNAN)
// From C++11
using std::isnan;
#define finite(x) std::isfinite(x)
#elif defined(USE_GLOBAL_ISNAN)
// From C99
using ::isnan;
using ::finite;
#elif defined(USE_STD_ISNAN)
// From C++11
using std::isnan;
#define finite(x) std::isfinite(x)
#endif
namespace Cantera {

View file

@ -327,7 +327,7 @@ extern "C" {
try {
return ThermoCabinet::item(n).nAtoms(k,m);
} catch (...) {
return handleAllExceptions(-1, ERR);
return handleAllExceptions(ERR, ERR);
}
}

View file

@ -155,13 +155,12 @@ void ImplicitSurfChem::eval(doublereal time, doublereal* y,
{
updateState(y); // synchronize the surface state(s) with y
doublereal rs0, sum;
size_t loc, kstart;
size_t loc = 0, kstart;
for (size_t n = 0; n < m_nsurf; n++) {
rs0 = 1.0/m_surf[n]->siteDensity();
m_vecKinPtrs[n]->getNetProductionRates(DATA_PTR(m_work));
kstart = m_vecKinPtrs[n]->kineticsSpeciesIndex(0,m_surfindex[n]);
sum = 0.0;
loc = 0;
for (size_t k = 1; k < m_nsp[n]; k++) {
ydot[k + loc] = m_work[kstart + k] * rs0 * m_surf[n]->size(k);
sum -= ydot[k];

View file

@ -119,24 +119,46 @@ void phasemethods(int nlhs, mxArray* plhs[],
// floating-point attributes
case 1:
vv = phase_temperature(ph);
if (vv == DERR) {
reportError();
}
break;
case 2:
vv = phase_density(ph);
if (vv == DERR) {
reportError();
}
break;
case 3:
vv = phase_molarDensity(ph);
if (vv == DERR) {
reportError();
}
break;
case 4:
vv = phase_meanMolecularWeight(ph);
if (vv == DERR) {
reportError();
}
break;
case 8:
vv = 1.0/phase_density(ph);
vv = phase_density(ph);
if (vv == DERR) {
reportError();
}
vv = 1.0/vv;
break;
case 10:
vv = static_cast<int>(phase_nElements(ph));
if (vv == -1) {
reportError();
}
break;
case 11:
vv = static_cast<int>(phase_nSpecies(ph));
if (vv == -1) {
reportError();
}
break;
case 12:
input_buf = getString(prhs[3]);
@ -150,18 +172,21 @@ void phasemethods(int nlhs, mxArray* plhs[],
k = getInt(prhs[3]);
m = getInt(prhs[4]);
vv = phase_nAtoms(ph,k-1,m-1);
if (vv == ERR) {
reportError();
}
break;
case 15:
show_thermo = getInt(prhs[3]);
threshold = getDouble(prhs[4]);
vv = write_phase(ph,show_thermo,threshold);
if (vv == -1 || vv == ERR) {
reportError();
}
break;
default:
mexErrMsgTxt("Unknown job number");
}
if (vv == DERR || vv == -1 || vv == ERR) {
reportError();
}
plhs[0] = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL);
double* h = mxGetPr(plhs[0]);
*h = vv;

View file

@ -1037,7 +1037,7 @@ void DebyeHuckel::initThermoXML(XML_Node& phaseNode, const std::string& id_)
for (size_t k = 0; k < m_kk; k++) {
std::string kname = speciesName(k);
const XML_Node* spPtr = xspecies[k];
if (!spPtr) {
if (spPtr) {
if (spPtr->hasChild("electrolyteSpeciesType")) {
std::string est = getChildValue(*spPtr, "electrolyteSpeciesType");
if ((m_electrolyteSpeciesType[k] = interp_est(est)) == -1) {

View file

@ -173,10 +173,6 @@ void GeneralSpeciesThermo::reportParams(size_t index, int& type,
if (sp) {
sp->reportParameters(n, type, minTemp_, maxTemp_,
refPressure_, c);
if (n != index) {
throw CanteraError("GeneralSpeciesThermo::reportParams",
"Internal error encountered");
}
} else {
type = -1;
}

View file

@ -1533,7 +1533,7 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_)
std::vector<const XML_Node*> xspecies = speciesData();
for (size_t k = 0; k < m_kk; k++) {
const XML_Node* spPtr = xspecies[k];
if (!spPtr) {
if (spPtr) {
if (spPtr->hasChild("electrolyteSpeciesType")) {
string est = getChildValue(*spPtr, "electrolyteSpeciesType");
if ((m_electrolyteSpeciesType[k] = interp_est(est)) == -1) {

View file

@ -7,6 +7,7 @@
#include "cantera/thermo/IdealGasPhase.h"
#include "cantera/base/vec_functions.h"
#include "cantera/thermo/ThermoFactory.h"
using namespace std;
@ -30,7 +31,7 @@ IdealGasPhase::IdealGasPhase(XML_Node& phaseRef, const std::string& id_) :
m_p0(-1.0),
m_logc0(0.0)
{
initThermoXML(phaseRef, id_);
importPhase(phaseRef, this);
}
IdealGasPhase::IdealGasPhase(const IdealGasPhase& right) :

View file

@ -645,15 +645,19 @@ doublereal Phase::elementalMassFraction(const size_t m) const
doublereal Phase::elementalMoleFraction(const size_t m) const
{
checkElementIndex(m);
doublereal Z_n = 0.0;
for (size_t k = 0; k != m_kk; ++k) {
double nTotalAtoms = 0;
for (size_t l = 0; l != m_mm; ++l) {
nTotalAtoms += nAtoms(k, l);
double denom = 0;
for (size_t k = 0; k < m_kk; k++) {
double atoms = 0;
for (size_t j = 0; j < nElements(); j++) {
atoms += nAtoms(k, j);
}
Z_n += nAtoms(k, m) / nTotalAtoms * moleFraction(k);
denom += atoms * moleFraction(k);
}
return Z_n;
doublereal numerator = 0.0;
for (size_t k = 0; k != m_kk; ++k) {
numerator += nAtoms(k, m) * moleFraction(k);
}
return numerator / denom;
}
doublereal Phase::molarDensity() const

View file

@ -465,23 +465,28 @@ void GasTransport::getTransportData()
{
for (size_t k = 0; k < m_thermo->nSpecies(); k++) {
shared_ptr<Species> s = m_thermo->species(m_thermo->speciesName(k));
const GasTransportData& sptran =
dynamic_cast<GasTransportData&>(*s->transport.get());
if (sptran.geometry == "atom") {
const GasTransportData* sptran =
dynamic_cast<GasTransportData*>(s->transport.get());
if (!sptran) {
throw CanteraError("GasTransport::getTransportData",
"Missing gas-phase transport data for species '" + s->name + "'");
}
if (sptran->geometry == "atom") {
m_crot[k] = 0.0;
} else if (sptran.geometry == "linear") {
} else if (sptran->geometry == "linear") {
m_crot[k] = 1.0;
} else if (sptran.geometry == "nonlinear") {
} else if (sptran->geometry == "nonlinear") {
m_crot[k] = 1.5;
}
m_sigma[k] = sptran.diameter;
m_eps[k] = sptran.well_depth;
m_dipole(k,k) = sptran.dipole;
m_polar[k] = (sptran.dipole > 0);
m_alpha[k] = sptran.polarizability;
m_zrot[k] = sptran.rotational_relaxation;
m_w_ac[k] = sptran.acentric_factor;
m_sigma[k] = sptran->diameter;
m_eps[k] = sptran->well_depth;
m_dipole(k,k) = sptran->dipole;
m_polar[k] = (sptran->dipole > 0);
m_alpha[k] = sptran->polarizability;
m_zrot[k] = sptran->rotational_relaxation;
m_w_ac[k] = sptran->acentric_factor;
}
}

View file

@ -9,7 +9,7 @@ namespace Cantera
bool FlowDevice::install(ReactorBase& in, ReactorBase& out)
{
if (m_in || m_out) {
return false;
throw CanteraError("FlowDevice::install", "Already installed");
}
m_in = &in;
m_out = &out;
@ -19,9 +19,6 @@ bool FlowDevice::install(ReactorBase& in, ReactorBase& out)
// construct adapters between inlet and outlet species
ThermoPhase* mixin = &m_in->contents();
ThermoPhase* mixout = &m_out->contents();
if (mixin == 0 || mixout == 0) {
return false;
}
m_nspin = mixin->nSpecies();
m_nspout = mixout->nSpecies();

View file

@ -234,6 +234,11 @@ size_t ReactorNet::globalComponentIndex(const string& component, size_t reactor)
void ReactorNet::registerSensitivityReaction(void* reactor,
size_t reactionIndex, const std::string& name, int leftright)
{
if (m_integrator_init) {
throw CanteraError("ReactorNet::registerSensitivityReaction",
"Sensitivity reactions cannot be added after the"
"integrator has been initialized.");
}
std::pair<void*, int> R = std::make_pair(reactor, leftright);
if (m_sensOrder.count(R) &&
m_sensOrder[R].count(reactionIndex)) {

View file

@ -28,12 +28,8 @@ localenv['ENV']['CANTERA_DATA'] = Dir('#build/data').abspath
PASSED_FILES = {}
# Needed for Intel runtime libraries when compiling with ICC
# Add build/lib in order to find Cantera shared library
if localenv['ENV'].get('LD_LIBRARY_PATH'):
localenv['ENV']['LD_LIBRARY_PATH'] += os.pathsep + Dir('#build/lib').abspath
else:
localenv['ENV']['LD_LIBRARY_PATH'] = Dir('#build/lib').abspath
localenv.PrependENVPath('LD_LIBRARY_PATH', Dir('#build/lib').abspath)
def addTestProgram(subdir, progName, env_vars={}):
"""

View file

@ -13,8 +13,14 @@ REACTIONS
R1A+R1B=>H+P1 1e12 0.0 20000.0
FORD / R1A 1.5 /
FORD / R1B 0.5 /
DUPLICATE
H+P1=>R1A+R1B 5e13 -2.0 5000.0
FORD / P1 0.2 /
R1A+R1B=>H+P1 1e12 0.0 20000.0
FORD / R1A 3.0 /
FORD / R1B 0.0 /
DUPLICATE
END

View file

@ -108,7 +108,7 @@
<reactionData id="reaction_data">
<!-- reaction 0001 -->
<reaction reversible="no" id="0001">
<reaction duplicate="yes" reversible="no" id="0001">
<equation>R1A + R1B =] H + P1</equation>
<order species="R1B">0.5</order>
<order species="R1A">1.5</order>
@ -138,5 +138,21 @@
<reactants>H:1.0 P1:1</reactants>
<products>R1B:1 R1A:1.0</products>
</reaction>
<!-- reaction 0003 -->
<reaction duplicate="yes" reversible="no" id="0003">
<equation>R1A + R1B =] H + P1</equation>
<order species="R1B">0.0</order>
<order species="R1A">3.0</order>
<rateCoeff>
<Arrhenius>
<A>1.000000E+06</A>
<b>0.0</b>
<E units="cal/mol">20000.000000</E>
</Arrhenius>
</rateCoeff>
<reactants>R1B:1 R1A:1.0</reactants>
<products>H:1.0 P1:1</products>
</reaction>
</reactionData>
</ctml>

View file

@ -91,4 +91,15 @@ TEST_F(TestThermoMethods, getMassFractionsByName)
EXPECT_EQ(Y.size(), (size_t) 3);
}
TEST_F(TestThermoMethods, setState_nan)
{
double nan = std::numeric_limits<double>::quiet_NaN();
thermo->setState_TP(500, 12345);
EXPECT_THROW(thermo->setState_TP(nan, 55555), CanteraError);
EXPECT_THROW(thermo->setState_TP(555, nan), CanteraError);
EXPECT_THROW(thermo->setState_HP(nan, 55555), CanteraError);
EXPECT_THROW(thermo->setState_SV(1234, nan), CanteraError);
EXPECT_THROW(thermo->setState_TR(555, nan), CanteraError);
}
}

View file

@ -7,7 +7,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
#ifdef DEBUG_CHEMEQUIL

View file

@ -9,7 +9,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try {

View file

@ -33,10 +33,7 @@ else:
localenv['ENV']['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'build', 'data')
# Add build/lib in order to find Cantera shared library
if localenv['ENV'].get('LD_LIBRARY_PATH'):
localenv['ENV']['LD_LIBRARY_PATH'] += os.pathsep + Dir('#build/lib').abspath
else:
localenv['ENV']['LD_LIBRARY_PATH'] = Dir('#build/lib').abspath
localenv.PrependENVPath('LD_LIBRARY_PATH', Dir('#build/lib').abspath)
PASSED_FILES = {}

View file

@ -25,7 +25,7 @@ void printUsage()
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
suppress_deprecation_warnings();

View file

@ -11,7 +11,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try {

View file

@ -30,7 +30,7 @@ void pAtable(HMWSoln* HMW)
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int retn = 0;

View file

@ -30,7 +30,7 @@ void pAtable(HMWSoln* HMW)
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif

View file

@ -24,7 +24,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif

View file

@ -23,7 +23,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif

View file

@ -24,7 +24,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif

View file

@ -8,7 +8,7 @@ using namespace Cantera;
int main()
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
WaterPropsIAPWSphi* phi = new WaterPropsIAPWSphi();

View file

@ -20,7 +20,7 @@ double numdpdt(WaterPropsIAPWS* water, double T, double pres)
int main()
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double dens, u, s, h;

View file

@ -9,7 +9,7 @@ using namespace Cantera;
int main()
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double dens, u, s, h, cv, cp, pres;

View file

@ -18,7 +18,7 @@ double tvalue(double val, double atol = 1.0E-9)
int main()
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double pres;

View file

@ -17,7 +17,7 @@ double tvalue(double val, double atol = 1.0E-9)
int main()
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double pres;

View file

@ -33,7 +33,7 @@ exfun fex[] = {kinetics_example1, kinetics_example3,
// main program
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
int example_num = 0;

View file

@ -26,7 +26,7 @@ void printDbl(double val)
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
if (argc != 2) {

View file

@ -26,7 +26,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
string infile = "diamond.xml";

View file

@ -36,7 +36,7 @@ static double cutoff(double val, double atol=1.0E-15)
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
string infile = "diamond.xml";

View file

@ -17,7 +17,7 @@ double tvalue(double val, double atol = 1.0E-9)
int main()
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
double pres;

View file

@ -77,7 +77,7 @@ int openRankine(int np, void* p)
int main()
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try {

View file

@ -9,7 +9,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
try {

View file

@ -151,7 +151,7 @@ void printSurf(ostream& oooo,
int main(int argc, char** argv)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
string infile;