*** empty log message ***
This commit is contained in:
parent
5277428179
commit
53ceee2aa3
11 changed files with 3121 additions and 1519 deletions
|
|
@ -52,8 +52,6 @@ while length(property_argin) >= 2,
|
|||
if sz == nComponents(a)
|
||||
setTolerances(a, val(1,:), val(2,:));
|
||||
elseif length(val) == 2
|
||||
%rt = val(1)*ones(1,nComponents(a));
|
||||
%at = val(2)*ones(1,nComponents(a));
|
||||
setTolerances(a, 'default', val(1), val(2));
|
||||
else
|
||||
error('wrong array size for error tolerances');
|
||||
|
|
@ -63,8 +61,8 @@ while length(property_argin) >= 2,
|
|||
if sz == nComponents(a)
|
||||
setTolerances(a, val(1,:), val(2,:));
|
||||
elseif length(val) == 2
|
||||
rt = val(1) %*ones(1,nComponents(a));
|
||||
at = val(2) %*ones(1,nComponents(a));
|
||||
rt = val(1);
|
||||
at = val(2);
|
||||
setTolerances(a, 'default', rt, at, 'ts');
|
||||
else
|
||||
error('wrong array size for error tolerances');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
function d = setFixedTempProfile(d, profile)
|
||||
% SETFIXEDTEMPPROFILE -
|
||||
% SETFIXEDTEMPPROFILE - set the temperature profile to use when the
|
||||
% energy equation is not being solved. The profile must be entered
|
||||
% as an array of positions / temperatures, which may be in rows or
|
||||
% columns.
|
||||
%
|
||||
sz = size(profile);
|
||||
if sz(1) == 2
|
||||
|
|
|
|||
|
|
@ -130,8 +130,14 @@ class Domain1D:
|
|||
def setDesc(self, desc):
|
||||
return _cantera.domain_setDesc(self._hndl, desc)
|
||||
|
||||
def grid(self, n):
|
||||
return _cantera.domain_grid(self._hndl, n)
|
||||
def grid(self, n = -1):
|
||||
if n >= 0:
|
||||
return _cantera.domain_grid(self._hndl, n)
|
||||
else:
|
||||
g = zeros(self.nPoints(),'d')
|
||||
for j in range(len(g)):
|
||||
g[j] = _cantera.domain_grid(self._hndl, j)
|
||||
return g
|
||||
|
||||
def set(self, **options):
|
||||
self._set(options)
|
||||
|
|
|
|||
|
|
@ -126,6 +126,12 @@ finish-install:
|
|||
@INSTALL@ examples/cxx/Makefile @prefix@/cantera/demos/c++
|
||||
chown -R @username@ @prefix@/cantera/demos/c++
|
||||
@INSTALL@ -d @prefix@/cantera/demos/f77
|
||||
@INSTALL@ Cantera/fortran/f77demos/*.f @prefix@/cantera/demos/f77
|
||||
@INSTALL@ tools/templates/f77/demo_ftnlib.cpp @prefix@/cantera/demos/f77
|
||||
@INSTALL@ Cantera/fortran/f77demos/*.txt @prefix@/cantera/demos/f77
|
||||
@INSTALL@ Cantera/fortran/f77demos/f77demos.mak @prefix@/cantera/demos/f77/Makefile
|
||||
chown -R @username@ @prefix@/cantera/demos/f77
|
||||
|
||||
(PYTHONPATH=''; @PYTHON_CMD@ tools/bin/finish_install.py @prefix@ @PYTHON_CMD@)
|
||||
#@INSTALL@ bin/ctmkmf @prefix@/bin/ctnew
|
||||
#@INSTALL@ bin/cxx_examples @prefix@/cantera/demos/c++
|
||||
|
|
|
|||
10
config.h
10
config.h
|
|
@ -9,11 +9,11 @@
|
|||
//------------------------ Fortran settings -------------------//
|
||||
|
||||
|
||||
// define types doublereal, integer, and ftnlen to match the
|
||||
// define types doublereal, integer, and ftnlen to match the
|
||||
// corresponding Fortran data types on your system. The defaults
|
||||
// are OK for most systems
|
||||
|
||||
typedef double doublereal; // Fortran double precision
|
||||
typedef double doublereal; // Fortran double precision
|
||||
typedef int integer; // Fortran integer
|
||||
typedef int ftnlen; // Fortran hidden string length type
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ typedef int ftnlen; // Fortran hidden string length type
|
|||
// adding a hidden argement with the length of the string. Some
|
||||
// compilers add the hidden length argument immediately after the
|
||||
// CHARACTER variable being passed, while others put all of the hidden
|
||||
// length arguments at the end of the argument list. Define this if
|
||||
// length arguments at the end of the argument list. Define this if
|
||||
// the lengths are at the end of the argument list. This is usually the
|
||||
// case for most unix Fortran compilers, but is (by default) false for
|
||||
// Visual Fortran under Windows.
|
||||
|
|
@ -37,7 +37,7 @@ typedef int ftnlen; // Fortran hidden string length type
|
|||
//-------- LAPACK / BLAS ---------
|
||||
|
||||
// Define if you are using LAPACK and BLAS from the Intel Math Kernel
|
||||
// Library
|
||||
// Library
|
||||
/* #undef HAVE_INTEL_MKL */
|
||||
|
||||
#define LAPACK_FTN_STRING_LEN_AT_END
|
||||
|
|
@ -45,7 +45,7 @@ typedef int ftnlen; // Fortran hidden string length type
|
|||
#define LAPACK_FTN_TRAILING_UNDERSCORE
|
||||
|
||||
|
||||
//--------- Cantera --------------
|
||||
//--------- Cantera --------------
|
||||
|
||||
|
||||
//--------- CKReader -------------
|
||||
|
|
|
|||
4404
config/configure
vendored
4404
config/configure
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -402,6 +402,7 @@ AC_OUTPUT(../Cantera/Makefile \
|
|||
../Cantera/src/transport/Makefile \
|
||||
../Cantera/clib/src/Makefile \
|
||||
../Cantera/fortran/src/Makefile \
|
||||
../Cantera/fortran/f77demos/f77demos.mak \
|
||||
../Cantera/matlab/Makefile \
|
||||
../Cantera/python/Makefile \
|
||||
../Cantera/python/setup.py \
|
||||
|
|
|
|||
2
configure
vendored
2
configure
vendored
|
|
@ -58,7 +58,7 @@ BUILD_PYTHON_INTERFACE=${BUILD_PYTHON_INTERFACE:="y"}
|
|||
# Set this to "y" if you want to build the Matlab toolbox. Matlab must
|
||||
# be installed on your system first, since the build process runs a
|
||||
# Matlab script.
|
||||
|
||||
PYTHON_CMD=${PYTHON_CMD:="/usr/local/bin/python"}
|
||||
BUILD_MATLAB_TOOLBOX=${BUILD_MATLAB_TOOLBOX:="y"}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -6,22 +6,38 @@
|
|||
#include "Cantera.h"
|
||||
#include "IdealGasMix.h"
|
||||
#include "equilibrium.h"
|
||||
#include "transport.h"
|
||||
|
||||
using namespace Cantera;
|
||||
|
||||
int main() {
|
||||
void demoprog() {
|
||||
|
||||
IdealGasMix gas("h2o2.xml");
|
||||
IdealGasMix gas("h2o2.cti","ohmech");
|
||||
double temp = 1200.0;
|
||||
double pres = OneAtm;
|
||||
gas.setState_TPX(temp, pres, "H2:2, O2:1, OH:0.01, H:0.01, O:0.01");
|
||||
equilibrate(gas,"HP");
|
||||
|
||||
printf("\n\n**** C++ Test Program ****\n\n");
|
||||
|
||||
|
||||
// Thermodynamic properties
|
||||
|
||||
printf("\n\nInitial state:\n\n");
|
||||
printf(
|
||||
"Temperature: %14.5g K\n"
|
||||
"Pressure: %14.5g Pa\n"
|
||||
"Density: %14.5g kg/m3\n"
|
||||
"Molar Enthalpy: %14.5g J/kmol\n"
|
||||
"Molar Entropy: %14.5g J/kmol-K\n"
|
||||
"Molar cp: %14.5g J/kmol-K\n",
|
||||
gas.temperature(), gas.pressure(), gas.density(),
|
||||
gas.enthalpy_mole(), gas.entropy_mole(), gas.cp_mole());
|
||||
|
||||
// set the gas to the equilibrium state with the same specific
|
||||
// enthalpy and pressure
|
||||
equilibrate(gas,"HP");
|
||||
|
||||
printf("\n\nEquilibrium state:\n\n");
|
||||
printf(
|
||||
"Temperature: %14.5g K\n"
|
||||
"Pressure: %14.5g Pa\n"
|
||||
|
|
@ -32,7 +48,6 @@ int main() {
|
|||
gas.temperature(), gas.pressure(), gas.density(),
|
||||
gas.enthalpy_mole(), gas.entropy_mole(), gas.cp_mole());
|
||||
|
||||
|
||||
// Reaction information
|
||||
|
||||
int irxns = gas.nReactions();
|
||||
|
|
@ -40,14 +55,42 @@ int main() {
|
|||
double* qr = new double[irxns];
|
||||
double* q = new double[irxns];
|
||||
|
||||
// since the gas has been set to an equilibrium state, the forward
|
||||
// and reverse rates of progress should be equal, and the net
|
||||
// rates should be zero.
|
||||
gas.getFwdRatesOfProgress(qf);
|
||||
gas.getRevRatesOfProgress(qr);
|
||||
gas.getNetRatesOfProgress(q);
|
||||
|
||||
for (int i = 0; i < irxns; i++) {
|
||||
printf("%30s %14.5g %14.5g %14.5g \n",
|
||||
printf("%30s %14.5g %14.5g %14.5g kmol/m3/s\n",
|
||||
gas.reactionString(i).c_str(), qf[i], qr[i], q[i]);
|
||||
}
|
||||
|
||||
// transport properties
|
||||
|
||||
Transport* tr = newTransportMgr("Mix", &gas, 1);
|
||||
printf("\n\nViscosity: %14.5g Pa-s\n", tr->viscosity());
|
||||
printf("Thermal conductivity: %14.5g W/m/K\n", tr->thermalConductivity());
|
||||
|
||||
int nsp = gas.nSpecies();
|
||||
double* diff = new double[nsp];
|
||||
tr->getMixDiffCoeffs(diff);
|
||||
int k;
|
||||
printf("\n\n%20s %26s\n", "Species","Diffusion Coefficient");
|
||||
for (k = 0; k < nsp; k++) {
|
||||
printf("%20s %14.5g m2/s \n", gas.speciesName(k).c_str(), diff[k]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
try {
|
||||
demoprog();
|
||||
}
|
||||
catch (CanteraError) {
|
||||
showErrors(cout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,17 +3,21 @@ c Replace this sample main program with your program
|
|||
c
|
||||
c This program uses functions defined in demo_ftnlib.cpp to create
|
||||
c an ideal gas mixture and print some its properties.
|
||||
c
|
||||
c For a C++ version of this program, see ../cxx/demo.cpp.
|
||||
c
|
||||
program demo
|
||||
implicit double precision (a-h,o-z)
|
||||
parameter (MAXSP = 20, MAXRXNS = 100)
|
||||
double precision q(MAXRXNS), qf(MAXRXNS), qr(MAXRXNS)
|
||||
double precision x(MAXSP), y(MAXSP), wdot(MAXSP)
|
||||
double precision diff(MAXSP)
|
||||
character*80 eq
|
||||
character*20 name
|
||||
c
|
||||
write(*,*) '**** Fortran 77 Test Program ****'
|
||||
|
||||
call newIdealGasMix('h2o2.cti','ohmech')
|
||||
call newIdealGasMix('h2o2.cti','ohmech','Mix')
|
||||
t = 1200.0
|
||||
p = 101325.0
|
||||
call setState_TPX_String(t, p,
|
||||
|
|
@ -60,7 +64,24 @@ c for each reaction, print the equation and the rates of progress
|
|||
20 format(a27,3e14.5,' kmol/m3/s')
|
||||
end do
|
||||
|
||||
c
|
||||
c Transport properties
|
||||
c
|
||||
dnu = viscosity()
|
||||
dlam = thermalConductivity()
|
||||
call getMixDiffCoeffs(diff)
|
||||
|
||||
write(*,30) dnu, dlam
|
||||
30 format(//'Viscosity: ',g14.5,' Pa-s'/
|
||||
$ 'Thermal conductivity: ',g14.5,' W/m/K'/)
|
||||
write(*,*) 'Species ',
|
||||
$ ' Diffusion Coefficient'
|
||||
nsp = nSpecies()
|
||||
do k = 1, nsp
|
||||
call getSpeciesName(k, name)
|
||||
write(*,40) name, diff(k)
|
||||
40 format(' ',a20,e14.5,' m2/s')
|
||||
end do
|
||||
|
||||
stop
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,29 +7,47 @@
|
|||
functions that access the objects through the pointers.
|
||||
|
||||
This particular example defines functions that return thermodynamic
|
||||
properties and kinetic rates for reacting ideal gas mixtures. Only a
|
||||
single pointer to an IdealGasMix object is stored, so only one
|
||||
reaction mechanism may be used at any one time in the application.
|
||||
Of course, it is a simple modification to store multiple objects if
|
||||
it is desired to use multiple reaction mechanisms.
|
||||
properties, transport properties, and kinetic rates for reacting
|
||||
ideal gas mixtures. Only a single pointer to an IdealGasMix object is
|
||||
stored, so only one reaction mechanism may be used at any one time in
|
||||
the application. Of course, it is a simple modification to store
|
||||
multiple objects if it is desired to use multiple reaction
|
||||
mechanisms.
|
||||
|
||||
The functions defined here are ones commonly needed in application
|
||||
programs that simulate gas-phase combustion or similar processes.
|
||||
programs that simulate gas-phase combustion or similar
|
||||
processes. Similar libraries to access other capabilities of Cantera
|
||||
(surface chemistry, etc.) could be written in the same way.
|
||||
|
||||
*/
|
||||
|
||||
// add any other Cantera header files you need here
|
||||
#include "IdealGasMix.h"
|
||||
#include "equilibrium.h"
|
||||
|
||||
// store a pointer to an IdealGasMix object. The object itself will
|
||||
// be created by the call to init_.
|
||||
|
||||
// store a pointer to an IdealGasMix object
|
||||
static IdealGasMix* _gas = 0;
|
||||
|
||||
|
||||
// provides access to the pointer for functions in other libraries
|
||||
// provides access to the pointers for functions in other libraries
|
||||
IdealGasMix* _gasptr() { return _gas; }
|
||||
|
||||
// comment these out to produce a smaller executable if not needed
|
||||
#define WITH_EQUIL
|
||||
#define WITH_TRANSPORT
|
||||
|
||||
#ifdef WITH_EQUIL
|
||||
#include "equilibrium.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WITH_TRANSPORT
|
||||
#include "transport.h"
|
||||
|
||||
// store a pointer to a transport manager
|
||||
static Transport* _trans = 0;
|
||||
Transport* _transptr() { return _trans; }
|
||||
#endif
|
||||
|
||||
// error handler
|
||||
void handleError() {
|
||||
showErrors(cout);
|
||||
|
|
@ -50,17 +68,28 @@ extern "C" {
|
|||
* you have a file in Chemkin-compatible format, use utility
|
||||
* program ck2cti first to convert it into Cantera format.)
|
||||
*/
|
||||
void newidealgasmix_(char* file, char* id,
|
||||
ftnlen lenfile, ftnlen lenid) {
|
||||
void newidealgasmix_(char* file, char* id, char* transport,
|
||||
ftnlen lenfile, ftnlen lenid, ftnlen lentr) {
|
||||
string trmodel = "";
|
||||
try {
|
||||
string fin = string(file, lenfile);
|
||||
string fth = string(id, lenid);
|
||||
trmodel = string(transport, lentr);
|
||||
if (_gas) delete _gas;
|
||||
_gas = new IdealGasMix(fin, fth);
|
||||
}
|
||||
catch (CanteraError) {
|
||||
handleError();
|
||||
}
|
||||
#ifdef WITH_TRANSPORT
|
||||
try {
|
||||
if (_trans) delete _trans;
|
||||
_trans = newTransportMgr(trmodel,_gas,1);
|
||||
}
|
||||
catch (CanteraError) {
|
||||
_trans = newTransportMgr("",_gas,1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// integer function nElements()
|
||||
|
|
@ -72,6 +101,14 @@ extern "C" {
|
|||
/// integer function nReactions()
|
||||
integer nreactions_() { return _gas->nReactions(); }
|
||||
|
||||
void getspeciesname_(integer* k, char* name, ftnlen n) {
|
||||
int ik = *k - 1;
|
||||
fill(name, name + n, ' ');
|
||||
string spnm = _gas->speciesName(ik);
|
||||
int ns = spnm.size();
|
||||
unsigned int nmx = (ns > n ? n : ns);
|
||||
copy(spnm.begin(), spnm.begin()+nmx, name);
|
||||
}
|
||||
|
||||
//-------------- setting the state ----------------------------
|
||||
|
||||
|
|
@ -99,6 +136,20 @@ extern "C" {
|
|||
catch (CanteraError) { handleError(); }
|
||||
}
|
||||
|
||||
void setstate_tpy_(doublereal* T, doublereal* p, doublereal* Y) {
|
||||
try {
|
||||
_gas->setState_TPY(*T, *p, Y);
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
}
|
||||
|
||||
void setstate_sp_(doublereal* s, doublereal* p) {
|
||||
try {
|
||||
_gas->setState_SP(*s, *p);
|
||||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
}
|
||||
|
||||
//-------------- thermodynamic properties ----------------------
|
||||
|
||||
/// Temperature (K)
|
||||
|
|
@ -162,6 +213,10 @@ extern "C" {
|
|||
return _gas->cp_mass();
|
||||
}
|
||||
|
||||
doublereal cv_mass_() {
|
||||
return _gas->cv_mass();
|
||||
}
|
||||
|
||||
doublereal gibbs_mass_() {
|
||||
return _gas->gibbs_mass();
|
||||
}
|
||||
|
|
@ -174,6 +229,7 @@ extern "C" {
|
|||
_gas->getMassFractions(y);
|
||||
}
|
||||
|
||||
#ifdef WITH_EQUIL
|
||||
void equilibrate_(char* opt, ftnlen lenopt) {
|
||||
try {
|
||||
if (lenopt != 2) {
|
||||
|
|
@ -185,7 +241,7 @@ extern "C" {
|
|||
}
|
||||
catch (CanteraError) { handleError(); }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//---------------- kinetics -------------------------
|
||||
|
||||
|
|
@ -222,6 +278,38 @@ extern "C" {
|
|||
_gas->getRevRatesOfProgress(q);
|
||||
}
|
||||
|
||||
//-------------------- transport properties --------------------
|
||||
|
||||
#ifdef WITH_TRANSPORT
|
||||
double viscosity_() {
|
||||
try {
|
||||
return _trans->viscosity();
|
||||
}
|
||||
catch (CanteraError) { handleError(); return 0.0; }
|
||||
}
|
||||
|
||||
double thermalconductivity_() {
|
||||
try {
|
||||
return _trans->thermalConductivity();
|
||||
}
|
||||
catch (CanteraError) { handleError(); return 0.0; }
|
||||
}
|
||||
|
||||
void getmixdiffcoeffs_(double* diff) {
|
||||
try {
|
||||
_trans->getMixDiffCoeffs(diff);
|
||||
}
|
||||
catch (CanteraError) { handleError();}
|
||||
}
|
||||
|
||||
void getthermaldiffcoeffs_(double* dt) {
|
||||
try {
|
||||
_trans->getThermalDiffCoeffs(dt);
|
||||
}
|
||||
catch (CanteraError) { handleError();}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue