Continuing transfering LiquidTransport changes, doing bugfixes, and
qualifying against our testsuite.
This commit is contained in:
parent
55dec034ed
commit
ea25de7fe7
51 changed files with 5171 additions and 3636 deletions
|
|
@ -80,6 +80,7 @@ const doublereal logGasConstant = std::log(GasConstant);
|
|||
|
||||
//! One atmosphere [Pa]
|
||||
const doublereal OneAtm = 1.01325e5;
|
||||
const doublereal OneBar = 1.0E5;
|
||||
|
||||
//! Universal gas constant in cal/mol/K
|
||||
const doublereal GasConst_cal_mol_K = GasConstant / 4184.0;
|
||||
|
|
|
|||
65
include/cantera/equil/vcs_SpeciesProperties.h
Normal file
65
include/cantera/equil/vcs_SpeciesProperties.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
#ifndef VCS_SPECIES_PROPERTIES_H
|
||||
#define VCS_SPECIES_PROPERTIES_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace VCSnonideal
|
||||
{
|
||||
|
||||
class VCS_SPECIES_THERMO;
|
||||
class vcs_VolPhase;
|
||||
|
||||
class vcs_SpeciesProperties
|
||||
{
|
||||
|
||||
public:
|
||||
size_t IndexPhase;
|
||||
size_t IndexSpeciesPhase;
|
||||
vcs_VolPhase* OwningPhase;
|
||||
size_t NumElements;
|
||||
|
||||
//! Name of the species
|
||||
std::string SpName;
|
||||
|
||||
VCS_SPECIES_THERMO* SpeciesThermo; /* Pointer to the thermo
|
||||
structure for this species */
|
||||
double WtSpecies; /* Molecular Weight of the species (gm/mol) */
|
||||
|
||||
//! Column of the formula matrix, comprising the
|
||||
//! element composition of the species */
|
||||
std::vector<double> FormulaMatrixCol;
|
||||
|
||||
double Charge; /* Charge state of the species -> This may
|
||||
be duplication of what's in the
|
||||
FormulaMatrixCol entries. However, it's prudent
|
||||
to separate it out. */
|
||||
int SurfaceSpecies; /* True if this species belongs to a surface phase */
|
||||
/*
|
||||
* Various Calculated Quantities that are appropriate to
|
||||
* keep copies of at this level.
|
||||
*/
|
||||
double VolPM; /* Partial molar volume of the species */
|
||||
double ReferenceMoleFraction; /* Representative value of the mole
|
||||
fraction of this species in a phase.
|
||||
This value is used for convergence issues
|
||||
and for calculation of numerical derivs */
|
||||
|
||||
/*
|
||||
* constructor and destructor
|
||||
*/
|
||||
vcs_SpeciesProperties(size_t indexPhase, size_t indexSpeciesPhase,
|
||||
vcs_VolPhase* owning);
|
||||
virtual ~vcs_SpeciesProperties();
|
||||
|
||||
/*
|
||||
* Copy constructor and assignment operator
|
||||
*/
|
||||
vcs_SpeciesProperties(const vcs_SpeciesProperties& b);
|
||||
vcs_SpeciesProperties& operator=(const vcs_SpeciesProperties& b);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
#define VCS_VOLPHASE_H
|
||||
|
||||
#include "cantera/equil/vcs_DoubleStarStar.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -1445,6 +1445,48 @@ private:
|
|||
*/
|
||||
void vcs_updateMolNumVolPhases(const int stateCalc);
|
||||
|
||||
public:
|
||||
//! Calculate the rank of a matrix and return the rows and columns that will generate an independent basis
|
||||
//! for that rank
|
||||
/*
|
||||
* Choose the optimum component species basis for the calculations, finding the rank and
|
||||
* set of linearly independent rows for that calculation.
|
||||
* Then find the set of linearly indepedent element columns that can support that rank.
|
||||
* This is done by taking the transpose of the matrix and redoing the same calculation.
|
||||
* (there may be a better way to do this. I don't know.)
|
||||
*
|
||||
*
|
||||
* Input
|
||||
* ---------
|
||||
*
|
||||
* @param awtmp Vector of mole numbers which will be used to construct a
|
||||
* ranking for how to pick the basis species. This is largely ignored
|
||||
* here.
|
||||
*
|
||||
* @param numSpecies Number of species. This is the number of rows in the matrix.
|
||||
*
|
||||
* @param matrix Matrix. This is the formula matrix. Nominally, the rows are species, while
|
||||
* the columns are element compositions. However, this routine
|
||||
* is totally general, so that the rows and columns can be anything.
|
||||
*
|
||||
* @param numElemConstraints Number of element constraints
|
||||
*
|
||||
* Output
|
||||
* ---------
|
||||
* @param usedZeroedSpecies = If true, then a species with a zero concentration
|
||||
* was used as a component.
|
||||
*
|
||||
*
|
||||
* @param compRes Vector of rows which are linearly independent. (these are the components)
|
||||
*
|
||||
* @param elemComp Vector of columns which are linearly independent (These are the actionable element
|
||||
* constraints).
|
||||
*
|
||||
* @return Returns number of components. This is the rank of the matrix
|
||||
*/
|
||||
int vcs_rank(const double * awtmp, size_t numSpecies, const double * matrix, size_t numElemConstraints,
|
||||
std::vector<size_t> &compRes, std::vector<size_t> &elemComp, int * const usedZeroedSpecies) const;
|
||||
|
||||
|
||||
public:
|
||||
//! value of the number of species used to malloc data structures
|
||||
|
|
|
|||
264
include/cantera/equil/vcs_species_thermo.h
Normal file
264
include/cantera/equil/vcs_species_thermo.h
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
|
||||
/*
|
||||
* Copyright (2005) Sandia Corporation. Under the terms of
|
||||
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
|
||||
* U.S. Government retains certain rights in this software.
|
||||
*/
|
||||
|
||||
#ifndef VCS_SPECIES_THERMO_H
|
||||
#define VCS_SPECIES_THERMO_H
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace VCSnonideal
|
||||
{
|
||||
|
||||
class vcs_VolPhase;
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Models for the species standard state Naught temperature
|
||||
* dependence
|
||||
*/
|
||||
#define VCS_SS0_NOTHANDLED -1
|
||||
#define VCS_SS0_CONSTANT 0
|
||||
//#define VCS_SS0_NASA_POLY 1
|
||||
#define VCS_SS0_CONSTANT_CP 2
|
||||
|
||||
|
||||
/*
|
||||
* Models for the species standard state extra pressure dependence
|
||||
*
|
||||
*/
|
||||
#define VCS_SSSTAR_NOTHANDLED -1
|
||||
#define VCS_SSSTAR_CONSTANT 0
|
||||
#define VCS_SSSTAR_IDEAL_GAS 1
|
||||
|
||||
/*
|
||||
* Identifies the thermo model for the species
|
||||
* This structure is shared by volumetric and surface species. However,
|
||||
* each will have its own types of thermodynamic models. These
|
||||
* quantities all have appropriate units. The units are specified by
|
||||
* VCS_UnitsFormat.
|
||||
*/
|
||||
class VCS_SPECIES_THERMO
|
||||
{
|
||||
/*
|
||||
* All objects are public for ease of development
|
||||
*/
|
||||
public:
|
||||
/**
|
||||
* Index of the phase that this species belongs to.
|
||||
*/
|
||||
size_t IndexPhase;
|
||||
|
||||
/**
|
||||
* Index of this species in the current phase.
|
||||
*/
|
||||
size_t IndexSpeciesPhase;
|
||||
|
||||
/**
|
||||
* Pointer to the owning phase object.
|
||||
*/
|
||||
vcs_VolPhase* OwningPhase;
|
||||
|
||||
/**
|
||||
* Integer representing the models for the species standard state
|
||||
* Naught temperature dependence. They are listed above and start
|
||||
* with VCS_SS0_...
|
||||
*/
|
||||
int SS0_Model;
|
||||
|
||||
/**
|
||||
* Internal storage of the last calculation of the reference
|
||||
* naught Gibbs free energy at SS0_TSave.
|
||||
* (always in units of Kelvin)
|
||||
*/
|
||||
double SS0_feSave;
|
||||
|
||||
/**
|
||||
* Internal storage of the last temperature used in the
|
||||
* calculation of the reference naught Gibbs free energy.
|
||||
* units = kelvin
|
||||
*/
|
||||
double SS0_TSave;
|
||||
|
||||
/**
|
||||
* Base temperature used in the VCS_SS0_CONSTANT_CP
|
||||
* model
|
||||
*/
|
||||
double SS0_T0;
|
||||
|
||||
/**
|
||||
* Base enthalpy used in the VCS_SS0_CONSTANT_CP
|
||||
* model
|
||||
*/
|
||||
double SS0_H0;
|
||||
|
||||
/**
|
||||
* Base entropy used in the VCS_SS0_CONSTANT_CP
|
||||
* model
|
||||
*/
|
||||
double SS0_S0;
|
||||
|
||||
/**
|
||||
* Base heat capacity used in the VCS_SS0_CONSTANT_CP
|
||||
* model
|
||||
*/
|
||||
double SS0_Cp0;
|
||||
|
||||
/**
|
||||
* Value of the pressure for the reference state.
|
||||
* defaults to 1.01325E5 = 1 atm
|
||||
*/
|
||||
double SS0_Pref;
|
||||
/**
|
||||
* Pointer to a list of parameters that is malloced for
|
||||
* complicated reference state calculation.
|
||||
*/
|
||||
void* SS0_Params;
|
||||
/**
|
||||
* Integer value representing the star state model.
|
||||
*/
|
||||
int SSStar_Model;
|
||||
|
||||
/**
|
||||
* Pointer to a list of parameters that is malloced for
|
||||
* complicated reference star state calculation.
|
||||
*/
|
||||
void* SSStar_Params;
|
||||
|
||||
/**
|
||||
* Integer value representing the activity coefficient model
|
||||
* These are defined in vcs_VolPhase.h and start with
|
||||
* VCS_AC_...
|
||||
*/
|
||||
int Activity_Coeff_Model;
|
||||
|
||||
/**
|
||||
* Pointer to a list of parameters that is malloced for
|
||||
* activity coefficient models.
|
||||
*/
|
||||
void* Activity_Coeff_Params;
|
||||
|
||||
/**
|
||||
* Models for the standard state volume of each species
|
||||
*/
|
||||
int SSStar_Vol_Model;
|
||||
|
||||
/**
|
||||
* Pointer to a list of parameters that is malloced for
|
||||
* volume models
|
||||
*/
|
||||
void* SSStar_Vol_Params;
|
||||
|
||||
/**
|
||||
* parameter that is used int eh VCS_SSVOL_CONSTANT model.
|
||||
*/
|
||||
double SSStar_Vol0;
|
||||
|
||||
/**
|
||||
* If true, this object will call Cantera to do its member
|
||||
* calculations.
|
||||
*/
|
||||
bool UseCanteraCalls;
|
||||
|
||||
int m_VCS_UnitsFormat;
|
||||
/*
|
||||
* constructor and destructor
|
||||
*/
|
||||
VCS_SPECIES_THERMO(size_t indexPhase, size_t indexSpeciesPhase);
|
||||
virtual ~VCS_SPECIES_THERMO();
|
||||
|
||||
/*
|
||||
* Copy constructor and assignment operator
|
||||
*/
|
||||
VCS_SPECIES_THERMO(const VCS_SPECIES_THERMO& b);
|
||||
VCS_SPECIES_THERMO& operator=(const VCS_SPECIES_THERMO& b);
|
||||
|
||||
/*
|
||||
* Duplication function for inherited classes.
|
||||
*/
|
||||
virtual VCS_SPECIES_THERMO* duplMyselfAsVCS_SPECIES_THERMO();
|
||||
|
||||
/**
|
||||
* This function calculates the standard state Gibbs free energy
|
||||
* for species, kspec, at the temperature TKelvin and pressure, Pres.
|
||||
*
|
||||
*
|
||||
* Input
|
||||
* TKelvin = Temperature in Kelvin
|
||||
* pres = pressure is given in units specified by if__ variable.
|
||||
*
|
||||
*
|
||||
* Output
|
||||
* return value = standard state free energy in units of Kelvin.
|
||||
*/
|
||||
virtual double GStar_R_calc(size_t kspec, double TKelvin, double pres);
|
||||
|
||||
/**
|
||||
*
|
||||
* G0_calc:
|
||||
*
|
||||
* This function calculates the standard state Gibbs free energy
|
||||
* for species, kspec, at the temperature TKelvin
|
||||
*
|
||||
* Input
|
||||
*
|
||||
*
|
||||
* Output
|
||||
* return value = standard state free energy in Kelvin.
|
||||
*/
|
||||
virtual double G0_R_calc(size_t kspec, double TKelvin);
|
||||
|
||||
/**
|
||||
* cpc_ts_VStar_calc:
|
||||
*
|
||||
* This function calculates the standard state molar volume
|
||||
* for species, kspec, at the temperature TKelvin and pressure, Pres,
|
||||
*
|
||||
*
|
||||
* Input
|
||||
*
|
||||
*
|
||||
* Output
|
||||
* return value = standard state volume in cm**3 per mol.
|
||||
* (if__=3) m**3 / kmol
|
||||
*/
|
||||
virtual double VolStar_calc(size_t kglob, double TKelvin, double Pres);
|
||||
|
||||
/**
|
||||
* This function evaluates the activity coefficient
|
||||
* for species, kspec
|
||||
*
|
||||
* Input
|
||||
* kspec -> integer value of the species in the global
|
||||
* species list within VCS_SOLVE. Phase and local species id
|
||||
* can be looked up within object.
|
||||
*
|
||||
* Note, T, P and mole fractions are obtained from the
|
||||
* single private instance of VCS_SOLVE
|
||||
*
|
||||
*
|
||||
*
|
||||
* Output
|
||||
* return value = activity coefficient for species kspec
|
||||
*/
|
||||
virtual double eval_ac(size_t kspec);
|
||||
|
||||
/**
|
||||
* Get the pointer to the vcs_VolPhase object for this species.
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
/* Externals for vcs_species_thermo.c */
|
||||
|
||||
//extern double vcs_Gxs_phase_calc(vcs_VolPhase *, double *);
|
||||
//extern double vcs_Gxs_calc(int iphase);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -6,7 +6,11 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2004 Sandia Corporation. Under the terms of Contract
|
||||
* $Date$
|
||||
* $Revision$
|
||||
*/
|
||||
/*
|
||||
* Copywrite 2004 Sandia Corporation. Under the terms of Contract
|
||||
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
|
||||
* retains certain rights in this software.
|
||||
* See file License.txt for licensing information.
|
||||
|
|
@ -15,62 +19,61 @@
|
|||
#ifndef CT_NONLINEARSOLVER_H
|
||||
#define CT_NONLINEARSOLVER_H
|
||||
|
||||
#include "ResidJacEval.h"
|
||||
#include "SquareMatrix.h"
|
||||
#include "cantera/numerics/ResidJacEval.h"
|
||||
#include "cantera/numerics/SquareMatrix.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
namespace Cantera {
|
||||
|
||||
//@{
|
||||
/// @name Constant which determines the type of the nonlinear solve
|
||||
/*!
|
||||
//@{
|
||||
/// @name Constant which determines the type of the nonlinear solve
|
||||
/*!
|
||||
* I think steady state is the only option I'm gunning for
|
||||
*/
|
||||
//! The nonlinear problem is part of a pseudo time dependent calculation (NOT TESTED)
|
||||
//! The nonlinear problem is part of a pseudo time dependent calculation (NOT TESTED)
|
||||
#define NSOLN_TYPE_PSEUDO_TIME_DEPENDENT 2
|
||||
//! The nonlinear problem is part of a time dependent calculation
|
||||
//! The nonlinear problem is part of a time dependent calculation
|
||||
#define NSOLN_TYPE_TIME_DEPENDENT 1
|
||||
//! The nonlinear problem is part of a steady state calculation
|
||||
//! The nonlinear problem is part of a steady state calculation
|
||||
#define NSOLN_TYPE_STEADY_STATE 0
|
||||
//@}
|
||||
//@}
|
||||
|
||||
|
||||
//@{
|
||||
/// @name Constant which determines the Return int from the nonlinear solver
|
||||
/*!
|
||||
//@{
|
||||
/// @name Constant which determines the Return int from the nonlinear solver
|
||||
/*!
|
||||
* This int is returned from the nonlinear solver
|
||||
*/
|
||||
//! The nonlinear solve is successful.
|
||||
//! The nonlinear solve is successful.
|
||||
#define NSOLN_RETN_SUCCESS 1
|
||||
//! Problem isn't solved yet
|
||||
//! Problem isn't solved yet
|
||||
#define NSOLN_RETN_CONTINUE 0
|
||||
//! The nonlinear problem started to take too small an update step. This indicates that either the
|
||||
//! Jacobian is bad, or a constraint is being bumped up against.
|
||||
//! The nonlinear problem started to take too small an update step. This indicates that either the
|
||||
//! Jacobian is bad, or a constraint is being bumped up against.
|
||||
#define NSOLN_RETN_FAIL_STEPTOOSMALL -1
|
||||
//! The nonlinear problem didn't solve the problem
|
||||
//! The nonlinear problem didn't solve the problem
|
||||
#define NSOLN_RETN_FAIL_DAMPSTEP -2
|
||||
//! The nonlinear problem's jacobian is singular
|
||||
//! The nonlinear problem's jacobian is singular
|
||||
#define NSOLN_RETN_MATRIXINVERSIONERROR -3
|
||||
//! The nonlinear problem's jacobian formation produced an error
|
||||
//! The nonlinear problem's jacobian formation produced an error
|
||||
#define NSOLN_RETN_JACOBIANFORMATIONERROR -4
|
||||
//! The nonlinear problem's base residual produced an error
|
||||
//! The nonlinear problem's base residual produced an error
|
||||
#define NSOLN_RETN_RESIDUALFORMATIONERROR -5
|
||||
//! The nonlinear problem's max number of iterations has been exceeded
|
||||
//! The nonlinear problem's max number of iterations has been exceeded
|
||||
#define NSOLN_RETN_MAXIMUMITERATIONSEXCEEDED -7
|
||||
//@}
|
||||
//@}
|
||||
//@}
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/// @name Constant which determines the type of the Jacobian
|
||||
//! The jacobian will be calculated from a numerical method
|
||||
//@{
|
||||
/// @name Constant which determines the type of the Jacobian
|
||||
//! The jacobian will be calculated from a numerical method
|
||||
#define NSOLN_JAC_NUM 1
|
||||
//! The jacobian is calculated from an analytical function
|
||||
//! The jacobian is calculated from an analytical function
|
||||
#define NSOLN_JAC_ANAL 2
|
||||
//@}
|
||||
//@}
|
||||
|
||||
|
||||
//! Class that calculates the solution to a nonlinear system
|
||||
/*!
|
||||
//! Class that calculates the solution to a nonlinear system
|
||||
/*!
|
||||
* This is a small nonlinear solver that can solve highly nonlinear problems that
|
||||
* must use a dense matrix to relax the system.
|
||||
*
|
||||
|
|
@ -130,21 +133,20 @@ namespace Cantera
|
|||
*
|
||||
* @ingroup numerics
|
||||
*/
|
||||
class NonlinearSolver
|
||||
{
|
||||
class NonlinearSolver {
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Default constructor
|
||||
/*!
|
||||
* @param func Residual and jacobian evaluator function object
|
||||
*/
|
||||
NonlinearSolver(ResidJacEval* func);
|
||||
NonlinearSolver(ResidJacEval *func);
|
||||
|
||||
//!Copy Constructor for the %ThermoPhase object.
|
||||
/*!
|
||||
* @param right Item to be copied
|
||||
*/
|
||||
NonlinearSolver(const NonlinearSolver& right);
|
||||
NonlinearSolver(const NonlinearSolver &right);
|
||||
|
||||
//! Destructor
|
||||
~NonlinearSolver();
|
||||
|
|
@ -157,7 +159,7 @@ public:
|
|||
* copied into the
|
||||
* current one.
|
||||
*/
|
||||
NonlinearSolver& operator=(const NonlinearSolver& right);
|
||||
NonlinearSolver& operator=(const NonlinearSolver &right);
|
||||
|
||||
//! Create solution weights for convergence criteria
|
||||
/*!
|
||||
|
|
@ -170,7 +172,7 @@ public:
|
|||
*
|
||||
* @param y vector of the current solution values
|
||||
*/
|
||||
void createSolnWeights(const doublereal* const y);
|
||||
void createSolnWeights(const doublereal * const y);
|
||||
|
||||
//! L2 norm of the delta of the solution vector
|
||||
/*!
|
||||
|
|
@ -189,7 +191,7 @@ public:
|
|||
*
|
||||
* @return Returns the L2 norm of the delta
|
||||
*/
|
||||
doublereal solnErrorNorm(const doublereal* const delta_y, const char* title = 0, int printLargest = 0,
|
||||
doublereal solnErrorNorm(const doublereal * const delta_y, const char * title = 0, int printLargest = 0,
|
||||
const doublereal dampFactor = 1.0) const;
|
||||
|
||||
//! L2 norm of the residual of the equation system
|
||||
|
|
@ -209,27 +211,27 @@ public:
|
|||
*
|
||||
* @return Returns the L2 norm of the delta
|
||||
*/
|
||||
doublereal residErrorNorm(const doublereal* const resid, const char* title = 0, const int printLargest = 0,
|
||||
const doublereal* const y = 0) const;
|
||||
doublereal residErrorNorm(const doublereal * const resid, const char * title = 0, const int printLargest = 0,
|
||||
const doublereal * const y = 0) const;
|
||||
|
||||
//! Compute the current residual
|
||||
/*!
|
||||
* The current value of the residual is stored in the internal work array m_resid, which is defined
|
||||
* The current value of the residual is storred in the internal work array m_resid, which is defined
|
||||
* as mutable
|
||||
*
|
||||
* @param time_curr Value of the time
|
||||
* @param typeCalc Type of the calculation
|
||||
* @param y_curr Current value of the solution vector
|
||||
* @param ydot_curr Current value of the time derivative of the solution vector
|
||||
* @param evalType Base evaluation type
|
||||
* @param evalType Base evalulation type
|
||||
* Defaults to Base_ResidEval
|
||||
*
|
||||
* @return Returns a flag to indicate that operation is successful.
|
||||
* 1 Means a successful operation
|
||||
* -0 or neg value Means an unsuccessful operation
|
||||
*/
|
||||
int doResidualCalc(const doublereal time_curr, const int typeCalc, const doublereal* const y_curr,
|
||||
const doublereal* const ydot_curr,
|
||||
int doResidualCalc(const doublereal time_curr, const int typeCalc, const doublereal * const y_curr,
|
||||
const doublereal * const ydot_curr,
|
||||
const ResidEval_Type_Enum evalType = Base_ResidEval) const;
|
||||
|
||||
//! Compute the undamped Newton step
|
||||
|
|
@ -255,8 +257,8 @@ public:
|
|||
* @return Returns the result code from lapack. A zero means success. Anything
|
||||
* else indicates a failure.
|
||||
*/
|
||||
int doNewtonSolve(const doublereal time_curr, const doublereal* const y_curr,
|
||||
const doublereal* const ydot_curr, doublereal* const delta_y,
|
||||
int doNewtonSolve(const doublereal time_curr, const doublereal * const y_curr,
|
||||
const doublereal * const ydot_curr, doublereal * const delta_y,
|
||||
GeneralMatrix& jac);
|
||||
|
||||
//! Compute the newton step, either by direct newton's or by solving a close problem that is represented
|
||||
|
|
@ -284,14 +286,14 @@ public:
|
|||
*
|
||||
* Internal input
|
||||
* ---------------
|
||||
* internal m_resid Stored residual is used as input
|
||||
* internal m_resid Storred residual is used as input
|
||||
*
|
||||
*
|
||||
* @return Returns the result code from lapack. A zero means success. Anything
|
||||
* else indicates a failure.
|
||||
*/
|
||||
int doAffineNewtonSolve(const doublereal* const y_curr, const doublereal* const ydot_curr,
|
||||
doublereal* const delta_y, GeneralMatrix& jac);
|
||||
int doAffineNewtonSolve(const doublereal * const y_curr, const doublereal * const ydot_curr,
|
||||
doublereal * const delta_y, GeneralMatrix& jac);
|
||||
|
||||
//! Calculate the length of the current trust region in terms of the solution error norm
|
||||
/*!
|
||||
|
|
@ -316,9 +318,9 @@ public:
|
|||
/*!
|
||||
* @param deltaBoundsMagnitudes set the deltaBoundsMagnitude vector
|
||||
*/
|
||||
void setDeltaBoundsMagnitudes(const doublereal* const deltaBoundsMagnitudes);
|
||||
void setDeltaBoundsMagnitudes(const doublereal * const deltaBoundsMagnitudes);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
//! Readjust the trust region vectors
|
||||
/*!
|
||||
|
|
@ -353,11 +355,11 @@ protected:
|
|||
*
|
||||
* @param deltaX Current value of deltaX
|
||||
*/
|
||||
doublereal calcTrustDistance(std::vector<doublereal> const& deltaX) const;
|
||||
doublereal calcTrustDistance(std::vector<doublereal> const & deltaX) const;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Bound the step
|
||||
/*!
|
||||
*
|
||||
|
|
@ -389,7 +391,7 @@ public:
|
|||
*
|
||||
* @return Returns the damping factor determined by the bounds calculation
|
||||
*/
|
||||
doublereal boundStep(const doublereal* const y, const doublereal* const step0);
|
||||
doublereal boundStep(const doublereal * const y, const doublereal * const step0);
|
||||
|
||||
//! Set bounds constraints for all variables in the problem
|
||||
/*!
|
||||
|
|
@ -397,8 +399,8 @@ public:
|
|||
* @param y_low_bounds Vector of lower bounds
|
||||
* @param y_high_bounds Vector of high bounds
|
||||
*/
|
||||
void setBoundsConstraints(const doublereal* const y_low_bounds,
|
||||
const doublereal* const y_high_bounds);
|
||||
void setBoundsConstraints(const doublereal * const y_low_bounds,
|
||||
const doublereal * const y_high_bounds);
|
||||
|
||||
//! Return an editable vector of the low bounds constraints
|
||||
std::vector<doublereal> & lowBoundsConstraintVector();
|
||||
|
|
@ -415,7 +417,7 @@ public:
|
|||
* @param y_curr current value of the solution
|
||||
* @param ydot_curr Calculated value of the solution derivative that is consistent with y_curr
|
||||
*/
|
||||
void calc_ydot(const int order, const doublereal* const y_curr, doublereal* const ydot_curr) const;
|
||||
void calc_ydot(const int order, const doublereal * const y_curr, doublereal * const ydot_curr) const;
|
||||
|
||||
//! Function called to evaluate the jacobian matrix and the current
|
||||
//! residual vector at the current time step
|
||||
|
|
@ -436,9 +438,9 @@ public:
|
|||
* 1 Means a successful operation
|
||||
* 0 Means an unsuccessful operation
|
||||
*/
|
||||
int beuler_jac(GeneralMatrix& J, doublereal* const f,
|
||||
doublereal time_curr, doublereal CJ, doublereal* const y,
|
||||
doublereal* const ydot, int num_newt_its);
|
||||
int beuler_jac(GeneralMatrix &J, doublereal * const f,
|
||||
doublereal time_curr, doublereal CJ, doublereal * const y,
|
||||
doublereal * const ydot, int num_newt_its);
|
||||
|
||||
//! Apply a filtering process to the step
|
||||
/*!
|
||||
|
|
@ -448,7 +450,7 @@ public:
|
|||
*
|
||||
* @return Returns the norm of the value of the amount filtered
|
||||
*/
|
||||
doublereal filterNewStep(const doublereal timeCurrent, const doublereal* const ybase, doublereal* const step0);
|
||||
doublereal filterNewStep(const doublereal timeCurrent, const doublereal * const ybase, doublereal * const step0);
|
||||
|
||||
//! Apply a filter to the solution
|
||||
/*!
|
||||
|
|
@ -458,8 +460,8 @@ public:
|
|||
*
|
||||
* @return Returns the norm of the value of the amount filtered
|
||||
*/
|
||||
doublereal filterNewSolution(const doublereal timeCurrent, doublereal* const y_current,
|
||||
doublereal* const ydot_current);
|
||||
doublereal filterNewSolution(const doublereal timeCurrent, doublereal * const y_current,
|
||||
doublereal * const ydot_current);
|
||||
|
||||
//! Return the factor by which the undamped Newton step 'step0'
|
||||
//! must be multiplied in order to keep the update within the bounds of an accurate jacobian.
|
||||
|
|
@ -477,7 +479,7 @@ public:
|
|||
*
|
||||
* @return returns the damping factor
|
||||
*/
|
||||
doublereal deltaBoundStep(const doublereal* const y, const doublereal* const step0);
|
||||
doublereal deltaBoundStep(const doublereal * const y, const doublereal * const step0);
|
||||
|
||||
//! Find a damping coefficient through a look-ahead mechanism
|
||||
/*!
|
||||
|
|
@ -492,7 +494,7 @@ public:
|
|||
* @param time_curr Current physical time
|
||||
* @param y_n_curr Base value of the solution before any steps
|
||||
* are taken
|
||||
* @param ydot_n_curr Base value of the time derivative of the
|
||||
* @param ydot_n_curr Base value of the time derivative of teh
|
||||
* solution
|
||||
* @param step_1 Initial step suggested.
|
||||
* @param y_n_1 Value of y1, the suggested solution after damping
|
||||
|
|
@ -505,10 +507,10 @@ public:
|
|||
*
|
||||
* @return returns an integer indicating what happened.
|
||||
*/
|
||||
int dampStep(const doublereal time_curr, const doublereal* const y_n_curr,
|
||||
const doublereal* const ydot_n_curr, doublereal* const step_1,
|
||||
doublereal* const y_n_1, doublereal* const ydot_n_1, doublereal* step_2,
|
||||
doublereal& stepNorm_2, GeneralMatrix& jac, bool writetitle,
|
||||
int dampStep(const doublereal time_curr, const doublereal * const y_n_curr,
|
||||
const doublereal * const ydot_n_curr, doublereal * const step_1,
|
||||
doublereal * const y_n_1, doublereal * const ydot_n_1, doublereal * step_2,
|
||||
doublereal & stepNorm_2, GeneralMatrix& jac, bool writetitle,
|
||||
int& num_backtracks);
|
||||
|
||||
//! Find the solution to F(X) = 0 by damped Newton iteration.
|
||||
|
|
@ -538,15 +540,15 @@ public:
|
|||
* @return A positive value indicates a successful convergence
|
||||
* -1 Failed convergence
|
||||
*/
|
||||
int solve_nonlinear_problem(int SolnType, doublereal* const y_comm, doublereal* const ydot_comm, doublereal CJ,
|
||||
doublereal time_curr, GeneralMatrix& jac, int& num_newt_its,
|
||||
int& num_linear_solves, int& num_backtracks, int loglevelInput);
|
||||
int solve_nonlinear_problem(int SolnType, doublereal * const y_comm, doublereal * const ydot_comm, doublereal CJ,
|
||||
doublereal time_curr, GeneralMatrix & jac, int &num_newt_its,
|
||||
int &num_linear_solves, int &num_backtracks, int loglevelInput);
|
||||
|
||||
private:
|
||||
private:
|
||||
//! Set the column scales
|
||||
void calcColumnScales();
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
//! Set the column scaling that are used for the inversion of the matrix
|
||||
/*!
|
||||
|
|
@ -557,7 +559,7 @@ public:
|
|||
* effect of ensuring that all delta variables will have the same order of magnitude at convergence
|
||||
* end.
|
||||
*
|
||||
* The second way is the explicitly set the column factors in the second argument of this function call.
|
||||
* The second way is the explicity set the column factors in the second argument of this function call.
|
||||
*
|
||||
* The final way to input the scales is to override the ResidJacEval member function call,
|
||||
*
|
||||
|
|
@ -568,7 +570,7 @@ public:
|
|||
* @param useColScaling Turn this on if you want to use column scaling in the calculations
|
||||
* @param scaleFactors A vector of doubles that specifies the column factors.
|
||||
*/
|
||||
void setColumnScaling(bool useColScaling, const double* const scaleFactors = 0);
|
||||
void setColumnScaling(bool useColScaling, const double * const scaleFactors = 0);
|
||||
|
||||
|
||||
//! Set the rowscaling that are used for the inversion of the matrix
|
||||
|
|
@ -587,7 +589,7 @@ public:
|
|||
* @param time_curr current value of the time
|
||||
* @param num_newt_its Current value of the number of newt its
|
||||
*/
|
||||
void scaleMatrix(GeneralMatrix& jac, doublereal* const y_comm, doublereal* const ydot_comm,
|
||||
void scaleMatrix(GeneralMatrix& jac, doublereal * const y_comm, doublereal * const ydot_comm,
|
||||
doublereal time_curr, int num_newt_its);
|
||||
|
||||
//! Print solution norm contribution
|
||||
|
|
@ -605,10 +607,10 @@ public:
|
|||
* @param num_entries Number of entries to print out
|
||||
*/
|
||||
void
|
||||
print_solnDelta_norm_contrib(const doublereal* const step_1, const char* const stepNorm_1,
|
||||
const doublereal* const step_2, const char* const stepNorm_2,
|
||||
const char* const title, const doublereal* const y_n_curr,
|
||||
const doublereal* const y_n_1, doublereal damp, size_t num_entries);
|
||||
print_solnDelta_norm_contrib(const doublereal * const step_1, const char * const stepNorm_1,
|
||||
const doublereal * const step_2, const char * const stepNorm_2,
|
||||
const char * const title, const doublereal * const y_n_curr,
|
||||
const doublereal * const y_n_1, doublereal damp, int num_entries);
|
||||
|
||||
//! Compute the Residual Weights
|
||||
/*!
|
||||
|
|
@ -627,7 +629,7 @@ public:
|
|||
/*!
|
||||
* @param residWts Vector of length neq_
|
||||
*/
|
||||
void getResidWts(doublereal* const residWts) const;
|
||||
void getResidWts(doublereal * const residWts) const;
|
||||
|
||||
|
||||
|
||||
|
|
@ -655,7 +657,7 @@ public:
|
|||
*
|
||||
* @param atol Vector of length neq_ that contains the tolerances to be used for the solution variables
|
||||
*/
|
||||
void setAtol(const doublereal* const atol);
|
||||
void setAtol(const doublereal * const atol);
|
||||
|
||||
//! Set the relative tolerances for the solution variables
|
||||
/*!
|
||||
|
|
@ -680,6 +682,9 @@ public:
|
|||
* and the residual norms are converging at the same time and thus accounts for some-illconditioning issues
|
||||
* but not all.
|
||||
*
|
||||
* With this routine the user can override or add to the residual weighting norm evaluation by specifying
|
||||
* their own vector of residual absolute and relative tolerances.
|
||||
*
|
||||
* The user specified tolerance for the residual is given by the following quantity
|
||||
*
|
||||
* residWeightNorm[i] = residAtol[i] + residRtol * m_rowWtScales[i] / neq
|
||||
|
|
@ -692,7 +697,7 @@ public:
|
|||
* 2 Use the minimum value of the residual weights calculcated by method 1 and 2.
|
||||
* This is the default if this routine is called and this parameter isn't specified.
|
||||
*/
|
||||
void setResidualTols(double residRtol, double* residATol, int residNormHandling = 2);
|
||||
void setResidualTols(double residRtol, double * residATol, int residNormHandling = 2);
|
||||
|
||||
//! Set the value of the maximum # of newton iterations
|
||||
/*!
|
||||
|
|
@ -737,10 +742,10 @@ public:
|
|||
*
|
||||
* @param time_curr Current time
|
||||
* @param ydot0 INPUT Current value of the derivative of the solution vector
|
||||
* @param ydot1 INPUT Time derivatives of solution at the conditions which are evaluated for success
|
||||
* @param ydot1 INPUT Time derivates of solution at the conditions which are evalulated for success
|
||||
* @param numTrials OUTPUT Counter for the number of residual evaluations
|
||||
*/
|
||||
void descentComparison(doublereal time_curr ,doublereal* ydot0, doublereal* ydot1, int& numTrials);
|
||||
void descentComparison(doublereal time_curr ,doublereal * ydot0, doublereal * ydot1, int &numTrials);
|
||||
|
||||
|
||||
//! Setup the parameters for the double dog leg
|
||||
|
|
@ -758,7 +763,7 @@ public:
|
|||
*
|
||||
* @return Returns the leg number ( 0, 1, or 2).
|
||||
*/
|
||||
int lambdaToLeg(const doublereal lambda, doublereal& alpha) const;
|
||||
int lambdaToLeg(const doublereal lambda, doublereal &alpha) const;
|
||||
|
||||
//! Given a trust distance, this routine calculates the intersection of the this distance with the
|
||||
//! double dogleg curve
|
||||
|
|
@ -768,7 +773,7 @@ public:
|
|||
* @param alpha (OUTPUT) Returns the relative distance along the appropriate leg
|
||||
* @return leg (OUTPUT) Returns the leg ID (0, 1, or 2)
|
||||
*/
|
||||
int calcTrustIntersection(doublereal trustVal, doublereal& lambda, doublereal& alpha) const;
|
||||
int calcTrustIntersection(doublereal trustVal, doublereal &lambda, doublereal &alpha) const;
|
||||
|
||||
//! Initialize the size of the trust vector.
|
||||
/*!
|
||||
|
|
@ -818,7 +823,7 @@ public:
|
|||
* -2 Unsuccessful step.
|
||||
*/
|
||||
int dampDogLeg(const doublereal time_curr, const doublereal* y_n_curr,
|
||||
const doublereal* ydot_n_curr, std::vector<doublereal> & step_1,
|
||||
const doublereal *ydot_n_curr, std::vector<doublereal> & step_1,
|
||||
doublereal* const y_n_1, doublereal* const ydot_n_1,
|
||||
doublereal& stepNorm_1, doublereal& stepNorm_2, GeneralMatrix& jac, int& num_backtracks);
|
||||
|
||||
|
|
@ -835,8 +840,8 @@ public:
|
|||
* @param y_n_curr INPUT Current value of the solution vector
|
||||
* @param ydot_n_curr INPUT Current value of the derivative of the solution vector
|
||||
* @param step_1 INPUT Trial step
|
||||
* @param y_n_1 OUTPUT Solution values at the conditions which are evaluated for success
|
||||
* @param ydot_n_1 OUTPUT Time derivatives of solution at the conditions which are evaluated for success
|
||||
* @param y_n_1 OUTPUT Solution values at the conditions which are evalulated for success
|
||||
* @param ydot_n_1 OUTPUT Time derivates of solution at the conditions which are evalulated for success
|
||||
* @param trustDeltaOld INPUT Value of the trust length at the old conditions
|
||||
*
|
||||
*
|
||||
|
|
@ -849,10 +854,10 @@ public:
|
|||
* -2 Current value of the solution vector caused a residual error in its evaluation.
|
||||
* Step is a failure, and the step size must be reduced in order to proceed further.
|
||||
*/
|
||||
int decideStep(const doublereal time_curr, int leg, doublereal alpha, const doublereal* const y_n_curr,
|
||||
const doublereal* const ydot_n_curr,
|
||||
int decideStep(const doublereal time_curr, int leg, doublereal alpha, const doublereal * const y_n_curr,
|
||||
const doublereal * const ydot_n_curr,
|
||||
const std::vector<doublereal> & step_1,
|
||||
const doublereal* const y_n_1, const doublereal* const ydot_n_1, doublereal trustDeltaOld);
|
||||
const doublereal * const y_n_1, const doublereal * const ydot_n_1, doublereal trustDeltaOld);
|
||||
|
||||
//! Calculated the expected residual along the double dogleg curve.
|
||||
/*!
|
||||
|
|
@ -873,8 +878,8 @@ public:
|
|||
* @param legBest OUTPUT leg of the dogleg that gives the lowest residual
|
||||
* @param alphaBest OUTPUT distance along dogleg for best result.
|
||||
*/
|
||||
void residualComparisonLeg(const doublereal time_curr, const doublereal* const ydot0, int& legBest,
|
||||
doublereal& alphaBest) const;
|
||||
void residualComparisonLeg(const doublereal time_curr, const doublereal * const ydot0, int & legBest,
|
||||
doublereal & alphaBest) const;
|
||||
|
||||
//! Set the print level from the nonlinear solver
|
||||
/*!
|
||||
|
|
@ -912,20 +917,20 @@ public:
|
|||
* MEMBER DATA
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
private:
|
||||
private:
|
||||
|
||||
//! Pointer to the residual and jacobian evaluator for the
|
||||
//! function
|
||||
/*!
|
||||
* See ResidJacEval.h for an evaluator.
|
||||
*/
|
||||
ResidJacEval* m_func;
|
||||
ResidJacEval *m_func;
|
||||
|
||||
//! Solution type
|
||||
int solnType_;
|
||||
|
||||
//! Local copy of the number of equations
|
||||
size_t neq_;
|
||||
int neq_;
|
||||
|
||||
//! Soln error weights
|
||||
std::vector<doublereal> m_ewt;
|
||||
|
|
@ -1067,8 +1072,10 @@ private:
|
|||
//! Total number of newton iterations
|
||||
int m_numTotalNewtIts;
|
||||
|
||||
public:
|
||||
//! Minimum number of newton iterations to use
|
||||
int m_min_newt_its;
|
||||
private:
|
||||
|
||||
//! Maximum number of newton iterations
|
||||
int maxNewtIts_;
|
||||
|
|
@ -1103,7 +1110,7 @@ private:
|
|||
doublereal atolBase_;
|
||||
|
||||
//! Pointer containing the solution derivative at the previous time step
|
||||
doublereal* m_ydot_nm1;
|
||||
doublereal *m_ydot_nm1;
|
||||
|
||||
//! absolute tolerance in the solution unknown
|
||||
/*!
|
||||
|
|
@ -1132,8 +1139,10 @@ private:
|
|||
* 2 -> short description, points of interest: Table of nonlinear solve - one line per iteration
|
||||
* 3 -> Table is included -> More printing per nonlinear iteration (default) that occurs during the table
|
||||
* 4 -> Summaries of the nonlinear solve iteration as they are occurring -> table no longer printed
|
||||
* Base_ShowSolution Residual called for residual printing at the end of convergence.
|
||||
* 5 -> Algorithm information on the nonlinear iterates are printed out
|
||||
* 6 -> Additional info on the nonlinear iterates are printed out
|
||||
* Base_ShowSolution Residual called for residual printing at the end of each step.
|
||||
* 7 -> Additional info on the linear solve is printed out.
|
||||
* 8 -> Info on a per iterate of the linear solve is printed out.
|
||||
*/
|
||||
|
|
@ -1144,12 +1153,12 @@ private:
|
|||
|
||||
//! Copy of the jacobian that doesn't get overwritten when the inverse is determined
|
||||
/*!
|
||||
* The jacobian stored here is the raw matrix, before any row or column scaling is carried out
|
||||
* The jacobian storred here is the raw matrix, before any row or column scaling is carried out
|
||||
*/
|
||||
Cantera::GeneralMatrix* jacCopyPtr_;
|
||||
Cantera::GeneralMatrix * jacCopyPtr_;
|
||||
|
||||
//! Hessian
|
||||
Cantera::GeneralMatrix* HessianPtr_;
|
||||
Cantera::GeneralMatrix * HessianPtr_;
|
||||
|
||||
/*********************************************************************************************
|
||||
* VARIABLES ASSOCIATED WITH STEPS AND ASSOCIATED DOUBLE DOGLEG PARAMETERS
|
||||
|
|
@ -1253,7 +1262,7 @@ private:
|
|||
//! Factor indicating how much trust region has been changed next iteration - output variable
|
||||
doublereal NextTrustFactor_;
|
||||
|
||||
//! Boolean indicating that the residual weights have been reevaluated this iteration - output variable
|
||||
//! Boolean indicating that the residual weights have been reevalulated this iteration - output variable
|
||||
bool ResidWtsReevaluated_;
|
||||
|
||||
//! Expected DResid_dS for the steepest descent path - output variable
|
||||
|
|
@ -1272,7 +1281,7 @@ private:
|
|||
* STATIC VARIABLES
|
||||
*****************************************************************************************/
|
||||
|
||||
public:
|
||||
public:
|
||||
//! Turn off printing of time
|
||||
/*!
|
||||
* Necessary to do for test suites
|
||||
|
|
@ -1297,7 +1306,7 @@ public:
|
|||
*/
|
||||
static bool s_alwaysAssumeNewtonGood;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,23 @@ public:
|
|||
* These routines are basically wrappers around the derived copy
|
||||
* constructor.
|
||||
*/
|
||||
virtual Transport* duplMyselfAsTransport() const;
|
||||
virtual Transport *duplMyselfAsTransport() const;
|
||||
|
||||
//! Specifies the %ThermPhase object.
|
||||
/*!
|
||||
* We have relaxed this operation so that it will succeed when
|
||||
* the underlying old and new ThermoPhase objects have the same
|
||||
* number of species and the same names of the species in the
|
||||
* same order. The idea here is to allow copy constructors and duplicators
|
||||
* to work. In order for them to work, we need a method to switch the
|
||||
* internal pointer within the Transport object after the duplication
|
||||
* takes place. Also, different thermodynamic instanteations of the same
|
||||
* species should also work.
|
||||
*
|
||||
* @param thermo Reference to the ThermoPhase object that
|
||||
* the transport object will use
|
||||
*/
|
||||
virtual void setThermo(thermo_t& thermo);
|
||||
|
||||
//---------------------------------------------------------
|
||||
// overloaded base class methods
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ enum TransportPropertyType {
|
|||
TP_THERMALCOND,
|
||||
TP_DIFFUSIVITY,
|
||||
TP_HYDRORADIUS,
|
||||
TP_ELECTCOND
|
||||
TP_ELECTCOND,
|
||||
TP_DEFECTCONC,
|
||||
TP_DEFECTDIFF
|
||||
};
|
||||
|
||||
//====================================================================================================================
|
||||
|
|
@ -97,7 +99,7 @@ public:
|
|||
* is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*/
|
||||
LTPspecies(const XML_Node* const propNode = 0, const std::string& name = "-",
|
||||
LTPspecies(const XML_Node * const propNode = 0, const std::string name = "-",
|
||||
TransportPropertyType tp_ind = TP_UNKNOWN, const thermo_t* thermo = 0);
|
||||
|
||||
//! Copy constructor
|
||||
|
|
@ -225,8 +227,8 @@ public:
|
|||
* is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*/
|
||||
LTPspecies_Const(const XML_Node& propNode, const std::string& name,
|
||||
TransportPropertyType tp_ind, const thermo_t* const thermo);
|
||||
LTPspecies_Const(const XML_Node &propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t * const thermo);
|
||||
|
||||
//! Copy constructor
|
||||
/*!
|
||||
|
|
@ -308,9 +310,10 @@ public:
|
|||
* is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*
|
||||
|
||||
*/
|
||||
LTPspecies_Arrhenius(const XML_Node& propNode, const std::string& name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo);
|
||||
LTPspecies_Arrhenius(const XML_Node &propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t * thermo);
|
||||
|
||||
//! Copy constructor
|
||||
/*!
|
||||
|
|
@ -415,8 +418,9 @@ public:
|
|||
* is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*
|
||||
|
||||
*/
|
||||
LTPspecies_Poly(const XML_Node& propNode, const std::string& name, TransportPropertyType tp_ind, const thermo_t* thermo);
|
||||
LTPspecies_Poly(const XML_Node &propNode, const std::string name, TransportPropertyType tp_ind, const thermo_t * thermo);
|
||||
|
||||
//! Copy constructor
|
||||
/*!
|
||||
|
|
@ -504,9 +508,10 @@ public:
|
|||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*
|
||||
*/
|
||||
LTPspecies_ExpT(const XML_Node& propNode, const std::string& name,
|
||||
LTPspecies_ExpT(const XML_Node &propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo);
|
||||
|
||||
|
||||
//! Copy constructor
|
||||
/*!
|
||||
* @param right Object to be copied
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
// Cantera includes
|
||||
#include "LTPspecies.h"
|
||||
#include "TransportBase.h"
|
||||
#include "cantera/numerics/DenseMatrix.h"
|
||||
|
||||
|
|
@ -62,14 +63,47 @@ public:
|
|||
*/
|
||||
virtual Transport* duplMyselfAsTransport() const;
|
||||
|
||||
|
||||
virtual int model() const {
|
||||
return cSolidTransport;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ionic conducitivity in 1/ohm/m.
|
||||
*/
|
||||
virtual doublereal ionConductivity() ;
|
||||
|
||||
|
||||
//! Returns the mixture thermal conductivity in W/m/K.
|
||||
/*!
|
||||
* Units are in W / m K or equivalently kg m / s3 K
|
||||
*
|
||||
* @return returns thermal conductivity in W/m/K.
|
||||
*/
|
||||
virtual doublereal thermalConductivity();
|
||||
|
||||
/**
|
||||
* The electrical conductivity (Siemens/m).
|
||||
*/
|
||||
virtual doublereal electricalConductivity();
|
||||
|
||||
/**
|
||||
* The diffusivity of defects in the solid (m^2/s).
|
||||
*/
|
||||
virtual doublereal defectDiffusivity();
|
||||
|
||||
/**
|
||||
* The activity of defects in the solid.
|
||||
* At some point this should be variable and the diffusion coefficient should depend on it...
|
||||
*/
|
||||
virtual doublereal defectActivity();
|
||||
|
||||
|
||||
|
||||
|
||||
///////////HEWSON WONDERS IF THE FOLLOWING ARE RELEVANT??
|
||||
virtual void getMixDiffCoeffs(doublereal* const d);
|
||||
|
||||
|
||||
//! Compute the electrical mobilities of the species from the diffusion coefficients,
|
||||
//! using the Einstein relation.
|
||||
/*!
|
||||
|
|
@ -87,17 +121,72 @@ public:
|
|||
*/
|
||||
virtual void getMobilities(doublereal* const mobil);
|
||||
|
||||
//! Set model parameters for derived classes
|
||||
/*!
|
||||
* This method may be derived in subclasses to set model-specific parameters.
|
||||
* The primary use of this class is to set parameters while in the middle of a calculation
|
||||
* without actually having to dynamically cast the base Transport pointer.
|
||||
*
|
||||
* @param type Specifies the type of parameters to set
|
||||
* 0 : Diffusion coefficient
|
||||
* 1 : Thermal Conductivity
|
||||
* The rest are currently unused.
|
||||
* @param k Species index to set the parameters on
|
||||
* @param p Vector of parameters. The length of the vector
|
||||
* varies with the parameterization
|
||||
*/
|
||||
virtual void setParameters(const int n, const int k, const doublereal* const p);
|
||||
|
||||
friend class TransportFactory;
|
||||
|
||||
/**
|
||||
* The electrical conductivity (Siemens/m).
|
||||
protected:
|
||||
|
||||
//! Initialize the transport object
|
||||
/*!
|
||||
* Here we change all of the internal dimensions to be sufficient.
|
||||
* We get the object ready to do property evaluations.
|
||||
* A lot of the input required to do property evaluations is
|
||||
* contained in the SolidTransportParams class that is
|
||||
* filled in TransportFactory.
|
||||
*
|
||||
* @param tr Transport parameters for all of the species
|
||||
* in the phase.
|
||||
*/
|
||||
virtual doublereal electricalConductivity();
|
||||
virtual bool initSolid(SolidTransportData& tr);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
|
||||
//! Model type for the ionic conductivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* m_ionConductivity;
|
||||
|
||||
//! Model type for the thermal conductivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* m_thermalConductivity;
|
||||
|
||||
//! Model type for the electrical conductivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* m_electConductivity;
|
||||
|
||||
//! Model type for the defectDiffusivity -- or more like a defect diffusivity in the context of the solid phase.
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* m_defectDiffusivity;
|
||||
|
||||
//! Model type for the defectActivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* m_defectActivity;
|
||||
|
||||
//! number of mobile species
|
||||
/*!
|
||||
|
|
|
|||
130
include/cantera/transport/SolidTransportData.h
Normal file
130
include/cantera/transport/SolidTransportData.h
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* @file SolidTransportData.h
|
||||
* Header file defining class SolidTransportData
|
||||
*/
|
||||
/*
|
||||
* $Author: hkmoffa $
|
||||
* $Date: 2010-07-13 13:22:30 -0600 (Tue, 13 Jul 2010) $
|
||||
* $Revision: 507 $
|
||||
*/
|
||||
|
||||
#ifndef CT_SOLIDTRANSPORTDATA_H
|
||||
#define CT_SOLIDTRANSPORTDATA_H
|
||||
|
||||
|
||||
// STL includes
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// Cantera includes
|
||||
#include "cantera/base/ct_defs.h"
|
||||
#include "cantera/transport/TransportBase.h"
|
||||
#include "cantera/transport/TransportParams.h"
|
||||
#include "cantera/base/FactoryBase.h"
|
||||
#include "cantera/transport/LTPspecies.h"
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
//! Class SolidTransportData holds transport parameters for a
|
||||
//! specific solid-phase species.
|
||||
/*!
|
||||
* A SolidTransportData object is created for a solid phase
|
||||
* (not for each species as happens for the analogous LiquidTransportData).
|
||||
*
|
||||
* This class is mainly used to collect transport properties
|
||||
* from the parse phase in the TranportFactory and transfer
|
||||
* them to the Transport class. Transport properties are
|
||||
* expressed by subclasses of LTPspecies.
|
||||
* Note that we use the liquid phase species model for the solid phases.
|
||||
* That is, for the time being at least, we ignore mixing models for
|
||||
* solid phases and just specify a transport property at the level
|
||||
* that we specify the transport property for a species in the liquid phase.
|
||||
* One may need to be careful about deleting pointers to LTPspecies
|
||||
* objects created in the TransportFactory.
|
||||
*
|
||||
* All of the pointers in this class are shallow pointers. Therefore, this
|
||||
* is a passthrough class, which keeps track of pointer ownership by zeroing
|
||||
* pointers as we go. Yes, Yes, yes, this is not good.
|
||||
*/
|
||||
class SolidTransportData : public TransportParams {
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
SolidTransportData();
|
||||
|
||||
//! Copy constructor
|
||||
SolidTransportData(const SolidTransportData &right);
|
||||
|
||||
//! Assignment operator
|
||||
SolidTransportData& operator=(const SolidTransportData& right );
|
||||
|
||||
//! Destructor
|
||||
~SolidTransportData();
|
||||
|
||||
//! A SolidTransportData object is instantiated for each species.
|
||||
//! This is the species name for which this object is instantiated.
|
||||
std::string speciesName;
|
||||
|
||||
//! Model type for the ionic conductivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* ionConductivity;
|
||||
|
||||
//! Model type for the thermal conductivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* thermalConductivity;
|
||||
|
||||
//! Model type for the electrical conductivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* electConductivity;
|
||||
|
||||
//! Model type for the defectDiffusivity -- or more like a defect diffusivity in the context of the solid phase.
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* defectDiffusivity;
|
||||
|
||||
//! Model type for the defectActivity
|
||||
/*!
|
||||
* shallow pointer that should be zero during destructor
|
||||
*/
|
||||
LTPspecies* defectActivity;
|
||||
|
||||
protected:
|
||||
//protected members of SolidTransportData are analogous to those found in TransportParams
|
||||
|
||||
//! Local storage of the number of species
|
||||
// int nsp_;
|
||||
|
||||
//! Pointer to the ThermoPhase object
|
||||
// thermo_t* thermo;
|
||||
|
||||
//! Local storage of the molecular weights of the species
|
||||
/*!
|
||||
* Length is nsp_ and units are kg kmol-1.
|
||||
*/
|
||||
// vector_fp mw;
|
||||
|
||||
//! Maximum temperatures for parameter fits
|
||||
// doublereal tmax;
|
||||
|
||||
//! Minimum temperatures for parameter fits
|
||||
// doublereal tmin;
|
||||
|
||||
//! Pointer to the xml tree describing the implementation of transport for this object
|
||||
// XML_Writer* xml;
|
||||
|
||||
//! Log level
|
||||
// int log_level;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -30,6 +30,7 @@ namespace Cantera
|
|||
class TransportParams;
|
||||
class GasTransportParams;
|
||||
class LiquidTransportParams;
|
||||
class SolidTransportData;
|
||||
|
||||
/*!
|
||||
* \addtogroup tranprops
|
||||
|
|
@ -833,14 +834,40 @@ protected:
|
|||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
//! Called by TransportFactory to set parameters.
|
||||
/*!
|
||||
* This is called by classes that use the solid phase parameter
|
||||
* list to initialize themselves.
|
||||
*
|
||||
* @param tr Reference to the parameter list that will be used
|
||||
* to initialize the class
|
||||
*/
|
||||
virtual bool initSolid(SolidTransportData& tr)
|
||||
{
|
||||
err("initSolid");
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
//! Specifies the %ThermPhase object.
|
||||
/*!
|
||||
* We have relaxed this operation so that it will succeed when
|
||||
* the underlying old and new ThermoPhase objects have the same
|
||||
* number of species and the same names of the species in the
|
||||
* same order. The idea here is to allow copy constructors and duplicators
|
||||
* to work. In order for them to work, we need a method to switch the
|
||||
* internal pointer within the Transport object after the duplication
|
||||
* takes place. Also, different thermodynamic instanteations of the same
|
||||
* species should also work.
|
||||
*
|
||||
* @param thermo Reference to the ThermoPhase object that
|
||||
* the transport object will use
|
||||
*/
|
||||
void setThermo(thermo_t& thermo);
|
||||
virtual void setThermo(thermo_t& thermo);
|
||||
|
||||
|
||||
protected:
|
||||
//! Enable the transport object for use.
|
||||
/*!
|
||||
* Once finalize() has been called, the
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "TransportBase.h"
|
||||
#include "cantera/base/FactoryBase.h"
|
||||
#include "LiquidTransportParams.h"
|
||||
#include "SolidTransportData.h"
|
||||
|
||||
//======================================================================================================================
|
||||
namespace Cantera
|
||||
|
|
@ -78,6 +79,9 @@ public:
|
|||
virtual ~TransportFactory() {}
|
||||
|
||||
//! Get the name of the transport model corresponding to the specified constant.
|
||||
/*!
|
||||
* @param model Integer representing the model name
|
||||
*/
|
||||
static std::string modelName(int model);
|
||||
|
||||
//! Make one of several transport models, and return a base class pointer to it.
|
||||
|
|
@ -90,7 +94,8 @@ public:
|
|||
* @param tp_ind TransportPropertyType class
|
||||
* @param thermo Pointer to the %ThermoPhase class
|
||||
*/
|
||||
virtual LTPspecies* newLTP(const XML_Node& trNode, std::string& name,
|
||||
|
||||
virtual LTPspecies* newLTP(const XML_Node &trNode, const std::string &name,
|
||||
TransportPropertyType tp_ind, thermo_t* thermo);
|
||||
|
||||
|
||||
|
|
@ -164,6 +169,26 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
|
||||
//! Initialize an existing transport manager for solid phase
|
||||
/*!
|
||||
* This routine sets up an existing solid-phase transport manager.
|
||||
* It is similar to initTransport except that it uses the SolidTransportData
|
||||
* class and calls setupSolidTransport().
|
||||
*
|
||||
* @param tr Pointer to the Transport manager
|
||||
* @param thermo Pointer to the ThermoPhase object
|
||||
* @param log_level Defaults to zero, no logging
|
||||
*
|
||||
* In DEBUG_MODE, this routine will create the file transport_log.xml
|
||||
* and write informative information to it.
|
||||
*/
|
||||
virtual void initSolidTransport(Transport* tr, thermo_t* thermo, int log_level=0);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
//! Static instance of the factor -> This is the only instance of this
|
||||
//! object allowed
|
||||
static TransportFactory* s_factory;
|
||||
|
|
@ -239,6 +264,22 @@ private:
|
|||
void getLiquidInteractionsTransportData(const XML_Node& phaseTran_db, XML_Node& log,
|
||||
const std::vector<std::string>& names, LiquidTransportParams& tr);
|
||||
|
||||
|
||||
//! Read transport property data from a file for a solid phase
|
||||
/*!
|
||||
* Given a phase XML data base, this method constructs the
|
||||
* SolidTransportData object containing the transport data for the phase.
|
||||
*
|
||||
* @param db Reference to XML_Node containing the phase.
|
||||
* @param log Reference to an XML log file. (currently unused)
|
||||
* @param tr Reference to the SolidTransportData object that will contain the results.
|
||||
*/
|
||||
void getSolidTransportData(const XML_Node &transportNode,
|
||||
XML_Node& log,
|
||||
const std::string phaseName,
|
||||
SolidTransportData& tr);
|
||||
|
||||
|
||||
//! Generate polynomial fits to the viscosity, conductivity, and
|
||||
//! the binary diffusion coefficients
|
||||
/*!
|
||||
|
|
@ -307,6 +348,15 @@ private:
|
|||
*/
|
||||
void setupLiquidTransport(std::ostream& flog, thermo_t* thermo, int log_level, LiquidTransportParams& trParam);
|
||||
|
||||
//! Prepare to build a new transport manager for solids
|
||||
/*!
|
||||
* @param flog Reference to the ostream for writing log info
|
||||
* @param thermo Pointer to the %ThermoPhase object
|
||||
* @param log_level log level
|
||||
* @param trParam SolidTransportData structure to be filled up with information
|
||||
*/
|
||||
void setupSolidTransport(std::ostream &flog, thermo_t* thermo, int log_level, SolidTransportData& trParam);
|
||||
|
||||
|
||||
//! Second-order correction to the binary diffusion coefficients
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// Cantera includes
|
||||
#include "cantera/thermo/SurfPhase.h"
|
||||
#include "cantera/kinetics/InterfaceKinetics.h"
|
||||
#include "kinetics/ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
#include "Cabinet.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ namespace Cantera
|
|||
// Constructor.
|
||||
MultiPhase::MultiPhase() :
|
||||
m_np(0),
|
||||
m_temp(0.0),
|
||||
m_press(0.0),
|
||||
m_temp(298.15),
|
||||
m_press(OneBar),
|
||||
m_nel(0),
|
||||
m_nsp(0),
|
||||
m_init(false),
|
||||
|
|
@ -37,8 +37,8 @@ MultiPhase::MultiPhase() :
|
|||
*/
|
||||
MultiPhase::MultiPhase(const MultiPhase& right) :
|
||||
m_np(0),
|
||||
m_temp(0.0),
|
||||
m_press(0.0),
|
||||
m_temp(298.15),
|
||||
m_press(OneBar),
|
||||
m_nel(0),
|
||||
m_nsp(0),
|
||||
m_init(false),
|
||||
|
|
@ -160,8 +160,8 @@ addPhase(ThermoPhase* p, doublereal moles)
|
|||
|
||||
// If the mixture temperature hasn't been set, then set the
|
||||
// temperature and pressure to the values for the phase being
|
||||
// added.
|
||||
if (m_temp == 0.0 && p->temperature() > 0.0) {
|
||||
// added. There is no good way to do this. However, this will be overridden later.
|
||||
if (m_temp == 298.15 && p->temperature() > 2.0E-3) {
|
||||
m_temp = p->temperature();
|
||||
m_press = p->pressure();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@
|
|||
#include "cantera/equil/vcs_prob.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
|
||||
#include "cantera/equil/vcs_solve.h"
|
||||
|
||||
|
|
@ -26,6 +25,7 @@
|
|||
#include "cantera/thermo/IdealSolidSolnPhase.h"
|
||||
#include "cantera/thermo/IdealMolalSoln.h"
|
||||
#include "cantera/equil/ChemEquil.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
* @file vcs_SpeciesProperties.cpp
|
||||
*/
|
||||
#include "cantera/equil/vcs_defs.h"
|
||||
#include "vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "cantera/equil/vcs_solve.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
*/
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "vcs_SpeciesProperties.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_solve.h"
|
||||
|
||||
#include "cantera/thermo/ThermoPhase.h"
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
#include "cantera/equil/vcs_prob.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "cantera/equil/vcs_solve.h"
|
||||
#include "cantera/equil/equil.h"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
#include "cantera/equil/vcs_solve.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "cantera/equil/vcs_prob.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "cantera/equil/vcs_prob.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
|
||||
#include "cantera/thermo/ThermoPhase.h"
|
||||
|
|
|
|||
348
src/equil/vcs_rank.cpp
Normal file
348
src/equil/vcs_rank.cpp
Normal file
|
|
@ -0,0 +1,348 @@
|
|||
|
||||
/*!
|
||||
* @file vcs_rank.cpp
|
||||
* Header file for the internal class that holds the problem.
|
||||
*/
|
||||
/*
|
||||
* $Id: vcs_solve.cpp 735 2011-07-25 14:44:41Z hkmoffa $
|
||||
*/
|
||||
/*
|
||||
* Copywrite (2005) Sandia Corporation. Under the terms of
|
||||
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
|
||||
* U.S. Government retains certain rights in this software.
|
||||
*/
|
||||
|
||||
|
||||
#include "cantera/equil/vcs_solve.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "cantera/equil/vcs_prob.h"
|
||||
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
|
||||
#include "cantera/base/clockWC.h"
|
||||
#include "cantera/base/ctexceptions.h"
|
||||
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "math.h"
|
||||
using namespace std;
|
||||
|
||||
namespace VCSnonideal {
|
||||
//====================================================================================================================
|
||||
static int basisOptMax1(const double * const molNum,
|
||||
const int n) {
|
||||
// int largest = 0;
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
||||
if (molNum[i] > -1.0E200 && fabs(molNum[i]) > 1.0E-13) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
||||
if (molNum[i] > -1.0E200) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return n-1;
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Calculate the rank of a matrix and return the rows and columns that will generate an independent basis
|
||||
// for that rank
|
||||
/*
|
||||
* Choose the optimum component species basis for the calculations, finding the rank and
|
||||
* set of linearly independent rows for that calculation.
|
||||
* Then find the set of linearly indepedent element columns that can support that rank.
|
||||
* This is done by taking the transpose of the matrix and redoing the same calculation.
|
||||
* (there may be a better way to do this. I don't know.)
|
||||
*
|
||||
*
|
||||
* Input
|
||||
* ---------
|
||||
*
|
||||
* @param awtmp Vector of mole numbers which will be used to construct a
|
||||
* ranking for how to pick the basis species. This is largely ignored
|
||||
* here.
|
||||
*
|
||||
* @param numSpecies Number of species. This is the number of rows in the matrix.
|
||||
*
|
||||
* @param matrix Matrix. This is the formula matrix. Nominally, the rows are species, while
|
||||
* the columns are element compositions. However, this routine
|
||||
* is totally general, so that the rows and columns can be anything.
|
||||
*
|
||||
* @param numElemConstraints Number of element constraints
|
||||
*
|
||||
* Output
|
||||
* ---------
|
||||
* @param usedZeroedSpecies = If true, then a species with a zero concentration
|
||||
* was used as a component.
|
||||
*
|
||||
*
|
||||
* @param compRes Vector of rows which are linearly independent. (these are the components)
|
||||
*
|
||||
* @param elemComp Vector of columns which are linearly independent (These are the actionable element
|
||||
* constraints).
|
||||
*
|
||||
* @return Returns number of components. This is the rank of the matrix
|
||||
*/
|
||||
int VCS_SOLVE::vcs_rank(const double * awtmp, size_t numSpecies, const double matrix[], size_t numElemConstraints,
|
||||
std::vector<size_t> &compRes, std::vector<size_t>& elemComp, int * const usedZeroedSpecies) const
|
||||
{
|
||||
|
||||
int lindep;
|
||||
size_t j, k, jl, i, l, ml;
|
||||
int numComponents = 0;
|
||||
|
||||
compRes.clear();
|
||||
elemComp.clear();
|
||||
vector<double> sm(numElemConstraints*numSpecies);
|
||||
vector<double> sa(numSpecies);
|
||||
vector<double> ss(numSpecies);
|
||||
|
||||
double test = -0.2512345E298;
|
||||
#ifdef DEBUG_MODE
|
||||
if (m_debug_print_lvl >= 2) {
|
||||
plogf(" "); for(i=0; i<77; i++) plogf("-"); plogf("\n");
|
||||
plogf(" --- Subroutine vcs_rank called to ");
|
||||
plogf("calculate the rank and independent rows /colums of the following matrix\n");
|
||||
if (m_debug_print_lvl >= 5) {
|
||||
plogf(" --- Species | ");
|
||||
for (j = 0; j < numElemConstraints; j++) {
|
||||
plogf(" ");
|
||||
plogf(" %3d ", j);
|
||||
}
|
||||
plogf("\n");
|
||||
plogf(" --- -----------");
|
||||
for (j = 0; j < numElemConstraints; j++) {
|
||||
plogf("---------");
|
||||
}
|
||||
plogf("\n");
|
||||
for (k = 0; k < numSpecies; k++) {
|
||||
plogf(" --- ");
|
||||
plogf(" %3d ", k);
|
||||
plogf(" |");
|
||||
for (j = 0; j < numElemConstraints; j++) {
|
||||
plogf(" %8.2g", matrix[j*numSpecies + k]);
|
||||
}
|
||||
plogf("\n");
|
||||
}
|
||||
plogf(" ---");
|
||||
plogendl();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Calculate the maximum value of the number of components possible
|
||||
* It's equal to the minimum of the number of elements and the
|
||||
* number of total species.
|
||||
*/
|
||||
int ncTrial = std::min(numElemConstraints, numSpecies);
|
||||
numComponents = ncTrial;
|
||||
*usedZeroedSpecies = false;
|
||||
|
||||
/*
|
||||
* Use a temporary work array for the mole numbers, aw[]
|
||||
*/
|
||||
std::vector<double> aw(numSpecies);
|
||||
for (j = 0; j < numSpecies; j++) {
|
||||
aw[j] = awtmp[j];
|
||||
}
|
||||
|
||||
int jr = -1;
|
||||
/*
|
||||
* Top of a loop of some sort based on the index JR. JR is the
|
||||
* current number of component species found.
|
||||
*/
|
||||
do {
|
||||
++jr;
|
||||
/* - Top of another loop point based on finding a linearly */
|
||||
/* - independent species */
|
||||
do {
|
||||
/*
|
||||
* Search the remaining part of the mole number vector, AW,
|
||||
* for the largest remaining species. Return its identity in K.
|
||||
* The first search criteria is always the largest positive
|
||||
* magnitude of the mole number.
|
||||
*/
|
||||
k = basisOptMax1(VCS_DATA_PTR(aw), numSpecies);
|
||||
|
||||
if ((aw[k] != test) && fabs(aw[k]) == 0.0) {
|
||||
*usedZeroedSpecies = true;
|
||||
}
|
||||
|
||||
|
||||
if (aw[k] == test) {
|
||||
numComponents = jr;
|
||||
|
||||
goto L_CLEANUP;
|
||||
}
|
||||
/*
|
||||
* Assign a small negative number to the component that we have
|
||||
* just found, in order to take it out of further consideration.
|
||||
*/
|
||||
aw[k] = test;
|
||||
/* *********************************************************** */
|
||||
/* **** CHECK LINEAR INDEPENDENCE WITH PREVIOUS SPECIES ****** */
|
||||
/* *********************************************************** */
|
||||
/*
|
||||
* Modified Gram-Schmidt Method, p. 202 Dalquist
|
||||
* QR factorization of a matrix without row pivoting.
|
||||
*/
|
||||
jl = jr;
|
||||
for (j = 0; j < numElemConstraints; ++j) {
|
||||
sm[j + jr*numElemConstraints] = matrix[j*numSpecies + k];
|
||||
}
|
||||
if (jl > 0) {
|
||||
/*
|
||||
* Compute the coefficients of JA column of the
|
||||
* the upper triangular R matrix, SS(J) = R_J_JR
|
||||
* (this is slightly different than Dalquist)
|
||||
* R_JA_JA = 1
|
||||
*/
|
||||
for (j = 0; j < jl; ++j) {
|
||||
ss[j] = 0.0;
|
||||
for (i = 0; i < numElemConstraints; ++i) {
|
||||
ss[j] += sm[i + jr* numElemConstraints] * sm[i + j* numElemConstraints];
|
||||
}
|
||||
ss[j] /= sa[j];
|
||||
}
|
||||
/*
|
||||
* Now make the new column, (*,JR), orthogonal to the
|
||||
* previous columns
|
||||
*/
|
||||
for (j = 0; j < jl; ++j) {
|
||||
for (l = 0; l < numElemConstraints; ++l) {
|
||||
sm[l + jr*numElemConstraints] -= ss[j] * sm[l + j*numElemConstraints];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Find the new length of the new column in Q.
|
||||
* It will be used in the denominator in future row calcs.
|
||||
*/
|
||||
sa[jr] = 0.0;
|
||||
for (ml = 0; ml < numElemConstraints; ++ml) {
|
||||
sa[jr] += SQUARE(sm[ml + jr * numElemConstraints]);
|
||||
}
|
||||
/* **************************************************** */
|
||||
/* **** IF NORM OF NEW ROW .LT. 1E-3 REJECT ********** */
|
||||
/* **************************************************** */
|
||||
if (sa[jr] < 1.0e-6) lindep = true;
|
||||
else lindep = false;
|
||||
} while(lindep);
|
||||
/* ****************************************** */
|
||||
/* **** REARRANGE THE DATA ****************** */
|
||||
/* ****************************************** */
|
||||
compRes.push_back(k);
|
||||
elemComp.push_back(jr);
|
||||
|
||||
} while (jr < (ncTrial-1));
|
||||
|
||||
L_CLEANUP: ;
|
||||
|
||||
if (numComponents == ncTrial && numElemConstraints == numSpecies) {
|
||||
return numComponents;
|
||||
}
|
||||
|
||||
|
||||
int numComponentsR = numComponents;
|
||||
|
||||
ss.resize(numElemConstraints);
|
||||
sa.resize(numElemConstraints);
|
||||
|
||||
|
||||
elemComp.clear();
|
||||
|
||||
aw.resize(numElemConstraints);
|
||||
for (j = 0; j < numSpecies; j++) {
|
||||
aw[j] = 1.0;
|
||||
}
|
||||
|
||||
jr = -1;
|
||||
|
||||
do {
|
||||
++jr;
|
||||
|
||||
do {
|
||||
|
||||
k = basisOptMax1(VCS_DATA_PTR(aw), numElemConstraints);
|
||||
|
||||
if (aw[k] == test) {
|
||||
numComponents = jr;
|
||||
goto LE_CLEANUP;
|
||||
}
|
||||
aw[k] = test;
|
||||
|
||||
|
||||
jl = jr;
|
||||
for (j = 0; j < numSpecies; ++j) {
|
||||
sm[j + jr*numSpecies] = matrix[k*numSpecies + j];
|
||||
}
|
||||
if (jl > 0) {
|
||||
|
||||
for (j = 0; j < jl; ++j) {
|
||||
ss[j] = 0.0;
|
||||
for (i = 0; i < numSpecies; ++i) {
|
||||
ss[j] += sm[i + jr* numSpecies] * sm[i + j* numSpecies];
|
||||
}
|
||||
ss[j] /= sa[j];
|
||||
}
|
||||
|
||||
for (j = 0; j < jl; ++j) {
|
||||
for (l = 0; l < numSpecies; ++l) {
|
||||
sm[l + jr*numSpecies] -= ss[j] * sm[l + j*numSpecies];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sa[jr] = 0.0;
|
||||
for (ml = 0; ml < numSpecies; ++ml) {
|
||||
sa[jr] += SQUARE(sm[ml + jr * numSpecies]);
|
||||
}
|
||||
|
||||
if (sa[jr] < 1.0e-6) lindep = true;
|
||||
else lindep = false;
|
||||
} while(lindep);
|
||||
|
||||
elemComp.push_back(k);
|
||||
|
||||
} while (jr < (ncTrial-1));
|
||||
numComponents = jr;
|
||||
LE_CLEANUP: ;
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
if (m_debug_print_lvl >= 2) {
|
||||
plogf(" --- vcs_rank found rank %d\n", numComponents);
|
||||
if (m_debug_print_lvl >= 5) {
|
||||
if (compRes.size() == elemComp.size()) {
|
||||
printf(" --- compRes elemComp\n");
|
||||
for (int i = 0; i < (int) compRes.size(); i++) {
|
||||
printf(" --- %d %d \n", (int) compRes[i], (int) elemComp[i]);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < (int) compRes.size(); i++) {
|
||||
printf(" --- compRes[%d] = %d \n", (int) i, (int) compRes[i]);
|
||||
}
|
||||
for (int i = 0; i < (int) elemComp.size(); i++) {
|
||||
printf(" --- elemComp[%d] = %d \n", (int) i, (int) elemComp[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (numComponentsR != numComponents) {
|
||||
printf("vcs_rank ERROR: number of components are different: %d %d\n", numComponentsR, numComponents);
|
||||
throw Cantera::CanteraError("vcs_rank ERROR:",
|
||||
" logical inconsistency");
|
||||
exit(-1);
|
||||
}
|
||||
return numComponents;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_solve.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
#include "cantera/equil/vcs_prob.h"
|
||||
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_SpeciesProperties.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
|
||||
#include "cantera/base/clockWC.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include "cantera/equil/vcs_solve.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/base/ctexceptions.h"
|
||||
|
||||
#include "cantera/base/clockWC.h"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#include "cantera/equil/vcs_solve.h"
|
||||
#include "cantera/equil/vcs_internal.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_prob.h"
|
||||
|
||||
#include "cantera/base/clockWC.h"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
|
||||
#include "cantera/equil/vcs_solve.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_species_thermo.h"
|
||||
#include "cantera/equil/vcs_defs.h"
|
||||
#include "cantera/equil/vcs_VolPhase.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
// Copyright 2001 California Institute of Technology
|
||||
|
||||
#include "ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
#include "cantera/numerics/Integrator.h"
|
||||
#include "solveSP.h"
|
||||
#include "cantera/kinetics/solveSP.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "cantera/kinetics/ReactionData.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
|
||||
#include "ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "cantera/kinetics/StoichManager.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
|
||||
#include "ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* See file License.txt for licensing information.
|
||||
*/
|
||||
|
||||
#include "solveSP.h"
|
||||
#include "cantera/kinetics/solveSP.h"
|
||||
#include "cantera/base/clockWC.h"
|
||||
#include "cantera/numerics/ctlapack.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
// Copyright 2001 California Institute of Technology
|
||||
#include "cantera/base/config.h"
|
||||
|
||||
#include "CVodesIntegrator.h"
|
||||
#include "cantera/numerics/CVodesIntegrator.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
||||
#include <iostream>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
|
||||
#ifdef HAS_SUNDIALS
|
||||
#include "CVodesIntegrator.h"
|
||||
#include "cantera/numerics/CVodesIntegrator.h"
|
||||
#else
|
||||
#include "CVodeInt.h"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -328,14 +328,28 @@ operator=(const HMWSoln& b)
|
|||
m_Lambda_nj_LL = b.m_Lambda_nj_LL;
|
||||
m_Lambda_nj_P = b.m_Lambda_nj_P;
|
||||
m_Lambda_nj_coeff = b.m_Lambda_nj_coeff;
|
||||
|
||||
m_Mu_nnn = b.m_Mu_nnn;
|
||||
m_Mu_nnn_L = b.m_Mu_nnn_L;
|
||||
m_Mu_nnn_LL = b.m_Mu_nnn_LL;
|
||||
m_Mu_nnn_P = b.m_Mu_nnn_P;
|
||||
m_Mu_nnn_coeff = b.m_Mu_nnn_coeff;
|
||||
|
||||
m_lnActCoeffMolal_Scaled = b.m_lnActCoeffMolal_Scaled;
|
||||
m_lnActCoeffMolal_Unscaled = b.m_lnActCoeffMolal_Unscaled;
|
||||
|
||||
m_dlnActCoeffMolaldT_Scaled = b.m_dlnActCoeffMolaldT_Scaled;
|
||||
m_dlnActCoeffMolaldT_Unscaled = b.m_dlnActCoeffMolaldT_Unscaled;
|
||||
|
||||
m_d2lnActCoeffMolaldT2_Scaled = b.m_d2lnActCoeffMolaldT2_Scaled;
|
||||
m_d2lnActCoeffMolaldT2_Unscaled= b.m_d2lnActCoeffMolaldT2_Unscaled;
|
||||
|
||||
m_dlnActCoeffMolaldP_Scaled = b.m_dlnActCoeffMolaldP_Scaled;
|
||||
m_dlnActCoeffMolaldP_Unscaled = b.m_dlnActCoeffMolaldP_Unscaled;
|
||||
m_dlnActCoeffMolaldT_Scaled = b.m_dlnActCoeffMolaldT_Unscaled;
|
||||
m_d2lnActCoeffMolaldT2_Scaled = b.m_d2lnActCoeffMolaldT2_Unscaled;
|
||||
m_dlnActCoeffMolaldP_Scaled = b.m_dlnActCoeffMolaldP_Unscaled;
|
||||
|
||||
m_molalitiesCropped = b.m_molalitiesCropped;
|
||||
m_molalitiesAreCropped = b.m_molalitiesAreCropped;
|
||||
m_CounterIJ = b.m_CounterIJ;
|
||||
|
||||
m_gfunc_IJ = b.m_gfunc_IJ;
|
||||
m_g2func_IJ = b.m_g2func_IJ;
|
||||
|
|
@ -397,9 +411,7 @@ operator=(const HMWSoln& b)
|
|||
CROP_ln_gamma_k_min = b.CROP_ln_gamma_k_min;
|
||||
CROP_ln_gamma_k_max = b.CROP_ln_gamma_k_max;
|
||||
CROP_speciesCropped_ = b.CROP_speciesCropped_;
|
||||
m_CounterIJ = b.m_CounterIJ;
|
||||
m_molalitiesCropped = b.m_molalitiesCropped;
|
||||
m_molalitiesAreCropped= b.m_molalitiesAreCropped;
|
||||
|
||||
m_debugCalc = b.m_debugCalc;
|
||||
}
|
||||
return *this;
|
||||
|
|
@ -2645,9 +2657,9 @@ s_updatePitzer_lnMolalityActCoeff() const
|
|||
if (counterIJ == 2) {
|
||||
printf("%s %s\n", speciesName(i).c_str(),
|
||||
speciesName(j).c_str());
|
||||
printf("beta0MX[%d] = %g\n", counterIJ, beta0MX[counterIJ]);
|
||||
printf("beta1MX[%d] = %g\n", counterIJ, beta1MX[counterIJ]);
|
||||
printf("beta2MX[%d] = %g\n", counterIJ, beta2MX[counterIJ]);
|
||||
printf("beta0MX[%d] = %g\n", (int) counterIJ, beta0MX[counterIJ]);
|
||||
printf("beta1MX[%d] = %g\n", (int) counterIJ, beta1MX[counterIJ]);
|
||||
printf("beta2MX[%d] = %g\n", (int) counterIJ, beta2MX[counterIJ]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2662,7 +2674,7 @@ s_updatePitzer_lnMolalityActCoeff() const
|
|||
#ifdef DEBUG_MODE
|
||||
if (m_debugCalc) {
|
||||
printf("%d %g: %g %g %g %g\n",
|
||||
counterIJ, BMX[counterIJ], beta0MX[counterIJ],
|
||||
(int) counterIJ, BMX[counterIJ], beta0MX[counterIJ],
|
||||
beta1MX[counterIJ], beta2MX[counterIJ], gfunc[counterIJ]);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2722,7 +2734,7 @@ s_updatePitzer_lnMolalityActCoeff() const
|
|||
if (counterIJ == 2) {
|
||||
printf("%s %s\n", speciesName(i).c_str(),
|
||||
speciesName(j).c_str());
|
||||
printf("CphiMX[%d] = %g\n", counterIJ, CphiMX[counterIJ]);
|
||||
printf("CphiMX[%d] = %g\n", (int) counterIJ, CphiMX[counterIJ]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -4597,7 +4609,7 @@ void HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2() const
|
|||
#ifdef DEBUG_MODE
|
||||
if (m_debugCalc) {
|
||||
printf("%d %g: %g %g %g %g\n",
|
||||
counterIJ, BMX_LL[counterIJ], beta0MX_LL[counterIJ],
|
||||
(int) counterIJ, BMX_LL[counterIJ], beta0MX_LL[counterIJ],
|
||||
beta1MX_LL[counterIJ], beta2MX_LL[counterIJ], gfunc[counterIJ]);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -5479,7 +5491,7 @@ void HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP() const
|
|||
#ifdef DEBUG_MODE
|
||||
if (m_debugCalc) {
|
||||
printf("%d %g: %g %g %g %g\n",
|
||||
counterIJ, BMX_P[counterIJ], beta0MX_P[counterIJ],
|
||||
(int) counterIJ, BMX_P[counterIJ], beta0MX_P[counterIJ],
|
||||
beta1MX_P[counterIJ], beta2MX_P[counterIJ], gfunc[counterIJ]);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ IdealSolidSolnPhase& IdealSolidSolnPhase::
|
|||
operator=(const IdealSolidSolnPhase& b)
|
||||
{
|
||||
if (this != &b) {
|
||||
//ThermoPhase::operator=(b);
|
||||
// m_spthermo = dupMyselfAsSpeciesThermo(b.m_spthermo);
|
||||
ThermoPhase::operator=(b);
|
||||
|
||||
m_formGC = b.m_formGC;
|
||||
m_Pref = b.m_Pref;
|
||||
m_Pcurrent = b.m_Pcurrent;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ IonsFromNeutralVPSSTP::IonsFromNeutralVPSSTP(const std::string& inputFile,
|
|||
if (neutralPhase) {
|
||||
IOwnNThermoPhase_ = false;
|
||||
}
|
||||
initThermoFile(inputFile, id);
|
||||
constructPhaseFile(inputFile, id);
|
||||
geThermo = dynamic_cast<GibbsExcessVPSSTP*>(neutralMoleculePhase_);
|
||||
}
|
||||
//====================================================================================================================
|
||||
|
|
@ -125,7 +125,7 @@ IonsFromNeutralVPSSTP::IonsFromNeutralVPSSTP(XML_Node& phaseRoot,
|
|||
if (neutralPhase) {
|
||||
IOwnNThermoPhase_ = false;
|
||||
}
|
||||
importPhase(*findXMLPhase(&phaseRoot, id), this);
|
||||
constructPhaseXML(phaseRoot, id);
|
||||
geThermo = dynamic_cast<GibbsExcessVPSSTP*>(neutralMoleculePhase_);
|
||||
}
|
||||
|
||||
|
|
@ -846,7 +846,7 @@ void IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions() const
|
|||
}
|
||||
#ifdef DEBUG_MODE
|
||||
sum = -1.0;
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
for (size_t k = 0; k < m_kk; k++) {
|
||||
sum += moleFractions_[k];
|
||||
}
|
||||
if (fabs(sum) > 1.0E-11) {
|
||||
|
|
|
|||
|
|
@ -65,14 +65,14 @@ ThermoFactory* ThermoFactory::s_factory = 0;
|
|||
mutex_t ThermoFactory::thermo_mutex;
|
||||
|
||||
//! Define the number of %ThermoPhase types for use in this factory routine
|
||||
static int ntypes = 23;
|
||||
static int ntypes = 24;
|
||||
|
||||
//! Define the string name of the %ThermoPhase types that are handled by this factory routine
|
||||
static string _types[] = {"IdealGas", "Incompressible",
|
||||
"Surface", "Edge", "Metal", "StoichSubstance",
|
||||
"PureFluid", "LatticeSolid", "Lattice",
|
||||
"HMW", "IdealSolidSolution", "DebyeHuckel",
|
||||
"IdealMolalSolution", "IdealGasVPSS",
|
||||
"IdealMolalSolution", "IdealGasVPSS", "IdealSolnVPSS",
|
||||
"MineralEQ3", "MetalSHEelectrons", "Margules", "PhaseCombo_Interaction",
|
||||
"IonsFromNeutralMolecule", "FixedChemPot", "MolarityIonicVPSSTP",
|
||||
"MixedSolventElectrolyte", "Redlich-Kister"
|
||||
|
|
@ -83,7 +83,7 @@ static int _itypes[] = {cIdealGas, cIncompressible,
|
|||
cSurf, cEdge, cMetal, cStoichSubstance,
|
||||
cPureFluid, cLatticeSolid, cLattice,
|
||||
cHMW, cIdealSolidSolnPhase, cDebyeHuckel,
|
||||
cIdealMolalSoln, cVPSS_IdealGas,
|
||||
cIdealMolalSoln, cVPSS_IdealGas, cIdealSolnGasVPSS_iscv,
|
||||
cMineralEQ3, cMetalSHEelectrons,
|
||||
cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral, cFixedChemPot,
|
||||
cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP
|
||||
|
|
@ -202,6 +202,10 @@ ThermoPhase* ThermoFactory::newThermoPhase(const std::string& model)
|
|||
th = new IdealSolnGasVPSS;
|
||||
break;
|
||||
|
||||
case cIdealSolnGasVPSS_iscv:
|
||||
th = new IdealSolnGasVPSS;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw UnknownThermoPhaseModel("ThermoFactory::newThermoPhase",
|
||||
model);
|
||||
|
|
|
|||
|
|
@ -384,6 +384,10 @@ void ThermoPhase::setState_HPorUV(doublereal Htarget, doublereal p,
|
|||
// spinodal value of H.
|
||||
for (int its = 0; its < 10; its++) {
|
||||
Tnew = Told + dt;
|
||||
if (Tnew < Told / 3.0) {
|
||||
Tnew = Told / 3.0;
|
||||
dt = -2.0 * Told / 3.0;
|
||||
}
|
||||
setState_conditional_TP(Tnew, p, !doUV);
|
||||
if (doUV) {
|
||||
Hnew = intEnergy_mass();
|
||||
|
|
|
|||
|
|
@ -112,10 +112,10 @@ DustyGasTransport& DustyGasTransport::operator=(const DustyGasTransport& right)
|
|||
DustyGasTransport::~DustyGasTransport()
|
||||
{
|
||||
delete m_gastran;
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Duplication routine for objects which inherit from %Transport
|
||||
/*
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Duplication routine for objects which inherit from %Transport
|
||||
/*
|
||||
* This virtual routine can be used to duplicate %Transport objects
|
||||
* inherited from %Transport even if the application only has
|
||||
* a pointer to %Transport to work with.
|
||||
|
|
@ -123,13 +123,33 @@ DustyGasTransport::~DustyGasTransport()
|
|||
* These routines are basically wrappers around the derived copy
|
||||
* constructor.
|
||||
*/
|
||||
Transport* DustyGasTransport::duplMyselfAsTransport() const
|
||||
{
|
||||
return new DustyGasTransport(*this);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Set the Parameters in the model
|
||||
/*
|
||||
Transport *DustyGasTransport::duplMyselfAsTransport() const {
|
||||
DustyGasTransport* tr = new DustyGasTransport(*this);
|
||||
return (dynamic_cast<Transport *>(tr));
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Specifies the %ThermPhase object.
|
||||
/*
|
||||
* We have relaxed this operation so that it will succeed when
|
||||
* the underlying old and new ThermoPhase objects have the same
|
||||
* number of species and the same names of the species in the
|
||||
* same order. The idea here is to allow copy constructors and duplicators
|
||||
* to work. In order for them to work, we need a method to switch the
|
||||
* internal pointer within the Transport object after the duplication
|
||||
* takes place. Also, different thermodynamic instanteations of the same
|
||||
* species should also work.
|
||||
*
|
||||
* @param thermo Reference to the ThermoPhase object that
|
||||
* the transport object will use
|
||||
*/
|
||||
void DustyGasTransport::setThermo(thermo_t& thermo) {
|
||||
|
||||
Transport::setThermo(thermo);
|
||||
m_gastran->setThermo(thermo);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Set the Parameters in the model
|
||||
/*
|
||||
* @param type Type of the parameter to set
|
||||
* 0 - porosity
|
||||
* 1 - tortuosity
|
||||
|
|
@ -140,9 +160,8 @@ Transport* DustyGasTransport::duplMyselfAsTransport() const
|
|||
* @param p pointer to double for the input list of parameters
|
||||
*
|
||||
*/
|
||||
void DustyGasTransport::setParameters(const int type, const int k, const doublereal* const p)
|
||||
{
|
||||
switch (type) {
|
||||
void DustyGasTransport::setParameters(const int type, const int k, const doublereal* const p) {
|
||||
switch(type) {
|
||||
case 0:
|
||||
setPorosity(p[0]);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -47,10 +47,11 @@ static void getArrhenius(const XML_Node& node,
|
|||
b = getFloat(node, "b");
|
||||
E = getFloat(node, "E", "actEnergy");
|
||||
E /= GasConstant;
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid transport property.
|
||||
/*
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid tranport property.
|
||||
/*
|
||||
* The species transport property is constructed from the XML node,
|
||||
* \verbatim <propNode>, \endverbatim that is a child of the
|
||||
* \verbatim <transport> \endverbatim node in the species block and specifies a type of transport
|
||||
|
|
@ -62,24 +63,25 @@ static void getArrhenius(const XML_Node& node,
|
|||
* is creating a parameterization for (e.g., viscosity)
|
||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*/
|
||||
LTPspecies::LTPspecies(const XML_Node* const propNode, const std::string& name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
||||
LTPspecies::LTPspecies(const XML_Node * const propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t * thermo) :
|
||||
m_speciesName(name),
|
||||
m_model(LTP_TD_NOTSET),
|
||||
m_property(tp_ind),
|
||||
m_thermo(thermo),
|
||||
m_mixWeight(1.0)
|
||||
{
|
||||
{
|
||||
if (propNode) {
|
||||
if (propNode->hasChild("mixtureWeighting")) {
|
||||
if (propNode->hasChild("mixtureWeighting") ) {
|
||||
m_mixWeight = getFloat(*propNode, "mixtureWeighting");
|
||||
}
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Copy constructor
|
||||
LTPspecies::LTPspecies(const LTPspecies& right)
|
||||
{
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Copy constructor
|
||||
LTPspecies::LTPspecies(const LTPspecies &right)
|
||||
{
|
||||
|
||||
*this = right;
|
||||
}
|
||||
//====================================================================================================================
|
||||
|
|
@ -126,34 +128,35 @@ doublereal LTPspecies::getSpeciesTransProp()
|
|||
bool LTPspecies::checkPositive() const
|
||||
{
|
||||
return (m_coeffs[0] > 0);
|
||||
}
|
||||
//====================================================================================================================
|
||||
doublereal LTPspecies::getMixWeight() const
|
||||
{
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
doublereal LTPspecies::getMixWeight() const
|
||||
{
|
||||
return m_mixWeight;
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Internal model to adjust species-specific properties for composition.
|
||||
/*
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Internal model to adjust species-specific properties for composition.
|
||||
/*
|
||||
* Currently just a place holder, but this method could take
|
||||
* the composition from the thermo object and adjust coefficients
|
||||
* accoding to some unspecified model.
|
||||
*/
|
||||
void LTPspecies::adjustCoeffsForComposition()
|
||||
{
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid transport property
|
||||
// expressed as a constant value.
|
||||
/* The transport property is constructed from the XML node,
|
||||
void LTPspecies::adjustCoeffsForComposition()
|
||||
{
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid tranport property
|
||||
// expressed as a constant value.
|
||||
/* The transport property is constructed from the XML node,
|
||||
* \verbatim <propNode>, \endverbatim that is a child of the
|
||||
* \verbatim <transport> \endverbatim node and specifies a type of
|
||||
* transport property (like viscosity)
|
||||
*/
|
||||
LTPspecies_Const::LTPspecies_Const(const XML_Node& propNode, const std::string& name,
|
||||
TransportPropertyType tp_ind, const thermo_t* const thermo) :
|
||||
LTPspecies_Const::LTPspecies_Const(const XML_Node &propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t * const thermo) :
|
||||
LTPspecies(&propNode, name, tp_ind, thermo)
|
||||
{
|
||||
{
|
||||
m_model = LTP_TD_CONSTANT;
|
||||
double A_k = getFloatCurrent(propNode, "toSI");
|
||||
if (A_k > 0.0) {
|
||||
|
|
@ -196,17 +199,18 @@ LTPspecies* LTPspecies_Const::duplMyselfAsLTPspecies() const
|
|||
doublereal LTPspecies_Const::getSpeciesTransProp()
|
||||
{
|
||||
return m_coeffs[0];
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid transport property
|
||||
// expressed in extended Arrhenius form.
|
||||
/*
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid tranport property
|
||||
// expressed in extended Arrhenius form.
|
||||
/*
|
||||
* The transport property is constructed from the XML node,
|
||||
* \verbatim <propNode>, \endverbatim that is a child of the
|
||||
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity)
|
||||
*
|
||||
*
|
||||
* @param propNode Reference to the XML node that contains the property information.This class
|
||||
* @param propNode Referenc to the XML node that contains the property information.This class
|
||||
* is assumed to be parameterized by reading XML_Node information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||
|
|
@ -214,10 +218,11 @@ doublereal LTPspecies_Const::getSpeciesTransProp()
|
|||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*
|
||||
*/
|
||||
LTPspecies_Arrhenius::LTPspecies_Arrhenius(const XML_Node& propNode, const std::string& name,
|
||||
LTPspecies_Arrhenius::LTPspecies_Arrhenius(const XML_Node &propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
||||
LTPspecies(&propNode, name, tp_ind, thermo)
|
||||
{
|
||||
{
|
||||
|
||||
m_model = LTP_TD_ARRHENIUS;
|
||||
m_temp = 0.0;
|
||||
m_prop = 0.0;
|
||||
|
|
@ -310,15 +315,16 @@ doublereal LTPspecies_Arrhenius::getSpeciesTransProp()
|
|||
m_prop = exp(m_logProp);
|
||||
}
|
||||
return m_prop;
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid transport property expressed as a polynomial in temperature.
|
||||
/*
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid tranport property expressed as a polynomial in temperature.
|
||||
/*
|
||||
* The transport property is constructed from the XML node, \verbatim <propNode>, \endverbatim that is a child of the
|
||||
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity).
|
||||
*
|
||||
*
|
||||
* @param propNode Reference to the XML node that contains the property information. This class
|
||||
* @param propNode Referenc to the XML node that contains the property information. This class
|
||||
* must be parameterized by reading XML_Node information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||
|
|
@ -326,7 +332,7 @@ doublereal LTPspecies_Arrhenius::getSpeciesTransProp()
|
|||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*
|
||||
*/
|
||||
LTPspecies_Poly::LTPspecies_Poly(const XML_Node& propNode, const std::string& name,
|
||||
LTPspecies_Poly::LTPspecies_Poly(const XML_Node &propNode, const std::string name,
|
||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
||||
LTPspecies(&propNode, name, tp_ind, thermo),
|
||||
m_temp(-1.0),
|
||||
|
|
@ -381,16 +387,17 @@ doublereal LTPspecies_Poly::getSpeciesTransProp()
|
|||
}
|
||||
}
|
||||
return m_prop;
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid transport property
|
||||
// expressed as an exponential in temperature.
|
||||
/*
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Construct an LTPspecies object for a liquid tranport property
|
||||
// expressed as an exponential in temperature.
|
||||
/*
|
||||
* The transport property is constructed from the XML node, \verbatim <propNode>, \endverbatim that is a child of the
|
||||
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity).
|
||||
*
|
||||
*
|
||||
* @param propNode Reference to the XML node that contains the property information. This class
|
||||
* @param propNode Referenc to the XML node that contains the property information. This class
|
||||
* must be parameterized by reading XML_Node information.
|
||||
* @param name String containing the species name
|
||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||
|
|
@ -398,8 +405,9 @@ doublereal LTPspecies_Poly::getSpeciesTransProp()
|
|||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
||||
*
|
||||
*/
|
||||
LTPspecies_ExpT::LTPspecies_ExpT(const XML_Node& propNode, const std::string& name, TransportPropertyType tp_ind,
|
||||
LTPspecies_ExpT::LTPspecies_ExpT(const XML_Node &propNode, const std::string name, TransportPropertyType tp_ind,
|
||||
const thermo_t* thermo) :
|
||||
|
||||
LTPspecies(&propNode, name, tp_ind, thermo),
|
||||
m_temp(-1.0),
|
||||
m_prop(0.0)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@
|
|||
// copyright 2008 California Institute of Technology
|
||||
|
||||
#include "cantera/thermo/ThermoPhase.h"
|
||||
#include "cantera/transport/SolidTransportData.h"
|
||||
#include "cantera/transport/SolidTransport.h"
|
||||
|
||||
|
||||
#include "cantera/base/utilities.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -25,7 +28,7 @@ SolidTransport::SolidTransport() :
|
|||
m_Ndiff(0),
|
||||
m_Ediff(0),
|
||||
m_sp(0),
|
||||
m_Alam(0),
|
||||
m_Alam(-1.0),
|
||||
m_Nlam(0),
|
||||
m_Elam(0)
|
||||
{
|
||||
|
|
@ -42,7 +45,7 @@ SolidTransport::SolidTransport(const SolidTransport& right) :
|
|||
m_Ndiff(0),
|
||||
m_Ediff(0),
|
||||
m_sp(0),
|
||||
m_Alam(0),
|
||||
m_Alam(-1.0),
|
||||
m_Nlam(0),
|
||||
m_Elam(0)
|
||||
{
|
||||
|
|
@ -70,15 +73,56 @@ SolidTransport& SolidTransport::operator=(const SolidTransport& b)
|
|||
m_Elam = b.m_Elam;
|
||||
|
||||
return *this;
|
||||
}
|
||||
//====================================================================================================================
|
||||
Transport* SolidTransport::duplMyselfAsTransport() const
|
||||
{
|
||||
return new SolidTransport(*this);
|
||||
}
|
||||
//====================================================================================================================
|
||||
void SolidTransport::setParameters(const int n, const int k, const doublereal* const p)
|
||||
{
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
Transport *SolidTransport::duplMyselfAsTransport() const
|
||||
{
|
||||
SolidTransport* tr = new SolidTransport(*this);
|
||||
return (dynamic_cast<Transport *>(tr));
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
// Initialize the transport object
|
||||
/*
|
||||
* Here we change all of the internal dimensions to be sufficient.
|
||||
* We get the object ready to do property evaluations.
|
||||
* A lot of the input required to do property evaluations is
|
||||
* contained in the SolidTransportData class that is
|
||||
* filled in TransportFactory.
|
||||
*
|
||||
* @param tr Transport parameters for the phase
|
||||
*/
|
||||
bool SolidTransport::initSolid(SolidTransportData& tr) {
|
||||
|
||||
m_thermo = tr.thermo;
|
||||
tr.thermo = 0;
|
||||
//m_nsp = m_thermo->nSpecies();
|
||||
//m_tmin = m_thermo->minTemp();
|
||||
//m_tmax = m_thermo->maxTemp();
|
||||
|
||||
// make a local copy of the molecular weights
|
||||
//m_mw.resize(m_nsp, 0.0);
|
||||
//copy(m_thermo->molecularWeights().begin(),
|
||||
// m_thermo->molecularWeights().end(), m_mw.begin());
|
||||
|
||||
m_ionConductivity = tr.ionConductivity;
|
||||
tr.ionConductivity = 0;
|
||||
m_electConductivity = tr.electConductivity;
|
||||
tr.electConductivity = 0;
|
||||
m_thermalConductivity = tr.thermalConductivity;
|
||||
tr.thermalConductivity = 0;
|
||||
m_defectDiffusivity = tr.defectDiffusivity;
|
||||
tr.defectDiffusivity = 0;
|
||||
m_defectActivity = tr.defectActivity;
|
||||
tr.defectActivity = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
|
||||
void SolidTransport::setParameters(const int n, const int k, const doublereal * const p) {
|
||||
switch (n) {
|
||||
|
||||
case 0:
|
||||
|
|
@ -103,35 +147,116 @@ void SolidTransport::setParameters(const int n, const int k, const doublereal* c
|
|||
}
|
||||
|
||||
m_work.resize(m_thermo->nSpecies());
|
||||
}
|
||||
//====================================================================================================================
|
||||
/*
|
||||
|
||||
}
|
||||
|
||||
/****************** ionConductivity ******************************/
|
||||
|
||||
// Returns the ionic conductivity of the phase
|
||||
/*
|
||||
* The thermo phase needs to be updated (temperature) prior to calling this.
|
||||
* The ionConductivity calculation is handled by subclasses of
|
||||
* LTPspecies as specified in the input file.
|
||||
*
|
||||
*/
|
||||
doublereal SolidTransport::ionConductivity() {
|
||||
// LTPspecies method
|
||||
return m_ionConductivity->getSpeciesTransProp();
|
||||
}
|
||||
|
||||
/****************** electron Conductivity ******************************/
|
||||
|
||||
// Returns the electron conductivity of the phase
|
||||
/*
|
||||
* The thermo phase needs to be updated (temperature) prior to calling this.
|
||||
* The ionConductivity calculation is handled by subclasses of
|
||||
* LTPspecies as specified in the input file.
|
||||
*
|
||||
* There is also a legacy multicomponent diffusion approach to electrical conductivity.
|
||||
*
|
||||
*/
|
||||
doublereal SolidTransport::electricalConductivity() {
|
||||
if ( m_nmobile == 0 ) {
|
||||
// LTPspecies method
|
||||
return m_electConductivity->getSpeciesTransProp();
|
||||
} else {
|
||||
getMobilities(&m_work[0]);
|
||||
int nsp = m_thermo->nSpecies();
|
||||
doublereal sum = 0.0;
|
||||
for (int k = 0; k < nsp; k++) {
|
||||
sum += m_thermo->charge(k) * m_thermo->moleFraction(k) * m_work[k];
|
||||
}
|
||||
return sum * m_thermo->molarDensity();
|
||||
}
|
||||
}
|
||||
|
||||
/****************** thermalConductivity ******************************/
|
||||
|
||||
// Returns the thermal conductivity of the phase
|
||||
/*
|
||||
* The thermo phase needs to be updated (temperature) prior to calling this.
|
||||
* The thermalConductivity calculation is handled by subclasses of
|
||||
* LTPspecies as specified in the input file.
|
||||
*
|
||||
* There is also a legacy method to evaluate
|
||||
* \f[
|
||||
* \lambda = A T^n \exp(-E/RT)
|
||||
* \f]
|
||||
*/
|
||||
doublereal SolidTransport::thermalConductivity() {
|
||||
if ( m_Alam > 0.0 ) {
|
||||
//legacy test case?
|
||||
doublereal t = m_thermo->temperature();
|
||||
return m_Alam * pow(t, m_Nlam) * exp(-m_Elam/t);
|
||||
} else {
|
||||
// LTPspecies method
|
||||
return m_thermalConductivity->getSpeciesTransProp();
|
||||
}
|
||||
}
|
||||
|
||||
/****************** defectDiffusivity ******************************/
|
||||
|
||||
// Returns the diffusivity of the phase
|
||||
/*
|
||||
* The thermo phase needs to be updated (temperature) prior to calling this.
|
||||
* The defectDiffusivity calculation is handled by subclasses of
|
||||
* LTPspecies as specified in the input file.
|
||||
*
|
||||
*/
|
||||
doublereal SolidTransport::defectDiffusivity() {
|
||||
// LTPspecies method
|
||||
return m_defectDiffusivity->getSpeciesTransProp();
|
||||
}
|
||||
|
||||
/****************** defectActivity ******************************/
|
||||
|
||||
// Returns the diffusivity of the phase
|
||||
/*
|
||||
* The thermo phase needs to be updated (temperature) prior to calling this.
|
||||
* The defectActivity calculation is handled by subclasses of
|
||||
* LTPspecies as specified in the input file.
|
||||
*
|
||||
*/
|
||||
doublereal SolidTransport::defectActivity() {
|
||||
// LTPspecies method
|
||||
return m_defectActivity->getSpeciesTransProp();
|
||||
}
|
||||
//====================================================================================================================
|
||||
/*
|
||||
* Compute the mobilities of the species from the diffusion coefficients,
|
||||
* using the Einstein relation.
|
||||
*/
|
||||
void SolidTransport::getMobilities(doublereal* const mobil)
|
||||
{
|
||||
void SolidTransport::getMobilities(doublereal* const mobil) {
|
||||
getMixDiffCoeffs(mobil);
|
||||
doublereal t = m_thermo->temperature();
|
||||
doublereal c1 = ElectronCharge / (Boltzmann * t);
|
||||
for (size_t k = 0; k < m_thermo->nSpecies(); k++) {
|
||||
mobil[k] *= c1;
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
/*
|
||||
* Thermal Conductivity.
|
||||
* \f[
|
||||
* \lambda = A T^n \exp(-E/RT)
|
||||
* \f]
|
||||
*/
|
||||
doublereal SolidTransport::thermalConductivity()
|
||||
{
|
||||
doublereal t = m_thermo->temperature();
|
||||
return m_Alam * pow(t, m_Nlam) * exp(-m_Elam/t);
|
||||
}
|
||||
//====================================================================================================================
|
||||
/*
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
/*
|
||||
* The diffusion coefficients are computed from
|
||||
*
|
||||
* \f[
|
||||
|
|
@ -142,28 +267,11 @@ doublereal SolidTransport::thermalConductivity()
|
|||
* which parameters have been specified using method
|
||||
* setParameters.
|
||||
*/
|
||||
void SolidTransport::getMixDiffCoeffs(doublereal* const d)
|
||||
{
|
||||
doublereal temp = m_thermo->temperature();
|
||||
void SolidTransport::getMixDiffCoeffs(doublereal* const d) {
|
||||
size_t nsp = m_thermo->nSpecies();
|
||||
for (size_t k = 0; k < nsp; k++) {
|
||||
d[k] = 0.0;
|
||||
}
|
||||
for (size_t k = 0; k < m_nmobile; k++) {
|
||||
d[m_sp[k]] =
|
||||
m_Adiff[k] * pow(temp, m_Ndiff[k]) * exp(-m_Ediff[k]/temp);
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
doublereal SolidTransport::electricalConductivity()
|
||||
{
|
||||
getMobilities(&m_work[0]);
|
||||
size_t nsp = m_thermo->nSpecies();
|
||||
doublereal sum = 0.0;
|
||||
for (size_t k = 0; k < nsp; k++) {
|
||||
sum += m_thermo->charge(k) * m_thermo->moleFraction(k) * m_work[k];
|
||||
}
|
||||
return sum * m_thermo->molarDensity();
|
||||
}
|
||||
//====================================================================================================================
|
||||
}
|
||||
|
|
|
|||
80
src/transport/SolidTransportData.cpp
Normal file
80
src/transport/SolidTransportData.cpp
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @file SolidTransportData.cpp
|
||||
* Source code for solid transport property evaluations.
|
||||
*/
|
||||
/*
|
||||
* $Author: hkmoffa $
|
||||
* $Date: 2010-07-13 13:22:30 -0600 (Tue, 13 Jul 2010) $
|
||||
* $Revision: 507 $
|
||||
*/
|
||||
|
||||
#include "cantera/transport/SolidTransportData.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifndef SAFE_DELETE
|
||||
#define SAFE_DELETE(x) if (x) { delete (x); x = 0; }
|
||||
#endif
|
||||
namespace Cantera {
|
||||
|
||||
//====================================================================================================================
|
||||
SolidTransportData::SolidTransportData() :
|
||||
speciesName("-"),
|
||||
ionConductivity(0),
|
||||
thermalConductivity(0),
|
||||
electConductivity(0),
|
||||
defectDiffusivity(0),
|
||||
defectActivity(0)
|
||||
{
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Copy constructor
|
||||
SolidTransportData::SolidTransportData(const SolidTransportData &right) :
|
||||
speciesName("-"),
|
||||
ionConductivity(0),
|
||||
thermalConductivity(0),
|
||||
electConductivity(0),
|
||||
defectDiffusivity(0),
|
||||
defectActivity(0)
|
||||
{
|
||||
*this = right; //use assignment operator to do other work
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Assignment operator
|
||||
SolidTransportData& SolidTransportData::operator=(const SolidTransportData& right)
|
||||
{
|
||||
if (&right != this) {
|
||||
// These are all shallow pointer copies - yes, yes, yes horrible crime.
|
||||
speciesName = right.speciesName;
|
||||
if (right.ionConductivity) {
|
||||
ionConductivity = (right.ionConductivity)->duplMyselfAsLTPspecies();
|
||||
}
|
||||
|
||||
if (right.thermalConductivity) {
|
||||
thermalConductivity = (right.thermalConductivity)->duplMyselfAsLTPspecies();
|
||||
}
|
||||
if (right.electConductivity) {
|
||||
electConductivity = (right.electConductivity)->duplMyselfAsLTPspecies();
|
||||
}
|
||||
if (right.defectDiffusivity) {
|
||||
defectDiffusivity = (right.defectDiffusivity)->duplMyselfAsLTPspecies();
|
||||
}
|
||||
if (right.defectActivity) {
|
||||
defectActivity = (right.defectActivity)->duplMyselfAsLTPspecies();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
//====================================================================================================================
|
||||
SolidTransportData::~SolidTransportData() {
|
||||
|
||||
SAFE_DELETE(ionConductivity);
|
||||
SAFE_DELETE(thermalConductivity);
|
||||
SAFE_DELETE(electConductivity);
|
||||
SAFE_DELETE(defectDiffusivity);
|
||||
SAFE_DELETE(defectActivity);
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
}
|
||||
|
|
@ -98,6 +98,7 @@ void Transport::checkSpeciesArraySize(size_t kk) const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Set transport model parameters. This method may be
|
||||
* overloaded in subclasses to set model-specific parameters.
|
||||
*/
|
||||
|
|
@ -108,16 +109,31 @@ void Transport::setParameters(const int type, const int k,
|
|||
}
|
||||
|
||||
|
||||
void Transport::setThermo(thermo_t& thermo)
|
||||
{
|
||||
void Transport::setThermo(thermo_t& thermo) {
|
||||
if (!ready()) {
|
||||
m_thermo = &thermo;
|
||||
m_nsp = m_thermo->nSpecies();
|
||||
} else
|
||||
//m_nmin = m_thermo->nSpecies();
|
||||
}
|
||||
else {
|
||||
int newNum = thermo.nSpecies();
|
||||
int oldNum = m_thermo->nSpecies();
|
||||
if (newNum != oldNum) {
|
||||
throw CanteraError("Transport::setThermo",
|
||||
"the phase object cannot be changed after "
|
||||
"the transport manager has been constructed.");
|
||||
}
|
||||
"base object cannot be changed after "
|
||||
"the transport manager has been constructed because num species isn't the same.");
|
||||
}
|
||||
for (int i = 0; i < newNum; i++) {
|
||||
std::string newS0 = thermo.speciesName(i);
|
||||
std::string oldS0 = m_thermo->speciesName(i);
|
||||
if (newNum != oldNum) {
|
||||
throw CanteraError("Transport::setThermo",
|
||||
"base object cannot be changed after "
|
||||
"the transport manager has been constructed because species names are not the same");
|
||||
}
|
||||
}
|
||||
m_thermo = &thermo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doublereal Transport::err(const std::string& msg) const
|
||||
|
|
|
|||
|
|
@ -19,16 +19,19 @@
|
|||
|
||||
#include "cantera/numerics/polyfit.h"
|
||||
#include "MMCollisionInt.h"
|
||||
|
||||
#include "cantera/base/xml.h"
|
||||
#include "cantera/base/XML_Writer.h"
|
||||
#include "cantera/transport/TransportParams.h"
|
||||
#include "cantera/transport/LiquidTransportParams.h"
|
||||
#include "cantera/transport/LiquidTranInteraction.h"
|
||||
#include "cantera/transport/SolidTransportData.h"
|
||||
#include "cantera/base/global.h"
|
||||
#include "cantera/thermo/IdealGasPhase.h"
|
||||
#include "cantera/base/ctml.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
|
@ -220,6 +223,8 @@ TransportFactory::TransportFactory() :
|
|||
m_tranPropMap["speciesDiffusivity"] = TP_DIFFUSIVITY;
|
||||
m_tranPropMap["hydrodynamicRadius"] = TP_HYDRORADIUS;
|
||||
m_tranPropMap["electricalConductivity"] = TP_ELECTCOND;
|
||||
m_tranPropMap["defectDiffusivity"] = TP_DEFECTDIFF;
|
||||
m_tranPropMap["defectActivity"] = TP_DEFECTCONC;
|
||||
|
||||
m_LTRmodelMap[""] = LTP_TD_CONSTANT;
|
||||
m_LTRmodelMap["constant"] = LTP_TD_CONSTANT;
|
||||
|
|
@ -260,15 +265,16 @@ std::string TransportFactory::modelName(int model)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
make one of several transport models, and return a base class
|
||||
pointer to it. This method operates at the level of a
|
||||
single transport property as a function of temperature
|
||||
and possibly composition.
|
||||
*/
|
||||
LTPspecies* TransportFactory::newLTP(const XML_Node& trNode, std::string& name,
|
||||
*/
|
||||
LTPspecies* TransportFactory::newLTP(const XML_Node &trNode, const std::string &name,
|
||||
TransportPropertyType tp_ind, thermo_t* thermo)
|
||||
{
|
||||
{
|
||||
LTPspecies* ltps = 0;
|
||||
std::string model = lowercase(trNode["model"]);
|
||||
switch (m_LTRmodelMap[model]) {
|
||||
|
|
@ -395,7 +401,9 @@ Transport* TransportFactory::newTransport(const std::string& transportModel,
|
|||
initTransport(tr, phase, 0, log_level);
|
||||
break;
|
||||
case cSolidTransport:
|
||||
|
||||
tr = new SolidTransport;
|
||||
initSolidTransport(tr, phase, log_level);
|
||||
tr->setThermo(*phase);
|
||||
break;
|
||||
case cDustyGasTransport:
|
||||
|
|
@ -642,10 +650,57 @@ void TransportFactory::setupLiquidTransport(std::ostream& flog, thermo_t* thermo
|
|||
XML_Node& transportNode = phase_database->child("transport");
|
||||
getLiquidInteractionsTransportData(transportNode, log, trParam.thermo->speciesNames(), trParam);
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Initialize an existing transport manager
|
||||
/*
|
||||
|
||||
}
|
||||
|
||||
|
||||
//====================================================================================================================
|
||||
// Prepare to build a new transport manager for solids
|
||||
/*
|
||||
* @param flog Reference to the ostream for writing log info
|
||||
* @param thermo Pointer to the %ThermoPhase object
|
||||
* @param log_level log level
|
||||
* @param trParam SolidTransportParams structure to be filled up with information
|
||||
*/
|
||||
void TransportFactory::setupSolidTransport(std::ostream &flog, thermo_t* thermo, int log_level,
|
||||
SolidTransportData& trParam) {
|
||||
|
||||
const XML_Node* phase_database = &thermo->xml();
|
||||
|
||||
// constant mixture attributes
|
||||
trParam.thermo = thermo;
|
||||
trParam.nsp_ = trParam.thermo->nSpecies();
|
||||
int nsp = trParam.nsp_;
|
||||
|
||||
trParam.tmin = thermo->minTemp();
|
||||
trParam.tmax = thermo->maxTemp();
|
||||
trParam.log_level = log_level;
|
||||
|
||||
// Get the molecular weights and load them into trParam
|
||||
trParam.mw.resize(nsp);
|
||||
copy(trParam.thermo->molecularWeights().begin(),
|
||||
trParam.thermo->molecularWeights().end(), trParam.mw.begin());
|
||||
|
||||
// Resize all other vectors in trParam
|
||||
//trParam.LTData.resize(nsp);
|
||||
|
||||
XML_Node root, log;
|
||||
|
||||
// Note that getSolidSpeciesTransportData just populates the pure species transport data.
|
||||
// const std::vector<const XML_Node*> & species_database = thermo->speciesData();
|
||||
// getSolidSpeciesTransportData(species_database, log, trParam.thermo->speciesNames(), trParam);
|
||||
|
||||
// getSolidTransportData() populates the
|
||||
// phase transport models like electronic conductivity
|
||||
// thermal conductivity, interstitial diffusion
|
||||
if (phase_database->hasChild("transport")) {
|
||||
XML_Node& transportNode = phase_database->child("transport");
|
||||
getSolidTransportData(transportNode, log, thermo->name(), trParam);
|
||||
}
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Initialize an existing transport manager
|
||||
/*
|
||||
* This routine sets up an existing gas-phase transport manager.
|
||||
* It calculates the collision integrals and calls the initGas() function to
|
||||
* populate the species-dependent data structure.
|
||||
|
|
@ -659,10 +714,11 @@ void TransportFactory::setupLiquidTransport(std::ostream& flog, thermo_t* thermo
|
|||
* In DEBUG_MODE, this routine will create the file transport_log.xml
|
||||
* and write informative information to it.
|
||||
*/
|
||||
void TransportFactory::initTransport(Transport* tran,
|
||||
thermo_t* thermo, int mode, int log_level)
|
||||
{
|
||||
void TransportFactory::initTransport(Transport* tran,
|
||||
thermo_t* thermo, int mode, int log_level) {
|
||||
|
||||
ScopedLock transportLock(transport_mutex);
|
||||
|
||||
const std::vector<const XML_Node*> & transport_database = thermo->speciesData();
|
||||
|
||||
GasTransportParams trParam;
|
||||
|
|
@ -725,7 +781,47 @@ void TransportFactory::initLiquidTransport(Transport* tran,
|
|||
#endif
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
|
||||
/* Similar to initTransport except uses SolidTransportParams
|
||||
class and calls setupSolidTransport().
|
||||
*/
|
||||
void TransportFactory::initSolidTransport(Transport* tran,
|
||||
thermo_t* thermo,
|
||||
int log_level) {
|
||||
|
||||
SolidTransportData trParam;
|
||||
|
||||
//setup output
|
||||
#ifdef DEBUG_MODE
|
||||
ofstream flog("transport_log.xml");
|
||||
trParam.xml = new XML_Writer(flog);
|
||||
if (m_verbose) {
|
||||
trParam.xml->XML_open(flog, "transport");
|
||||
}
|
||||
#else
|
||||
// create the object, but don't associate it with a file
|
||||
std::ostream &flog(std::cout);
|
||||
#endif
|
||||
|
||||
//real work next two statements
|
||||
setupSolidTransport(flog, thermo, log_level, trParam );
|
||||
// do model-specific initialization
|
||||
tran->initSolid( trParam );
|
||||
|
||||
|
||||
#ifdef DEBUG_MODE
|
||||
if (m_verbose) {
|
||||
trParam.xml->XML_close(flog, "transport");
|
||||
}
|
||||
// finished with log file
|
||||
flog.close();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void TransportFactory::fitCollisionIntegrals(ostream& logfile,
|
||||
GasTransportParams& tr,
|
||||
|
|
@ -1060,7 +1156,8 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
|
|||
|
||||
trParam.mobilityRatio.resize(nsp*nsp,0);
|
||||
trParam.selfDiffusion.resize(nsp,0);
|
||||
ThermoPhase* temp_thermo = trParam.thermo;
|
||||
ThermoPhase *temp_thermo = trParam.thermo;
|
||||
|
||||
|
||||
if (tranTypeNode.hasChild("compositionDependence")) {
|
||||
//compDepNode contains the interaction model
|
||||
|
|
@ -1154,6 +1251,85 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Given a phase XML data base, this method constructs the
|
||||
* SolidTransportData object containing the transport data for the phase.
|
||||
*
|
||||
* @param db Reference to a vector of XML_Node pointers containing the species XML
|
||||
* nodes.
|
||||
* @param log Reference to an XML log file. (currently unused)
|
||||
* @param tr Reference to the SolidTransportData object that will contain the results.
|
||||
* NOTE: For now we are using the LTPspecies class to describe the solid transport models.
|
||||
*/
|
||||
void TransportFactory::getSolidTransportData(const XML_Node &transportNode,
|
||||
XML_Node& log,
|
||||
const std::string phaseName,
|
||||
SolidTransportData& trParam)
|
||||
{
|
||||
try {
|
||||
|
||||
int num = transportNode.nChildren();
|
||||
for (int iChild = 0; iChild < num; iChild++) {
|
||||
//tranTypeNode is a type of transport property like viscosity
|
||||
XML_Node &tranTypeNode = transportNode.child(iChild);
|
||||
std::string nodeName = tranTypeNode.name();
|
||||
|
||||
ThermoPhase *temp_thermo = trParam.thermo;
|
||||
|
||||
//tranTypeNode contains the interaction model
|
||||
// XML_Node &compDepNode = tranTypeNode.child("compositionDependence");
|
||||
switch (m_tranPropMap[nodeName]) {
|
||||
case TP_IONCONDUCTIVITY:
|
||||
trParam.ionConductivity = newLTP(tranTypeNode, phaseName,
|
||||
m_tranPropMap[nodeName],
|
||||
temp_thermo);
|
||||
break;
|
||||
case TP_THERMALCOND:
|
||||
trParam.thermalConductivity = newLTP(tranTypeNode, phaseName,
|
||||
m_tranPropMap[nodeName],
|
||||
temp_thermo);
|
||||
break;
|
||||
case TP_DEFECTDIFF:
|
||||
trParam.defectDiffusivity = newLTP(tranTypeNode, phaseName,
|
||||
m_tranPropMap[nodeName],
|
||||
temp_thermo);
|
||||
break;
|
||||
case TP_DEFECTCONC:
|
||||
trParam.defectActivity = newLTP(tranTypeNode, phaseName,
|
||||
m_tranPropMap[nodeName],
|
||||
temp_thermo);
|
||||
break;
|
||||
case TP_ELECTCOND:
|
||||
trParam.electConductivity = newLTP(tranTypeNode, phaseName,
|
||||
m_tranPropMap[nodeName],
|
||||
temp_thermo);
|
||||
break;
|
||||
default:
|
||||
throw CanteraError("getSolidTransportData","unknown transport property: " + nodeName);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CanteraError) {
|
||||
showErrors(std::cout);
|
||||
}
|
||||
//catch(CanteraError) {
|
||||
// ;
|
||||
//}
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************************
|
||||
*
|
||||
* Polynomial fitting
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
|
||||
/*********************************************************
|
||||
*
|
||||
* Polynomial fitting
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ static void printUsage()
|
|||
|
||||
#include "cantera/Interface.h"
|
||||
#include "cantera/kinetics.h"
|
||||
#include "kinetics/ImplicitSurfChem.h"
|
||||
#include "kinetics/solveSP.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/solveSP.h"
|
||||
|
||||
using namespace Cantera;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ static void printUsage()
|
|||
|
||||
#include "cantera/Interface.h"
|
||||
#include "cantera/kinetics.h"
|
||||
#include "kinetics/ImplicitSurfChem.h"
|
||||
#include "kinetics/solveSP.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/solveSP.h"
|
||||
|
||||
using namespace Cantera;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue