Merge remote-tracking branch 'liquidTransportDevelop'

This commit is contained in:
Ray Speth 2012-02-09 18:05:01 +00:00
commit a47addf412
526 changed files with 70586 additions and 22677 deletions

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: hkmoffa $
# $Date: 2007/05/06 17:16:43 $
# $Revision: 1.8 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2001 California Institute of Technology
# See file License.txt for licensing information

View file

@ -48,8 +48,6 @@
#endif
namespace Cantera {}
//using namespace Cantera;
namespace std {}
//using namespace std;
#endif

View file

@ -17,10 +17,11 @@
#include "Func1.h"
#include "ctexceptions.h"
using namespace Cantera;
#include "Cabinet.h"
using namespace Cantera;
using namespace std;
typedef Func1 func_t;

View file

@ -565,12 +565,13 @@ extern "C" {
catch (CanteraError) { return -1; }
}
int DLL_EXPORT sim1D_writeStats(int i) {
int DLL_EXPORT sim1D_writeStats(int i, int printTime) {
try {
_sim1D(i)->writeStats();
_sim1D(i)->writeStats(printTime);
return 0;
} catch (CanteraError) {
return -1;
}
catch (CanteraError) { return -1; }
}
int DLL_EXPORT sim1D_domainIndex(int i, char* name) {

View file

@ -84,7 +84,7 @@ extern "C" {
EEXXTT int DLL_CPREFIX sim1D_save(int i, char* fname, char* id,
char* desc);
EEXXTT int DLL_CPREFIX sim1D_restore(int i, char* fname, char* id);
EEXXTT int DLL_CPREFIX sim1D_writeStats(int i);
EEXXTT int DLL_CPREFIX sim1D_writeStats(int i, int printTime = 1);
EEXXTT int DLL_CPREFIX sim1D_domainIndex(int i, char* name);
EEXXTT double DLL_CPREFIX sim1D_value(int i, int idom, int icomp, int localPoint);
EEXXTT double DLL_CPREFIX sim1D_workValue(int i, int idom,

View file

@ -27,6 +27,8 @@
#include "Storage.h"
using namespace CanteraZeroD;
using namespace Cantera;
using namespace std;
typedef ReactorBase reactor_t;
typedef ReactorNet reactornet_t;

View file

@ -429,8 +429,8 @@ extern "C" {
return 0;
}
int DLL_EXPORT onedim_writeStats(int i) {
_onedim(i)->writeStats();
int DLL_EXPORT onedim_writeStats(int i, int printTime) {
_onedim(i)->writeStats(printTime);
return 0;
}

View file

@ -68,7 +68,7 @@ extern "C" {
int DLL_IMPORT onedim_settransientmode(int i, double dt, double* x);
int DLL_IMPORT onedim_setnewtonoptions(int i, int maxage);
int DLL_IMPORT onedim_resize(int i);
int DLL_IMPORT onedim_writeStats(int i);
int DLL_IMPORT onedim_writeStats(int i, int printTime = 1);
double DLL_IMPORT onedim_timestep(int i, int nsteps, double dt,
double* x, double* xnew, int loglevel);
int DLL_IMPORT onedim_save(int i, char* fname, char* id, char* desc, double* soln);

View file

@ -24,6 +24,7 @@
using namespace std;
using namespace Cantera;
using namespace ctml;
// Assign storage for the static member of the Templated Cabinet class

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: hkmoffa $
# $Date: 2009/04/04 03:27:43 $
# $Revision: 1.14 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2001 California Institute of Technology
# See file License.txt for licensing information
@ -18,7 +18,7 @@ INSTALL_TSC = ../../../bin/install_tsc
CXX_H = Cantera.h equilibrium.h IncompressibleSolid.h \
kinetics.h onedim.h surface.h GRI30.h integrators.h \
Metal.h PureFluid.h transport.h Edge.h \
IdealGasMix.h Interface.h numerics.h \
IdealGasMix.h Interface.h numerics.h solvers.h \
reactionpaths.h zerodim.h importPhase.h thermo.h \
radiation.h spectra.h electrolyteThermo.h Cantera.mak Cantera_bt.mak

View file

@ -12,6 +12,7 @@
using namespace std;
using namespace Cantera;
using namespace Cantera_CXX;
// The program is put into a function so that error handling code can

View file

@ -12,6 +12,9 @@
#include <cantera/IdealGasMix.h>
using namespace CanteraZeroD;
using namespace Cantera;
using namespace Cantera_CXX;
using namespace std;
void runexample() {

View file

@ -17,6 +17,7 @@
using namespace Cantera;
using namespace Cantera_CXX;
using namespace std;
int flamespeed(int np, void* p) {
try {

View file

@ -5,11 +5,8 @@
#include <cantera/kernel/plots.h>
namespace Cantera{}
using namespace Cantera;
namespace std{}
using namespace std;
namespace CanteraZeroD{}
using namespace CanteraZeroD;
// Save the temperature, density, pressure, and mole fractions at one
// time
@ -48,18 +45,18 @@ void makeDataLabels(const G& gas, V& names) {
}
template<class G, class A>
void plotSoln(string fname, string fmt, string title, const G& gas, const A& soln) {
vector<string> names;
void plotSoln(std::string fname, std::string fmt, std::string title, const G& gas, const A& soln) {
std::vector<std::string> names;
makeDataLabels(gas, names);
writePlotFile(fname, fmt, title, names, soln);
}
inline void writeCanteraHeader(ostream& s) {
s << endl;
s << " Cantera version " << "CANTERA_VERSION" << endl;
s << " Copyright California Institute of Technology, 2002." << endl;
s << " http://www.cantera.org" << endl;
s << endl;
inline void writeCanteraHeader(std::ostream& s) {
s << std::endl;
s << " Cantera version " << "CANTERA_VERSION" << std::endl;
s << " Copyright California Institute of Technology, 2002." << std::endl;
s << " http://www.cantera.org" << std::endl;
s << std::endl;
}
#endif

View file

@ -2,9 +2,9 @@
//
// zero-dimensional kinetics example program
//
// $Author: hkmoffa $
// $Revision: 1.2 $
// $Date: 2009/05/13 21:52:29 $
// $Author$
// $Revision$
// $Date$
//
// copyright California Institute of Technology 2002
//
@ -24,6 +24,10 @@
#include <time.h>
#include "example_utils.h"
using namespace std;
using namespace Cantera;
using namespace CanteraZeroD;
using namespace Cantera_CXX;
int kinetics1(int np, void* p) {

View file

@ -1,7 +1,6 @@
/**
* @file Cantera.h
* Basic include file to be used in all Cantera application
* environments.
* Basic include file to be used in all Cantera application environments.
*/
/*
@ -11,18 +10,24 @@
// Copyright 2001 California Institute of Technology
/*
* Note, this include should be the first include that code containing the
* Cantera namespace sees when in the Cantera application environment.
*/
#ifndef CANTERA_H_INCL
#define CANTERA_H_INCL
// definitions
// If we are using this file, then we are in the Cantera Apps environment.
// Define a variable to signify this fact.
#ifndef CANTERA_APP
#define CANTERA_APP
#endif
// define the presence of the Cantera_CXX namespace
namespace Cantera_CXX{ }
using namespace Cantera_CXX;
// Include global typedefs and values for physical constants using SI units
#include "kernel/ct_defs.h"
// some useful functions
@ -31,9 +36,6 @@ using namespace Cantera_CXX;
// the CanteraError exception class
#include "kernel/ctexceptions.h"
//
//#include "kernel/importCTML.h"
// The Cantera logger class
#include "kernel/logger.h"
@ -46,10 +48,9 @@ using namespace Cantera_CXX;
// Include string utility routines
#include "kernel/stringUtils.h"
// Include the array object
#include "kernel/Array.h"
#endif

View file

@ -15,16 +15,16 @@
#
#
#####################################################################
# $Id: Cantera.mak.in,v 1.5 2009/01/09 23:26:41 hkmoffa Exp $
# $Id$
#
#
# This variable determines whether we are making this example in the
# build tree environment or in the install tree environment.
#
in_CanteraBuildTree = 0
#
CANTERA_VERSION=@ctversion@
#
###############################################################################
# CANTERA CORE
###############################################################################
@ -88,9 +88,13 @@ CANTERA_SUNDIALS_LIB_DIR=@sundials_lib_dir@
ifeq ($(CANTERA_use_sundials), 1)
CANTERA_CVODE_LIBS=-L$(CANTERA_SUNDIALS_LIB_DIR) @CVODE_LIBS@
CANTERA_CVODE_LIBS_DEP=@sundials_lib_dep@
CANTERA_SUNDIALS_LIBS=-L$(CANTERA_SUNDIALS_LIB_DIR) @sundials_lib@
CANTERA_SUNDIALS_LIBS_DEP=@sundials_lib_dep@
else
CANTERA_CVODE_LIBS= -L$(CANTERA_LIBSDIR) -lcvode
CANTERA_CVODE_LIBS_DEP=$(CANTERA_LIBSDIR)/libcvode.a
CANTERA_SUNDIALS_LIBS=-L$(CANTERA_LIBSDIR) -lcvode
CANTERA_SUNDIALS_LIBS_DEP=-L$(CANTERA_LIBSDIR)/libcvode.a
endif
#
#######################################################################
@ -133,14 +137,13 @@ CANTERA_DEFINES = -DCANTERA_VERSION=@ctversion@
CANTERA_TOTAL_LIBS2 = -L$(CANTERA_LIBSDIR) @LOCAL_LIBS@
#
CANTERA_TOTAL_LIBS= $(CANTERA_CORE_LIBS) $(CANTERA_BOOST_LIBS) \
$(CANTERA_CVODE_LIBS) $(CANTERA_BLAS_LAPACK_LIBS) \
$(CANTERA_SUNDIALS_LIBS) $(CANTERA_BLAS_LAPACK_LIBS) \
$(CANTERA_F2C_LIBS)
#
CANTERA_TOTAL_LIBS_DEP= $(CANTERA_CORE_LIBS_DEP) \
$(CANTERA_CVODE_LIBS_DEP) \
$(CANTERA_SUNDIALS_LIBS_DEP) \
$(CANTERA_BLAS_LAPACK_LIBS_DEP)
#
#
# Dependency Line
#
CANTERA_LIBS_DEP= @INSTALL_LIBS_DEP@ $(CANTERA_LIBDIR)/libctcxx.a

View file

@ -15,13 +15,17 @@
#
#
#####################################################################
# $Id: Cantera_bt.mak.in,v 1.2 2008/01/21 21:17:52 hkmoffa Exp $
# $Id$
#
#
# This variable determines whether we are making this example in the
# build tree environment or in the install tree environment.
#
in_CanteraBuildTree = 0
#
CANTERA_VERSION=@ctversion@
#
CANTERA_VERSION=@ctversion@
CANTERA_VERSION=@ctversion@
@ -112,18 +116,17 @@ CANTERA_F2C_LIBS= -L$(CANTERA_LIBSDIR) -lctf2c
else
CANTERA_F2C_LIBS= @F2C_SYSTEMLIB@
endif
#
#####################################################################
# COMBINATIONS OF INCLUDES AND LIBS
####################################################################
#
CANTERA_TOTAL_INCLUDES= $(CANTERA_CORE_INCLUDES) $(CANTERA_BOOST_INCLUDES) $(CANTERA_CVODE_INCLUDE)
#
# You can add this into the compilation environment to identify the version number
#
CANTERA_DEFINES = -DCANTERA_VERSION=@ctversion@
#
CANTERA_TOTAL_LIBS2 = @LOCAL_LIB_DIRS@ @LOCAL_LIBS@
CANTERA_TOTAL_LIBS= $(CANTERA_CORE_LIBS) $(CANTERA_BOOST_LIBS) \

View file

@ -7,7 +7,6 @@
#include "kernel/EdgeKinetics.h"
#include "kernel/importKinetics.h"
using namespace Cantera;
namespace Cantera_CXX {
class Edge :

View file

@ -11,6 +11,7 @@
#include "kernel/importKinetics.h"
#include "kernel/stringUtils.h"
namespace Cantera_CXX {
/**

View file

@ -15,77 +15,128 @@
#include "Cantera.h"
#include "thermo.h"
#include "kinetics.h"
// #include "kernel/SurfPhase.h"
// #include "kernel/InterfaceKinetics.h"
// #include "kernel/importKinetics.h"
/**
* This namespace is used for the Cantera C++ user interface.
*/
namespace Cantera_CXX {
/**
* An interface between multiple bulk phases. This class is
* defined mostly for convenience. It inherits both from
* Cantera::SurfPhase and Cantera::InterfaceKinetics. It therefore
* represents a surface phase, and also acts as the kinetics
* manager to manage reaction occurring on the surface, possibly
* involving species from other phases.
//! An interface between multiple bulk phases.
/*!
* This class isdefined mostly for convenience. It inherits both from
* Cantera::SurfPhase and Cantera::InterfaceKinetics. It therefore
* represents a surface phase, and also acts as the kinetics
* manager to manage reactions occurring on the surface, possibly
* involving species from other phases.
*/
class Interface :
public Cantera::SurfPhase,
public Cantera::InterfaceKinetics
{
public:
//! Constructor.
/*!
* Construct an Interface instance from a specification in an input file.
*
* @param infile. Cantera input file in CTI or CTML format.
* @param id Identification string to distinguish between
* multiple definitions within one input file.
* @param otherPhases Neighboring phases that may participate in the
* reactions on this interface. Don't include the
* surface phase
*
* @deprecated
* While it's convenient to have the surface phase and the interfacial reaction
* together, this class doesn't satisfy the primary issue, which is one
* of instantiation of all the ThermoPhase classes that accompany a
* surface reaction. This is accomplished by the PhaseList class along with
* the ReactingSurface class. These classes will be migrated into Cantera
* soon.
*/
class Interface :
public Cantera::SurfPhase,
public Cantera::InterfaceKinetics
Interface(std::string infile, std::string id,
std::vector<Cantera::ThermoPhase*> otherPhases) :
m_ok(false),
m_r(0)
{
public:
/**
* Constructor. Construct an Interface instance from
* a specification in an input file.
* @param infile. Cantera input file in CTI or CTML format.
* @param id Identification string to distinguish between
* multiple definitions within one input file.
* @param phases Neighboring phases that may participate in the
* reactions on this interface.
*/
Interface(std::string infile, std::string id,
std::vector<Cantera::ThermoPhase*> phases)
: m_ok(false), m_r(0) {
m_r = Cantera::get_XML_File(infile);
if (id == "-") id = "";
Cantera::XML_Node* x = Cantera::get_XML_Node("#"+id, m_r);
if (!x)
throw Cantera::CanteraError("Interface","error in get_XML_Node");
Cantera::importPhase(*x, this);
phases.push_back(this);
Cantera::importKinetics(*x, phases, this);
m_ok = true;
}
/// Destructor. Does nothing.
virtual ~Interface() {}
bool operator!() { return !m_ok;}
bool ready() const { return m_ok; }
protected:
bool m_ok;
Cantera::XML_Node* m_r;
private:
};
/**
* Import an instance of class Interface from a specification in an
* input file. This is the preferred method to create an Interface
* instance.
*/
inline Interface* importInterface(std::string infile, std::string id,
std::vector<Cantera::ThermoPhase*> phases) {
return new Interface(infile, id, phases);
m_r = Cantera::get_XML_File(infile);
if (id == "-") id = "";
Cantera::XML_Node* x = Cantera::get_XML_Node("#"+id, m_r);
if (!x) {
throw Cantera::CanteraError("Interface","error in get_XML_Node");
}
Cantera::importPhase(*x, this);
otherPhases.push_back(this);
Cantera::importKinetics(*x, otherPhases, this);
m_ok = true;
}
//! Copy Constructor
/*!
* @param ii Interface object to be copied.
*/
Interface(const Interface& ii) :
Cantera::SurfPhase(ii),
Cantera::InterfaceKinetics(ii),
m_ok(ii.m_ok),
m_r(ii.m_r)
{
}
//! Assignment operator
/*!
* @param right Interface object to be copied.
*/
Interface & operator=(const Interface &right) {
if (this == &right) return *this;
Cantera::SurfPhase::operator=(right);
Cantera::InterfaceKinetics::operator=(right);
m_ok = right.m_ok;
m_r = right.m_r;
return *this;
}
//! Destructor. Does nothing.
virtual ~Interface() {
}
//! Not operator
bool operator!() {
return !m_ok;
}
//! return whether the object has been instantiated
/*!
* @return Returns a bool.
*/
bool ready() const {
return m_ok;
}
protected:
//! Flag indicating that the object has been instantiated
bool m_ok;
//! XML_Node pointer to the XML File object that contains the Surface and the Interfacial Reaction object
//! description
Cantera::XML_Node* m_r;
};
//! Import an instance of class Interface from a specification in an input file.
/*!
* This is the preferred method to create an Interface instance.
*/
Interface* importInterface(std::string infile, std::string id, std::vector<Cantera::ThermoPhase*> phases) {
return new Interface(infile, id, phases);
}
}

View file

@ -9,8 +9,8 @@
#ifndef CT_ELECTROLYTETHERMO_INCL
#define CT_ELECTROLYTETHERMO_INCL
#include "thermo.h"
#ifdef WITH_ELECTROLYTES
#include "kernel/electrolytes.h"
#include "kernel/MolalityVPSSTP.h"
#include "kernel/VPStandardStateTP.h"
@ -26,3 +26,5 @@
#include "kernel/VPSSMgr_Water_HKFT.h"
#include "kernel/VPSSMgr_Water_ConstVol.h"
#endif
#endif

View file

@ -6,5 +6,7 @@
#define CT_INTEG_H_INCL
#include "kernel/Integrator.h"
#include "kernel/DAE_Solver.h"
#include "kernel/IDA_Solver.h"
#endif

View file

@ -4,5 +4,6 @@
#include "kernel/DenseMatrix.h"
#include "kernel/BandMatrix.h"
#include "kernel/SquareMatrix.h"
#include "kernel/NonlinearSolver.h"
#endif

View file

@ -0,0 +1,12 @@
/**
* @file solvers.h
* solvers of small embedded problems
*/
#ifndef CT_SOLVERS_H_INCL
#define CT_SOLVERS_H_INCL
#include "kernel/ResidEval.h"
#include "kernel/solveProb.h"
#endif

View file

@ -14,4 +14,33 @@
#include "kernel/SurfPhase.h"
#include "kernel/EdgePhase.h"
#ifdef WITH_IDEAL_SOLUTIONS
#include "kernel/GibbsExcessVPSSTP.h"
#include "kernel/MargulesVPSSTP.h"
#endif
#ifdef WITH_ELECTROLYTES
#include "electrolyteThermo.h"
#endif
#ifdef WITH_LATTICE_SOLID
#include "kernel/LatticePhase.h"
#include "kernel/LatticeSolidPhase.h"
#endif
#ifdef WITH_PURE_FLUIDS
#endif
#endif

View file

@ -13,4 +13,5 @@
#include "kernel/DustyGasTransport.h"
#include "kernel/MultiTransport.h"
#include "kernel/MixTransport.h"
#include "kernel/LiquidTransport.h"
#endif

View file

@ -11,7 +11,6 @@
#include "kernel/FlowReactor.h"
#include "kernel/ConstPressureReactor.h"
using namespace CanteraZeroD;
#endif

View file

@ -18,6 +18,10 @@ FORT = @F77@
# Fortran compile flags
FORT_FLAGS = @FFLAGS@
FCLIBS= @FCLIBS@
FLIBS = @FLIBS@
# Fortran libraries
FORT_LIBS = @LCXX_FLIBS@ @LCXX_END_LIBS@ @FLIBS@

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: hkmoffa $
# $Date: 2009/04/04 03:23:32 $
# $Revision: 1.21 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2001 California Institute of Technology
#

View file

@ -7,7 +7,7 @@
* pointers are passed to or from the calling application.
*/
/*
* $Id: fct.cpp,v 1.14 2009/07/23 16:56:48 hkmoffa Exp $
* $Id$
*/
// turn off warnings under Windows
@ -30,6 +30,9 @@
#include "flib_defs.h"
using namespace Cantera;
using namespace std;
// Assert that there is storage
// for the templated classes' static member
// (needed to compile on solaris)
@ -39,7 +42,7 @@ inline XML_Node* _xml(const integer* n) {
return Cabinet<XML_Node>::cabinet()->item(*n);
}
inline ThermoPhase* _fph(const integer* n) {
inline Cantera::ThermoPhase* _fph(const integer* n) {
return th(*n);
}

View file

@ -4,8 +4,8 @@
*/
/*
* $Revision: 1.9 $
* $Date: 2009/07/23 17:03:04 $
* $Revision$
* $Date$
*/
// Copyright 2001 California Institute of Technology
@ -19,6 +19,7 @@
using namespace ctml;
using namespace std;
using namespace Cantera;
#include "../../clib/src/Cabinet.h"

View file

@ -21,8 +21,6 @@
typedef integer status_t;
namespace Cantera {}
using namespace Cantera;
namespace std{}
using namespace std;
#endif

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: hkmoffa $
# $Date: 2009/07/06 23:52:40 $
# $Revision: 1.33 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2001-2004 California Institute of Technology
# See file License.txt for licensing information

View file

@ -33,7 +33,7 @@
% ctclear - Clear all objects from memory.
%
% Copyright 2002 California Institute of Technology
% $Revision: 1.1.1.1 $ $Date: 2003/04/14 17:57:49 $
% $Revision$ $Date$

View file

@ -2,7 +2,7 @@
* @file ctfunctions.cpp
*/
/*
* $Id: ctfunctions.cpp,v 1.10 2009/07/11 16:43:12 hkmoffa Exp $
* $Id$
*/
#include "mex.h"

View file

@ -2,7 +2,6 @@ const double Undef = -999.123;
//const double DERR = -999.999;
#include <string>
using namespace std;
void reportError();
@ -24,13 +23,13 @@ inline char* getString(const mxArray* p) {
int m = mxGetM(p);
int n = mxGetN(p);
int buflen = m*n + 1;
string msg;
std::string msg;
if (m == 1) {
input_buf = (char*)mxCalloc(buflen, sizeof(char));
status = mxGetString(p, input_buf, buflen);
if(status != 0) {
msg = string(input_buf)
msg = std::string(input_buf)
+ "\nNot enough space. String is truncated.";
mexWarnMsgTxt(msg.c_str());
}

View file

@ -2,7 +2,7 @@
* @file mixturemethods.cpp
*/
/*
* $Id: mixturemethods.cpp,v 1.3 2009/07/11 16:43:12 hkmoffa Exp $
* $Id$
*/
#include "mex.h"
#include "../../../clib/src/ctmultiphase.h"

View file

@ -2,7 +2,7 @@
* @file mlloger.h
*/
/*
* $Id: mllogger.h,v 1.5 2009/07/11 16:43:12 hkmoffa Exp $
* $Id$
*/
#ifndef MLLOGGER_H
@ -13,7 +13,6 @@
#include "cantera/kernel/logger.h"
#include <iostream>
//using namespace std;
static std::string ss = "disp(' ";

View file

@ -2,7 +2,7 @@
* @file phasemethods.cpp
*/
/*
* $Id: phasemethods.cpp,v 1.5 2009/07/11 16:43:12 hkmoffa Exp $
* $Id$
*/
#include "mex.h"

View file

@ -2,7 +2,7 @@
* @file reactormethods.cpp
*/
/*
* $Id: reactormethods.cpp,v 1.5 2009/07/11 16:43:12 hkmoffa Exp $
* $Id$
*/
#include "mex.h"

View file

@ -2,7 +2,7 @@
* @file reactornetmethods.cpp
*/
/*
* $Id: reactornetmethods.cpp,v 1.4 2009/07/11 16:43:13 hkmoffa Exp $
* $Id$
*/
#include "mex.h"

View file

@ -2,7 +2,7 @@
* @file thermomethods.cpp
*/
/*
* $Id: thermomethods.cpp,v 1.11 2009/07/11 16:43:13 hkmoffa Exp $
* $Id$
*/
#include "mex.h"
#include "../../../clib/src/ct.h"

View file

@ -2,7 +2,7 @@
* @file wallmethods.cpp
*/
/*
* $Id: wallmethods.cpp,v 1.5 2009/07/11 16:43:13 hkmoffa Exp $
* $Id$
*/
#include "mex.h"
#include "../../../clib/src/ctreactor.h"

View file

@ -2,7 +2,7 @@
* @file xmlmethods.cpp
*/
/*
* $Id: xmlmethods.cpp,v 1.5 2009/07/11 16:43:13 hkmoffa Exp $
* $Id$
*/
#include "mex.h"

View file

@ -1,7 +1,7 @@
#
# python script to create a few key files for the windows build
#
# $Id: setup_winmatlab.py,v 1.29 2009/07/20 19:38:53 hkmoffa Exp $
# $Id$
#
import sys
import os

View file

@ -7,7 +7,7 @@ from SurfacePhase import EdgePhase
from Kinetics import Kinetics
import XML
__revision__ = "$Id: Edge.py,v 1.1 2006/04/23 07:27:10 dggoodwin Exp $"
__revision__ = "$Id$"
class Edge(EdgePhase, Kinetics):
"""

View file

@ -7,7 +7,7 @@ from SurfacePhase import SurfacePhase, EdgePhase
from Kinetics import Kinetics
import XML
__revision__ = "$Id: Interface.py,v 1.8 2007/02/17 10:48:09 dggoodwin Exp $"
__revision__ = "$Id$"
class Interface(SurfacePhase, Kinetics):
"""

View file

@ -615,9 +615,14 @@ class Stack:
"""
return _cantera.sim1D_restore(self._hndl, file, id)
def showStats(self):
"""Show the statistics for the last solution."""
return _cantera.sim1D_writeStats(self._hndl)
def showStats(self, printTime = 1):
"""Show the statistics for the last solution.
If invoked with no arguments or with a non-zero argument, the
timing statistics will be printed. If invoked with a zero argument,
the timing will not be printed.
Default: print timing enabled.
"""
return _cantera.sim1D_writeStats(self._hndl, _onoff[printTime])
def domainIndex(self, name):
"""Integer index of the domain with name 'name'"""

View file

@ -10,7 +10,7 @@ import types
from Cantera.num import asarray
from exceptions import CanteraError
__revision__ = "$Id: Phase.py,v 1.9 2007/05/25 14:17:38 dggoodwin Exp $"
__revision__ = "$Id$"
# return true is x is a sequence
def _isseq(n, x):

View file

@ -8,7 +8,7 @@ import Interface
import Edge
import XML
__revision__ = "$Id: importFromFile.py,v 1.12 2007/02/17 10:48:09 dggoodwin Exp $"
__revision__ = "$Id$"
def importPhase(file, name = '', loglevel = 0, debug = 0):
"""Import one phase from an input file. If 'name' is specified, the

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: hkmoffa $
# $Date: 2009/04/19 21:11:51 $
# $Revision: 1.31 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2001 California Institute of Technology
# See file License.txt for licensing information

View file

@ -16,7 +16,7 @@
#
#
# $Id: ctml_writer.py,v 1.25 2007/12/30 04:19:38 dggoodwin Exp $
# $Id$
import string

View file

@ -118,7 +118,7 @@ fcsv.close()
print 'solution saved to npflame1.csv'
f.showSolution()
f.showStats()
f.showStats(0)

View file

@ -2588,14 +2588,14 @@ solution saved to npflame1.csv
Statistics:
Grid Functions Time Jacobians Time
8 589 1.2400 22 1.3700
8 820 1.7500 49 3.2200
13 1341 6.2100 45 6.8000
20 2488 19.5700 45 12.2500
30 253 3.1500 17 7.8000
44 61 1.1300 3 2.1700
66 25 0.7400 2 2.4100
106 31 1.4700 2 4.4300
155 24 1.6800 2 7.2600
173 12 0.9400 1 4.2700
178 2 0.1600 1 4.4600
8 589 NA 22 NA
8 820 NA 49 NA
13 1341 NA 45 NA
20 2488 NA 45 NA
30 253 NA 17 NA
44 61 NA 3 NA
66 25 NA 2 NA
106 31 NA 2 NA
155 24 NA 2 NA
173 12 NA 1 NA
178 2 NA 1 NA

View file

@ -2,7 +2,7 @@
#
#
temp_success="1"
/bin/rm -f output_0.txt npflame1.csv diff_csv.txt diff_out_0.txt
/bin/rm -f output_0.txt npflame1.csv diff_csv.txt diff_out_0.txt npflame1.xml
##########################################################################
prog=npflame1.py
@ -40,7 +40,7 @@ then
fi
retnCSVTotal=1
if test $retnStat_csv_0 = "1"
if test $retnStat_csv_0 = "0"
then
retnCSVTotal=0
fi
@ -57,7 +57,7 @@ else
echo " see diff_csv.txt "
if test $retnTotal != "0"
then
echo " ASCII files are different too - see diff_test*.txt"
echo " ASCII files are different too - see diff_out_0.txt"
fi
fi

View file

@ -729,27 +729,27 @@ no new points needed in flow
C(S) 1.368e-07
O(S) 0.867
Solution saved to file catcomb.xml as solution soln1.
Solution saved to file catcomb.xml as solution soln1_2.
solution saved to catcomb.csv
Statistics:
Grid Functions Time Jacobians Time
8 38 0.0400 3 0.2100
9 16 0.0300 2 0.1800
10 8 0.0300 1 0.1000
10 16 0.0500 2 0.2200
10 10 0.0200 1 0.1100
10 14 0.0300 2 0.2200
10 16 0.0500 2 0.2100
10 14 0.0300 2 0.2200
10 8 0.0300 1 0.1000
10 41 0.1200 3 0.3100
17 37 0.1100 3 0.4800
25 26 0.1500 2 0.4900
28 11 0.0700 1 0.2800
29 11 0.0600 1 0.2900
30 6 0.0300 1 0.3100
32 6 0.0500 1 0.3300
33 4 0.0200 1 0.3500
34 2 0.0000 1 0.3600
8 38 0.0400 3 0.1200
9 16 0.0100 2 0.0900
10 8 0.0100 1 0.0600
10 16 0.0300 2 0.1100
10 10 0.0200 1 0.0500
10 14 0.0200 2 0.1100
10 16 0.0400 2 0.1100
10 14 0.0200 2 0.1100
10 8 0.0100 1 0.0500
10 41 0.0500 3 0.1600
17 37 0.1100 3 0.3600
25 26 0.1100 2 0.3900
28 11 0.0500 1 0.2200
29 11 0.1000 1 0.2300
30 6 0.0300 1 0.2400
32 6 0.0400 1 0.2600
33 4 0.0300 1 0.2600
34 2 0.0000 1 0.2800

View file

@ -40,7 +40,7 @@ then
fi
retnCSVTotal=1
if test $retnStat_csv_0 = "1"
if test $retnStat_csv_0 = "0"
then
retnCSVTotal=0
fi

View file

@ -40,7 +40,7 @@ then
fi
retnCSVTotal=1
if test $retnStat_csv_0 = "1"
if test $retnStat_csv_0 = "0"
then
retnCSVTotal=0
fi

View file

@ -1,31 +1,31 @@
[[ 6.04406471e-06 1.01738100e-06 3.25467803e-15 9.44878921e-07
3.20196626e-07 3.45252809e-15 3.12341397e-15 3.09815027e-15
2.93166212e-15]
3.20196626e-07 3.45252809e-15 3.12341397e-15 3.09815027e-15
2.93166212e-15]
[ 5.08690499e-15 1.00940773e-05 2.95033119e-15 8.72973220e-07
2.90021521e-07 3.22819878e-15 2.88500792e-15 2.86100892e-15
2.70458750e-15]
2.90021521e-07 3.22819878e-15 2.88500792e-15 2.86100892e-15
2.70458750e-15]
[ 3.25467803e-15 5.90066238e-07 2.40899947e-06 8.67150386e-07
2.75178768e-07 3.02514701e-15 2.87336197e-15 2.85661971e-15
2.73675664e-15]
2.75178768e-07 3.02514701e-15 2.87336197e-15 2.85661971e-15
2.73675664e-15]
[ 3.14959640e-15 5.81982147e-07 2.89050129e-15 2.56318977e-06
2.87270338e-07 3.25199672e-15 3.05588867e-15 3.04247847e-15
2.94726056e-15]
2.87270338e-07 3.25199672e-15 3.05588867e-15 3.04247847e-15
2.94726056e-15]
[ 3.20196626e-15 5.80043042e-07 2.75178768e-15 8.61811015e-07
2.62146728e-06 2.99922209e-15 2.85602138e-15 2.83971549e-15
2.72221044e-15]
2.62146728e-06 2.99922209e-15 2.85602138e-15 2.83971549e-15
2.72221044e-15]
[ 3.45252809e-15 6.45639757e-07 3.02514701e-15 9.75599015e-07
2.99922209e-07 2.08849997e-06 3.19672263e-15 3.17885565e-15
3.07926377e-15]
2.99922209e-07 2.08849997e-06 3.19672263e-15 3.17885565e-15
3.07926377e-15]
[ 3.12341397e-15 5.77001585e-07 2.87336197e-15 9.16766600e-07
2.85602138e-07 3.19672263e-15 1.62315735e-06 3.02939857e-15
2.93566827e-15]
2.85602138e-07 3.19672263e-15 1.62315735e-06 3.02939857e-15
2.93566827e-15]
[ 3.09815027e-15 5.72201784e-07 2.85661971e-15 9.12743541e-07
2.83971549e-07 3.17885565e-15 3.02939857e-15 1.60480867e-06
2.92422492e-15]
2.83971549e-07 3.17885565e-15 3.02939857e-15 1.60480867e-06
2.92422492e-15]
[ 2.93166212e-15 5.40917501e-07 2.73675664e-15 8.84178169e-07
2.72221044e-07 3.07926377e-15 2.93566827e-15 2.92422492e-15
1.51904485e-06]]
2.72221044e-07 3.07926377e-15 2.93566827e-15 2.92422492e-15
1.51904485e-06]]
[-0. -0. -0. -0. -0. -0. -0. -0. -0.]
[ -7.04749149e-14 -1.88567695e-05 -3.64733235e-14 -9.21405522e-06
-3.58390239e-06 -3.54030661e-14 -3.04704797e-14 -3.02364800e-14
-2.89579939e-14]
[ -6.90966189e-14 -1.84036152e-05 -3.65042941e-14 -9.29059107e-06
-3.58923841e-06 -3.54785016e-14 -3.07335477e-14 -3.05071031e-14
-2.92655613e-14]

View file

@ -11,10 +11,11 @@ libs = []
platform = sys.platform
flibs = []
if @build_with_f2c@ <> 1:
flibstr = '@FLIBS@'
f1 = flibstr.replace('-l', ' ')
flibs = f1.split()
# HKM -> not clear we need FLIBS here
#if @build_with_f2c@ == 1:
# flibstr = '@FLIBS@'
# f1 = flibstr.replace('-l', ' ')
# flibs = f1.split()
linkargs = '@LCXX_FLAGS@'

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: dggoodwin $
# $Date: 2003/04/14 17:57:50 $
# $Revision: 1.1.1.1 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2001 California Institute of Technology
#

View file

@ -4,7 +4,7 @@
*/
/*
* $Id: ctkinetics_methods.cpp,v 1.8 2009/04/19 21:03:10 hkmoffa Exp $
* $Id$
*/

View file

@ -1,6 +1,6 @@
/*
* $Id: ctonedim_methods.cpp,v 1.12 2009/03/24 19:13:02 hkmoffa Exp $
* $Id$
*/
@ -870,11 +870,14 @@ py_sim1D_writeStats(PyObject *self, PyObject *args)
{
int _val;
int i;
if (!PyArg_ParseTuple(args, "i:sim1D_writeStats", &i))
int printTime;
if (!PyArg_ParseTuple(args, "ii:sim1D_writeStats", &i, &printTime)) {
return NULL;
_val = sim1D_writeStats(i);
if (int(_val) == -1) return reportCanteraError();
}
_val = sim1D_writeStats(i, printTime);
if (int(_val) == -1) {
return reportCanteraError();
}
return Py_BuildValue("i",_val);
}

View file

@ -5,7 +5,6 @@
#include <string>
#include "cantera/kernel/logger.h"
using namespace std;
static std::string ss = "print \"\"\" ";
@ -18,7 +17,7 @@ namespace Cantera {
Py_Logger() {}
virtual ~Py_Logger() {}
virtual void write(const string& s) {
virtual void write(const std::string& s) {
char ch = s[0];
int n = 0;
while (ch != '\0') {
@ -35,7 +34,7 @@ namespace Cantera {
}
virtual void error(const std::string& msg) {
string err = "raise \""+msg+"\"";
std::string err = "raise \""+msg+"\"";
PyRun_SimpleString((char *)err.c_str());
}

View file

@ -1,8 +1,8 @@
#/bin/sh
###############################################################
# $Author: dggoodwin $
# $Date: 2007/12/15 17:15:50 $
# $Revision: 1.58 $
# $Author$
# $Date$
# $Revision$
#
# Copyright 2001 California Institute of Technology
#

View file

@ -19,6 +19,8 @@
#include "ctexceptions.h"
#include "utilities.h"
#include <cstring>
namespace Cantera {
@ -118,6 +120,16 @@ namespace Cantera {
m_data.resize(n*m, v);
}
//! Copy the data from one array into another without doing any checking
/*!
* This differs from the assignment operator as no resizing is done and memcpy() is used.
* @param y Array to be copied
*/
void copyData(const Array2D& y) {
size_t n = sizeof(doublereal) * m_nrows * m_ncols;
(void) memcpy(DATA_PTR(m_data), y.ptrColumn(0), n);
}
//! Append a column to the existing matrix using a std vector
/*!
* This operation will add a column onto the existing matrix.
@ -223,6 +235,17 @@ namespace Cantera {
for (; b != end(); ++b, ++xb, ++yb) *b = a*(*xb) + *yb;
}
//! Set all of the entries to zero
inline void zero() {
int nn = m_nrows * m_ncols;
if (nn > 0) {
/*
* Using memset is the fastest way to zero a contiguous
* section of memory.
*/
(void) memset((void *) &m_data[0], 0, nn * sizeof(doublereal));
}
}
//! Allows setting elements using the syntax A(i,j) = x.
/*!

View file

@ -50,11 +50,11 @@ namespace mdp {
void checkFinite(const double tmp) throw(std::range_error) {
if (_finite(tmp)) {
if(_isnan(tmp)) {
printf("ERROR: we have encountered a nan!\n");
printf("checkFinite() ERROR: we have encountered a nan!\n");
} else if (_fpclass(tmp) == _FPCLASS_PINF) {
printf("ERROR: we have encountered a pos inf!\n");
printf("checkFinite() ERROR: we have encountered a pos inf!\n");
} else {
printf("ERROR: we have encountered a neg inf!\n");
printf("checkFinite() ERROR: we have encountered a neg inf!\n");
}
const std::string s = "checkFinite()";
throw std::range_error(s);
@ -64,11 +64,11 @@ namespace mdp {
void checkFinite(const double tmp) throw(std::range_error) {
if (! finite(tmp)) {
if(isnan(tmp)) {
printf("ERROR: we have encountered a nan!\n");
printf("checkFinite() ERROR: we have encountered a nan!\n");
} else if (isinf(tmp) == 1) {
printf("ERROR: we have encountered a pos inf!\n");
printf("checkFinite() ERROR: we have encountered a pos inf!\n");
} else {
printf("ERROR: we have encountered a neg inf!\n");
printf("checkFinite() ERROR: we have encountered a neg inf!\n");
}
const std::string s = "checkFinite()";
throw std::range_error(s);
@ -102,7 +102,7 @@ namespace mdp {
checkFinite(tmp);
if (fabs(tmp) >= trigger) {
char sbuf[64];
sprintf(sbuf, "checkMagnitude: Trigger %g exceeded: %g\n", trigger,
sprintf(sbuf, "checkMagnitude() ERROR: Trigger %g exceeded: %g\n", trigger,
tmp);
throw std::range_error(sbuf);
}
@ -119,16 +119,16 @@ namespace mdp {
void checkZeroFinite(const double tmp) throw(std::range_error) {
if ((tmp == 0.0) || (! _finite(tmp))) {
if (tmp == 0.0) {
printf("ERROR: we have encountered a zero!\n");
printf("checkZeroFinite() ERROR: we have encountered a zero!\n");
} else if(_isnan(tmp)) {
printf("ERROR: we have encountered a nan!\n");
printf("checkZeroFinite() ERROR: we have encountered a nan!\n");
} else if (_fpclass(tmp) == _FPCLASS_PINF) {
printf("ERROR: we have encountered a pos inf!\n");
printf("checkZeroFinite() ERROR: we have encountered a pos inf!\n");
} else {
printf("ERROR: we have encountered a neg inf!\n");
printf("checkZeroFinite() ERROR: we have encountered a neg inf!\n");
}
char sbuf[64];
sprintf(sbuf, "checkZeroFinite: zero or indef exceeded: %g\n",
sprintf(sbuf, "checkZeroFinite() ERROR: zero or indef exceeded: %g\n",
tmp);
throw std::range_error(sbuf);
}
@ -137,16 +137,16 @@ void checkZeroFinite(const double tmp) throw(std::range_error) {
void checkZeroFinite(const double tmp) throw(std::range_error) {
if ((tmp == 0.0) || (! finite(tmp))) {
if (tmp == 0.0) {
printf("ERROR: we have encountered a zero!\n");
printf("checkZeroFinite() ERROR: we have encountered a zero!\n");
} else if(isnan(tmp)) {
printf("ERROR: we have encountered a nan!\n");
printf("checkZeroFinite() ERROR: we have encountered a nan!\n");
} else if (isinf(tmp) == 1) {
printf("ERROR: we have encountered a pos inf!\n");
printf("checkZeroFinite() ERROR: we have encountered a pos inf!\n");
} else {
printf("ERROR: we have encountered a neg inf!\n");
printf("checkZeroFinite() ERROR: we have encountered a neg inf!\n");
}
char sbuf[64];
sprintf(sbuf, "checkZeroFinite: zero or indef exceeded: %g\n",
sprintf(sbuf, "checkZeroFinite() ERROR: zero or indef exceeded: %g\n",
tmp);
throw std::range_error(sbuf);
}

View file

@ -90,14 +90,14 @@ namespace Cantera {
CanteraError(std::string procedure, std::string msg);
//! Destructor for base class does nothing
virtual ~CanteraError() throw() {}
virtual ~CanteraError() throw();
protected:
//! Empty base constructor is made protected so that it may be used only by
//! inherited classes.
/*!
* We want to discourage throwing an error containing no information.
*/
CanteraError() {}
CanteraError();
};
//! Array size error.

View file

@ -37,10 +37,20 @@ using namespace Cantera;
namespace ctml {
std::string FP_Format = "%23.15E";
std::string INT_Format = "%8d";
//====================================================================================================================
//! Convert a floating point value from a string to a double
/*!
* @param val String value input
*
* @return Returns a double
*/
static doublereal fpValue(std::string val) {
return atof(stripws(val).c_str());
}
//====================================================================================================================
// This function adds a child node with the name, "bool", with a value
// consisting of a single bool
/*
@ -79,7 +89,7 @@ namespace ctml {
XML_Node& f = node.addChild("bool", v);
f.addAttribute("title", title);
}
//====================================================================================================================
// This function adds a child node with the name, "integer", with a value
// consisting of a single integer
/*
@ -118,12 +128,17 @@ namespace ctml {
*/
void addInteger(Cantera::XML_Node& node, const std::string &title, const int val,
const std::string units, const std::string type) {
XML_Node& f = node.addChild("integer",val);
f.addAttribute("title",title);
#ifdef CTML_VERSION_1_4
XML_Node& f = node.addChild("integer", val);
f.addAttribute("title", title);
#else
XML_Node& f = node.addChild(title, val);
#endif
f.addAttribute("vtype", "integer");
if (type != "") f.addAttribute("type",type);
if (units != "") f.addAttribute("units",units);
}
//====================================================================================================================
// This function adds a child node with the name, "intArray", with a value
// consisting of a comma separated list of integers
/*
@ -179,24 +194,30 @@ namespace ctml {
void addIntegerArray(Cantera::XML_Node& node, const std::string &title, const int n,
const int* const vals, const std::string units, const std::string type,
const doublereal minval, const doublereal maxval) {
std::string fmt = "%8d";
int i;
std::string v = "";
for (i = 0; i < n; i++) {
v += int2str(vals[i],fmt);
v += int2str(vals[i],INT_Format);
if (i == n-1) v += "\n";
else if (i > 0 && (i+1) % 3 == 0) v += ",\n";
else v += ", ";
}
XML_Node& f = node.addChild("intArray",v);
#ifdef CTML_VERSION_1_4
XML_Node& f = node.addChild("intArray",v);
f.addAttribute("title",title);
#else
XML_Node& f = node.addChild(title, v);
#endif
if (type != "") f.addAttribute("type",type);
f.addAttribute("size",n);
#ifndef CTML_VERSION_1_4
f.addAttribute("vtype", "intArray");
#endif
if (units != "") f.addAttribute("units",units);
if (minval != Undef) f.addAttribute("min",minval);
if (maxval != Undef) f.addAttribute("max",maxval);
}
//====================================================================================================================
// This function adds a child node with the name, "float", with a value
// consisting of a single floating point number
/*
@ -243,19 +264,19 @@ namespace ctml {
const doublereal val, const std::string units,
const std::string type, const doublereal minval,
const doublereal maxval) {
string fmt = "%17.9E";
#ifdef CTML_VERSION_1_4
XML_Node& f = node.addChild("float",val,fmt);
f.addAttribute("title",title);
XML_Node& f = node.addChild("float", val, ctml::FP_Format);
f.addAttribute("title", title);
#else
XML_Node& f = node.addChild(title,val,fmt);
XML_Node& f = node.addChild(title, val, ctml::FP_Format);
#endif
if (type != "") f.addAttribute("type",type);
if (units != "") f.addAttribute("units",units);
f.addAttribute("vtype", "float");
if (minval != Undef) f.addAttribute("min",minval);
if (maxval != Undef) f.addAttribute("max",maxval);
}
//====================================================================================================================
// This function adds a child node with the name, "floatArray", with a value
// consisting of a comma separated list of floats
/*
@ -293,7 +314,7 @@ namespace ctml {
* @param unitsString String name of the Units attribute. This is an optional
* parameter. The default is to
* have an empty string.
* @param typeString String type. This is an optional parameter. The default
* @param type String type. This is an optional parameter. The default
* is to have an empty string.
* @param minval Minimum allowed value of the int. This is an optional
* parameter. The default is the
@ -312,11 +333,10 @@ namespace ctml {
const doublereal* const vals, const std::string units,
const std::string type,
const doublereal minval, const doublereal maxval) {
std::string fmt = "%17.9E";
int i;
std::string v = "";
for (i = 0; i < n; i++) {
v += fp2str(vals[i],fmt);
v += fp2str(vals[i],FP_Format);
if (i == n-1) v += "\n";
else if (i > 0 && (i+1) % 3 == 0) v += ",\n";
else v += ", ";
@ -329,7 +349,87 @@ namespace ctml {
if (minval != Undef) f.addAttribute("min",minval);
if (maxval != Undef) f.addAttribute("max",maxval);
}
//====================================================================================================================
// This function adds a child node with the name given by the first parameter with a value
// consisting of a comma separated list of floats
/*
* This function will add a child node to the current XML node, with the
* name given in the list. It will have a title attribute, and the body
* of the XML node will be filled out with a comma separated list of
* integers
*
* Example:
*
* Code snipet:
* @verbatum
const XML_Node &node;
std::string titleString = "additionalTemperatures";
int n = 3;
int Tcases[3] = [273.15, 298.15, 373.15];
std::string typeString = "optional";
std::string units = "Kelvin";
addNamedFloatArray(node, titleString, n, &cases[0], typeString, units);
@endverbatum
*
* Creates the following the snippet in the XML file:
* @verbatum
<parentNode>
<additionalTemperatures type="optional" vtype="floatArray" size = "3" units="Kelvin">
273.15, 298.15, 373.15
<\additionalTemperatures>
<\parentNode>
@endverbatum
*
* @param node reference to the XML_Node object of the parent XML element
* @param name Name of the XML node
* @param n Length of the doubles vector.
* @param values Pointer to a vector of doubles
* @param unitsString String name of the Units attribute. This is an optional
* parameter. The default is to
* have an empty string.
* @param type String type. This is an optional parameter. The default
* is to have an empty string.
* @param minval Minimum allowed value of the int. This is an optional
* parameter. The default is the
* special double, Cantera::Undef, which means to ignore the
* entry.
* @param maxval Maximum allowed value of the int. This is an optional
* parameter. The default is the
* special double, Cantera::Undef, which means to ignore the
* entry.
*
* @todo I don't think this is used. Figure out what is used for writing integers,
* and codify that. unitsString shouldn't be here, since it's an int.
* typeString should be codified as to its usage.
*/
void addNamedFloatArray(Cantera::XML_Node& node, const std::string &name, const int n,
const doublereal* const vals, const std::string units,
const std::string type, const doublereal minval,
const doublereal maxval) {
int i;
std::string v = "";
for (i = 0; i < n; i++) {
v += fp2str(vals[i],FP_Format);
if (i == n-1) v += "\n";
else if (i > 0 && (i+1) % 3 == 0) v += ",\n";
else v += ", ";
}
XML_Node& f = node.addChild(name, v);
if (type != "") {
f.addAttribute("type",type);
}
/*
* Add vtype, which indicates the type of the value. Here we specify it as a list of floats separated
* by commas, with a length given by size attribute.
*/
f.addAttribute("vtype", "floatArray");
f.addAttribute("size", n);
if (units != "") f.addAttribute("units", units);
if (minval != Undef) f.addAttribute("min", minval);
if (maxval != Undef) f.addAttribute("max", maxval);
}
//====================================================================================================================
// This function adds a child node with the name string with a string value
// to the current node
/*
@ -376,7 +476,7 @@ namespace ctml {
}
return 0;
}
//====================================================================================================================
// This function reads a child node with the name string and returns
// its xml value as the return string
/*
@ -409,7 +509,7 @@ namespace ctml {
if (!parent.hasChild(nameString)) return "";
return parent(nameString);
}
//====================================================================================================================
// This function reads a child node with the name, "string", with a specific
// title attribute named "titleString"
/*
@ -433,10 +533,11 @@ namespace ctml {
<\string>
@endverbatum
*
* @param node reference to the XML_Node object of the parent XML element
* @param node Reference to the XML_Node object of the parent XML element
* @param titleString String name of the title attribute of the child node
* @param valueString Value string that is found in the child node. output variable
* @param typeString String type. This is an optional output variable
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry.
*/
void getString(const Cantera::XML_Node& node, const std::string &titleString, std::string& valueString,
std::string& typeString) {
@ -451,7 +552,70 @@ namespace ctml {
}
}
//====================================================================================================================
// This function attempts to read a named child node and returns with the contents in the value string.
// title attribute named "titleString"
/*
* This function will read a child node to the current XML node, with the
* name "string". It must have a title attribute, named titleString, and the body
* of the XML node will be read into the valueString output argument.
*
* If the child node is not found then the empty string is returned.
*
* Example:
*
* Code snipet:
* @verbatum
const XML_Node &node;
std::string valueString;
std::string typeString;
std::string nameString = "timeIncrement";
getString(XML_Node& node, nameString, valueString, valueString, typeString);
@endverbatum
*
* Reads the following the snippet in the XML file:
*
* * @verbatum
<nameString type="typeString">
valueString
<\nameString>
@endverbatum
*
* or alternatively as a retrofit and special case, it also reads the following case
*
* @verbatum
<string title="nameString" type="typeString">
valueString
<\string>
@endverbatum
*
* @param node Reference to the XML_Node object of the parent XML element
* @param nameString Name of the XML Node input variable
* @param valueString Value string that is found in the child node. output variable
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry. output variable
*/
void getNamedStringValue(const Cantera::XML_Node& node, const std::string &nameString, std::string& valueString,
std::string& typeString)
{
valueString = "";
typeString = "";
if (node.hasChild(nameString)) {
XML_Node &xc = node.child(nameString);
valueString = xc.value();
typeString = xc["type"];
} else {
XML_Node* s = getByTitle(node, nameString);
if (s) {
if (s->name() == "string") {
valueString = (*s).value();
typeString = (*s)["type"];
return;
}
}
}
}
//====================================================================================================================
// Get a vector of integer values from a child element.
/*
* Returns a std::map containing a keyed values for child XML_Nodes
@ -512,7 +676,7 @@ namespace ctml {
}
}
//====================================================================================================================
// Get a vector of floating-point values from a child element.
/*
* Returns a std::map containing a keyed values for child XML_Nodes
@ -554,7 +718,7 @@ namespace ctml {
* @param v Output map of the results.
* @param convert Turn on conversion to SI units
*/
void getFloats(const Cantera::XML_Node& node, std::map<std::string, double>& v,
void getFloats(const Cantera::XML_Node& node, std::map<std::string, doublereal > & v,
const bool convert) {
std::vector<XML_Node*> f;
node.getChildren("float",f);
@ -590,7 +754,7 @@ namespace ctml {
}
}
//====================================================================================================================
// Get a floating-point value from a child element.
/*
* Returns a double value for the child named 'name' of element 'parent'. If
@ -624,8 +788,7 @@ namespace ctml {
* and "" , for no conversion. The default value is ""
* which implies that no conversion is allowed.
*/
doublereal getFloat(const Cantera::XML_Node& parent,
const std::string &name,
doublereal getFloat(const Cantera::XML_Node& parent, const std::string &name,
const std::string type) {
if (!parent.hasChild(name))
throw CanteraError("getFloat (called from XML Node \"" +
@ -635,7 +798,39 @@ namespace ctml {
return getFloatCurrent(node, type);
}
//====================================================================================================================
// Get a floating-point value from the current XML element
/*
* Returns a doublereal value from the current element. If
* 'type' is supplied and matches a known unit type, unit
* conversion to SI will be done if the child element has an attribute 'units'.
*
* Note, it's an error for the child element not to exist.
*
* Example:
*
* Code snipet:
* @verbatim
const XML_Node &State_XMLNode;
doublereal pres = OneAtm;
if (state_XMLNode.hasChild("pressure")) {
XML_Node *pres_XMLNode = State_XMLNode.getChild("pressure");
pres = getFloatCurrent(pres_XMLNode, "toSI");
}
@endverbatim
*
* Rreads the corresponding XML file:
* @verbatim
<state>
<pressure units="Pa"> 101325.0 </pressure>
<\state>
@endverbatim
*
* @param currXML reference to the current XML_Node object
* @param type String type. Currently known types are "toSI" and "actEnergy",
* and "" , for no conversion. The default value is "",
* which implies that no conversion is allowed.
*/
doublereal getFloatCurrent(const Cantera::XML_Node& node,
const std::string type) {
doublereal x, x0, x1, fctr = 1.0;
@ -691,7 +886,7 @@ namespace ctml {
return fctr*x;
}
//====================================================================================================================
bool getOptionalFloat(const Cantera::XML_Node& parent,
const std::string &name,
doublereal &fltRtn,
@ -702,7 +897,7 @@ namespace ctml {
}
return false;
}
//====================================================================================================================
// Get an optional floating-point value from a child element.
/*
* Returns a doublereal value for the child named 'name' of element 'parent'. If
@ -765,7 +960,37 @@ namespace ctml {
val /= fctr;
return val;
}
//====================================================================================================================
// Get an optional model name from a named child node.
/*
* Returns the model name attribute for the child named 'nodeName' of element 'parent'.
* Note, it's optional for the child node to exist
*
* Example:
*
* Code snipet:
* @verbatim
std::string modelName = "";
bool exists = getOptionalModel(transportNode, "compositionDependence",
modelName);
@endverbatim
*
* Reads the corresponding XML file:
*
* @verbatim
<transport>
<compositionDependence model="Solvent_Only"/>
</transport>
@endverbatim
*
* On return modelName is set to "Solvent_Only".
*
* @param parent Reference to the XML_Node object of the parent XML element
* @param nodeName Name of the XML child element
* @param modelName On return this contains the contents of the model attribute
*
* @return True if the nodeName XML node exists. False otherwise.
*/
bool getOptionalModel(const Cantera::XML_Node& parent, const std::string nodeName,
std::string &modelName) {
if (parent.hasChild(nodeName)) {
@ -775,7 +1000,7 @@ namespace ctml {
}
return false;
}
//====================================================================================================================
// Get an integer value from a child element.
/*
* Returns an integer value for the child named 'name' of element 'parent'.
@ -796,7 +1021,7 @@ namespace ctml {
* reads the corresponding XML file:
* @verbatum
<state>
<numProcs> 10 <numProcs/>
<numProcs> 10 <\numProcs>
<\state>
@endverbatum
*
@ -833,7 +1058,7 @@ namespace ctml {
}
return x;
}
//====================================================================================================================
// This function reads the current node or a child node of the current node
// with the default name, "floatArray", with a value field
// consisting of a comma separated list of floats
@ -890,11 +1115,13 @@ namespace ctml {
* The default value for the node name is floatArray
*
* @return Returns the number of floats read
*
* @note change the v to a std::vector to eliminate a doxygen error. No idea why doxygen needs this.
*/
int getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
int getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
const bool convert, const std::string unitsString,
const std::string nodeName) {
string::size_type icom;
std::string::size_type icom;
string numstr;
doublereal dtmp;
string nn = node.name();
@ -908,6 +1135,11 @@ namespace ctml {
+ nodeName + "but accessed " + node.name());
} else {
readNode = ll[0];
ll.clear();
readNode->getChildren("floatArray", ll);
if (ll.size() > 0) {
readNode = ll[0];
}
}
}
@ -974,7 +1206,97 @@ namespace ctml {
}
return v.size();
}
//====================================================================================================================
int getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string & nodeName, std::vector<doublereal> & v,
const bool convert, const std::string unitsString) {
std::string::size_type icom;
std::string numstr;
doublereal dtmp;
std::string nn = parentNode.name();
v.clear();
const Cantera::XML_Node *readNode = parentNode.findByName(nodeName);
if (!readNode) {
return 0;
}
doublereal vmin = Undef;
doublereal vmax = Undef;
doublereal funit = 1.0;
/*
* Get the attributes field, units, from the XML node
*/
std::string units = (*readNode)["units"];
if (units != "" && convert) {
if (unitsString == "actEnergy" && units != "") {
funit = actEnergyToSI(units);
} else if (unitsString != "" && units != "") {
funit = toSI(units);
}
}
if ((*readNode)["min"] != "")
vmin = atofCheck((*readNode)["min"].c_str());
if ((*readNode)["max"] != "")
vmax = atofCheck((*readNode)["max"].c_str());
int expectedSize = 0;
nn = (*readNode)["size"];
expectedSize = atoi(nn.c_str());
nn = (*readNode)["vtype"];
if (nn != "floatArray") {
throw CanteraError("getNamedFloatArray",
"node named " + nodeName + "didn't have correct vtype");
}
doublereal vv;
std::string val = readNode->value();
while (1 > 0) {
icom = val.find(',');
if (icom != string::npos) {
numstr = val.substr(0,icom);
val = val.substr(icom+1,val.size());
dtmp = atofCheck(numstr.c_str());
v.push_back(dtmp);
}
else {
/*
* This little bit of code is to allow for the
* possibility of a comma being the last
* item in the value text. This was allowed in
* previous versions of Cantera, even though it
* would appear to be odd. So, we keep the
* possibilty in for backwards compatibility.
*/
int nlen = strlen(val.c_str());
if (nlen > 0) {
dtmp = atofCheck(val.c_str());
v.push_back(dtmp);
}
break;
}
vv = v.back();
if (vmin != Undef && vv < vmin - Tiny) {
writelog("\nWarning: value "+fp2str(vv)+
" is below lower limit of " +fp2str(vmin)+".\n");
}
if (vmax != Undef && vv > vmax + Tiny) {
writelog("\nWarning: value "+fp2str(vv)+
" is above upper limit of " +fp2str(vmin)+".\n");
}
}
int nv = v.size();
for (int n = 0; n < nv; n++) {
v[n] *= funit;
}
if (nv != expectedSize) {
throw CanteraError("getNamedFloatArray",
"node named " + nodeName + "didn't have correct number of floats"
+ int2str(expectedSize) + " vs " + int2str(nv));
}
return nv;
}
//====================================================================================================================
// This routine is used to interpret the value portions of XML
// elements that contain colon separated pairs.
/*
@ -1012,7 +1334,7 @@ namespace ctml {
m[key] = val;
}
}
//====================================================================================================================
// This function interprets the value portion of an XML element
// as a series of "Pairs" separated by white space.
/*
@ -1062,7 +1384,7 @@ namespace ctml {
}
return n;
}
//====================================================================================================================
// This function interprets the value portion of an XML element
// as a series of "Matrix ids and entries" separated by white space.
/*
@ -1193,7 +1515,7 @@ namespace ctml {
}
}
}
//====================================================================================================================
// This function interprets the value portion of an XML element
// as a string. It then separates the string up into tokens
// according to the location of white space.
@ -1207,7 +1529,7 @@ namespace ctml {
std::string val = node.value();
tokenizeString(val, v);
}
//====================================================================================================================
// This function reads a child node with the default name, "floatArray", with a value
// consisting of a comma separated list of floats
/*
@ -1221,26 +1543,27 @@ namespace ctml {
* separating each field.
* If the node array has an units attribute field, then
* the units are used to convert the floats, iff convert is true.
* This function is a wrapper around the function getFloatArray().
*
* Example:
*
* Code snipet:
* @verbatum
* @verbatim
const XML_Node &State_XMLNode;
vector_fp v;
bool convert = true;
unitsString = "";
nodeName="floatArray";
getFloatArray(State_XMLNode, v, convert, unitsString, nodeName);
@endverbatum
@endverbatim
*
* reads the corresponding XML file:
*
* @verbatum
* @verbatim
<state>
<floatArray units="m3"> 32.4, 1, 100. <\floatArray>
<\state>
@endverbatum
@endverbatim
*
* Will produce the vector
*
@ -1250,19 +1573,15 @@ namespace ctml {
*
*
* @param node XML parent node of the floatArray
* @param v Output vector of floats containing the floatArray information.
* @param convert Conversion to SI is carried out if this boolean is
* True. The default is true.
* @param typeString String name of the type attribute. This is an optional
* parameter. The default is to have an empty string.
* The only string that is recognized is actEnergy.
* Anything else has no effect. This affects what
* units converter is used.
* @param nodeName XML Name of the XML node to read.
* The default value for the node name is floatArray
* @param typeString Returns the type attribute of the current node.
* @param xmin Returns the minimum value attribute of the
* current node.
* @param xmax Returns the maximum value attribute of the
* current node.
* @param coeffs Output vector of floats containing the floatArray information.
*/
void getFunction(const Cantera::XML_Node& node, std::string& type, doublereal& xmin,
doublereal& xmax, Cantera::vector_fp& coeffs) {
doublereal& xmax, std::vector<doublereal> & coeffs) {
const XML_Node& c = node.child("floatArray");
coeffs.clear();
getFloatArray(c,coeffs);
@ -1272,4 +1591,5 @@ namespace ctml {
if (node["max"] != "") xmax = fpValue(node["max"]);
type = node["type"];
}
//====================================================================================================================
}

View file

@ -22,6 +22,9 @@
//! The ctml namespace adds functionality to the XML object, by providing
//! standard functions that read, write, and interpret XML files and
//! object trees.
/*!
* Standardization of reads and write from Cantera files occur here.
*/
namespace ctml {
//! const Specifying the CTML version number
@ -30,6 +33,10 @@ namespace ctml {
*/
const std::string CTML_Version = "1.4.1";
extern std::string FP_Format;
extern std::string INT_Format;
//! This function adds a child node with the name, "bool", with a value
//! consisting of a single bool
/*!
@ -279,6 +286,15 @@ namespace ctml {
const doublereal minval = Cantera::Undef,
const doublereal maxval = Cantera::Undef);
void addNamedFloatArray(Cantera::XML_Node& parentNode, const std::string &name, const int n,
const doublereal* const vals, const std::string units = "",
const std::string type = "",
const doublereal minval = Cantera::Undef,
const doublereal maxval = Cantera::Undef);
//! This function adds a child node with the name string with a string value
//! to the current node
/*!
@ -367,7 +383,7 @@ namespace ctml {
* The default value for the node name is floatArray
* @return Returns the number of floats read into v.
*/
int getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
int getFloatArray(const Cantera::XML_Node& node, std::vector<doublereal> & v,
const bool convert=true, const std::string unitsString="",
const std::string nodeName = "floatArray");
@ -570,8 +586,7 @@ namespace ctml {
/*!
* Returns a doublereal value from the current element. If
* 'type' is supplied and matches a known unit type, unit
* conversion to SI will be done if the child element has an attribute
* 'units'.
* conversion to SI will be done if the child element has an attribute 'units'.
*
* Note, it's an error for the child element not to exist.
*
@ -587,7 +602,7 @@ namespace ctml {
}
@endverbatim
*
* reads the corresponding XML file:
* Rreads the corresponding XML file:
* @verbatim
<state>
<pressure units="Pa"> 101325.0 </pressure>
@ -682,7 +697,7 @@ namespace ctml {
* @param v Output map of the results.
* @param convert Turn on conversion to SI units
*/
void getFloats(const Cantera::XML_Node& node, std::map<std::string, double>& v,
void getFloats(const Cantera::XML_Node& node, std::map<std::string, doublereal >& v,
const bool convert=true);
//! Get an integer value from a child element.
@ -778,7 +793,7 @@ namespace ctml {
* @param nodeName Name of the XML child element
* @param modelName On return this contains the contents of the model attribute
*
* @return True if the nodeName XML node exists. False otherwise
* @return True if the nodeName XML node exists. False otherwise.
*/
bool getOptionalModel(const Cantera::XML_Node& parent, const std::string nodeName,
std::string &modelName);
@ -831,12 +846,10 @@ namespace ctml {
* current node.
* @param xmax Returns the maximum value attribute of the
* current node.
* @param v Output vector of floats containing the floatArray
* information.
* @param coeffs Output vector of floats containing the floatArray information.
*/
void getFunction(const Cantera::XML_Node& node, std::string& typeString,
doublereal& xmin, doublereal& xmax, Cantera::vector_fp& v);
doublereal& xmin, doublereal& xmax, std::vector<doublereal> & coeffs);
//! Search the child nodes of the current node for an XML Node with a Title
//! attribute of a given name.
@ -851,6 +864,40 @@ namespace ctml {
//! This function reads a child node with the name string with a specific
//! title attribute named titleString
/*!
* This function will read a child node to the current XML node with the name "string".
* It must have a title attribute, named titleString, and the body
* of the XML node will be read into the valueString output argument.
*
* If the child node is not found then the empty string is returned.
*
* Example:
*
* Code snipet:
* @verbatim
const XML_Node &node;
getString(XML_Node& node, std::string titleString, std::string valueString,
std::string typeString);
@endverbatim
*
* Reads the following the snippet in the XML file:
* @verbatim
<string title="titleString" type="typeString">
valueString
<\string>
@endverbatim
*
* @param node Reference to the XML_Node object of the parent XML element
* @param titleString String name of the title attribute of the child node
* @param valueString Value string that is found in the child node. output variable
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry.
*/
void getString(const Cantera::XML_Node& node, const std::string &titleString,
std::string& valueString, std::string& typeString);
//! This function attempts to read a named child node and returns with the contents in the value string.
//! title attribute named "titleString"
/*!
* This function will read a child node to the current XML node, with the
* name "string". It must have a title attribute, named titleString, and the body
@ -861,26 +908,39 @@ namespace ctml {
* Example:
*
* Code snipet:
* @verbatim
const XML_Node &node;
getString(XML_Node& node, std::string titleString, std::string valueString,
std::string typeString);
@endverbatim
* @verbatum
const XML_Node &node;
std::string valueString;
std::string typeString;
std::string nameString = "timeIncrement";
getString(XML_Node& node, nameString, valueString, valueString, typeString);
@endverbatum
*
* Reads the following the snippet in the XML file:
* @verbatim
<string title="titleString" type="typeString">
*
* * @verbatum
<nameString type="typeString">
valueString
<\nameString>
@endverbatum
*
* or alternatively as a retrofit and special case, it also reads the following case
*
* @verbatum
<string title="nameString" type="typeString">
valueString
<\string>
@endverbatim
@endverbatum
*
* @param node reference to the XML_Node object of the parent XML element
* @param titleString String name of the title attribute of the child node
* @param valueString Value string that is found in the child node. output variable
* @param typeString String type. This is an optional output variable
* @param node Reference to the XML_Node object of the parent XML element
* @param nameString Name of the XML Node input variable
* @param valueString Value string that is found in the child node. output variable
* @param typeString String type. This is an optional output variable. It is filled
* with the attribute "type" of the XML entry. output variable
*/
void getString(const Cantera::XML_Node& node, const std::string &titleString,
std::string& valueString, std::string& typeString);
void getNamedStringValue(const Cantera::XML_Node& node, const std::string &nameString, std::string& valueString,
std::string& typeString);
//! This function reads a child node with the name, nameString, and returns
//! its xml value as the return string

View file

@ -1658,7 +1658,7 @@ namespace mdp {
} else {
int m = len % 7;
if (m != 0) {
for (int i = 0; i < m; m++) {
for (int i = 0; i < m; i++) {
v[i] = value;
}
if (len < 7) return;
@ -1697,6 +1697,30 @@ namespace mdp {
(void) memset((void *)v, 0, len * sizeof(double));
}
}
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
void mdp_zero_int_1(int * const v, const int len)
/**************************************************************************
*
* mdp_zero_int_1:
*
* Zeroes out an int vector
*
* Input
* -------------
* v = Vector of values to be set to zero
* len = Length of the vector
**************************************************************************/
{
if (len > 0) {
(void) memset((void *)v, 0, len * sizeof(int));
}
}
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
@ -1727,7 +1751,7 @@ namespace mdp {
} else {
int m = len % 7;
if (m != 0) {
for (int i = 0; i < m; m++) {
for (int i = 0; i < m; i++) {
dstart[i] = value;
}
if (len < 7) return;
@ -1771,7 +1795,7 @@ namespace mdp {
} else {
int m = len % 7;
if (m != 0) {
for (int i = 0; i < m; m++) {
for (int i = 0; i < m; i++) {
v[i] = value;
}
if (len < 7) return;

View file

@ -45,7 +45,7 @@
* then it may be freed, always (and vica-versa).
*
* Where possible, the low leve routines
* memcopy and memset are used to copy or zero memory.
* memcpy and memset are used to copy or zero memory.
*
* No array bounds checking is ever done within these routines. buyer beware.
* The bounds of arrays are not carried with the array object, ever.
@ -674,6 +674,13 @@ namespace mdp {
*/
extern void mdp_zero_dbl_1(double * const v , const int len);
//! Zeroes an int vector
/*!
* @param v = Vector of values to be assigned
* @param len = Length of the vector
*/
extern void mdp_zero_int_1(int * const v , const int len);
//! Assigns a single value to a double matrix. Contiguous data for the
//! matrix is assumed.
/*!

View file

@ -53,11 +53,20 @@ using namespace std;
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
static boost::mutex dir_mutex; // For input directory access
static boost::mutex msg_mutex; // For access to string messages
static boost::mutex app_mutex; // Application state including creating singleton
//static boost::mutex log_mutex; // Logger pointer
static boost::mutex xml_mutex; // XML file storage
//! Mutex for input directory access
static boost::mutex dir_mutex;
//! Mutex for access to string messages
static boost::mutex msg_mutex;
//! Mutex for creating singeltons within the application object
static boost::mutex app_mutex;
// Mutex for controlling access to the log file
//static boost::mutex log_mutex;
//! Mutex for controlling access to XML file storage
static boost::mutex xml_mutex;
//! Macro for locking input directory access
#define DIR_LOCK() boost::mutex::scoped_lock d_lock(dir_mutex)
@ -1515,6 +1524,15 @@ protected:
CanteraError::CanteraError(std::string proc, std::string msg) {
app()->addError(proc, msg);
}
CanteraError::CanteraError()
{
}
CanteraError::~CanteraError() throw()
{
}
ArraySizeError::ArraySizeError(std::string proc, int sz, int reqd) :
CanteraError(proc, "Array size ("+int2str(sz)+
@ -1888,9 +1906,13 @@ protected:
#endif // WITH_HTML_LOGS
/// split a string at a '#' sign. Used to separate a file name
/// from an id string.
//===============================================================================================================
//! split a string at a '#' sign. Used to separate a file name from an id string.
/*!
* @param src Original string to be split up. This is unchanged.
* @param file Output string representing the first part of the string, which is the filename.
* @param id Output string representing the last part of the string, which is the id.
*/
static void split_at_pound(const std::string& src, std::string& file, std::string& id) {
string::size_type ipound = src.find('#');
if (ipound != string::npos) {
@ -1902,6 +1924,7 @@ protected:
file = src;
}
}
//===============================================================================================================
/*
* This routine will locate an XML node in either the input
* XML tree or in another input file specified by the file

View file

@ -35,7 +35,7 @@
namespace Cantera {
//================================================================================================
// Convert a double into a c++ string
/*
* This routine doesn't assume a formatting. You
@ -62,7 +62,7 @@ namespace Cantera {
}
return std::string(" ");
}
//================================================================================================
/*
* Convert an integer number to a std::string using sprintf.
*/
@ -75,7 +75,7 @@ namespace Cantera {
}
return std::string(" ");
}
//================================================================================================
// Convert an int to a string
/*
* @param n int to be converted
@ -89,14 +89,14 @@ namespace Cantera {
}
return std::string(" ");
}
//================================================================================================
std::string lowercase(const std::string &s) {
int n = static_cast<int>(s.size());
std::string lc(s);
for (int i = 0; i < n; i++) lc[i] = tolower(s[i]);
return lc;
}
//================================================================================================
//! Return the position of the first printable
//! character in the string
/*!
@ -113,7 +113,7 @@ namespace Cantera {
}
return i;
}
//================================================================================================
//! Return the position of the last printable
//! character in the string
/*!
@ -129,7 +129,7 @@ namespace Cantera {
if (s[i] != ' ' && isprint(s[i])) break;
return i;
}
//================================================================================================
// Strip the leading and trailing white space
// from a string
/*
@ -145,7 +145,7 @@ namespace Cantera {
int ilast = lastChar(s);
return s.substr(ifirst, ilast - ifirst + 1);
}
//================================================================================================
// Strip non-printing characters wherever they are
/*
* @param s Input string
@ -163,8 +163,7 @@ namespace Cantera {
}
return ss;
}
//================================================================================================
// Parse a composition string into a map consisting of individual key:composition
// pairs.
/*
@ -218,7 +217,7 @@ namespace Cantera {
}
while (s != "");
}
//================================================================================================
// Parse a composition string into individual key:composition
// pairs
/*
@ -249,7 +248,7 @@ namespace Cantera {
}
while (s != "");
}
//================================================================================================
int fillArrayFromString(const std::string& str,
doublereal* const a, const char delim) {
std::string::size_type iloc;
@ -271,7 +270,7 @@ namespace Cantera {
}
return count;
}
//================================================================================================
// Get the file name without the path or extension
/*
* @param fullPath Input file name consisting
@ -296,20 +295,19 @@ namespace Cantera {
}
return file;
}
//================================================================================================
int intValue(std::string val) {
return std::atoi(stripws(val).c_str());
}
//================================================================================================
doublereal fpValue(std::string val) {
return std::atof(stripws(val).c_str());
}
//================================================================================================
doublereal fpValueCheck(std::string val) {
return atofCheck(stripws(val).c_str());
}
//================================================================================================
// Generate a logfile name based on an input file name
/*
* It tries to find the basename. Then, it appends a .log
@ -324,7 +322,7 @@ namespace Cantera {
logfile += ".log";
return logfile;
}
//================================================================================================
// Line wrap a string via a copy operation
/*
* @param s Input string to be line wrapped
@ -346,8 +344,46 @@ namespace Cantera {
}
return r;
}
//================================================================================================
// Parse a name string, separating out the phase name from the species name
/*
* Name strings must not contain these internal characters "; \n \t "
* Only one colon is allowed, the one separating the phase name from the
* species name. Therefore, names may not include a colon.
*
* @param nameStr (input) Name string containing the phase name and the species
* name separated by a colon. The phase name is optional.
* example: "silane:SiH4"
* @param phaseName (output) Name of the phase, if specified. If not specified,
* a blank string is returned.
* @return (output) Species name is returned. If nameStr is blank
* an empty string is returned.
*/
std::string parseSpeciesName(const std::string& nameStr, std::string &phaseName) {
std::string s = stripws(nameStr);
std::string::size_type ibegin, iend, icolon;
phaseName = "";
ibegin = s.find_first_not_of(" ;\n\t");
if (ibegin != std::string::npos) {
s = s.substr(ibegin,s.size());
icolon = s.find(':');
iend = s.find_first_of(" ;\n\t");
if (icolon != std::string::npos) {
phaseName = s.substr(0, icolon);
s = s.substr(icolon+1, s.size());
icolon = s.find(':');
if (icolon != std::string::npos) {
throw CanteraError("parseSpeciesName()", "two colons in name: " + nameStr);
}
}
if (iend != std::string::npos) {
throw CanteraError("parseSpeciesName()",
"Species name has \" ;/\n/\t\" in the middle of it: " + nameStr);
}
}
return s;
}
//================================================================================================
// Routine strips off white space from a c character string
/*
* This routine strips off blanks and tabs (only leading and trailing
@ -396,7 +432,7 @@ namespace Cantera {
str[j] = '\0';
return (j);
}
//================================================================================================
// Translate a char string into a single double
/*
* atofCheck is a wrapper around the C stdlib routine atof().
@ -472,7 +508,7 @@ namespace Cantera {
free(eptr);
return rval;
}
//================================================================================================
// Interpret one or two token string as a single double
/*
* This is similar to atof(). However, the second token
@ -502,7 +538,15 @@ namespace Cantera {
doublereal val = atofCheck(v[0].c_str());
return (val * fp);
}
//================================================================================================
//! Find the first white space in a string
/*!
* Returns the location of the first white space character in a string
*
* @param val Input string to be parsed
* @return In a size_type variable, return the location of the first white space character.
* Return npos if none is found
*/
static std::string::size_type findFirstWS(const std::string& val) {
std::string::size_type ibegin = std::string::npos;
int j = 0;
@ -518,7 +562,15 @@ namespace Cantera {
}
return ibegin;
}
//================================================================================================
//! Find the first non-white space in a string
/*!
* Returns the location of the first non-white space character in a string
*
* @param val Input string to be parsed
* @return In a size_type variable, return the location of the first nonwhite space character.
* Return npos if none is found
*/
static std::string::size_type findFirstNotOfWS(const std::string& val) {
std::string::size_type ibegin = std::string::npos;
int j = 0;
@ -534,7 +586,7 @@ namespace Cantera {
}
return ibegin;
}
//================================================================================================
// This function separates a string up into tokens
// according to the location of white space.
/*
@ -566,6 +618,6 @@ namespace Cantera {
}
}
}
//================================================================================================
}

View file

@ -182,6 +182,22 @@ namespace Cantera {
*/
doublereal fpValueCheck(std::string val);
//! Parse a name string, separating out the phase name from the species name
/*!
* Name strings must not contain these internal characters "; \n \t ,"
* Only one colon is allowed, the one separating the phase name from the
* species name. Therefore, names may not include a colon.
*
* @param nameStr (input) Name string containing the phase name and the species
* name separated by a colon. The phase name is optional.
* example: "silane:SiH4"
* @param phaseName (output) Name of the phase, if specified. If not specified,
* a blank string is returned.
* @return (output) Species name is returned. If nameStr is blank
* an empty string is returned.
*/
std::string parseSpeciesName(const std::string& nameStr, std::string &phaseName);
//! Line wrap a string via a copy operation
/*!
* @param s Input string to be line wrapped

View file

@ -173,6 +173,7 @@ namespace Cantera {
static boost::mutex units_mutex;
#endif
//! Units class constructor, containing the default mappings between
//! strings and units.
Unit() :
@ -215,6 +216,7 @@ namespace Cantera {
// temperature
m_u["K"] = 1.0;
m_u["C"] = 1.0;
m_u["Kelvin"] = 1.0;
// mass
m_u["gm"] = 1.0e-3;
@ -232,6 +234,12 @@ namespace Cantera {
m_u["hr"] = 3600.0;
m_u["ms"] = 0.001;
// electric potential
m_u["volt"] = 1.0;
// charge
m_u["coulomb"] = 1.0;
/*
// frequency - Took frequency out to reevaluate it. Inverse cm is probably the wrong default unit
m_u["hZ"] = 0.01/(lightSpeed);

View file

@ -686,6 +686,7 @@ namespace Cantera {
}
}
//@}
}

View file

@ -181,7 +181,7 @@ namespace Cantera {
inline void fbo_copy_dbl_1(doublereal * const copyTo, const doublereal * const copyFrom,
const int len) {
if (len > 0) {
(void) memcpy((void *)copyTo, (const void *)copyFrom, len * sizeof(doublereal));
(void) std::memcpy((void *)copyTo, (const void *)copyFrom, len * sizeof(doublereal));
}
}
@ -196,7 +196,7 @@ namespace Cantera {
inline void fvo_copy_dbl_1(std::vector<doublereal> &copyTo, const std::vector<doublereal> &copyFrom,
const int len) {
if (len > 0) {
(void) memcpy((void *)(&copyTo[0]), (const void *)(&copyFrom[0]), len * sizeof(doublereal));
(void) std::memcpy((void *)(&copyTo[0]), (const void *)(&copyFrom[0]), len * sizeof(doublereal));
}
}
@ -209,7 +209,7 @@ namespace Cantera {
*/
inline void fbo_zero_dbl_1(doublereal * const v, const int len) {
if (len > 0) {
(void) memset((void *)v, 0, len * sizeof(doublereal));
(void) std::memset((void *)v, 0, len * sizeof(doublereal));
}
}
@ -222,7 +222,7 @@ namespace Cantera {
*/
inline void fvo_zero_dbl_1(std::vector<doublereal> &v, const int len) {
if (len > 0) {
(void) memset((void *)(&v[0]), 0, len * sizeof(doublereal));
(void) std::memset((void *)(&v[0]), 0, len * sizeof(doublereal));
}
}

View file

@ -52,9 +52,8 @@ namespace Cantera {
*/
XML_Error(int line=0) :
m_line(line),
m_msg(0)
m_msg("Error in XML file")
{
m_msg = "Error in XML file";
if (line > 0) {
m_msg += " at line " + int2str(line+1);
}
@ -221,10 +220,12 @@ namespace Cantera {
else return aline.substr(j+1, i - j - 1);
}
/**
* Find the first position of a character, q, in string s,
* which is not immediately preceded by the backslash character
* '\'
//! Find the first position of a character, q, in string, s, which is not immediately preceded by the backslash character
/*!
* @param s Input string
* @param q Search for this character
* @param istart Defaults to 0
*/
static string::size_type findUnbackslashed(std::string s, const char q,
std::string::size_type istart = 0) {
@ -392,13 +393,15 @@ namespace Cantera {
////////////////////////// XML_Node /////////////////////////////////
XML_Node::XML_Node(const char * cnm)
: m_name(""),
m_value(""),
m_parent(0),
m_locked(false),
m_nchildren(0),
m_iscomment(false)
XML_Node::XML_Node(const char * cnm) :
m_name(""),
m_value(""),
m_parent(0),
m_root(0),
m_locked(false),
m_nchildren(0),
m_iscomment(false) ,
m_linenum(0)
{
if (! cnm) {
m_name = "--";
@ -416,19 +419,21 @@ namespace Cantera {
* @param nm Name of the node.
* The default name of the node is "--"
*
* @param p pointer to the root for this node in the tree.
* The default is 0 indicating this is the top of the tree.
* @param parent Pointer to the parent for this node in the tree.
* A value of zero 0 indicates this is the top of the tree.
*/
XML_Node::XML_Node(const std::string nm, XML_Node * const p)
: m_name(nm),
m_value(""),
m_parent(p),
m_locked(false),
m_nchildren(0),
m_iscomment(false)
XML_Node::XML_Node(const std::string nm, XML_Node * const parent) :
m_name(nm),
m_value(""),
m_parent(parent),
m_root(0),
m_locked(false),
m_nchildren(0),
m_iscomment(false),
m_linenum(0)
{
if (!p) m_root = this;
else m_root = &p->root();
if (!parent) m_root = this;
else m_root = &(parent->root());
}
// Copy constructor
@ -439,11 +444,15 @@ namespace Cantera {
m_name(""),
m_value(""),
m_parent(0),
m_root(0),
m_locked(false),
m_nchildren(0),
m_iscomment(false)
m_iscomment(right.m_iscomment),
m_linenum(right.m_linenum)
{
m_root = this;
m_name = right.m_name;
m_value = right.m_value;
right.copy(this);
}
@ -516,26 +525,47 @@ namespace Cantera {
addChild("comment", comment);
}
// Add a child node to the current node
/*
* This will add an XML_Node as a child to the current node.
* Note, this actually adds the node. Therefore, node is changed.
* There is no copy made of the child node.
//! Merge an existing node as a child node to the current node
/*!
* This will merge an XML_Node as a child to the current node.
* Note, this actually adds the node. Therefore, the current node is changed.
* There is no copy made of the child node. The child node should not be deleted in the future.
*
* @param node Reference to a child XML_Node object
*
* @return returns a reference to the added node
* @return Returns a reference to the added child node
*/
XML_Node& XML_Node::addChild(XML_Node& node) {
XML_Node& XML_Node::mergeAsChild(XML_Node& node) {
m_children.push_back(&node);
m_nchildren = static_cast<int>(m_children.size());
m_childindex[node.name()] = m_children.back();
m_childindex.insert(pair<const std::string, XML_Node *>(node.name(), m_children.back()));
node.setRoot(root());
node.setParent(this);
return *m_children.back();
}
// Add a child node to the current node with a specified name
// Add a child node to the current node by makeing a copy of an existing node tree
/*
* This will add an XML_Node as a child to the current node.
* Note, this actually adds the node. Therefore, node is changed.
* A copy is made of the underlying tree.
*
* @param node Reference to a child XML_Node object
*
* @return returns a reference to the added node
*/
XML_Node& XML_Node::addChild(const XML_Node& node) {
XML_Node *xx = new XML_Node(node);
m_children.push_back(xx);
m_nchildren = static_cast<int>(m_children.size());
m_childindex.insert( pair<const std::string, XML_Node *>(xx->name(), xx));
xx->setRoot(root());
xx->setParent(this);
return *m_children.back();
}
// Add a new malloced child node to the current node with a specified name
/*
* This will add an XML_Node as a child to the current node.
* The node will be blank except for the specified name.
@ -548,13 +578,17 @@ namespace Cantera {
XML_Node *xxx = new XML_Node(sname, this);
m_children.push_back(xxx);
m_nchildren = static_cast<int>(m_children.size());
m_childindex[sname] = m_children.back();
m_childindex.insert(pair<const std::string, XML_Node *>(sname, xxx));
xxx->setRoot(root());
xxx->setParent(this);
return *m_children.back();
}
// Add a child node to the current xml node, and at the
XML_Node& XML_Node::addChild(const char *cstring) {
return addChild(std::string(cstring));
}
// Add a new malloced child node to the current xml node, and at the
// same time add a value to the child
/*
* Resulting XML string:
@ -763,6 +797,10 @@ namespace Cantera {
return m_attribs;
}
const std::map<std::string,std::string>& XML_Node::attribsConst() const {
return m_attribs;
}
// Set the line number
/*
* @param n the member data m_linenum is set to n
@ -833,15 +871,29 @@ namespace Cantera {
const std::vector<XML_Node*>& XML_Node::children() const {
return m_children;
}
// return the number of children
//=====================================================================================================================
// Return the number of children
/*
*
* @param discardComments Bool indicating whether we should ignore comments in the count. defaults to false
*/
int XML_Node::nChildren() const {
int XML_Node::nChildren(const bool discardComments) const {
if (discardComments) {
int count = 0;
for (int i = 0; i < m_nchildren; i++) {
XML_Node *xc = m_children[i];
if (!(xc->isComment())) {
count++;
}
}
return count;
}
return m_nchildren;
}
//=====================================================================================================================
bool XML_Node::isComment() const {
return m_iscomment;
}
//=====================================================================================================================
// Require that the current xml node have an attribute named
// by the first argument, a, and that this attribute have the
// the string value listed in the second argument, v.
@ -908,9 +960,65 @@ namespace Cantera {
}
return scResult;
}
//====================================================================================================================
// This routine carries out a search for an XML node based
// on both the xml element name and the attribute ID and an integer index.
/*
* If exact matches are found for all fields, the pointer
* to the matching XML Node is returned. The search is only carried out on
* the current element and the child elements of the current element.
*
* The "id" attribute may be defaulted by setting it to "".
* In this case the pointer to the first xml element matching the name
* only is returned.
*
* @param nameTarget Name of the XML Node that is being searched for
* @param idTarget "id" attribute of the XML Node that the routine
* looks for
* @param index Integer describing the index. The index is an
* attribute of the form index = "3"
*
* @return Returns the pointer to the XML node that fits the criteria
*
*/
XML_Node* XML_Node::findNameIDIndex(const std::string & nameTarget,
const std::string & idTarget, const int index_i) const {
XML_Node *scResult = 0;
XML_Node *sc;
std::string idattrib = id();
std::string ii = attrib("index");
std::string index_s = int2str(index_i);
int iMax = -1000000;
if (name() == nameTarget) {
if (idTarget == "" || idTarget == idattrib) {
if (index_s == ii) {
return const_cast<XML_Node*>(this);
}
}
}
for (int n = 0; n < m_nchildren; n++) {
sc = m_children[n];
if (sc->name() == nameTarget) {
ii = sc->attrib("index");
int indexR = atoi(ii.c_str());
idattrib = sc->id();
if (idTarget == idattrib || idTarget == "") {
if (index_s == ii) {
return sc;
}
}
if (indexR > iMax) {
scResult = sc;
iMax = indexR;
}
}
}
return scResult;
}
//====================================================================================================================
// This routine carries out a recursive search for an XML node based
// on the xml element attribute ID.
// on the xml element attribute, "id" .
/*
* If exact match is found, the pointer
* to the matching XML Node is returned. If not, 0 is returned.
@ -962,17 +1070,19 @@ namespace Cantera {
*
*/
XML_Node* XML_Node::findByAttr(const std::string& attr,
const std::string& val) const {
const std::string& val, int depth) const {
if (hasAttrib(attr)) {
if (attrib(attr) == val) {
return const_cast<XML_Node*>(this);
}
}
XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
r = m_children[i]->findByAttr(attr, val);
if (r != 0) return r;
if (depth > 0) {
XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
r = m_children[i]->findByAttr(attr, val, depth - 1);
if (r != 0) return r;
}
}
return 0;
}
@ -988,15 +1098,17 @@ namespace Cantera {
*
* @return Returns the pointer to the XML node that fits the criteria
*/
XML_Node* XML_Node::findByName(const std::string& nm) {
XML_Node* XML_Node::findByName(const std::string& nm, int depth) {
if (name() == nm) {
return this;
}
XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
r = m_children[i]->findByName(nm);
if (r != 0) return r;
if (depth > 0) {
XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
r = m_children[i]->findByName(nm);
if (r != 0) return r;
}
}
return 0;
}
@ -1012,15 +1124,17 @@ namespace Cantera {
*
* @return Returns the pointer to the XML node that fits the criteria
*/
const XML_Node* XML_Node::findByName(const std::string& nm) const {
const XML_Node* XML_Node::findByName(const std::string& nm, int depth) const {
if (name() == nm) {
return const_cast<XML_Node*>(this);
}
const XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
r = m_children[i]->findByName(nm);
if (r != 0) return r;
if (depth > 0) {
const XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
r = m_children[i]->findByName(nm);
if (r != 0) return r;
}
}
return 0;
}
@ -1079,8 +1193,7 @@ namespace Cantera {
}
else {
if (node->name() != nm.substr(1,nm.size()-1))
throw XML_TagMismatch(node->name(),
nm.substr(1,nm.size()-1), lnum);
throw XML_TagMismatch(node->name(), nm.substr(1,nm.size()-1), lnum);
node = node->parent();
}
}
@ -1154,6 +1267,7 @@ namespace Cantera {
int ndc;
node_dest->addValue(m_value);
node_dest->setName(m_name);
node_dest->setLineNumber(m_linenum);
if (m_name == "") return;
map<string,string>::const_iterator b = m_attribs.begin();
for (; b != m_attribs.end(); ++b) {
@ -1164,12 +1278,15 @@ namespace Cantera {
for (int n = 0; n < m_nchildren; n++) {
sc = m_children[n];
ndc = node_dest->nChildren();
// Here is where we do a malloc of the child node.
(void) node_dest->addChild(sc->name());
dc = vsc[ndc];
sc->copy(dc);
}
}
// Set the lock for this node
void XML_Node::lock() {
m_locked = true;
@ -1241,7 +1358,7 @@ namespace Cantera {
* main recursive routine. It doesn't put a final endl
* on. This is fixed up in the public method.
*/
void XML_Node::write_int(std::ostream& s, int level) const {
void XML_Node::write_int(std::ostream& s, int level, int numRecursivesAllowed) const {
if (m_name == "") return;
@ -1320,7 +1437,7 @@ namespace Cantera {
bool doSpace = true;
bool doNewLine = false;
int ll = static_cast<int>(m_value.size()) - 1;
if (ll > 15) {
if (ll > 25) {
doNewLine = true;
}
if (m_name == "floatArray") {
@ -1351,9 +1468,11 @@ namespace Cantera {
}
}
int i;
for (i = 0; i < m_nchildren; i++) {
s << endl;
m_children[i]->write_int(s,level + 2);
if (numRecursivesAllowed > 0) {
for (i = 0; i < m_nchildren; i++) {
s << endl;
m_children[i]->write_int(s,level + 2, numRecursivesAllowed - 1);
}
}
if (m_nchildren > 0) s << endl << indent;
s << "</" << m_name << ">";
@ -1370,14 +1489,14 @@ namespace Cantera {
* is skipped and the children are processed. "--" is used
* to denote the top of the tree.
*/
void XML_Node::write(std::ostream& s, const int level) const {
void XML_Node::write(std::ostream& s, const int level, int numRecursivesAllowed) const {
if (m_name == "--" && m_root == this) {
for (int i = 0; i < m_nchildren; i++) {
m_children[i]->write_int(s,level);
m_children[i]->write_int(s,level, numRecursivesAllowed-1);
s << endl;
}
} else {
write_int(s, level);
write_int(s, level, numRecursivesAllowed);
s << endl;
}
}
@ -1387,7 +1506,10 @@ namespace Cantera {
}
void XML_Node::setRoot(const XML_Node& root) {
m_root = const_cast<XML_Node*>(&root);
m_root = const_cast<XML_Node*>(&root);
for (int i = 0; i < m_nchildren; i++) {
m_children[i]->setRoot(root);
}
}
XML_Node * findXMLPhase(XML_Node *root,

View file

@ -45,8 +45,7 @@ namespace Cantera {
*/
XML_Reader(std::istream& input);
//! Read a single character from the input stream
//! and return it
//! Read a single character from the input stream and returns it
/*!
* All low level reads occur through this function.
* The function also keeps track of the line numbers.
@ -130,13 +129,14 @@ namespace Cantera {
std::string readValue();
protected:
//! Input Stream containing the XML file
//! Input stream containing the XML file
std::istream& m_s;
public:
//! Line count
int m_line;
};
@ -156,6 +156,10 @@ namespace Cantera {
class XML_Node {
public:
//! Value_type for the lookup multimap m_childindex. This is a convenience definition
//! for manipulating the multimap
typedef std::pair<const std::string, XML_Node *> CIPair;
//! Default constructor for XML_Node, representing a tree structure
/*!
* Constructor for an XML_Node, which is a node in a tree-like structure
@ -175,10 +179,10 @@ namespace Cantera {
* @param nm Name of the node.
* The default name of the node is "--"
*
* @param p pointer to the root for this node in the tree.
* The default is 0 indicating this is the top of the tree.
* @param parent Pointer to the parent for this node in the tree.
* A value of 0 indicates this is the top of the tree.
*/
XML_Node(const std::string nm, XML_Node * const p);
XML_Node(const std::string nm, XML_Node * const parent);
//! Copy constructor
/*!
@ -203,18 +207,31 @@ namespace Cantera {
*/
void addComment(const std::string &comment);
//! Add a child node to the current node
//! Merge an existing node as a child node to the current node
/*!
* This will add an XML_Node as a child to the current node.
* This will merge an XML_Node as a child to the current node.
* Note, this actually adds the node. Therefore, the current node is changed.
* There is no copy made of the child node.
* There is no copy made of the child node. The child node should not be deleted in the future
*
* @param node Reference to a child XML_Node object
*
* @return Returns a reference to the added child node
*/
XML_Node& addChild(XML_Node& node);
XML_Node& mergeAsChild(XML_Node& node);
// Add a child node to the current node by makeing a copy of an existing node tree
/*
* This will add an XML_Node as a child to the current node.
* Note, this actually adds the node. Therefore, node is changed.
* A copy is made of the underlying tree
*
* @param node Reference to a child XML_Node object
*
* @return returns a reference to the added node
*/
XML_Node& addChild(const XML_Node& node);
//! Add a child node to the current node with a specified name
/*!
* This will add an XML_Node as a child to the current node.
@ -226,6 +243,17 @@ namespace Cantera {
*/
XML_Node& addChild(const std::string &sname);
//! Add a child node to the current node with a specified name
/*!
* This will add an XML_Node as a child to the current node.
* The node will be blank except for the specified name.
*
* @param cstring Name of the new child as a c string
*
* @return Returns a reference to the added node
*/
XML_Node& addChild(const char * cstring);
//! Add a child node to the current xml node, and at the
//! same time add a value to the child
/*!
@ -388,6 +416,7 @@ namespace Cantera {
void clear();
private:
//! Returns a changeable value of the attributes map for the current node
/*!
* Note this is a simple accessor routine. And, it is a private function.
@ -397,6 +426,13 @@ namespace Cantera {
public:
//! Returns an unchangeable value of the attributs map for the current node
/*!
*
* @return Returns an unchangeable reference to the attributes map
*/
const std::map<std::string,std::string>& attribsConst() const;
//! Set the line number
/*!
* @param n the member data m_linenum is set to n
@ -408,7 +444,6 @@ namespace Cantera {
* @return returns the member data m_linenum
*/
int lineNumber() const;
//! Returns a pointer to the parent node of the current node
XML_Node* parent() const;
@ -472,12 +507,16 @@ namespace Cantera {
*/
const std::vector<XML_Node*>& children() const;
//! return the number of children
//! Return the number of children
/*!
*
* @param discardComments If true comments are discarded when adding up the number of children.
* Defaults to false.
*/
int nChildren() const;
int nChildren(bool discardComments = false) const;
//! Boolean function indicating whether a comment
bool isComment() const;
//! Require that the current xml node have an attribute named
//! by the first argument, a, and that this attribute have the
//! the string value listed in the second argument, v.
@ -512,8 +551,31 @@ namespace Cantera {
XML_Node* findNameID(const std::string &nameTarget,
const std::string &idTarget) const;
//! This routine carries out a search for an XML node based
//! on both the xml element name and the attribute ID and an integer index.
/*!
* If exact matches are found for all fields, the pointer
* to the matching XML Node is returned. The search is only carried out on
* the current element and the child elements of the current element.
*
* The "id" attribute may be defaulted by setting it to "".
* In this case the pointer to the first xml element matching the name
* only is returned.
*
* @param nameTarget Name of the XML Node that is being searched for
* @param idTarget "id" attribute of the XML Node that the routine
* looks for
* @param index Integer describing the index. The index is an
* attribute of the form index = "3"
*
* @return Returns the pointer to the XML node that fits the criteria
*
*/
XML_Node* findNameIDIndex(const std::string &nameTarget,
const std::string &idTarget, const int index) const;
//! This routine carries out a recursive search for an XML node based
//! on the xml element attribute ID.
//! on the xml element attribute, "id"
/*!
* If exact match is found, the pointer
* to the matching XML Node is returned. If not, 0 is returned.
@ -546,11 +608,14 @@ namespace Cantera {
* @param attr Attribute of the XML Node that the routine
* looks for
* @param val Value of the attribute
* @param depth Depth of the search. A value of 1 means that only the
* immediate children are searched.
*
* @return Returns the pointer to the XML node that fits the criteria
*
*/
XML_Node* findByAttr(const std::string& attr, const std::string& val) const;
XML_Node* findByAttr(const std::string& attr, const std::string& val,
int depth = 100000) const;
//! This routine carries out a recursive search for an XML node based
//! on the name of the node.
@ -560,10 +625,12 @@ namespace Cantera {
* This is the const version of the routine.
*
* @param nm Name of the XML node
* @param depth Depth of the search. A value of 1 means that only the
* immediate children are searched.
*
* @return Returns the pointer to the XML node that fits the criteria
*/
const XML_Node* findByName(const std::string& nm) const;
const XML_Node* findByName(const std::string& nm, int depth = 100000) const;
//! This routine carries out a recursive search for an XML node based
//! on the name of the node.
@ -573,10 +640,12 @@ namespace Cantera {
* This is the non-const version of the routine.
*
* @param nm Name of the XML node
* @param depth Depth of the search. A value of 1 means that only the
* immediate children are searched.
*
* @return Returns the pointer to the XML node that fits the criteria
*/
XML_Node* findByName(const std::string& nm);
XML_Node* findByName(const std::string& nm, int depth = 100000);
//! Get a vector of pointers to XML_Node containing all of the children
//! of the current node which matches the input name
@ -588,9 +657,11 @@ namespace Cantera {
*/
void getChildren(const std::string &name, std::vector<XML_Node*>& children) const;
//! Return a changeable reference to a child of the current node,
//! named by the argument
//! Return a changeable reference to a child of the current node, named by the argument
/*!
* Note the underlying data allows for more than one XML element with the same name.
* This routine returns the first child with the given name.
*
* @param loc Name of the child to return
*/
XML_Node& child(const std::string &loc) const;
@ -614,9 +685,10 @@ namespace Cantera {
* to denote the top of the tree.
*
* @param s ostream to write to
* @param level Indentation level to work from
* @param level Indentation level to work from
* @param numRecursivesAllowed Number of recursive calls allowed
*/
void write(std::ostream& s, const int level = 0) const;
void write(std::ostream& s, const int level = 0, int numRecursivesAllowed = 60000) const;
//! Return the root of the current XML_Node tree
/*!
@ -677,15 +749,16 @@ namespace Cantera {
//! Write an XML subtree to an output stream.
/*!
* This is the
* main recursive routine. It doesn't put a final endl
* on. This is fixed up in the public method.
* This is the main recursive routine. It doesn't put a final endl
* on. This is fixed up in the public method. A method to only write out a limited
* amount of the xml tree has been added.
*
*
* @param s ostream to write to
* @param level Indentation level to work from
* @param numRecurvivesAllowed Number of recursive calls allowed
*/
void write_int(std::ostream& s, int level = 0) const;
void write_int(std::ostream& s, int level = 0, int numRecursivesAllowed = 60000) const;
protected:
@ -719,9 +792,10 @@ namespace Cantera {
/*!
* m_childindex[node.name()] = XML_Node *pointer
*
* This object helps to speed up searches
* This object helps to speed up searches.
* The value_type for this multimap is CIPair.
*/
std::map<std::string, XML_Node*> m_childindex;
std::multimap<std::string, XML_Node*> m_childindex;
//! Storage of attributes for a node
/*!
@ -757,7 +831,7 @@ namespace Cantera {
//! True if the current node is a comment node
bool m_iscomment;
//! the member data m_linenum
//! The member data m_linenum
/*!
* Currently, unimplemented functionality
*/

View file

@ -22,7 +22,6 @@
#include "ckr_utils.h"
#include "writelog.h"
#include <cstdio>
//#include "../stringUtils.h"
#include <cstdlib>
using namespace std;

View file

@ -16,7 +16,6 @@
#include <fstream>
#include <string>
#include <iostream>
//using namespace std;
#include "ckr_defs.h"
#include "Element.h"
@ -58,17 +57,17 @@ namespace ckr {
bool readElementSection(elementList& elements);
bool readSpeciesSection(speciesList& species);
bool readThermoSection(vector<string>& names,
bool readThermoSection(std::vector<std::string>& names,
speciesTable& speciesData, vector_fp& temp,
int& optionFlag, ostream& log);
bool readReactionSection(const vector<string>& speciesNames,
vector<string>& elementNames,
int& optionFlag, std::ostream& log);
bool readReactionSection(const std::vector<std::string>& speciesNames,
std::vector<std::string>& elementNames,
reactionList& reactions, ReactionUnits& units);
bool advanceToKeyword(const std::string& kw, const std::string& stop);
bool verbose;
bool debug;
bool readNASA9ThermoSection(std::vector<string>& names,
bool readNASA9ThermoSection(std::vector<std::string>& names,
speciesTable& species, vector_fp& temp,
int& optionFlag, std::ostream& log);

View file

@ -23,7 +23,6 @@
#include <string>
#include <vector>
using namespace std;
namespace ckr {

View file

@ -11,7 +11,6 @@
#include <string>
#include <vector>
using namespace std;
namespace ckr {
@ -22,7 +21,7 @@ namespace ckr {
*/
class Constituent {
public:
string name; //!< The name of the object.
std::string name; //!< The name of the object.
double number; //!< The number of units (molecules, etc.).
};

View file

@ -11,8 +11,8 @@
#include <string>
#include <vector>
#include <ostream>
using namespace std;
namespace ckr {
@ -41,7 +41,7 @@ public:
/// Construct a new empty Element object
Element(const string& nm, double wt) :
Element(const std::string& nm, double wt) :
name(nm),
atomicWeight(wt),
valid(0),
@ -54,12 +54,12 @@ public:
/// Destructor
~Element() {}
string name; //!< Element name
std::string name; //!< Element name
double atomicWeight; //!< Atomic weight in amu
int valid; //!< flag returned by validation routines
int index; //!< index number
bool weightFromDB; //!< true if atomic weight is not specified
string comment; //!< comment in input file
std::string comment; //!< comment in input file
/**
@ -72,11 +72,11 @@ public:
bool operator!=(const Element& e) const {
return !(*this == e);
}
friend ostream& operator<<(ostream& s, const Element& e) {
friend std::ostream& operator<<(std::ostream& s, const Element& e) {
s << e.name;
if (!e.weightFromDB) s << "/" << e.atomicWeight << "/";
if (e.comment != "")
s << " !" << e.comment << endl;
s << " !" << e.comment << std::endl;
else
s << " ";
return s;
@ -84,18 +84,10 @@ public:
};
/// a list (vector) of Elements
typedef vector<Element> elementList;
typedef std::vector<Element> elementList;
}
#endif

View file

@ -14,6 +14,8 @@
#include <iostream>
#include <stdio.h>
using namespace std;
namespace ckr {
Reaction forwardReaction(const Reaction& rxn) {

View file

@ -12,7 +12,7 @@
#include <string>
#include <vector>
#include <map>
using namespace std;
#include <ostream>
#include "ckr_defs.h"
#include "ckr_utils.h"
@ -183,7 +183,7 @@ namespace ckr {
* third body collision partners, or a species name if only
* one species does.
*/
string thirdBody;
std::string thirdBody;
/// Reaction number.
int number;
@ -192,21 +192,21 @@ namespace ckr {
* list of species that participate as reactants,
* and their stoichiometric coefficients
*/
vector<RxnSpecies> reactants;
std::vector<RxnSpecies> reactants;
mutable map<string, double> fwdOrder;
mutable std::map<std::string, double> fwdOrder;
/**
* list of species that participate as products,
* and their stoichiometric coefficients
*/
vector<RxnSpecies> products;
std::vector<RxnSpecies> products;
/**
* map from species names to enhanced third-body collision efficiencies
*/
mutable map<string, double> e3b;
mutable std::map<std::string, double> e3b;
/**
* Forward rate coefficient. For falloff reactions, this is the
@ -231,28 +231,28 @@ namespace ckr {
/**
* auxiliary data not handled elsewhere.
*/
mutable map<string, auxdata> otherAuxData;
mutable std::map<std::string, auxdata> otherAuxData;
/**
* input file lines
*/
vector<string> lines;
std::vector<std::string> lines;
/**
* comments
*/
vector<string> comment;
std::vector<std::string> comment;
// methods
double stoichCoefficient(const string& s) const;
double stoichCoefficient(const std::string& s) const;
bool operator==(const Reaction& r) const;
void write(ostream& s) const;
void write(std::ostream& s) const;
};
/// a list of Reaction objects
typedef vector<Reaction> reactionList;
typedef std::vector<Reaction> reactionList;
Reaction forwardReaction(const Reaction& rxn);
Reaction reverseReaction(const Reaction& rxn);

View file

@ -11,15 +11,11 @@
#include <string>
#include <vector>
//#include "Cantera.h"
using namespace std;
namespace ckr {
typedef vector_int group_t;
typedef vector<group_t> grouplist_t;
typedef vector_int group_t;
typedef std::vector<group_t> grouplist_t;
/**
* A class for species in a reaction.
@ -29,7 +25,7 @@ class RxnSpecies {
public:
RxnSpecies() :
number(0) {}
string name; //!< The name of the object.
std::string name; //!< The name of the object.
double number; //!< The number of units (molecules, etc.).
grouplist_t groups;
};

View file

@ -58,19 +58,19 @@ namespace ckr {
int thermoFormatType;
//! Species Name
string name;
string id; //!< ID tag from 'date' field in input
string phase; //!< Phase string. Usually "G", "L", or "S".
std::string name;
std::string id; //!< ID tag from 'date' field in input
std::string phase; //!< Phase string. Usually "G", "L", or "S".
double tlow; //!< Min temperature for thermo data fit
double tmid; //!< Mid temperature for thermo data fit
double thigh; //!< Max temperature for thermo data fit
/// list of Constituent objects defining elemental composition
vector<Constituent> elements;
std::vector<Constituent> elements;
/// map from element symbols to atom numbers
mutable map<string, double> comp;
mutable std::map<std::string, double> comp;
/// polynomial coefficients for the lower temperature range
vector_fp lowCoeffs;
@ -91,7 +91,7 @@ namespace ckr {
/// position in the list of species in the input file
int index;
string m_commentsRef;
std::string m_commentsRef;
private:
//! Delete private data
@ -99,10 +99,10 @@ namespace ckr {
};
//! Shorthand for a list of Species
typedef vector<Species> speciesList;
typedef std::vector<Species> speciesList;
//! A map from species names to Species objects
typedef map<string, Species> speciesTable;
typedef std::map<std::string, Species> speciesTable;
}
#endif

View file

@ -14,9 +14,6 @@
#include <string>
#include <iostream>
#include <vector>
//using namespace std;
//#include "../ctvector.h"
/// the namespace for the CKReader packaage
namespace ckr {

View file

@ -17,7 +17,6 @@
#include <map>
#include <vector>
using namespace std;
#ifdef WIN32
#define TYPENAME_KEYWORD
@ -35,9 +34,9 @@ namespace ckr {
*/
template<class K, class V>
void getMapKeys(const map<K,V>& mp, vector<K>& keys) {
void getMapKeys(const std::map<K,V>& mp, std::vector<K>& keys) {
keys.clear();
TYPENAME_KEYWORD map<K,V>::const_iterator i = mp.begin();
TYPENAME_KEYWORD std::map<K,V>::const_iterator i = mp.begin();
for (; i != mp.end(); ++i) keys.push_back(i->first);
}
@ -49,9 +48,9 @@ void getMapKeys(const map<K,V>& mp, vector<K>& keys) {
*/
template<class K, class V>
void getMapValues(const map<K,V>& mp, vector<V>& values) {
void getMapValues(const std::map<K,V>& mp, std::vector<V>& values) {
values.clear();
TYPENAME_KEYWORD map<K,V>::const_iterator i = mp.begin();
TYPENAME_KEYWORD std::map<K,V>::const_iterator i = mp.begin();
for (; i != mp.end(); ++i) values.push_back(i->second);
}
@ -120,10 +119,10 @@ inline bool valid(L& list) {
/// Remove all white space from string s.
void removeWhiteSpace(string& s);
void removeWhiteSpace(std::string& s);
void getTokens(string& begin,
int n, vector<string>& toks, char delim=' ');
void getTokens(std::string& begin,
int n, std::vector<std::string>& toks, char delim=' ');
/**
@ -137,12 +136,12 @@ void getTokens(string& begin,
*
*/
bool match(const string& s1, const string& s2);
bool match(const std::string& s1, const std::string& s2);
/**
* Check whether string 'word' begins with a Chemkin keyword.
*/
inline bool isKeyword(string word)
inline bool isKeyword(std::string word)
{
return (match(word, "ELEM") ||
match(word, "SPEC") ||
@ -152,8 +151,8 @@ inline bool isKeyword(string word)
}
bool extractSlashData(string& s, string& name, string& data);
string capitalize(const string& word);
bool extractSlashData(std::string& s, std::string& name, std::string& data);
std::string capitalize(const std::string& word);
}

View file

@ -12,15 +12,13 @@
#include <string>
#include <vector>
#include <iostream>
//using namespace std;
#include "Species.h"
#include "Reaction.h"
//#include "Cantera.h"
namespace ckr {
std::string newTask(string msg);
std::string newTask(std::string msg);
bool writeFalloff(int type, const vector_fp& c, std::ostream& log);
bool writeRateCoeff(const RateCoeff& k, std::ostream& log);
void printReactionEquation(std::ostream& f, const Reaction& r);

View file

@ -22,11 +22,68 @@ using namespace std;
namespace Cantera {
int BasisOptimize_print_lvl = 0;
}
//! Print a string within a given space limit. This routine limits the amount of the string that will be printed to a
//! maximum of "space" characters.
/*!
*
* @param str String -> must be null terminated.
* @param space space limit for the printing.
* @param alignment 0 centered
* 1 right aligned
* 2 left aligned
*/
static void print_stringTrunc(const char *str, int space, int alignment);
#endif
//! Finds the location of the maximum component in a double vector INPUT
/*!
* @param x Vector to search
* @param j j <= i < n : i is the range of indecises to search in X(*)
* @param n Length of the vector
*
* @return index of the greatest value on X(*) searched
*/
static int amax(double *x, int j, int n);
//! Switch the position in the vector
/*!
* @param orderVector Vector to be manipulated
* @param jr first position
* @param kspec second species
*/
static void switch_pos(vector_int &orderVector, int jr, int kspec);
//! Invert an nxn matrix and solve m rhs's
/*!
*
* Solve C X + B = 0;
*
* This routine uses Gauss elimination and is optimized for the solution
* of lots of rhs's.
* A crude form of row pivoting is used here.
*
* @param c C is the matrix to be inverted
* @param idem first dimension in the calling routine
* idem >= n must be true
* @param n number of rows and columns in the matrix
* @param b rhs of the matrix problem
* @param m number of rhs to be solved for
*
* c[i+j*idem] = c_i_j = Matrix to be inverted: i = row number
* j = column number
* b[i+j*idem] = b_i_j = vectors of rhs's: i = row number
* j = column number
* (each column is a new rhs)
*
* @return Retuns the value
* 1 : Matrix is singluar
* 0 : solution is OK
*
* The solution is returned in the matrix b.
*/
static int mlequ(double *c, int idem, int n, double *b, int m);
//@{

View file

@ -74,7 +74,7 @@ VCSNONIDEAL_OBJ = vcs_solve_TP.o vcs_VolPhase.o vcs_solve.o vcs_prob.o \
vcs_root1d.o vcs_rxnadj.o \
vcs_SpeciesProperties.o vcs_equilibrate.o \
vcs_prep.o vcs_species_thermo.o vcs_Gibbs.o vcs_phaseStability.o \
$(DALT_OBJ)
vcs_solve_phaseStability.o $(DALT_OBJ)
VCSNONIDEAL_H = vcs_internal.h vcs_VolPhase.h vcs_solve.h vcs_prob.h \
vcs_IntStarStar.h vcs_DoubleStarStar.h vcs_defs.h \

View file

@ -21,7 +21,8 @@ using namespace std;
namespace Cantera {
/// Constructor.
//====================================================================================================================
// Constructor.
MultiPhase::MultiPhase() :
m_np(0),
m_temp(0.0),
@ -33,8 +34,67 @@ namespace Cantera {
m_Tmin(1.0),
m_Tmax(100000.0)
{
}
//====================================================================================================================
// Copy Constructor
/*
* @param right Object to be copied
*/
MultiPhase::MultiPhase(const MultiPhase &right) :
m_np(0),
m_temp(0.0),
m_press(0.0),
m_nel(0),
m_nsp(0),
m_init(false),
m_eloc(-1),
m_Tmin(1.0),
m_Tmax(100000.0)
{
operator=(right);
}
//====================================================================================================================
// Destructor.
/*
* Does nothing. Class MultiPhase does not take
* "ownership" (i.e. responsibility for destroying) the
* phase objects.
*/
MultiPhase::~MultiPhase()
{
}
//====================================================================================================================
// Assignment operator
/*
* @param right Object to be copied
*/
MultiPhase& MultiPhase::operator=(const MultiPhase& right)
{
if (&right != this) {
m_moles = right.m_moles;
// shallow copy of phase pointers
m_phase = right.m_phase;
m_atoms = right.m_atoms;
m_moleFractions = right.m_moleFractions;
m_spphase = right.m_spphase;
m_spstart = right.m_spstart;
m_enames = right.m_enames;
m_enamemap = right.m_enamemap;
m_np = right.m_np;
m_temp = right.m_temp;
m_press = right.m_press;
m_nel = right.m_nel;
m_nsp = right.m_nsp;
m_init = right.m_init;
m_eloc = right.m_eloc;
m_temp_OK = right.m_temp_OK;
m_Tmin = right.m_Tmin;
m_Tmax = right.m_Tmax;
m_elemAbundances = right.m_elemAbundances;
}
return *this;
}
//====================================================================================================================
void MultiPhase::
addPhases(MultiPhase& mix) {
index_t n;
@ -42,7 +102,7 @@ namespace Cantera {
addPhase(mix.m_phase[n], mix.m_moles[n]);
}
}
//====================================================================================================================
void MultiPhase::
addPhases(phase_list& phases, const vector_fp& phaseMoles) {
index_t np = phases.size();
@ -52,7 +112,7 @@ namespace Cantera {
}
init();
}
//====================================================================================================================
void MultiPhase::
addPhase(phase_t* p, doublereal moles) {
if (m_init) {
@ -121,8 +181,7 @@ namespace Cantera {
if (t < m_Tmax) m_Tmax = t;
}
}
//====================================================================================================================
// Process phases and build atomic composition array. This method
// must be called after all phases are added, before doing
// anything else with the mixture. After init() has been called,
@ -183,9 +242,10 @@ namespace Cantera {
updateMoleFractions();
updatePhases();
}
//====================================================================================================================
// Return a reference to phase n. The state of phase n is
// also updated to match the state stored locally in the
// mixture object.
@ -196,15 +256,17 @@ namespace Cantera {
m_phase[n]->setPressure(m_press);
return *m_phase[n];
}
//====================================================================================================================
/// Moles of species \c k.
doublereal MultiPhase::speciesMoles(index_t k) const {
index_t ip = m_spphase[k];
return m_moles[ip]*m_moleFractions[k];
}
/// Total moles of element m, summed over all
/// phases
//====================================================================================================================
// Total moles of global element \a m, summed over all phases.
/*
* @param m Index of the global element
*/
doublereal MultiPhase::elementMoles(index_t m) const {
doublereal sum = 0.0, phasesum;
index_t i, k = 0, ik, nsp;
@ -219,8 +281,8 @@ namespace Cantera {
}
return sum;
}
/// Total charge, summed over all phases
//====================================================================================================================
// Total charge, summed over all phases
doublereal MultiPhase::charge() const {
doublereal sum = 0.0;
index_t i;
@ -229,8 +291,11 @@ namespace Cantera {
}
return sum;
}
//====================================================================================================================
int MultiPhase::speciesIndex(std::string speciesName, std::string phaseName) {
if (!m_init) {
init();
}
int p = phaseIndex(phaseName);
if (p < 0) {
throw CanteraError("MultiPhase::speciesIndex", "phase not found: " + phaseName);
@ -241,7 +306,7 @@ namespace Cantera {
}
return m_spstart[p] + k;
}
//====================================================================================================================
/// Net charge of one phase (Coulombs). The net charge is computed as
/// \f[ Q_p = N_p \sum_k F z_k X_k \f]
/// where the sum runs only over species in phase \a p.
@ -255,7 +320,7 @@ namespace Cantera {
}
return Faraday*phasesum*m_moles[p];
}
//====================================================================================================================
/// Get the chemical potentials of all species in all phases.
void MultiPhase::getChemPotentials(doublereal* mu) const {
@ -266,7 +331,7 @@ namespace Cantera {
loc += m_phase[i]->nSpecies();
}
}
//====================================================================================================================
// Get chemical potentials of species with valid thermo
// data. This method is designed for use in computing chemical
// equilibrium by Gibbs minimization. For solution phases (more
@ -312,7 +377,7 @@ namespace Cantera {
loc += m_phase[i]->nSpecies();
}
}
//====================================================================================================================
/// True if species \a k belongs to a solution phase.
bool MultiPhase::solutionSpecies(index_t k) const {
if (m_phase[m_spphase[k]]->nSpecies() > 1)
@ -320,47 +385,59 @@ namespace Cantera {
else
return false;
}
//====================================================================================================================
/// The Gibbs free energy of the mixture (J).
doublereal MultiPhase::gibbs() const {
index_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++)
sum += m_phase[i]->gibbs_mole() * m_moles[i];
for (i = 0; i < m_np; i++) {
if (m_moles[i] > 0.0) {
sum += m_phase[i]->gibbs_mole() * m_moles[i];
}
}
return sum;
}
//====================================================================================================================
/// The enthalpy of the mixture (J).
doublereal MultiPhase::enthalpy() const {
index_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++)
sum += m_phase[i]->enthalpy_mole() * m_moles[i];
for (i = 0; i < m_np; i++) {
if (m_moles[i] > 0.0) {
sum += m_phase[i]->enthalpy_mole() * m_moles[i];
}
}
return sum;
}
//====================================================================================================================
/// The internal energy of the mixture (J).
doublereal MultiPhase::IntEnergy() const {
index_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++)
sum += m_phase[i]->intEnergy_mole() * m_moles[i];
for (i = 0; i < m_np; i++) {
if (m_moles[i] > 0.0) {
sum += m_phase[i]->intEnergy_mole() * m_moles[i];
}
}
return sum;
}
//====================================================================================================================
/// The entropy of the mixture (J/K).
doublereal MultiPhase::entropy() const {
index_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++)
sum += m_phase[i]->entropy_mole() * m_moles[i];
for (i = 0; i < m_np; i++) {
if (m_moles[i] > 0.0) {
sum += m_phase[i]->entropy_mole() * m_moles[i];
}
}
return sum;
}
//====================================================================================================================
/// The specific heat at constant pressure and composition (J/K).
/// Note that this does not account for changes in composition of
/// the mixture with temperature.
@ -368,16 +445,22 @@ namespace Cantera {
index_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++)
sum += m_phase[i]->cp_mole() * m_moles[i];
for (i = 0; i < m_np; i++) {
if (m_moles[i] > 0.0) {
sum += m_phase[i]->cp_mole() * m_moles[i];
}
}
return sum;
}
//====================================================================================================================
/// Set the mole fractions of phase \a n to the values in
/// array \a x.
void MultiPhase::setPhaseMoleFractions(const index_t n, const doublereal* const x) {
if (!m_init) {
init();
}
phase_t* p = m_phase[n];
p->setState_TPX(m_temp, m_press, x);
int nsp = p->nSpecies();
@ -386,7 +469,7 @@ namespace Cantera {
m_moleFractions[istart+k] = x[k];
}
}
//====================================================================================================================
// Set the species moles using a map. The map \a xMap maps
// species name strings to mole numbers. Mole numbers that are
// less than or equal to zero will be set to zero.
@ -400,7 +483,7 @@ namespace Cantera {
}
setMoles(DATA_PTR(moles));
}
//====================================================================================================================
// Set the species moles using a string. Unspecified species are
// set to zero.
void MultiPhase::setMolesByName(const std::string& x) {
@ -419,7 +502,7 @@ namespace Cantera {
parseCompString(x, xx);
setMolesByName(xx);
}
//====================================================================================================================
// Get the mole numbers of all species in the multiphase
// object
void MultiPhase::getMoles(doublereal * molNum) const {
@ -438,7 +521,7 @@ namespace Cantera {
}
}
}
//====================================================================================================================
/// Set the species moles to the values in array \a n. The state
/// of each phase object is also updated to have the specified
/// composition and the mixture temperature and pressure.
@ -470,7 +553,7 @@ namespace Cantera {
loc += nsp;
}
}
//====================================================================================================================
void MultiPhase::addSpeciesMoles(const int indexS, const doublereal addedMoles) {
vector_fp tmpMoles(m_nsp, 0.0);
getMoles(DATA_PTR(tmpMoles));
@ -480,21 +563,21 @@ namespace Cantera {
}
setMoles(DATA_PTR(tmpMoles));
}
//====================================================================================================================
void MultiPhase::setState_TP(const doublereal T, const doublereal Pres) {
if (!m_init) init();
m_temp = T;
m_press = Pres;
updatePhases();
}
//====================================================================================================================
void MultiPhase::setState_TPMoles(const doublereal T, const doublereal Pres,
const doublereal *n) {
m_temp = T;
m_press = Pres;
setMoles(n);
}
//====================================================================================================================
void MultiPhase::getElemAbundances(doublereal *elemAbundances) const {
index_t eGlobal;
calcElemAbundances();
@ -502,7 +585,7 @@ namespace Cantera {
elemAbundances[eGlobal] = m_elemAbundances[eGlobal];
}
}
//====================================================================================================================
// Internal routine to calculate the element abundance vector
void MultiPhase::calcElemAbundances() const {
index_t loc = 0;
@ -526,17 +609,18 @@ namespace Cantera {
loc += nspPhase;
}
}
//====================================================================================================================
/// The total mixture volume [m^3].
doublereal MultiPhase::volume() const {
int i;
doublereal sum = 0;
for (i = 0; i < int(m_np); i++) {
sum += m_moles[i]/m_phase[i]->molarDensity();
double vol = 1.0/m_phase[i]->molarDensity();
sum += m_moles[i] * vol;
}
return sum;
}
//====================================================================================================================
doublereal MultiPhase::equilibrate(int XY, doublereal err,
int maxsteps, int maxiter, int loglevel) {
doublereal error;
@ -850,18 +934,18 @@ namespace Cantera {
}
}
#endif
//====================================================================================================================
void MultiPhase::setTemperature(const doublereal T) {
if (!m_init) init();
m_temp = T;
updatePhases();
}
//====================================================================================================================
// Name of element \a m.
std::string MultiPhase::elementName(int m) const {
return m_enames[m];
}
//====================================================================================================================
// Index of element with name \a name.
int MultiPhase::elementIndex(std::string name) const {
for (size_t e = 0; e < m_nel; e++) {
@ -871,25 +955,25 @@ namespace Cantera {
}
return -1;
}
//====================================================================================================================
// Name of species with global index \a k.
std::string MultiPhase::speciesName(const int k) const {
return m_snames[k];
}
//====================================================================================================================
doublereal MultiPhase::nAtoms(const int kGlob, const int mGlob) const {
return m_atoms(mGlob, kGlob);
}
//====================================================================================================================
void MultiPhase::getMoleFractions(doublereal* const x) const {
std::copy(m_moleFractions.begin(), m_moleFractions.end(), x);
}
//====================================================================================================================
std::string MultiPhase::phaseName(const index_t iph) const {
const phase_t *tptr = m_phase[iph];
return tptr->id();
}
//====================================================================================================================
int MultiPhase::phaseIndex(const std::string &pName) const {
std::string tmp;
for (int iph = 0; iph < (int) m_np; iph++) {
@ -901,32 +985,33 @@ namespace Cantera {
}
return -1;
}
//====================================================================================================================
doublereal MultiPhase::phaseMoles(const index_t n) const {
return m_moles[n];
}
//====================================================================================================================
void MultiPhase::setPhaseMoles(const index_t n, const doublereal moles) {
m_moles[n] = moles;
}
//====================================================================================================================
int MultiPhase::speciesPhaseIndex(const index_t kGlob) const {
return m_spphase[kGlob];
}
//====================================================================================================================
doublereal MultiPhase::moleFraction(const index_t kGlob) const{
return m_moleFractions[kGlob];
}
//====================================================================================================================
bool MultiPhase::tempOK(const index_t p) const {
return m_temp_OK[p];
}
//====================================================================================================================
/// Update the locally-stored species mole fractions.
void MultiPhase::updateMoleFractions() {
uploadMoleFractionsFromPhases();
}
//====================================================================================================================
/// Update the locally-stored species mole fractions.
void MultiPhase::uploadMoleFractionsFromPhases() {
index_t ip, loc = 0;
@ -937,7 +1022,7 @@ namespace Cantera {
}
calcElemAbundances();
}
//====================================================================================================================
//-------------------------------------------------------------
//
// protected methods
@ -964,6 +1049,6 @@ namespace Cantera {
}
}
}
//====================================================================================================================
}

View file

@ -85,13 +85,25 @@ namespace Cantera {
*/
MultiPhase();
//! Copy Constructor
/*!
* @param right Object to be copied
*/
MultiPhase(const MultiPhase &right);
//! Destructor.
/*!
* Does nothing. Class MultiPhase does not take
* "ownership" (i.e. responsibility for destroying) the
* phase objects.
*/
virtual ~MultiPhase() {}
virtual ~MultiPhase();
//! Assignment operator
/*!
* @param right Object to be copied
*/
MultiPhase& operator=(const MultiPhase& right);
//! Add a vector of phases to the mixture
/*!
@ -111,7 +123,7 @@ namespace Cantera {
//! Add a phase to the mixture.
/*!
* This function must be called befure the init() function is called,
* This function must be called before the init() function is called,
* which serves to freeze the MultiPhase.
*
* @param p pointer to the phase object
@ -258,7 +270,7 @@ namespace Cantera {
/// conditions for which they are stable.
doublereal maxTemp() const { return m_Tmax; }
/// Total charge (Coulombs).
//! Total charge summed over all phases (Coulombs).
doublereal charge() const;
/// Charge (Coulombs) of phase with index \a p.
@ -267,7 +279,7 @@ namespace Cantera {
*/
doublereal phaseCharge(index_t p) const;
/// Total moles of global element \a m, summed over all phases.
//! Total moles of global element \a m, summed over all phases.
/*!
* @param m Index of the global element
*/
@ -549,8 +561,6 @@ namespace Cantera {
*/
void uploadMoleFractionsFromPhases();
private:
//! Set the states of the phase objects to the locally-stored
//! state within this MultiPhase object.
/*!
@ -567,6 +577,7 @@ namespace Cantera {
*/
void updatePhases() const;
private:
//! Calculate the element abundance vector
void calcElemAbundances() const;

View file

@ -19,6 +19,7 @@
//#include "ChemEquil.h"
#include "MultiPhase.h"
#include "vcs_defs.h"
namespace Cantera {
@ -72,7 +73,7 @@ namespace Cantera {
* @ingroup equil
*/
int equilibrate(thermo_t& s, const char* XY,
int solver = -1, doublereal rtol = 1.0e-9, int maxsteps = 5000,
int solver = -1, doublereal rtol = 1.0e-9, int maxsteps = VCS_MAXSTEPS,
int maxiter = 100, int loglevel = -99);
//! Equilibrate a MultiPhase object

View file

@ -42,7 +42,7 @@ using namespace std;
//using namespace VCSnonideal;
namespace VCSnonideal {
//====================================================================================================================
vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() :
m_vprob(0),
@ -51,7 +51,7 @@ namespace VCSnonideal {
m_vsolvePtr(0)
{
}
//====================================================================================================================
vcs_MultiPhaseEquil::vcs_MultiPhaseEquil(mix_t* mix, int printLvl) :
m_vprob(0),
m_mix(0),
@ -89,7 +89,7 @@ namespace VCSnonideal {
m_vsolvePtr = 0;
}
}
//====================================================================================================================
int vcs_MultiPhaseEquil::equilibrate_TV(int XY, doublereal xtarget,
int estimateEquil,
int printLvl, doublereal err,
@ -209,7 +209,7 @@ namespace VCSnonideal {
return iSuccess;
}
//====================================================================================================================
int vcs_MultiPhaseEquil::equilibrate_HP(doublereal Htarget,
int XY, double Tlow, double Thigh,
int estimateEquil,
@ -359,7 +359,7 @@ namespace VCSnonideal {
done:;
return iSuccess;
}
//====================================================================================================================
int vcs_MultiPhaseEquil::equilibrate_SP(doublereal Starget,
double Tlow, double Thigh,
int estimateEquil,
@ -515,7 +515,7 @@ namespace VCSnonideal {
done:;
return iSuccess;
}
//====================================================================================================================
/*
* Equilibrate the solution using the current element abundances
@ -566,7 +566,7 @@ namespace VCSnonideal {
}
return iSuccess;
}
//====================================================================================================================
/*
* Equilibrate the solution using the current element abundances
*/
@ -733,7 +733,7 @@ namespace VCSnonideal {
}
//====================================================================================================================
/**************************************************************************
*
*
@ -897,11 +897,15 @@ namespace VCSnonideal {
fclose(FP);
}
//! print char repeatedly to log file
/*!
* @param letter letter to be repeated
* @param num Number of times repeated
*/
static void print_char(const char letter, const int num) {
for (int i = 0; i < num; i++) plogf("%c", letter);
}
//====================================================================================================================
/*
*
*
@ -1280,7 +1284,7 @@ namespace VCSnonideal {
vcs_VolPhase *VolPhase = vprob->VPhaseList[iphase];
std::string sEOS = string16_EOSType(VolPhase->m_eqnState);
plogf("%16s %5d %5d %8d %16s %8d %16e ", VolPhase->PhaseName.c_str(),
VolPhase->VP_ID, VolPhase->m_singleSpecies,
VolPhase->VP_ID_, VolPhase->m_singleSpecies,
VolPhase->m_gasPhase, sEOS.c_str(),
VolPhase->nSpecies(), VolPhase->totalMolesInert() );
plogf("%16e\n", VolPhase->totalMoles());
@ -1295,7 +1299,7 @@ namespace VCSnonideal {
return VCS_SUCCESS;
}
//====================================================================================================================
// Transfer the current state of mphase into the VCS_PROB object
/*
* The basic problem has already been set up.
@ -1402,7 +1406,7 @@ namespace VCSnonideal {
vcs_VolPhase *VolPhase = vprob->VPhaseList[iphase];
std::string sEOS = string16_EOSType(VolPhase->m_eqnState);
plogf("%16s %5d %5d %8d %16s %8d %16e ", VolPhase->PhaseName.c_str(),
VolPhase->VP_ID, VolPhase->m_singleSpecies,
VolPhase->VP_ID_, VolPhase->m_singleSpecies,
VolPhase->m_gasPhase, sEOS.c_str(),
VolPhase->nSpecies(), VolPhase->totalMolesInert() );
plogf("%16e\n", VolPhase->totalMoles() );
@ -1417,7 +1421,7 @@ namespace VCSnonideal {
return VCS_SUCCESS;
}
//====================================================================================================================
// This routine hasn't been checked yet
void vcs_MultiPhaseEquil::getStoichVector(index_t rxn, Cantera::vector_fp& nu) {
int nsp = m_vsolvePtr->m_numSpeciesTot;
@ -1438,7 +1442,7 @@ namespace VCSnonideal {
}
}
//====================================================================================================================
int vcs_MultiPhaseEquil::numComponents() const {
int nc = -1;
if (m_vsolvePtr) {
@ -1446,7 +1450,7 @@ namespace VCSnonideal {
}
return nc;
}
//====================================================================================================================
int vcs_MultiPhaseEquil::numElemConstraints() const {
int nec = -1;
if (m_vsolvePtr) {
@ -1455,11 +1459,180 @@ namespace VCSnonideal {
return nec;
}
//====================================================================================================================
int vcs_MultiPhaseEquil::component(int m) const {
int nc = numComponents();
if (m < nc) return m_vsolvePtr->m_speciesMapIndex[m];
else return -1;
}
//====================================================================================================================
// Determine the phase stability of a phase at the current conditions
/*
* Equilibration of the solution is not done before the determination is made.
*
* @param iph Phase number to determine the equilibrium. If the phase
* has a non-zero mole number....
*
* @param funcStab Value of the phase pop function
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
*
* @param loglevel Determines the amount of printing to the HTML
* output file.
*/
int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double &funcStab, int printLvl, int loglevel) {
clockWC tickTock;
int nsp = m_mix->nSpecies();
int nel = m_mix->nElements();
int nph = m_mix->nPhases();
if (m_vprob == 0) {
m_vprob = new VCS_PROB(nsp, nel, nph);
}
m_printLvl = printLvl;
m_vprob->m_printLvl = printLvl;
/*
* Extract the current state information
* from the MultiPhase object and
* Transfer it to VCS_PROB object.
*/
int res = vcs_Cantera_update_vprob(m_mix, m_vprob);
if (res != 0) {
plogf("problems\n");
}
// Check obvious bounds on the temperature and pressure
// NOTE, we may want to do more here with the real bounds
// given by the ThermoPhase objects.
double T = m_mix->temperature();
if (T <= 0.0) {
throw CanteraError("vcs_MultiPhaseEquil::determine_PhaseStability",
"Temperature less than zero on input");
}
double pres = m_mix->pressure();
if (pres <= 0.0) {
throw CanteraError("vcs_MultiPhaseEquil::determine_PhaseStability",
"Pressure less than zero on input");
}
beginLogGroup("vcs_MultiPhaseEquil::determine_PhaseStability", loglevel);
addLogEntry("problem type", "fixed T,P");
addLogEntry("Temperature", T);
addLogEntry("Pressure", pres);
/*
* Print out the problem specification from the point of
* view of the vprob object.
*/
m_vprob->prob_report(m_printLvl);
/*
* Call the thermo Program
*/
int ip1 = m_printLvl;
if (m_printLvl >= 3) {
ip1 = m_printLvl - 2;
} else {
ip1 = 0;
}
if (!m_vsolvePtr) {
m_vsolvePtr = new VCS_SOLVE();
}
int iStable = m_vsolvePtr->vcs_PS(m_vprob, iph, printLvl, funcStab);
/*
* Transfer the information back to the MultiPhase object.
* Note we don't just call setMoles, because some multispecies
* solution phases may be zeroed out, and that would cause a problem
* for that routine. Also, the mole fractions of such zereod out
* phases actually contain information about likely reemergent
* states.
*/
m_mix->uploadMoleFractionsFromPhases();
// for (int i = 0; i < m_vprob->nspecies; i++) {
// plogf("%d %15.3e\n", m_vprob->m_gibbsSpecies[i]);
//}
m_mix->getChemPotentials(DATA_PTR(m_vprob->m_gibbsSpecies));
//for (int i = 0; i < m_vprob->nspecies; i++) {
// plogf("%d %15.3e\n", m_vprob->m_gibbsSpecies[i]);
//}
double te = tickTock.secondsWC();
if (printLvl > 0) {
plogf("\n Results from vcs_PS:\n");
plogf("\n");
plogf("Temperature = %g Kelvin\n", m_vprob->T);
plogf("Pressure = %g Pa\n", m_vprob->PresPA);
std::string sss = m_mix->phaseName(iph);
if (iStable) {
plogf("Phase %d named %s is stable, function value = %g > 0\n", iph, sss.c_str(), funcStab);
} else {
plogf("Phase %d named %s is not stable + function value = %g < 0\n", iph, sss.c_str(), funcStab);
}
plogf("\n");
plogf("----------------------------------------"
"---------------------\n");
plogf(" Name Mole_Number");
if (m_vprob->m_VCS_UnitsFormat == VCS_UNITS_MKS) {
plogf("(kmol)");
} else {
plogf("(gmol)");
}
plogf(" Mole_Fraction Chem_Potential");
if (m_vprob->m_VCS_UnitsFormat == VCS_UNITS_KCALMOL)
plogf(" (kcal/mol)\n");
else if (m_vprob->m_VCS_UnitsFormat == VCS_UNITS_UNITLESS)
plogf(" (Dimensionless)\n");
else if (m_vprob->m_VCS_UnitsFormat == VCS_UNITS_KJMOL)
plogf(" (kJ/mol)\n");
else if (m_vprob->m_VCS_UnitsFormat == VCS_UNITS_KELVIN)
plogf(" (Kelvin)\n");
else if (m_vprob->m_VCS_UnitsFormat == VCS_UNITS_MKS)
plogf(" (J/kmol)\n");
plogf("-------------------------------------------------------------\n");
for (int i = 0; i < m_vprob->nspecies; i++) {
plogf("%-12s", m_vprob->SpName[i].c_str());
if (m_vprob->SpeciesUnknownType[i] == VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) {
plogf(" %15.3e %15.3e ", 0.0, m_vprob->mf[i]);
plogf("%15.3e\n", m_vprob->m_gibbsSpecies[i]);
} else {
plogf(" %15.3e %15.3e ", m_vprob->w[i], m_vprob->mf[i]);
if (m_vprob->w[i] <= 0.0) {
int iph = m_vprob->PhaseID[i];
vcs_VolPhase *VPhase = m_vprob->VPhaseList[iph];
//if (VPhase->nSpecies() > 1) {
// plogf(" -1.000e+300\n");
//} else {
plogf("%15.3e\n", m_vprob->m_gibbsSpecies[i]);
//}
} else {
plogf("%15.3e\n", m_vprob->m_gibbsSpecies[i]);
}
}
}
plogf("------------------------------------------"
"-------------------\n");
if (printLvl > 2) {
if (m_vsolvePtr->m_timing_print_lvl > 0) {
plogf("Total time = %12.6e seconds\n", te);
}
}
}
if (loglevel > 0) {
endLogGroup();
}
return iStable;
}
//====================================================================================================================
}

View file

@ -15,7 +15,7 @@
#include "ct_defs.h"
#include "MultiPhase.h"
#include "vcs_defs.h"
namespace Cantera {
@ -81,7 +81,7 @@ namespace Cantera {
int vcs_equilibrate(thermo_t& s, const char* XY,
int estimateEquil = 0, int printLvl = 0,
int solver = -1, doublereal rtol = 1.0e-9,
int maxsteps = 5000,
int maxsteps = VCS_MAXSTEPS,
int maxiter = 100, int loglevel = -99);
@ -142,7 +142,7 @@ namespace Cantera {
int vcs_equilibrate(MultiPhase& s, const char* XY,
int estimateEquil = 0, int printLvl = 0,
int solver = 2,
doublereal rtol = 1.0e-9, int maxsteps = 5000,
doublereal rtol = 1.0e-9, int maxsteps = VCS_MAXSTEPS,
int maxiter = 100, int loglevel = -99);
//! Set a multi-phase chemical solution to chemical equilibrium.
@ -154,7 +154,7 @@ namespace Cantera {
* themselves. Two other thermodynamic quantities, determined by the
* XY string, are held constant during the equilibration.
*
* @param s The object to set to an equilibrium state
* @param s The MultiPhase object to be set to an equilibrium state
*
* @param ixy An integer specifying the two properties to be held
* constant.
@ -202,9 +202,33 @@ namespace Cantera {
int vcs_equilibrate_1(MultiPhase& s, int ixy,
int estimateEquil = 0, int printLvl = 0,
int solver = 2,
doublereal rtol = 1.0e-9, int maxsteps = 5000,
doublereal rtol = 1.0e-9, int maxsteps = VCS_MAXSTEPS,
int maxiter = 100, int loglevel = -99);
//! Determine the phase stability of a single phase given the current conditions
//! in a MultiPhase object
/*!
*
* @param s The MultiPhase object to be set to an equilibrium state
* @param iphase Phase index within the multiphase object to be
* tested for stability.
* @param funcStab Function value that tests equilibrium. > 0 indicates stable
* < 0 indicates unstable
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
*
* @param loglevel Controls amount of diagnostic output. loglevel
* = 0 suppresses diagnostics, and increasingly-verbose
* messages are written as loglevel increases. The
* messages are written to a file in HTML format for viewing
* in a web browser. @see HTML_logs
*/
int vcs_determine_PhaseStability(MultiPhase& s, int iphase,
double &funcStab, int printLvl, int loglevel);
}
namespace VCSnonideal {
@ -355,7 +379,7 @@ namespace VCSnonideal {
*/
int equilibrate(int XY, int estimateEquil = 0,
int printLvl= 0, doublereal err = 1.0e-6,
int maxsteps = 5000, int loglevel=-99);
int maxsteps = VCS_MAXSTEPS, int loglevel=-99);
//! Equilibrate the solution using the current element abundances
//! storred in the MultiPhase object using constant T and P
@ -385,7 +409,7 @@ namespace VCSnonideal {
*/
int equilibrate_TP(int estimateEquil = 0,
int printLvl= 0, doublereal err = 1.0e-6,
int maxsteps = 5000, int loglevel=-99);
int maxsteps = VCS_MAXSTEPS, int loglevel=-99);
//! Equilibrate the solution using the current element abundances
//! storred in the MultiPhase object using either constant H and P
@ -439,7 +463,7 @@ namespace VCSnonideal {
int equilibrate_HP(doublereal Htarget, int XY, double Tlow, double Thigh,
int estimateEquil = 0,
int printLvl = 0, doublereal err = 1.0E-6,
int maxsteps = 5000, int loglevel=-99);
int maxsteps = VCS_MAXSTEPS, int loglevel=-99);
//! Equilibrate the solution using the current element abundances
//! storred in the MultiPhase object using constant S and P.
@ -490,7 +514,7 @@ namespace VCSnonideal {
int equilibrate_SP(doublereal Starget, double Tlow, double Thigh,
int estimateEquil = 0,
int printLvl = 0, doublereal err = 1.0E-6,
int maxsteps = 5000, int loglevel=-99);
int maxsteps = VCS_MAXSTEPS, int loglevel=-99);
//! Equilibrate the solution using the current element abundances
@ -532,13 +556,28 @@ namespace VCSnonideal {
*
* @param maxsteps max steps allowed.
*
* @param loglevel Determines the amount of printing to the HTML
* @param logLevel Determines the amount of printing to the HTML
* output file.
*/
int equilibrate_TV(int XY, doublereal xtarget,
int estimateEquil = 0,
int printLvl = 0, doublereal err = 1.0E-6,
int maxsteps = 5000, int loglevel = -99);
int maxsteps = VCS_MAXSTEPS, int logLevel = -99);
//! Determine the phase stability of a phase at the current conditions
/*!
* Equilibration of the solution is not done before the determination is made.
*
* @param iph Phase number to determine the equilibrium. If the phase
* has a non-zero mole number....
* @param funcStab Value of the phase pop function
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
* @param logLevel Determines the amount of printing to the HTML output file.
*/
int determine_PhaseStability(int iph, double &funcStab, int printLvl= 0, int logLevel = -99);
//! Report the equilibrium answer in a comma separated table format
/*!
@ -563,6 +602,8 @@ namespace VCSnonideal {
*/
int numElemConstraints() const;
// Friend functions
friend int vcs_Cantera_to_vprob(Cantera::MultiPhase *mphase,
@ -638,13 +679,21 @@ namespace VCSnonideal {
//! Pointer to the object that does all of the equilibration work.
/*!
* VCS_SOLVE will have different ordering for species and element constraints
* than this object or the VCS_PROB object.
* This object owns the pointer.
* than this object or the VCS_PROB object. This object owns the pointer.
*/
VCSnonideal::VCS_SOLVE *m_vsolvePtr;
};
//! Global hook for turning on and off time printing.
/*!
* Default is to allow printing. But, you can assign this to zero
* globally to turn off all time printing.
* This is helpful for test suite purposes where you are interested
* in differences in text files.
*/
extern int vcs_timing_print_lvl;
}
#endif

Some files were not shown because too many files have changed in this diff Show more