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]
|
//! One atmosphere [Pa]
|
||||||
const doublereal OneAtm = 1.01325e5;
|
const doublereal OneAtm = 1.01325e5;
|
||||||
|
const doublereal OneBar = 1.0E5;
|
||||||
|
|
||||||
//! Universal gas constant in cal/mol/K
|
//! Universal gas constant in cal/mol/K
|
||||||
const doublereal GasConst_cal_mol_K = GasConstant / 4184.0;
|
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
|
#define VCS_VOLPHASE_H
|
||||||
|
|
||||||
#include "cantera/equil/vcs_DoubleStarStar.h"
|
#include "cantera/equil/vcs_DoubleStarStar.h"
|
||||||
|
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
||||||
|
|
@ -1445,6 +1445,48 @@ private:
|
||||||
*/
|
*/
|
||||||
void vcs_updateMolNumVolPhases(const int stateCalc);
|
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:
|
public:
|
||||||
//! value of the number of species used to malloc data structures
|
//! 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
|
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
|
||||||
* retains certain rights in this software.
|
* retains certain rights in this software.
|
||||||
* See file License.txt for licensing information.
|
* See file License.txt for licensing information.
|
||||||
|
|
@ -15,136 +19,134 @@
|
||||||
#ifndef CT_NONLINEARSOLVER_H
|
#ifndef CT_NONLINEARSOLVER_H
|
||||||
#define CT_NONLINEARSOLVER_H
|
#define CT_NONLINEARSOLVER_H
|
||||||
|
|
||||||
#include "ResidJacEval.h"
|
#include "cantera/numerics/ResidJacEval.h"
|
||||||
#include "SquareMatrix.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
|
||||||
* 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
|
#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
|
#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
|
#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
|
* This int is returned from the nonlinear solver
|
||||||
*/
|
*/
|
||||||
//! The nonlinear solve is successful.
|
//! The nonlinear solve is successful.
|
||||||
#define NSOLN_RETN_SUCCESS 1
|
#define NSOLN_RETN_SUCCESS 1
|
||||||
//! Problem isn't solved yet
|
//! Problem isn't solved yet
|
||||||
#define NSOLN_RETN_CONTINUE 0
|
#define NSOLN_RETN_CONTINUE 0
|
||||||
//! The nonlinear problem started to take too small an update step. This indicates that either the
|
//! 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.
|
//! Jacobian is bad, or a constraint is being bumped up against.
|
||||||
#define NSOLN_RETN_FAIL_STEPTOOSMALL -1
|
#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
|
#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
|
#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
|
#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
|
#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
|
#define NSOLN_RETN_MAXIMUMITERATIONSEXCEEDED -7
|
||||||
//@}
|
//@}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/// @name Constant which determines the type of the Jacobian
|
/// @name Constant which determines the type of the Jacobian
|
||||||
//! The jacobian will be calculated from a numerical method
|
//! The jacobian will be calculated from a numerical method
|
||||||
#define NSOLN_JAC_NUM 1
|
#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
|
#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
|
* This is a small nonlinear solver that can solve highly nonlinear problems that
|
||||||
* must use a dense matrix to relax the system.
|
* must use a dense matrix to relax the system.
|
||||||
*
|
*
|
||||||
* Newton's method is used.
|
* Newton's method is used.
|
||||||
*
|
*
|
||||||
* Damping is used extensively when relaxing the system.
|
* Damping is used extensively when relaxing the system.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* The basic idea is that we predict a direction that is parameterized by an overall coordinate
|
* The basic idea is that we predict a direction that is parameterized by an overall coordinate
|
||||||
* value, beta, from zero to one, This may or may not be the same as the value, damp,
|
* value, beta, from zero to one, This may or may not be the same as the value, damp,
|
||||||
* depending upon whether the direction is straight.
|
* depending upon whether the direction is straight.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* TIME STEP TYPE
|
* TIME STEP TYPE
|
||||||
*
|
*
|
||||||
* The code solves a nonlinear problem. Frequently the nonlinear problem is created from time-dependent
|
* The code solves a nonlinear problem. Frequently the nonlinear problem is created from time-dependent
|
||||||
* residual. Whenever you change the solution vector, you are also changing the derivative of the
|
* residual. Whenever you change the solution vector, you are also changing the derivative of the
|
||||||
* solution vector. Therefore, the code has the option of altering ydot, a vector of time derivatives
|
* solution vector. Therefore, the code has the option of altering ydot, a vector of time derivatives
|
||||||
* of the solution in tandem with the solution vector and then feeding a residual and Jacobian routine
|
* of the solution in tandem with the solution vector and then feeding a residual and Jacobian routine
|
||||||
* with the time derivatives as well as the solution. The code has support for a backwards euler method
|
* with the time derivatives as well as the solution. The code has support for a backwards euler method
|
||||||
* and a second order Adams-Bashforth or Trapezoidal Rule.
|
* and a second order Adams-Bashforth or Trapezoidal Rule.
|
||||||
*
|
*
|
||||||
* In order to use these methods, the solver must be initialized with delta_t and m_y_nm1[i] to specify
|
* In order to use these methods, the solver must be initialized with delta_t and m_y_nm1[i] to specify
|
||||||
* the conditions at the previous time step. For second order methods, the time derivative at t_nm1 must
|
* the conditions at the previous time step. For second order methods, the time derivative at t_nm1 must
|
||||||
* also be supplied, m_ydot_nm1[i]. Then the solution type NSOLN_TYPE_TIME_DEPENDENT may be used to
|
* also be supplied, m_ydot_nm1[i]. Then the solution type NSOLN_TYPE_TIME_DEPENDENT may be used to
|
||||||
* solve the problem.
|
* solve the problem.
|
||||||
*
|
*
|
||||||
* For steady state problem whose residual doesn't have a solution time derivative in it, you should
|
* For steady state problem whose residual doesn't have a solution time derivative in it, you should
|
||||||
* use the NSOLN_TYPE_STEADY_STATE problem type.
|
* use the NSOLN_TYPE_STEADY_STATE problem type.
|
||||||
*
|
*
|
||||||
* We have a NSOLN_TYPE_PSEUDO_TIME_DEPENDENT defined. However, this is not implemented yet. This would
|
* We have a NSOLN_TYPE_PSEUDO_TIME_DEPENDENT defined. However, this is not implemented yet. This would
|
||||||
* be a pseudo time dependent calculation, where an optional time derivative could be added in order to
|
* be a pseudo time dependent calculation, where an optional time derivative could be added in order to
|
||||||
* help equilibrate a nonlinear steady state system. The time transient is not important in and of
|
* help equilibrate a nonlinear steady state system. The time transient is not important in and of
|
||||||
* itself. Many physical systems have a time dependence to them that provides a natural way to relax
|
* itself. Many physical systems have a time dependence to them that provides a natural way to relax
|
||||||
* the nonlinear system.
|
* the nonlinear system.
|
||||||
*
|
*
|
||||||
* MATRIX SCALING
|
* MATRIX SCALING
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* NonlinearSolver *nls = new NonlinearSolver(&r1);
|
* NonlinearSolver *nls = new NonlinearSolver(&r1);
|
||||||
*
|
*
|
||||||
* int solnType = NSOLN_TYPE_STEADY_STATE ;
|
* int solnType = NSOLN_TYPE_STEADY_STATE ;
|
||||||
*
|
*
|
||||||
* nls->setDeltaBoundsMagnitudes(deltaBounds);
|
* nls->setDeltaBoundsMagnitudes(deltaBounds);
|
||||||
*
|
*
|
||||||
* nls->solve_nonlinear_problem(solnType, y_comm, ydot_comm, CJ, time_curr, jac,
|
* nls->solve_nonlinear_problem(solnType, y_comm, ydot_comm, CJ, time_curr, jac,
|
||||||
* num_newt_its, num_linear_solves, numBacktracks,
|
* num_newt_its, num_linear_solves, numBacktracks,
|
||||||
* loglevelInput);
|
* loglevelInput);
|
||||||
*
|
*
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @ingroup numerics
|
* @ingroup numerics
|
||||||
*/
|
*/
|
||||||
class NonlinearSolver
|
class NonlinearSolver {
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
/*!
|
/*!
|
||||||
* @param func Residual and jacobian evaluator function object
|
* @param func Residual and jacobian evaluator function object
|
||||||
*/
|
*/
|
||||||
NonlinearSolver(ResidJacEval* func);
|
NonlinearSolver(ResidJacEval *func);
|
||||||
|
|
||||||
//!Copy Constructor for the %ThermoPhase object.
|
//!Copy Constructor for the %ThermoPhase object.
|
||||||
/*!
|
/*!
|
||||||
* @param right Item to be copied
|
* @param right Item to be copied
|
||||||
*/
|
*/
|
||||||
NonlinearSolver(const NonlinearSolver& right);
|
NonlinearSolver(const NonlinearSolver &right);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~NonlinearSolver();
|
~NonlinearSolver();
|
||||||
|
|
@ -157,7 +159,7 @@ public:
|
||||||
* copied into the
|
* copied into the
|
||||||
* current one.
|
* current one.
|
||||||
*/
|
*/
|
||||||
NonlinearSolver& operator=(const NonlinearSolver& right);
|
NonlinearSolver& operator=(const NonlinearSolver &right);
|
||||||
|
|
||||||
//! Create solution weights for convergence criteria
|
//! Create solution weights for convergence criteria
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -170,7 +172,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param y vector of the current solution values
|
* @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
|
//! L2 norm of the delta of the solution vector
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -189,13 +191,13 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns the L2 norm of the delta
|
* @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;
|
const doublereal dampFactor = 1.0) const;
|
||||||
|
|
||||||
//! L2 norm of the residual of the equation system
|
//! L2 norm of the residual of the equation system
|
||||||
/*!
|
/*!
|
||||||
* Calculate the norm of the residual vector. This may
|
* Calculate the norm of the residual vector. This may
|
||||||
* involve using the row sum scaling from the matrix problem.
|
* involve using the row sum scaling from the matrix problem.
|
||||||
*
|
*
|
||||||
* The second argument has a default of false. However,
|
* The second argument has a default of false. However,
|
||||||
* if true, then a table of the largest values is printed
|
* if true, then a table of the largest values is printed
|
||||||
|
|
@ -209,40 +211,40 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns the L2 norm of the delta
|
* @return Returns the L2 norm of the delta
|
||||||
*/
|
*/
|
||||||
doublereal residErrorNorm(const doublereal* const resid, const char* title = 0, const int printLargest = 0,
|
doublereal residErrorNorm(const doublereal * const resid, const char * title = 0, const int printLargest = 0,
|
||||||
const doublereal* const y = 0) const;
|
const doublereal * const y = 0) const;
|
||||||
|
|
||||||
//! Compute the current residual
|
//! 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
|
* as mutable
|
||||||
*
|
*
|
||||||
* @param time_curr Value of the time
|
* @param time_curr Value of the time
|
||||||
* @param typeCalc Type of the calculation
|
* @param typeCalc Type of the calculation
|
||||||
* @param y_curr Current value of the solution vector
|
* @param y_curr Current value of the solution vector
|
||||||
* @param ydot_curr Current value of the time derivative 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
|
* Defaults to Base_ResidEval
|
||||||
*
|
*
|
||||||
* @return Returns a flag to indicate that operation is successful.
|
* @return Returns a flag to indicate that operation is successful.
|
||||||
* 1 Means a successful operation
|
* 1 Means a successful operation
|
||||||
* -0 or neg value Means an unsuccessful operation
|
* -0 or neg value Means an unsuccessful operation
|
||||||
*/
|
*/
|
||||||
int doResidualCalc(const doublereal time_curr, const int typeCalc, const doublereal* const y_curr,
|
int doResidualCalc(const doublereal time_curr, const int typeCalc, const doublereal * const y_curr,
|
||||||
const doublereal* const ydot_curr,
|
const doublereal * const ydot_curr,
|
||||||
const ResidEval_Type_Enum evalType = Base_ResidEval) const;
|
const ResidEval_Type_Enum evalType = Base_ResidEval) const;
|
||||||
|
|
||||||
//! Compute the undamped Newton step
|
//! Compute the undamped Newton step
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
* Compute the undamped Newton step. The residual function is
|
* Compute the undamped Newton step. The residual function is
|
||||||
* evaluated at the current time, t_n, at the current values of the
|
* evaluated at the current time, t_n, at the current values of the
|
||||||
* solution vector, m_y_n, and the solution time derivative, m_ydot_n.
|
* solution vector, m_y_n, and the solution time derivative, m_ydot_n.
|
||||||
* The Jacobian is not recomputed.
|
* The Jacobian is not recomputed.
|
||||||
*
|
*
|
||||||
* A factored jacobian is reused, if available. If a factored jacobian
|
* A factored jacobian is reused, if available. If a factored jacobian
|
||||||
* is not available, then the jacobian is factored. Before factoring,
|
* is not available, then the jacobian is factored. Before factoring,
|
||||||
* the jacobian is row and column-scaled. Column scaling is not
|
* the jacobian is row and column-scaled. Column scaling is not
|
||||||
* recomputed. The row scales are recomputed here, after column
|
* recomputed. The row scales are recomputed here, after column
|
||||||
* scaling has been implemented.
|
* scaling has been implemented.
|
||||||
*
|
*
|
||||||
|
|
@ -254,10 +256,10 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns the result code from lapack. A zero means success. Anything
|
* @return Returns the result code from lapack. A zero means success. Anything
|
||||||
* else indicates a failure.
|
* else indicates a failure.
|
||||||
*/
|
*/
|
||||||
int doNewtonSolve(const doublereal time_curr, const doublereal* const y_curr,
|
int doNewtonSolve(const doublereal time_curr, const doublereal * const y_curr,
|
||||||
const doublereal* const ydot_curr, doublereal* const delta_y,
|
const doublereal * const ydot_curr, doublereal * const delta_y,
|
||||||
GeneralMatrix& jac);
|
GeneralMatrix& jac);
|
||||||
|
|
||||||
//! Compute the newton step, either by direct newton's or by solving a close problem that is represented
|
//! Compute the newton step, either by direct newton's or by solving a close problem that is represented
|
||||||
//! by a Hessian (
|
//! by a Hessian (
|
||||||
|
|
@ -265,15 +267,15 @@ public:
|
||||||
* This is algorith A.6.5.1 in Dennis / Schnabel
|
* This is algorith A.6.5.1 in Dennis / Schnabel
|
||||||
*
|
*
|
||||||
* Compute the QR decomposition
|
* Compute the QR decomposition
|
||||||
*
|
*
|
||||||
* Compute the undamped Newton step. The residual function is
|
* Compute the undamped Newton step. The residual function is
|
||||||
* evaluated at the current time, t_n, at the current values of the
|
* evaluated at the current time, t_n, at the current values of the
|
||||||
* solution vector, m_y_n, and the solution time derivative, m_ydot_n.
|
* solution vector, m_y_n, and the solution time derivative, m_ydot_n.
|
||||||
* The Jacobian is not recomputed.
|
* The Jacobian is not recomputed.
|
||||||
*
|
*
|
||||||
* A factored jacobian is reused, if available. If a factored jacobian
|
* A factored jacobian is reused, if available. If a factored jacobian
|
||||||
* is not available, then the jacobian is factored. Before factoring,
|
* is not available, then the jacobian is factored. Before factoring,
|
||||||
* the jacobian is row and column-scaled. Column scaling is not
|
* the jacobian is row and column-scaled. Column scaling is not
|
||||||
* recomputed. The row scales are recomputed here, after column
|
* recomputed. The row scales are recomputed here, after column
|
||||||
* scaling has been implemented.
|
* scaling has been implemented.
|
||||||
*
|
*
|
||||||
|
|
@ -284,14 +286,14 @@ public:
|
||||||
*
|
*
|
||||||
* Internal input
|
* 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
|
* @return Returns the result code from lapack. A zero means success. Anything
|
||||||
* else indicates a failure.
|
* else indicates a failure.
|
||||||
*/
|
*/
|
||||||
int doAffineNewtonSolve(const doublereal* const y_curr, const doublereal* const ydot_curr,
|
int doAffineNewtonSolve(const doublereal * const y_curr, const doublereal * const ydot_curr,
|
||||||
doublereal* const delta_y, GeneralMatrix& jac);
|
doublereal * const delta_y, GeneralMatrix& jac);
|
||||||
|
|
||||||
//! Calculate the length of the current trust region in terms of the solution error norm
|
//! Calculate the length of the current trust region in terms of the solution error norm
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -314,11 +316,11 @@ public:
|
||||||
|
|
||||||
//! Set the delta Bounds magnitudes by hand
|
//! Set the delta Bounds magnitudes by hand
|
||||||
/*!
|
/*!
|
||||||
* @param deltaBoundsMagnitudes set the deltaBoundsMagnitude vector
|
* @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
|
//! Readjust the trust region vectors
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -326,7 +328,7 @@ protected:
|
||||||
* We periodically recalculate the trustVector_ values so that they renormalize to the
|
* We periodically recalculate the trustVector_ values so that they renormalize to the
|
||||||
* correct length. We change the trustDelta_ values regularly
|
* correct length. We change the trustDelta_ values regularly
|
||||||
*
|
*
|
||||||
* The trust region calculate is based on
|
* The trust region calculate is based on
|
||||||
*
|
*
|
||||||
* || delta_x dot 1/trustDeltaX_ || <= trustDelta_
|
* || delta_x dot 1/trustDeltaX_ || <= trustDelta_
|
||||||
*
|
*
|
||||||
|
|
@ -348,16 +350,16 @@ protected:
|
||||||
/*!
|
/*!
|
||||||
* The trust distance is defined as the length of the step according to the norm wrt to the trust region.
|
* The trust distance is defined as the length of the step according to the norm wrt to the trust region.
|
||||||
* We calculate the trust distance by the following method.
|
* We calculate the trust distance by the following method.
|
||||||
*
|
*
|
||||||
* trustDist = || delta_x dot 1/trustDeltaX_ ||
|
* trustDist = || delta_x dot 1/trustDeltaX_ ||
|
||||||
*
|
*
|
||||||
* @param deltaX Current value of deltaX
|
* @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
|
//! Bound the step
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
|
|
@ -378,8 +380,8 @@ public:
|
||||||
* Delta bounds: The idea behind these is that the Jacobian
|
* Delta bounds: The idea behind these is that the Jacobian
|
||||||
* couldn't possibly be representative if the
|
* couldn't possibly be representative if the
|
||||||
* variable is changed by a lot. (true for
|
* variable is changed by a lot. (true for
|
||||||
* nonlinear systems, false for linear systems)
|
* nonlinear systems, false for linear systems)
|
||||||
* Maximum increase in variable in any one newton iteration:
|
* Maximum increase in variable in any one newton iteration:
|
||||||
* factor of 2
|
* factor of 2
|
||||||
* Maximum decrease in variable in any one newton iteration:
|
* Maximum decrease in variable in any one newton iteration:
|
||||||
* factor of 5
|
* factor of 5
|
||||||
|
|
@ -389,23 +391,23 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns the damping factor determined by the bounds calculation
|
* @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
|
//! Set bounds constraints for all variables in the problem
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
* @param y_low_bounds Vector of lower bounds
|
* @param y_low_bounds Vector of lower bounds
|
||||||
* @param y_high_bounds Vector of high bounds
|
* @param y_high_bounds Vector of high bounds
|
||||||
*/
|
*/
|
||||||
void setBoundsConstraints(const doublereal* const y_low_bounds,
|
void setBoundsConstraints(const doublereal * const y_low_bounds,
|
||||||
const doublereal* const y_high_bounds);
|
const doublereal * const y_high_bounds);
|
||||||
|
|
||||||
//! Return an editable vector of the low bounds constraints
|
//! Return an editable vector of the low bounds constraints
|
||||||
std::vector<doublereal> & lowBoundsConstraintVector();
|
std::vector<doublereal> & lowBoundsConstraintVector();
|
||||||
|
|
||||||
//! Return an editable vector of the high bounds constraints
|
//! Return an editable vector of the high bounds constraints
|
||||||
std::vector<doublereal> & highBoundsConstraintVector();
|
std::vector<doublereal> & highBoundsConstraintVector();
|
||||||
|
|
||||||
//! Internal function to calculate the time derivative of the solution at the new step
|
//! Internal function to calculate the time derivative of the solution at the new step
|
||||||
/*!
|
/*!
|
||||||
* Previously, the user must have supplied information about the previous time step for this routine to
|
* Previously, the user must have supplied information about the previous time step for this routine to
|
||||||
|
|
@ -414,13 +416,13 @@ public:
|
||||||
* @param order of the BDF method
|
* @param order of the BDF method
|
||||||
* @param y_curr current value of the solution
|
* @param y_curr current value of the solution
|
||||||
* @param ydot_curr Calculated value of the solution derivative that is consistent with y_curr
|
* @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
|
//! Function called to evaluate the jacobian matrix and the current
|
||||||
//! residual vector at the current time step
|
//! residual vector at the current time step
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param J Jacobian matrix to be filled in
|
* @param J Jacobian matrix to be filled in
|
||||||
* @param f Right hand side. This routine returns the current
|
* @param f Right hand side. This routine returns the current
|
||||||
|
|
@ -431,14 +433,14 @@ public:
|
||||||
* @param y value of the solution vector
|
* @param y value of the solution vector
|
||||||
* @param ydot value of the time derivative of the solution vector
|
* @param ydot value of the time derivative of the solution vector
|
||||||
* @param num_newt_its Number of newton iterations
|
* @param num_newt_its Number of newton iterations
|
||||||
*
|
*
|
||||||
* @return Returns a flag to indicate that operation is successful.
|
* @return Returns a flag to indicate that operation is successful.
|
||||||
* 1 Means a successful operation
|
* 1 Means a successful operation
|
||||||
* 0 Means an unsuccessful operation
|
* 0 Means an unsuccessful operation
|
||||||
*/
|
*/
|
||||||
int beuler_jac(GeneralMatrix& J, doublereal* const f,
|
int beuler_jac(GeneralMatrix &J, doublereal * const f,
|
||||||
doublereal time_curr, doublereal CJ, doublereal* const y,
|
doublereal time_curr, doublereal CJ, doublereal * const y,
|
||||||
doublereal* const ydot, int num_newt_its);
|
doublereal * const ydot, int num_newt_its);
|
||||||
|
|
||||||
//! Apply a filtering process to the step
|
//! Apply a filtering process to the step
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -448,7 +450,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns the norm of the value of the amount filtered
|
* @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
|
//! Apply a filter to the solution
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -458,8 +460,8 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns the norm of the value of the amount filtered
|
* @return Returns the norm of the value of the amount filtered
|
||||||
*/
|
*/
|
||||||
doublereal filterNewSolution(const doublereal timeCurrent, doublereal* const y_current,
|
doublereal filterNewSolution(const doublereal timeCurrent, doublereal * const y_current,
|
||||||
doublereal* const ydot_current);
|
doublereal * const ydot_current);
|
||||||
|
|
||||||
//! Return the factor by which the undamped Newton step 'step0'
|
//! 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.
|
//! must be multiplied in order to keep the update within the bounds of an accurate jacobian.
|
||||||
|
|
@ -477,8 +479,8 @@ public:
|
||||||
*
|
*
|
||||||
* @return returns the damping factor
|
* @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
|
//! Find a damping coefficient through a look-ahead mechanism
|
||||||
/*!
|
/*!
|
||||||
* On entry, step_1 must contain an undamped Newton step for the
|
* On entry, step_1 must contain an undamped Newton step for the
|
||||||
|
|
@ -490,9 +492,9 @@ public:
|
||||||
* returned in step_2.
|
* returned in step_2.
|
||||||
*
|
*
|
||||||
* @param time_curr Current physical time
|
* @param time_curr Current physical time
|
||||||
* @param y_n_curr Base value of the solution before any steps
|
* @param y_n_curr Base value of the solution before any steps
|
||||||
* are taken
|
* 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
|
* solution
|
||||||
* @param step_1 Initial step suggested.
|
* @param step_1 Initial step suggested.
|
||||||
* @param y_n_1 Value of y1, the suggested solution after damping
|
* @param y_n_1 Value of y1, the suggested solution after damping
|
||||||
|
|
@ -505,13 +507,13 @@ public:
|
||||||
*
|
*
|
||||||
* @return returns an integer indicating what happened.
|
* @return returns an integer indicating what happened.
|
||||||
*/
|
*/
|
||||||
int dampStep(const doublereal time_curr, const doublereal* const y_n_curr,
|
int dampStep(const doublereal time_curr, const doublereal * const y_n_curr,
|
||||||
const doublereal* const ydot_n_curr, doublereal* const step_1,
|
const doublereal * const ydot_n_curr, doublereal * const step_1,
|
||||||
doublereal* const y_n_1, doublereal* const ydot_n_1, doublereal* step_2,
|
doublereal * const y_n_1, doublereal * const ydot_n_1, doublereal * step_2,
|
||||||
doublereal& stepNorm_2, GeneralMatrix& jac, bool writetitle,
|
doublereal & stepNorm_2, GeneralMatrix& jac, bool writetitle,
|
||||||
int& num_backtracks);
|
int& num_backtracks);
|
||||||
|
|
||||||
//! Find the solution to F(X) = 0 by damped Newton iteration.
|
//! Find the solution to F(X) = 0 by damped Newton iteration.
|
||||||
/*!
|
/*!
|
||||||
* On
|
* On
|
||||||
* entry, x0 contains an initial estimate of the solution. On
|
* entry, x0 contains an initial estimate of the solution. On
|
||||||
|
|
@ -529,7 +531,7 @@ public:
|
||||||
* @param CJ Inverse of the value of deltaT
|
* @param CJ Inverse of the value of deltaT
|
||||||
* @param time_curr Current value of the time
|
* @param time_curr Current value of the time
|
||||||
* @param jac Matrix that will be used to store the jacobian
|
* @param jac Matrix that will be used to store the jacobian
|
||||||
* @param num_newt_its Number of newton iterations taken
|
* @param num_newt_its Number of newton iterations taken
|
||||||
* @param num_linear_solves Number of linear solves taken
|
* @param num_linear_solves Number of linear solves taken
|
||||||
* @param num_backtracks Number of backtracking steps taken
|
* @param num_backtracks Number of backtracking steps taken
|
||||||
* @param loglevelInput Input log level determines the amount of printing.
|
* @param loglevelInput Input log level determines the amount of printing.
|
||||||
|
|
@ -538,15 +540,15 @@ public:
|
||||||
* @return A positive value indicates a successful convergence
|
* @return A positive value indicates a successful convergence
|
||||||
* -1 Failed convergence
|
* -1 Failed convergence
|
||||||
*/
|
*/
|
||||||
int solve_nonlinear_problem(int SolnType, doublereal* const y_comm, doublereal* const ydot_comm, doublereal CJ,
|
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,
|
doublereal time_curr, GeneralMatrix & jac, int &num_newt_its,
|
||||||
int& num_linear_solves, int& num_backtracks, int loglevelInput);
|
int &num_linear_solves, int &num_backtracks, int loglevelInput);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Set the column scales
|
//! Set the column scales
|
||||||
void calcColumnScales();
|
void calcColumnScales();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Set the column scaling that are used for the inversion of the matrix
|
//! Set the column scaling that are used for the inversion of the matrix
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -556,19 +558,19 @@ public:
|
||||||
* Then, the column scales will be set to the solution error weighting factors. This has the
|
* Then, the column scales will be set to the solution error weighting factors. This has the
|
||||||
* effect of ensuring that all delta variables will have the same order of magnitude at convergence
|
* effect of ensuring that all delta variables will have the same order of magnitude at convergence
|
||||||
* end.
|
* 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,
|
* The final way to input the scales is to override the ResidJacEval member function call,
|
||||||
*
|
*
|
||||||
* calcSolnScales(double time_n, const double *m_y_n_curr, const double *m_y_nm1, double *m_colScales)
|
* calcSolnScales(double time_n, const double *m_y_n_curr, const double *m_y_nm1, double *m_colScales)
|
||||||
*
|
*
|
||||||
* Overriding this function call will trump all other ways to specify the column scaling factors.
|
* Overriding this function call will trump all other ways to specify the column scaling factors.
|
||||||
*
|
*
|
||||||
* @param useColScaling Turn this on if you want to use column scaling in the calculations
|
* @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.
|
* @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
|
//! Set the rowscaling that are used for the inversion of the matrix
|
||||||
|
|
@ -587,8 +589,8 @@ public:
|
||||||
* @param time_curr current value of the time
|
* @param time_curr current value of the time
|
||||||
* @param num_newt_its Current value of the number of newt its
|
* @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);
|
doublereal time_curr, int num_newt_its);
|
||||||
|
|
||||||
//! Print solution norm contribution
|
//! Print solution norm contribution
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -605,10 +607,10 @@ public:
|
||||||
* @param num_entries Number of entries to print out
|
* @param num_entries Number of entries to print out
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
print_solnDelta_norm_contrib(const doublereal* const step_1, const char* const stepNorm_1,
|
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 doublereal * const step_2, const char * const stepNorm_2,
|
||||||
const char* const title, const doublereal* const y_n_curr,
|
const char * const title, const doublereal * const y_n_curr,
|
||||||
const doublereal* const y_n_1, doublereal damp, size_t num_entries);
|
const doublereal * const y_n_1, doublereal damp, int num_entries);
|
||||||
|
|
||||||
//! Compute the Residual Weights
|
//! Compute the Residual Weights
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -627,9 +629,9 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* @param residWts Vector of length neq_
|
* @param residWts Vector of length neq_
|
||||||
*/
|
*/
|
||||||
void getResidWts(doublereal* const residWts) const;
|
void getResidWts(doublereal * const residWts) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Check to see if the nonlinear problem has converged
|
//! Check to see if the nonlinear problem has converged
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -655,7 +657,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param atol Vector of length neq_ that contains the tolerances to be used for the solution variables
|
* @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
|
//! Set the relative tolerances for the solution variables
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -680,9 +682,12 @@ public:
|
||||||
* and the residual norms are converging at the same time and thus accounts for some-illconditioning issues
|
* and the residual norms are converging at the same time and thus accounts for some-illconditioning issues
|
||||||
* but not all.
|
* 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
|
* The user specified tolerance for the residual is given by the following quantity
|
||||||
*
|
*
|
||||||
* residWeightNorm[i] = residAtol[i] + residRtol * m_rowWtScales[i] / neq
|
* residWeightNorm[i] = residAtol[i] + residRtol * m_rowWtScales[i] / neq
|
||||||
*
|
*
|
||||||
* @param residNormHandling Parameter that sets the default handling of the residual norms
|
* @param residNormHandling Parameter that sets the default handling of the residual norms
|
||||||
* 0 The residual weighting vector is calculated to make sure that the solution
|
* 0 The residual weighting vector is calculated to make sure that the solution
|
||||||
|
|
@ -692,7 +697,7 @@ public:
|
||||||
* 2 Use the minimum value of the residual weights calculcated by method 1 and 2.
|
* 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.
|
* 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
|
//! Set the value of the maximum # of newton iterations
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -709,7 +714,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void calcSolnToResNormVector();
|
void calcSolnToResNormVector();
|
||||||
|
|
||||||
//! Calculate the steepest descent direction and the Cauchy Point where the quadratic formulation
|
//! Calculate the steepest descent direction and the Cauchy Point where the quadratic formulation
|
||||||
//! of the nonlinear problem expects a minimum along the descent direction.
|
//! of the nonlinear problem expects a minimum along the descent direction.
|
||||||
/*!
|
/*!
|
||||||
* @param jac Jacobian matrix: must be unfactored.
|
* @param jac Jacobian matrix: must be unfactored.
|
||||||
|
|
@ -737,12 +742,12 @@ public:
|
||||||
*
|
*
|
||||||
* @param time_curr Current time
|
* @param time_curr Current time
|
||||||
* @param ydot0 INPUT Current value of the derivative of the solution vector
|
* @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
|
* @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
|
//! Setup the parameters for the double dog leg
|
||||||
/*!
|
/*!
|
||||||
* The calls to the doCauchySolve() and doNewtonSolve() routines are done at the main level. This routine comes
|
* The calls to the doCauchySolve() and doNewtonSolve() routines are done at the main level. This routine comes
|
||||||
|
|
@ -758,7 +763,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns the leg number ( 0, 1, or 2).
|
* @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
|
//! Given a trust distance, this routine calculates the intersection of the this distance with the
|
||||||
//! double dogleg curve
|
//! double dogleg curve
|
||||||
|
|
@ -768,7 +773,7 @@ public:
|
||||||
* @param alpha (OUTPUT) Returns the relative distance along the appropriate leg
|
* @param alpha (OUTPUT) Returns the relative distance along the appropriate leg
|
||||||
* @return leg (OUTPUT) Returns the leg ID (0, 1, or 2)
|
* @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.
|
//! Initialize the size of the trust vector.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -787,7 +792,7 @@ public:
|
||||||
* 2 Factor of the first Cauchy Point distance
|
* 2 Factor of the first Cauchy Point distance
|
||||||
* 3 Factor of the first Newton step distance
|
* 3 Factor of the first Newton step distance
|
||||||
*
|
*
|
||||||
* @param factor Factor to use in combination with the method
|
* @param factor Factor to use in combination with the method
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void setTrustRegionInitializationMethod(int method, doublereal factor);
|
void setTrustRegionInitializationMethod(int method, doublereal factor);
|
||||||
|
|
@ -795,7 +800,7 @@ public:
|
||||||
|
|
||||||
//! Damp using the dog leg approach
|
//! Damp using the dog leg approach
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
* @param time_curr INPUT Current value of the time
|
* @param time_curr INPUT Current value of the time
|
||||||
* @param y_n_curr INPUT Current value of the solution vector
|
* @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 ydot_n_curr INPUT Current value of the derivative of the solution vector
|
||||||
|
|
@ -817,10 +822,10 @@ public:
|
||||||
* 0 Uncertain Success: s1 is about the same as s0
|
* 0 Uncertain Success: s1 is about the same as s0
|
||||||
* -2 Unsuccessful step.
|
* -2 Unsuccessful step.
|
||||||
*/
|
*/
|
||||||
int dampDogLeg(const doublereal time_curr, const doublereal* y_n_curr,
|
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* const y_n_1, doublereal* const ydot_n_1,
|
||||||
doublereal& stepNorm_1, doublereal& stepNorm_2, GeneralMatrix& jac, int& num_backtracks);
|
doublereal& stepNorm_1, doublereal& stepNorm_2, GeneralMatrix& jac, int& num_backtracks);
|
||||||
|
|
||||||
//! Decide whether the current step is acceptable and adjust the trust region size
|
//! Decide whether the current step is acceptable and adjust the trust region size
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -835,8 +840,8 @@ public:
|
||||||
* @param y_n_curr INPUT Current value of the solution vector
|
* @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 ydot_n_curr INPUT Current value of the derivative of the solution vector
|
||||||
* @param step_1 INPUT Trial step
|
* @param step_1 INPUT Trial step
|
||||||
* @param y_n_1 OUTPUT Solution values 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 derivatives of solution at the conditions which are evaluated 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
|
* @param trustDeltaOld INPUT Value of the trust length at the old conditions
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
@ -846,15 +851,15 @@ public:
|
||||||
* 0 The step passed.
|
* 0 The step passed.
|
||||||
* -1 The step size is now too small (||d || < 0.1). A really small step isn't decreasing the function.
|
* -1 The step size is now too small (||d || < 0.1). A really small step isn't decreasing the function.
|
||||||
* This is an error condition.
|
* This is an error condition.
|
||||||
* -2 Current value of the solution vector caused a residual error in its evaluation.
|
* -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.
|
* 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,
|
int decideStep(const doublereal time_curr, int leg, doublereal alpha, const doublereal * const y_n_curr,
|
||||||
const doublereal* const ydot_n_curr,
|
const doublereal * const ydot_n_curr,
|
||||||
const std::vector<doublereal> & step_1,
|
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.
|
//! Calculated the expected residual along the double dogleg curve.
|
||||||
/*!
|
/*!
|
||||||
* @param leg 0, 1, or 2 representing the curves of the dogleg
|
* @param leg 0, 1, or 2 representing the curves of the dogleg
|
||||||
* @param alpha Relative distance along the particular curve.
|
* @param alpha Relative distance along the particular curve.
|
||||||
|
|
@ -873,12 +878,12 @@ public:
|
||||||
* @param legBest OUTPUT leg of the dogleg that gives the lowest residual
|
* @param legBest OUTPUT leg of the dogleg that gives the lowest residual
|
||||||
* @param alphaBest OUTPUT distance along dogleg for best result.
|
* @param alphaBest OUTPUT distance along dogleg for best result.
|
||||||
*/
|
*/
|
||||||
void residualComparisonLeg(const doublereal time_curr, const doublereal* const ydot0, int& legBest,
|
void residualComparisonLeg(const doublereal time_curr, const doublereal * const ydot0, int & legBest,
|
||||||
doublereal& alphaBest) const;
|
doublereal & alphaBest) const;
|
||||||
|
|
||||||
//! Set the print level from the nonlinear solver
|
//! Set the print level from the nonlinear solver
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
* 0 -> absolutely nothing is printed for a single time step.
|
* 0 -> absolutely nothing is printed for a single time step.
|
||||||
* 1 -> One line summary per solve_nonlinear call
|
* 1 -> One line summary per solve_nonlinear call
|
||||||
* 2 -> short description, points of interest: Table of nonlinear solve - one line per iteration
|
* 2 -> short description, points of interest: Table of nonlinear solve - one line per iteration
|
||||||
|
|
@ -912,21 +917,21 @@ public:
|
||||||
* MEMBER DATA
|
* MEMBER DATA
|
||||||
* ------------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Pointer to the residual and jacobian evaluator for the
|
//! Pointer to the residual and jacobian evaluator for the
|
||||||
//! function
|
//! function
|
||||||
/*!
|
/*!
|
||||||
* See ResidJacEval.h for an evaluator.
|
* See ResidJacEval.h for an evaluator.
|
||||||
*/
|
*/
|
||||||
ResidJacEval* m_func;
|
ResidJacEval *m_func;
|
||||||
|
|
||||||
//! Solution type
|
//! Solution type
|
||||||
int solnType_;
|
int solnType_;
|
||||||
|
|
||||||
//! Local copy of the number of equations
|
//! Local copy of the number of equations
|
||||||
size_t neq_;
|
int neq_;
|
||||||
|
|
||||||
//! Soln error weights
|
//! Soln error weights
|
||||||
std::vector<doublereal> m_ewt;
|
std::vector<doublereal> m_ewt;
|
||||||
|
|
||||||
|
|
@ -970,7 +975,7 @@ private:
|
||||||
|
|
||||||
//! Weights for normalizing the values of the residuals
|
//! Weights for normalizing the values of the residuals
|
||||||
/*!
|
/*!
|
||||||
* They are calculated as the sum of the absolute values of the jacobian
|
* They are calculated as the sum of the absolute values of the jacobian
|
||||||
* multiplied by the solution weight function.
|
* multiplied by the solution weight function.
|
||||||
* This is carried out in scaleMatrix().
|
* This is carried out in scaleMatrix().
|
||||||
*/
|
*/
|
||||||
|
|
@ -997,7 +1002,7 @@ private:
|
||||||
//! Norm of the residual at the start of each nonlinear iteration
|
//! Norm of the residual at the start of each nonlinear iteration
|
||||||
doublereal m_normResid_0;
|
doublereal m_normResid_0;
|
||||||
|
|
||||||
//! Norm of the residual after it has been bounded
|
//! Norm of the residual after it has been bounded
|
||||||
doublereal m_normResid_Bound;
|
doublereal m_normResid_Bound;
|
||||||
|
|
||||||
//! Norm of the residual at the end of the first leg of the current iteration
|
//! Norm of the residual at the end of the first leg of the current iteration
|
||||||
|
|
@ -1067,8 +1072,10 @@ private:
|
||||||
//! Total number of newton iterations
|
//! Total number of newton iterations
|
||||||
int m_numTotalNewtIts;
|
int m_numTotalNewtIts;
|
||||||
|
|
||||||
|
public:
|
||||||
//! Minimum number of newton iterations to use
|
//! Minimum number of newton iterations to use
|
||||||
int m_min_newt_its;
|
int m_min_newt_its;
|
||||||
|
private:
|
||||||
|
|
||||||
//! Maximum number of newton iterations
|
//! Maximum number of newton iterations
|
||||||
int maxNewtIts_;
|
int maxNewtIts_;
|
||||||
|
|
@ -1086,14 +1093,14 @@ private:
|
||||||
//! Current system time
|
//! Current system time
|
||||||
/*!
|
/*!
|
||||||
* Note, we assume even for steady state problems that the residual
|
* Note, we assume even for steady state problems that the residual
|
||||||
* is a function of a system time.
|
* is a function of a system time.
|
||||||
*/
|
*/
|
||||||
doublereal time_n;
|
doublereal time_n;
|
||||||
|
|
||||||
//! Boolean indicating matrix conditioning
|
//! Boolean indicating matrix conditioning
|
||||||
int m_matrixConditioning;
|
int m_matrixConditioning;
|
||||||
|
|
||||||
//! Order of the time step method = 1
|
//! Order of the time step method = 1
|
||||||
int m_order;
|
int m_order;
|
||||||
|
|
||||||
//! value of the relative tolerance to use in solving the equation set
|
//! value of the relative tolerance to use in solving the equation set
|
||||||
|
|
@ -1103,7 +1110,7 @@ private:
|
||||||
doublereal atolBase_;
|
doublereal atolBase_;
|
||||||
|
|
||||||
//! Pointer containing the solution derivative at the previous time step
|
//! Pointer containing the solution derivative at the previous time step
|
||||||
doublereal* m_ydot_nm1;
|
doublereal *m_ydot_nm1;
|
||||||
|
|
||||||
//! absolute tolerance in the solution unknown
|
//! 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
|
* 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
|
* 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
|
* 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
|
* 5 -> Algorithm information on the nonlinear iterates are printed out
|
||||||
* 6 -> Additional info 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.
|
* 7 -> Additional info on the linear solve is printed out.
|
||||||
* 8 -> Info on a per iterate of 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
|
//! 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
|
//! Hessian
|
||||||
Cantera::GeneralMatrix* HessianPtr_;
|
Cantera::GeneralMatrix * HessianPtr_;
|
||||||
|
|
||||||
/*********************************************************************************************
|
/*********************************************************************************************
|
||||||
* VARIABLES ASSOCIATED WITH STEPS AND ASSOCIATED DOUBLE DOGLEG PARAMETERS
|
* VARIABLES ASSOCIATED WITH STEPS AND ASSOCIATED DOUBLE DOGLEG PARAMETERS
|
||||||
|
|
@ -1176,16 +1185,16 @@ private:
|
||||||
|
|
||||||
//! Residual dot Jd norm
|
//! Residual dot Jd norm
|
||||||
/*!
|
/*!
|
||||||
* This is equal to R_hat dot J_hat d_y_descent
|
* This is equal to R_hat dot J_hat d_y_descent
|
||||||
*/
|
*/
|
||||||
doublereal RJd_norm_;
|
doublereal RJd_norm_;
|
||||||
|
|
||||||
//! Value of lambdaStar_ which is used to calculate the Cauchy point
|
//! Value of lambdaStar_ which is used to calculate the Cauchy point
|
||||||
doublereal lambdaStar_;
|
doublereal lambdaStar_;
|
||||||
|
|
||||||
//! Jacobian times the steepest descent direction in the normalized coordinates.
|
//! Jacobian times the steepest descent direction in the normalized coordinates.
|
||||||
/*!
|
/*!
|
||||||
* This is equal to [ Jhat d^y_{descent} ] in the notes, Eqn. 18.
|
* This is equal to [ Jhat d^y_{descent} ] in the notes, Eqn. 18.
|
||||||
*/
|
*/
|
||||||
std::vector<doublereal> Jd_;
|
std::vector<doublereal> Jd_;
|
||||||
|
|
||||||
|
|
@ -1195,7 +1204,7 @@ private:
|
||||||
//! Current norm of the vector deltaX_trust_ in terms of the solution norm
|
//! Current norm of the vector deltaX_trust_ in terms of the solution norm
|
||||||
mutable doublereal norm_deltaX_trust_;
|
mutable doublereal norm_deltaX_trust_;
|
||||||
|
|
||||||
//! Current value of trust radius. This is used with deltaX_trust_ to
|
//! Current value of trust radius. This is used with deltaX_trust_ to
|
||||||
//! calculate the max step size.
|
//! calculate the max step size.
|
||||||
doublereal trustDelta_;
|
doublereal trustDelta_;
|
||||||
|
|
||||||
|
|
@ -1253,7 +1262,7 @@ private:
|
||||||
//! Factor indicating how much trust region has been changed next iteration - output variable
|
//! Factor indicating how much trust region has been changed next iteration - output variable
|
||||||
doublereal NextTrustFactor_;
|
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_;
|
bool ResidWtsReevaluated_;
|
||||||
|
|
||||||
//! Expected DResid_dS for the steepest descent path - output variable
|
//! Expected DResid_dS for the steepest descent path - output variable
|
||||||
|
|
@ -1272,7 +1281,7 @@ private:
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
*****************************************************************************************/
|
*****************************************************************************************/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Turn off printing of time
|
//! Turn off printing of time
|
||||||
/*!
|
/*!
|
||||||
* Necessary to do for test suites
|
* Necessary to do for test suites
|
||||||
|
|
@ -1297,7 +1306,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool s_alwaysAssumeNewtonGood;
|
static bool s_alwaysAssumeNewtonGood;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,23 @@ public:
|
||||||
* These routines are basically wrappers around the derived copy
|
* These routines are basically wrappers around the derived copy
|
||||||
* constructor.
|
* 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
|
// overloaded base class methods
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@ enum TransportPropertyType {
|
||||||
TP_THERMALCOND,
|
TP_THERMALCOND,
|
||||||
TP_DIFFUSIVITY,
|
TP_DIFFUSIVITY,
|
||||||
TP_HYDRORADIUS,
|
TP_HYDRORADIUS,
|
||||||
TP_ELECTCOND
|
TP_ELECTCOND,
|
||||||
|
TP_DEFECTCONC,
|
||||||
|
TP_DEFECTDIFF
|
||||||
};
|
};
|
||||||
|
|
||||||
//====================================================================================================================
|
//====================================================================================================================
|
||||||
|
|
@ -96,10 +98,10 @@ public:
|
||||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* is creating a parameterization for (e.g., viscosity)
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* @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);
|
TransportPropertyType tp_ind = TP_UNKNOWN, const thermo_t* thermo = 0);
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
/*!
|
/*!
|
||||||
* @param right Object to be copied
|
* @param right Object to be copied
|
||||||
|
|
@ -224,10 +226,10 @@ public:
|
||||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* is creating a parameterization for (e.g., viscosity)
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* @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,
|
LTPspecies_Const(const XML_Node &propNode, const std::string name,
|
||||||
TransportPropertyType tp_ind, const thermo_t* const thermo);
|
TransportPropertyType tp_ind, const thermo_t * const thermo);
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
/*!
|
/*!
|
||||||
* @param right Object to be copied
|
* @param right Object to be copied
|
||||||
|
|
@ -308,10 +310,11 @@ public:
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* is creating a parameterization for (e.g., viscosity)
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* @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
|
//! Copy constructor
|
||||||
/*!
|
/*!
|
||||||
* @param right Object to be copied
|
* @param right Object to be copied
|
||||||
|
|
@ -415,9 +418,10 @@ public:
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* is creating a parameterization for (e.g., viscosity)
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* @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
|
//! Copy constructor
|
||||||
/*!
|
/*!
|
||||||
* @param right Object to be copied
|
* @param right Object to be copied
|
||||||
|
|
@ -503,9 +507,10 @@ public:
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* is creating a parameterization for (e.g., viscosity)
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* @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);
|
TransportPropertyType tp_ind, const thermo_t* thermo);
|
||||||
|
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// Cantera includes
|
// Cantera includes
|
||||||
|
#include "LTPspecies.h"
|
||||||
#include "TransportBase.h"
|
#include "TransportBase.h"
|
||||||
#include "cantera/numerics/DenseMatrix.h"
|
#include "cantera/numerics/DenseMatrix.h"
|
||||||
|
|
||||||
|
|
@ -62,14 +63,47 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual Transport* duplMyselfAsTransport() const;
|
virtual Transport* duplMyselfAsTransport() const;
|
||||||
|
|
||||||
|
|
||||||
virtual int model() const {
|
virtual int model() const {
|
||||||
return cSolidTransport;
|
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();
|
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);
|
virtual void getMixDiffCoeffs(doublereal* const d);
|
||||||
|
|
||||||
|
|
||||||
//! Compute the electrical mobilities of the species from the diffusion coefficients,
|
//! Compute the electrical mobilities of the species from the diffusion coefficients,
|
||||||
//! using the Einstein relation.
|
//! using the Einstein relation.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -87,17 +121,72 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void getMobilities(doublereal* const mobil);
|
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);
|
virtual void setParameters(const int n, const int k, const doublereal* const p);
|
||||||
|
|
||||||
friend class TransportFactory;
|
friend class TransportFactory;
|
||||||
|
|
||||||
/**
|
protected:
|
||||||
* The electrical conductivity (Siemens/m).
|
|
||||||
|
//! 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
|
//! 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 TransportParams;
|
||||||
class GasTransportParams;
|
class GasTransportParams;
|
||||||
class LiquidTransportParams;
|
class LiquidTransportParams;
|
||||||
|
class SolidTransportData;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \addtogroup tranprops
|
* \addtogroup tranprops
|
||||||
|
|
@ -833,14 +834,40 @@ protected:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Specifies the %ThermPhase object.
|
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
|
* @param thermo Reference to the ThermoPhase object that
|
||||||
* the transport object will use
|
* the transport object will use
|
||||||
*/
|
*/
|
||||||
void setThermo(thermo_t& thermo);
|
virtual void setThermo(thermo_t& thermo);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
//! Enable the transport object for use.
|
//! Enable the transport object for use.
|
||||||
/*!
|
/*!
|
||||||
* Once finalize() has been called, the
|
* Once finalize() has been called, the
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "TransportBase.h"
|
#include "TransportBase.h"
|
||||||
#include "cantera/base/FactoryBase.h"
|
#include "cantera/base/FactoryBase.h"
|
||||||
#include "LiquidTransportParams.h"
|
#include "LiquidTransportParams.h"
|
||||||
|
#include "SolidTransportData.h"
|
||||||
|
|
||||||
//======================================================================================================================
|
//======================================================================================================================
|
||||||
namespace Cantera
|
namespace Cantera
|
||||||
|
|
@ -78,6 +79,9 @@ public:
|
||||||
virtual ~TransportFactory() {}
|
virtual ~TransportFactory() {}
|
||||||
|
|
||||||
//! Get the name of the transport model corresponding to the specified constant.
|
//! 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);
|
static std::string modelName(int model);
|
||||||
|
|
||||||
//! Make one of several transport models, and return a base class pointer to it.
|
//! Make one of several transport models, and return a base class pointer to it.
|
||||||
|
|
@ -90,8 +94,9 @@ public:
|
||||||
* @param tp_ind TransportPropertyType class
|
* @param tp_ind TransportPropertyType class
|
||||||
* @param thermo Pointer to the %ThermoPhase class
|
* @param thermo Pointer to the %ThermoPhase class
|
||||||
*/
|
*/
|
||||||
virtual LTPspecies* newLTP(const XML_Node& trNode, std::string& name,
|
|
||||||
TransportPropertyType tp_ind, thermo_t* thermo);
|
virtual LTPspecies* newLTP(const XML_Node &trNode, const std::string &name,
|
||||||
|
TransportPropertyType tp_ind, thermo_t* thermo);
|
||||||
|
|
||||||
|
|
||||||
//! Factory function for the construction of new LiquidTranInteraction
|
//! Factory function for the construction of new LiquidTranInteraction
|
||||||
|
|
@ -164,6 +169,26 @@ public:
|
||||||
|
|
||||||
private:
|
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
|
//! Static instance of the factor -> This is the only instance of this
|
||||||
//! object allowed
|
//! object allowed
|
||||||
static TransportFactory* s_factory;
|
static TransportFactory* s_factory;
|
||||||
|
|
@ -239,6 +264,22 @@ private:
|
||||||
void getLiquidInteractionsTransportData(const XML_Node& phaseTran_db, XML_Node& log,
|
void getLiquidInteractionsTransportData(const XML_Node& phaseTran_db, XML_Node& log,
|
||||||
const std::vector<std::string>& names, LiquidTransportParams& tr);
|
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
|
//! Generate polynomial fits to the viscosity, conductivity, and
|
||||||
//! the binary diffusion coefficients
|
//! the binary diffusion coefficients
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -307,6 +348,15 @@ private:
|
||||||
*/
|
*/
|
||||||
void setupLiquidTransport(std::ostream& flog, thermo_t* thermo, int log_level, LiquidTransportParams& trParam);
|
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
|
//! Second-order correction to the binary diffusion coefficients
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
// Cantera includes
|
// Cantera includes
|
||||||
#include "cantera/thermo/SurfPhase.h"
|
#include "cantera/thermo/SurfPhase.h"
|
||||||
#include "cantera/kinetics/InterfaceKinetics.h"
|
#include "cantera/kinetics/InterfaceKinetics.h"
|
||||||
#include "kinetics/ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
#include "Cabinet.h"
|
#include "Cabinet.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ namespace Cantera
|
||||||
// Constructor.
|
// Constructor.
|
||||||
MultiPhase::MultiPhase() :
|
MultiPhase::MultiPhase() :
|
||||||
m_np(0),
|
m_np(0),
|
||||||
m_temp(0.0),
|
m_temp(298.15),
|
||||||
m_press(0.0),
|
m_press(OneBar),
|
||||||
m_nel(0),
|
m_nel(0),
|
||||||
m_nsp(0),
|
m_nsp(0),
|
||||||
m_init(false),
|
m_init(false),
|
||||||
|
|
@ -37,8 +37,8 @@ MultiPhase::MultiPhase() :
|
||||||
*/
|
*/
|
||||||
MultiPhase::MultiPhase(const MultiPhase& right) :
|
MultiPhase::MultiPhase(const MultiPhase& right) :
|
||||||
m_np(0),
|
m_np(0),
|
||||||
m_temp(0.0),
|
m_temp(298.15),
|
||||||
m_press(0.0),
|
m_press(OneBar),
|
||||||
m_nel(0),
|
m_nel(0),
|
||||||
m_nsp(0),
|
m_nsp(0),
|
||||||
m_init(false),
|
m_init(false),
|
||||||
|
|
@ -160,8 +160,8 @@ addPhase(ThermoPhase* p, doublereal moles)
|
||||||
|
|
||||||
// If the mixture temperature hasn't been set, then set the
|
// If the mixture temperature hasn't been set, then set the
|
||||||
// temperature and pressure to the values for the phase being
|
// temperature and pressure to the values for the phase being
|
||||||
// added.
|
// added. There is no good way to do this. However, this will be overridden later.
|
||||||
if (m_temp == 0.0 && p->temperature() > 0.0) {
|
if (m_temp == 298.15 && p->temperature() > 2.0E-3) {
|
||||||
m_temp = p->temperature();
|
m_temp = p->temperature();
|
||||||
m_press = p->pressure();
|
m_press = p->pressure();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@
|
||||||
#include "cantera/equil/vcs_prob.h"
|
#include "cantera/equil/vcs_prob.h"
|
||||||
#include "cantera/equil/vcs_internal.h"
|
#include "cantera/equil/vcs_internal.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.h"
|
#include "cantera/equil/vcs_VolPhase.h"
|
||||||
#include "vcs_species_thermo.h"
|
#include "cantera/equil/vcs_species_thermo.h"
|
||||||
#include "vcs_SpeciesProperties.h"
|
|
||||||
|
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#include "cantera/equil/vcs_solve.h"
|
||||||
|
|
||||||
|
|
@ -26,6 +25,7 @@
|
||||||
#include "cantera/thermo/IdealSolidSolnPhase.h"
|
#include "cantera/thermo/IdealSolidSolnPhase.h"
|
||||||
#include "cantera/thermo/IdealMolalSoln.h"
|
#include "cantera/thermo/IdealMolalSoln.h"
|
||||||
#include "cantera/equil/ChemEquil.h"
|
#include "cantera/equil/ChemEquil.h"
|
||||||
|
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
* @file vcs_SpeciesProperties.cpp
|
* @file vcs_SpeciesProperties.cpp
|
||||||
*/
|
*/
|
||||||
#include "cantera/equil/vcs_defs.h"
|
#include "cantera/equil/vcs_defs.h"
|
||||||
#include "vcs_SpeciesProperties.h"
|
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.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/equil/vcs_internal.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#include "cantera/equil/vcs_solve.h"
|
||||||
#include "cantera/equil/vcs_internal.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 "cantera/equil/vcs_VolPhase.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
*/
|
*/
|
||||||
#include "cantera/equil/vcs_VolPhase.h"
|
#include "cantera/equil/vcs_VolPhase.h"
|
||||||
#include "cantera/equil/vcs_internal.h"
|
#include "cantera/equil/vcs_internal.h"
|
||||||
#include "vcs_SpeciesProperties.h"
|
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||||
#include "vcs_species_thermo.h"
|
#include "cantera/equil/vcs_species_thermo.h"
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#include "cantera/equil/vcs_solve.h"
|
||||||
|
|
||||||
#include "cantera/thermo/ThermoPhase.h"
|
#include "cantera/thermo/ThermoPhase.h"
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
#include "cantera/equil/vcs_prob.h"
|
#include "cantera/equil/vcs_prob.h"
|
||||||
#include "cantera/equil/vcs_internal.h"
|
#include "cantera/equil/vcs_internal.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.h"
|
#include "cantera/equil/vcs_VolPhase.h"
|
||||||
#include "vcs_species_thermo.h"
|
#include "cantera/equil/vcs_species_thermo.h"
|
||||||
#include "vcs_SpeciesProperties.h"
|
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.h"
|
#include "cantera/equil/vcs_VolPhase.h"
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#include "cantera/equil/vcs_solve.h"
|
||||||
#include "cantera/equil/equil.h"
|
#include "cantera/equil/equil.h"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#include "cantera/equil/vcs_solve.h"
|
||||||
#include "cantera/equil/vcs_internal.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 "cantera/equil/vcs_VolPhase.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include "cantera/equil/vcs_internal.h"
|
#include "cantera/equil/vcs_internal.h"
|
||||||
#include "cantera/equil/vcs_prob.h"
|
#include "cantera/equil/vcs_prob.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.h"
|
#include "cantera/equil/vcs_VolPhase.h"
|
||||||
#include "vcs_SpeciesProperties.h"
|
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "cantera/equil/vcs_prob.h"
|
#include "cantera/equil/vcs_prob.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.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/equil/vcs_internal.h"
|
||||||
|
|
||||||
#include "cantera/thermo/ThermoPhase.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_internal.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.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 "cantera/equil/vcs_solve.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
#include "cantera/equil/vcs_prob.h"
|
#include "cantera/equil/vcs_prob.h"
|
||||||
|
|
||||||
#include "cantera/equil/vcs_VolPhase.h"
|
#include "cantera/equil/vcs_VolPhase.h"
|
||||||
#include "vcs_SpeciesProperties.h"
|
#include "cantera/equil/vcs_SpeciesProperties.h"
|
||||||
#include "vcs_species_thermo.h"
|
#include "cantera/equil/vcs_species_thermo.h"
|
||||||
|
|
||||||
#include "cantera/base/clockWC.h"
|
#include "cantera/base/clockWC.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#include "cantera/equil/vcs_solve.h"
|
||||||
#include "cantera/equil/vcs_internal.h"
|
#include "cantera/equil/vcs_internal.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.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/ctexceptions.h"
|
||||||
|
|
||||||
#include "cantera/base/clockWC.h"
|
#include "cantera/base/clockWC.h"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#include "cantera/equil/vcs_solve.h"
|
||||||
#include "cantera/equil/vcs_internal.h"
|
#include "cantera/equil/vcs_internal.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.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/equil/vcs_prob.h"
|
||||||
|
|
||||||
#include "cantera/base/clockWC.h"
|
#include "cantera/base/clockWC.h"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "cantera/equil/vcs_solve.h"
|
#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_defs.h"
|
||||||
#include "cantera/equil/vcs_VolPhase.h"
|
#include "cantera/equil/vcs_VolPhase.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
*/
|
*/
|
||||||
// Copyright 2001 California Institute of Technology
|
// Copyright 2001 California Institute of Technology
|
||||||
|
|
||||||
#include "ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
#include "cantera/numerics/Integrator.h"
|
#include "cantera/numerics/Integrator.h"
|
||||||
#include "solveSP.h"
|
#include "cantera/kinetics/solveSP.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include "cantera/kinetics/ReactionData.h"
|
#include "cantera/kinetics/ReactionData.h"
|
||||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||||
|
|
||||||
#include "ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "cantera/kinetics/StoichManager.h"
|
#include "cantera/kinetics/StoichManager.h"
|
||||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||||
|
|
||||||
#include "ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
* See file License.txt for licensing information.
|
* See file License.txt for licensing information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "solveSP.h"
|
#include "cantera/kinetics/solveSP.h"
|
||||||
#include "cantera/base/clockWC.h"
|
#include "cantera/base/clockWC.h"
|
||||||
#include "cantera/numerics/ctlapack.h"
|
#include "cantera/numerics/ctlapack.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
// Copyright 2001 California Institute of Technology
|
// Copyright 2001 California Institute of Technology
|
||||||
#include "cantera/base/config.h"
|
#include "cantera/base/config.h"
|
||||||
|
|
||||||
#include "CVodesIntegrator.h"
|
#include "cantera/numerics/CVodesIntegrator.h"
|
||||||
#include "cantera/base/stringUtils.h"
|
#include "cantera/base/stringUtils.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAS_SUNDIALS
|
#ifdef HAS_SUNDIALS
|
||||||
#include "CVodesIntegrator.h"
|
#include "cantera/numerics/CVodesIntegrator.h"
|
||||||
#else
|
#else
|
||||||
#include "CVodeInt.h"
|
#include "CVodeInt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -328,14 +328,28 @@ operator=(const HMWSoln& b)
|
||||||
m_Lambda_nj_LL = b.m_Lambda_nj_LL;
|
m_Lambda_nj_LL = b.m_Lambda_nj_LL;
|
||||||
m_Lambda_nj_P = b.m_Lambda_nj_P;
|
m_Lambda_nj_P = b.m_Lambda_nj_P;
|
||||||
m_Lambda_nj_coeff = b.m_Lambda_nj_coeff;
|
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_Scaled = b.m_lnActCoeffMolal_Scaled;
|
||||||
m_lnActCoeffMolal_Unscaled = b.m_lnActCoeffMolal_Unscaled;
|
m_lnActCoeffMolal_Unscaled = b.m_lnActCoeffMolal_Unscaled;
|
||||||
|
|
||||||
|
m_dlnActCoeffMolaldT_Scaled = b.m_dlnActCoeffMolaldT_Scaled;
|
||||||
m_dlnActCoeffMolaldT_Unscaled = b.m_dlnActCoeffMolaldT_Unscaled;
|
m_dlnActCoeffMolaldT_Unscaled = b.m_dlnActCoeffMolaldT_Unscaled;
|
||||||
|
|
||||||
|
m_d2lnActCoeffMolaldT2_Scaled = b.m_d2lnActCoeffMolaldT2_Scaled;
|
||||||
m_d2lnActCoeffMolaldT2_Unscaled= b.m_d2lnActCoeffMolaldT2_Unscaled;
|
m_d2lnActCoeffMolaldT2_Unscaled= b.m_d2lnActCoeffMolaldT2_Unscaled;
|
||||||
|
|
||||||
|
m_dlnActCoeffMolaldP_Scaled = b.m_dlnActCoeffMolaldP_Scaled;
|
||||||
m_dlnActCoeffMolaldP_Unscaled = b.m_dlnActCoeffMolaldP_Unscaled;
|
m_dlnActCoeffMolaldP_Unscaled = b.m_dlnActCoeffMolaldP_Unscaled;
|
||||||
m_dlnActCoeffMolaldT_Scaled = b.m_dlnActCoeffMolaldT_Unscaled;
|
|
||||||
m_d2lnActCoeffMolaldT2_Scaled = b.m_d2lnActCoeffMolaldT2_Unscaled;
|
m_molalitiesCropped = b.m_molalitiesCropped;
|
||||||
m_dlnActCoeffMolaldP_Scaled = b.m_dlnActCoeffMolaldP_Unscaled;
|
m_molalitiesAreCropped = b.m_molalitiesAreCropped;
|
||||||
|
m_CounterIJ = b.m_CounterIJ;
|
||||||
|
|
||||||
m_gfunc_IJ = b.m_gfunc_IJ;
|
m_gfunc_IJ = b.m_gfunc_IJ;
|
||||||
m_g2func_IJ = b.m_g2func_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_min = b.CROP_ln_gamma_k_min;
|
||||||
CROP_ln_gamma_k_max = b.CROP_ln_gamma_k_max;
|
CROP_ln_gamma_k_max = b.CROP_ln_gamma_k_max;
|
||||||
CROP_speciesCropped_ = b.CROP_speciesCropped_;
|
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;
|
m_debugCalc = b.m_debugCalc;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -2645,9 +2657,9 @@ s_updatePitzer_lnMolalityActCoeff() const
|
||||||
if (counterIJ == 2) {
|
if (counterIJ == 2) {
|
||||||
printf("%s %s\n", speciesName(i).c_str(),
|
printf("%s %s\n", speciesName(i).c_str(),
|
||||||
speciesName(j).c_str());
|
speciesName(j).c_str());
|
||||||
printf("beta0MX[%d] = %g\n", counterIJ, beta0MX[counterIJ]);
|
printf("beta0MX[%d] = %g\n", (int) counterIJ, beta0MX[counterIJ]);
|
||||||
printf("beta1MX[%d] = %g\n", counterIJ, beta1MX[counterIJ]);
|
printf("beta1MX[%d] = %g\n", (int) counterIJ, beta1MX[counterIJ]);
|
||||||
printf("beta2MX[%d] = %g\n", counterIJ, beta2MX[counterIJ]);
|
printf("beta2MX[%d] = %g\n", (int) counterIJ, beta2MX[counterIJ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2662,7 +2674,7 @@ s_updatePitzer_lnMolalityActCoeff() const
|
||||||
#ifdef DEBUG_MODE
|
#ifdef DEBUG_MODE
|
||||||
if (m_debugCalc) {
|
if (m_debugCalc) {
|
||||||
printf("%d %g: %g %g %g %g\n",
|
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]);
|
beta1MX[counterIJ], beta2MX[counterIJ], gfunc[counterIJ]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2722,7 +2734,7 @@ s_updatePitzer_lnMolalityActCoeff() const
|
||||||
if (counterIJ == 2) {
|
if (counterIJ == 2) {
|
||||||
printf("%s %s\n", speciesName(i).c_str(),
|
printf("%s %s\n", speciesName(i).c_str(),
|
||||||
speciesName(j).c_str());
|
speciesName(j).c_str());
|
||||||
printf("CphiMX[%d] = %g\n", counterIJ, CphiMX[counterIJ]);
|
printf("CphiMX[%d] = %g\n", (int) counterIJ, CphiMX[counterIJ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -4597,7 +4609,7 @@ void HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2() const
|
||||||
#ifdef DEBUG_MODE
|
#ifdef DEBUG_MODE
|
||||||
if (m_debugCalc) {
|
if (m_debugCalc) {
|
||||||
printf("%d %g: %g %g %g %g\n",
|
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]);
|
beta1MX_LL[counterIJ], beta2MX_LL[counterIJ], gfunc[counterIJ]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -5479,7 +5491,7 @@ void HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP() const
|
||||||
#ifdef DEBUG_MODE
|
#ifdef DEBUG_MODE
|
||||||
if (m_debugCalc) {
|
if (m_debugCalc) {
|
||||||
printf("%d %g: %g %g %g %g\n",
|
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]);
|
beta1MX_P[counterIJ], beta2MX_P[counterIJ], gfunc[counterIJ]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,8 @@ IdealSolidSolnPhase& IdealSolidSolnPhase::
|
||||||
operator=(const IdealSolidSolnPhase& b)
|
operator=(const IdealSolidSolnPhase& b)
|
||||||
{
|
{
|
||||||
if (this != &b) {
|
if (this != &b) {
|
||||||
//ThermoPhase::operator=(b);
|
ThermoPhase::operator=(b);
|
||||||
// m_spthermo = dupMyselfAsSpeciesThermo(b.m_spthermo);
|
|
||||||
m_formGC = b.m_formGC;
|
m_formGC = b.m_formGC;
|
||||||
m_Pref = b.m_Pref;
|
m_Pref = b.m_Pref;
|
||||||
m_Pcurrent = b.m_Pcurrent;
|
m_Pcurrent = b.m_Pcurrent;
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ IonsFromNeutralVPSSTP::IonsFromNeutralVPSSTP(const std::string& inputFile,
|
||||||
if (neutralPhase) {
|
if (neutralPhase) {
|
||||||
IOwnNThermoPhase_ = false;
|
IOwnNThermoPhase_ = false;
|
||||||
}
|
}
|
||||||
initThermoFile(inputFile, id);
|
constructPhaseFile(inputFile, id);
|
||||||
geThermo = dynamic_cast<GibbsExcessVPSSTP*>(neutralMoleculePhase_);
|
geThermo = dynamic_cast<GibbsExcessVPSSTP*>(neutralMoleculePhase_);
|
||||||
}
|
}
|
||||||
//====================================================================================================================
|
//====================================================================================================================
|
||||||
|
|
@ -125,7 +125,7 @@ IonsFromNeutralVPSSTP::IonsFromNeutralVPSSTP(XML_Node& phaseRoot,
|
||||||
if (neutralPhase) {
|
if (neutralPhase) {
|
||||||
IOwnNThermoPhase_ = false;
|
IOwnNThermoPhase_ = false;
|
||||||
}
|
}
|
||||||
importPhase(*findXMLPhase(&phaseRoot, id), this);
|
constructPhaseXML(phaseRoot, id);
|
||||||
geThermo = dynamic_cast<GibbsExcessVPSSTP*>(neutralMoleculePhase_);
|
geThermo = dynamic_cast<GibbsExcessVPSSTP*>(neutralMoleculePhase_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -846,7 +846,7 @@ void IonsFromNeutralVPSSTP::calcNeutralMoleculeMoleFractions() const
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_MODE
|
#ifdef DEBUG_MODE
|
||||||
sum = -1.0;
|
sum = -1.0;
|
||||||
for (int k = 0; k < m_kk; k++) {
|
for (size_t k = 0; k < m_kk; k++) {
|
||||||
sum += moleFractions_[k];
|
sum += moleFractions_[k];
|
||||||
}
|
}
|
||||||
if (fabs(sum) > 1.0E-11) {
|
if (fabs(sum) > 1.0E-11) {
|
||||||
|
|
|
||||||
|
|
@ -65,14 +65,14 @@ ThermoFactory* ThermoFactory::s_factory = 0;
|
||||||
mutex_t ThermoFactory::thermo_mutex;
|
mutex_t ThermoFactory::thermo_mutex;
|
||||||
|
|
||||||
//! Define the number of %ThermoPhase types for use in this factory routine
|
//! 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
|
//! Define the string name of the %ThermoPhase types that are handled by this factory routine
|
||||||
static string _types[] = {"IdealGas", "Incompressible",
|
static string _types[] = {"IdealGas", "Incompressible",
|
||||||
"Surface", "Edge", "Metal", "StoichSubstance",
|
"Surface", "Edge", "Metal", "StoichSubstance",
|
||||||
"PureFluid", "LatticeSolid", "Lattice",
|
"PureFluid", "LatticeSolid", "Lattice",
|
||||||
"HMW", "IdealSolidSolution", "DebyeHuckel",
|
"HMW", "IdealSolidSolution", "DebyeHuckel",
|
||||||
"IdealMolalSolution", "IdealGasVPSS",
|
"IdealMolalSolution", "IdealGasVPSS", "IdealSolnVPSS",
|
||||||
"MineralEQ3", "MetalSHEelectrons", "Margules", "PhaseCombo_Interaction",
|
"MineralEQ3", "MetalSHEelectrons", "Margules", "PhaseCombo_Interaction",
|
||||||
"IonsFromNeutralMolecule", "FixedChemPot", "MolarityIonicVPSSTP",
|
"IonsFromNeutralMolecule", "FixedChemPot", "MolarityIonicVPSSTP",
|
||||||
"MixedSolventElectrolyte", "Redlich-Kister"
|
"MixedSolventElectrolyte", "Redlich-Kister"
|
||||||
|
|
@ -83,7 +83,7 @@ static int _itypes[] = {cIdealGas, cIncompressible,
|
||||||
cSurf, cEdge, cMetal, cStoichSubstance,
|
cSurf, cEdge, cMetal, cStoichSubstance,
|
||||||
cPureFluid, cLatticeSolid, cLattice,
|
cPureFluid, cLatticeSolid, cLattice,
|
||||||
cHMW, cIdealSolidSolnPhase, cDebyeHuckel,
|
cHMW, cIdealSolidSolnPhase, cDebyeHuckel,
|
||||||
cIdealMolalSoln, cVPSS_IdealGas,
|
cIdealMolalSoln, cVPSS_IdealGas, cIdealSolnGasVPSS_iscv,
|
||||||
cMineralEQ3, cMetalSHEelectrons,
|
cMineralEQ3, cMetalSHEelectrons,
|
||||||
cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral, cFixedChemPot,
|
cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral, cFixedChemPot,
|
||||||
cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP
|
cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP
|
||||||
|
|
@ -202,6 +202,10 @@ ThermoPhase* ThermoFactory::newThermoPhase(const std::string& model)
|
||||||
th = new IdealSolnGasVPSS;
|
th = new IdealSolnGasVPSS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case cIdealSolnGasVPSS_iscv:
|
||||||
|
th = new IdealSolnGasVPSS;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw UnknownThermoPhaseModel("ThermoFactory::newThermoPhase",
|
throw UnknownThermoPhaseModel("ThermoFactory::newThermoPhase",
|
||||||
model);
|
model);
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,10 @@ void ThermoPhase::setState_HPorUV(doublereal Htarget, doublereal p,
|
||||||
// spinodal value of H.
|
// spinodal value of H.
|
||||||
for (int its = 0; its < 10; its++) {
|
for (int its = 0; its < 10; its++) {
|
||||||
Tnew = Told + dt;
|
Tnew = Told + dt;
|
||||||
|
if (Tnew < Told / 3.0) {
|
||||||
|
Tnew = Told / 3.0;
|
||||||
|
dt = -2.0 * Told / 3.0;
|
||||||
|
}
|
||||||
setState_conditional_TP(Tnew, p, !doUV);
|
setState_conditional_TP(Tnew, p, !doUV);
|
||||||
if (doUV) {
|
if (doUV) {
|
||||||
Hnew = intEnergy_mass();
|
Hnew = intEnergy_mass();
|
||||||
|
|
|
||||||
|
|
@ -112,37 +112,56 @@ DustyGasTransport& DustyGasTransport::operator=(const DustyGasTransport& right)
|
||||||
DustyGasTransport::~DustyGasTransport()
|
DustyGasTransport::~DustyGasTransport()
|
||||||
{
|
{
|
||||||
delete m_gastran;
|
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
|
* This virtual routine can be used to duplicate %Transport objects
|
||||||
* inherited from %Transport even if the application only has
|
* inherited from %Transport even if the application only has
|
||||||
* a pointer to %Transport to work with.
|
* a pointer to %Transport to work with.
|
||||||
*
|
*
|
||||||
* These routines are basically wrappers around the derived copy
|
* These routines are basically wrappers around the derived copy
|
||||||
* constructor.
|
* constructor.
|
||||||
*/
|
*/
|
||||||
Transport* DustyGasTransport::duplMyselfAsTransport() const
|
Transport *DustyGasTransport::duplMyselfAsTransport() const {
|
||||||
{
|
DustyGasTransport* tr = new DustyGasTransport(*this);
|
||||||
return new DustyGasTransport(*this);
|
return (dynamic_cast<Transport *>(tr));
|
||||||
}
|
}
|
||||||
//====================================================================================================================
|
//====================================================================================================================
|
||||||
// Set the Parameters in the model
|
// Specifies the %ThermPhase object.
|
||||||
/*
|
/*
|
||||||
* @param type Type of the parameter to set
|
* We have relaxed this operation so that it will succeed when
|
||||||
* 0 - porosity
|
* the underlying old and new ThermoPhase objects have the same
|
||||||
* 1 - tortuosity
|
* number of species and the same names of the species in the
|
||||||
* 2 - mean pore radius
|
* same order. The idea here is to allow copy constructors and duplicators
|
||||||
* 3 - mean particle radius
|
* to work. In order for them to work, we need a method to switch the
|
||||||
* 4 - permeability
|
* internal pointer within the Transport object after the duplication
|
||||||
* @param k Unused int
|
* takes place. Also, different thermodynamic instanteations of the same
|
||||||
* @param p pointer to double for the input list of parameters
|
* species should also work.
|
||||||
*
|
*
|
||||||
*/
|
* @param thermo Reference to the ThermoPhase object that
|
||||||
void DustyGasTransport::setParameters(const int type, const int k, const doublereal* const p)
|
* the transport object will use
|
||||||
{
|
*/
|
||||||
switch (type) {
|
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
|
||||||
|
* 2 - mean pore radius
|
||||||
|
* 3 - mean particle radius
|
||||||
|
* 4 - permeability
|
||||||
|
* @param k Unused int
|
||||||
|
* @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) {
|
||||||
case 0:
|
case 0:
|
||||||
setPorosity(p[0]);
|
setPorosity(p[0]);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -47,39 +47,41 @@ static void getArrhenius(const XML_Node& node,
|
||||||
b = getFloat(node, "b");
|
b = getFloat(node, "b");
|
||||||
E = getFloat(node, "E", "actEnergy");
|
E = getFloat(node, "E", "actEnergy");
|
||||||
E /= GasConstant;
|
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
|
* The species transport property is constructed from the XML node,
|
||||||
* \verbatim <transport> \endverbatim node in the species block and specifies a type of transport
|
* \verbatim <propNode>, \endverbatim that is a child of the
|
||||||
* property (like viscosity)
|
* \verbatim <transport> \endverbatim node in the species block and specifies a type of transport
|
||||||
*
|
* property (like viscosity)
|
||||||
* @param propNode Pointer to the XML node that contains the property information
|
*
|
||||||
* @param name String containing the species name
|
* @param propNode Pointer to the XML node that contains the property information
|
||||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
* @param name String containing the species name
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* 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,
|
||||||
m_speciesName(name),
|
TransportPropertyType tp_ind, const thermo_t * thermo) :
|
||||||
m_model(LTP_TD_NOTSET),
|
m_speciesName(name),
|
||||||
m_property(tp_ind),
|
m_model(LTP_TD_NOTSET),
|
||||||
m_thermo(thermo),
|
m_property(tp_ind),
|
||||||
m_mixWeight(1.0)
|
m_thermo(thermo),
|
||||||
{
|
m_mixWeight(1.0)
|
||||||
if (propNode) {
|
{
|
||||||
if (propNode->hasChild("mixtureWeighting")) {
|
if (propNode) {
|
||||||
m_mixWeight = getFloat(*propNode, "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;
|
*this = right;
|
||||||
}
|
}
|
||||||
//====================================================================================================================
|
//====================================================================================================================
|
||||||
|
|
@ -126,35 +128,36 @@ doublereal LTPspecies::getSpeciesTransProp()
|
||||||
bool LTPspecies::checkPositive() const
|
bool LTPspecies::checkPositive() const
|
||||||
{
|
{
|
||||||
return (m_coeffs[0] > 0);
|
return (m_coeffs[0] > 0);
|
||||||
}
|
|
||||||
//====================================================================================================================
|
}
|
||||||
doublereal LTPspecies::getMixWeight() const
|
//====================================================================================================================
|
||||||
{
|
doublereal LTPspecies::getMixWeight() const
|
||||||
return m_mixWeight;
|
{
|
||||||
}
|
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
|
* Currently just a place holder, but this method could take
|
||||||
* accoding to some unspecified model.
|
* the composition from the thermo object and adjust coefficients
|
||||||
*/
|
* accoding to some unspecified model.
|
||||||
void LTPspecies::adjustCoeffsForComposition()
|
*/
|
||||||
{
|
void LTPspecies::adjustCoeffsForComposition()
|
||||||
}
|
{
|
||||||
//====================================================================================================================
|
}
|
||||||
// Construct an LTPspecies object for a liquid transport property
|
//====================================================================================================================
|
||||||
// expressed as a constant value.
|
// Construct an LTPspecies object for a liquid tranport property
|
||||||
/* The transport property is constructed from the XML node,
|
// expressed as a constant value.
|
||||||
* \verbatim <propNode>, \endverbatim that is a child of the
|
/* The transport property is constructed from the XML node,
|
||||||
* \verbatim <transport> \endverbatim node and specifies a type of
|
* \verbatim <propNode>, \endverbatim that is a child of the
|
||||||
* transport property (like viscosity)
|
* \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,
|
||||||
LTPspecies(&propNode, name, tp_ind, thermo)
|
TransportPropertyType tp_ind, const thermo_t * const thermo) :
|
||||||
{
|
LTPspecies(&propNode, name, tp_ind, thermo)
|
||||||
m_model = LTP_TD_CONSTANT;
|
{
|
||||||
|
m_model = LTP_TD_CONSTANT;
|
||||||
double A_k = getFloatCurrent(propNode, "toSI");
|
double A_k = getFloatCurrent(propNode, "toSI");
|
||||||
if (A_k > 0.0) {
|
if (A_k > 0.0) {
|
||||||
m_coeffs.push_back(A_k);
|
m_coeffs.push_back(A_k);
|
||||||
|
|
@ -196,28 +199,30 @@ LTPspecies* LTPspecies_Const::duplMyselfAsLTPspecies() const
|
||||||
doublereal LTPspecies_Const::getSpeciesTransProp()
|
doublereal LTPspecies_Const::getSpeciesTransProp()
|
||||||
{
|
{
|
||||||
return m_coeffs[0];
|
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
|
* The transport property is constructed from the XML node,
|
||||||
* \verbatim <transport> \endverbatim node and specifies a type of transport property (like viscosity)
|
* \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
|
*
|
||||||
* is assumed to be parameterized by reading XML_Node information.
|
* @param propNode Referenc to the XML node that contains the property information.This class
|
||||||
* @param name String containing the species name
|
* is assumed to be parameterized by reading XML_Node information.
|
||||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
* @param name String containing the species name
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* 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::LTPspecies_Arrhenius(const XML_Node& propNode, const std::string& name,
|
*/
|
||||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
LTPspecies_Arrhenius::LTPspecies_Arrhenius(const XML_Node &propNode, const std::string name,
|
||||||
LTPspecies(&propNode, name, tp_ind, thermo)
|
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
||||||
{
|
LTPspecies(&propNode, name, tp_ind, thermo)
|
||||||
|
{
|
||||||
|
|
||||||
m_model = LTP_TD_ARRHENIUS;
|
m_model = LTP_TD_ARRHENIUS;
|
||||||
m_temp = 0.0;
|
m_temp = 0.0;
|
||||||
m_prop = 0.0;
|
m_prop = 0.0;
|
||||||
|
|
@ -310,24 +315,25 @@ doublereal LTPspecies_Arrhenius::getSpeciesTransProp()
|
||||||
m_prop = exp(m_logProp);
|
m_prop = exp(m_logProp);
|
||||||
}
|
}
|
||||||
return m_prop;
|
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).
|
* 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
|
*
|
||||||
* must be parameterized by reading XML_Node information.
|
* @param propNode Referenc to the XML node that contains the property information. This class
|
||||||
* @param name String containing the species name
|
* must be parameterized by reading XML_Node information.
|
||||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
* @param name String containing the species name
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* 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::LTPspecies_Poly(const XML_Node& propNode, const std::string& name,
|
*/
|
||||||
TransportPropertyType tp_ind, const thermo_t* thermo) :
|
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),
|
LTPspecies(&propNode, name, tp_ind, thermo),
|
||||||
m_temp(-1.0),
|
m_temp(-1.0),
|
||||||
m_prop(0.0)
|
m_prop(0.0)
|
||||||
|
|
@ -381,25 +387,27 @@ doublereal LTPspecies_Poly::getSpeciesTransProp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m_prop;
|
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).
|
* 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
|
*
|
||||||
* must be parameterized by reading XML_Node information.
|
* @param propNode Referenc to the XML node that contains the property information. This class
|
||||||
* @param name String containing the species name
|
* must be parameterized by reading XML_Node information.
|
||||||
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
* @param name String containing the species name
|
||||||
* is creating a parameterization for (e.g., viscosity)
|
* @param tp_ind enum TransportPropertyType containing the property id that this object
|
||||||
* @param thermo const pointer to the ThermoPhase object, which is used to find the temperature.
|
* is creating a parameterization for (e.g., viscosity)
|
||||||
*
|
* @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,
|
*/
|
||||||
const thermo_t* thermo) :
|
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),
|
LTPspecies(&propNode, name, tp_ind, thermo),
|
||||||
m_temp(-1.0),
|
m_temp(-1.0),
|
||||||
m_prop(0.0)
|
m_prop(0.0)
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,12 @@
|
||||||
// copyright 2008 California Institute of Technology
|
// copyright 2008 California Institute of Technology
|
||||||
|
|
||||||
#include "cantera/thermo/ThermoPhase.h"
|
#include "cantera/thermo/ThermoPhase.h"
|
||||||
|
#include "cantera/transport/SolidTransportData.h"
|
||||||
#include "cantera/transport/SolidTransport.h"
|
#include "cantera/transport/SolidTransport.h"
|
||||||
|
|
||||||
|
|
||||||
#include "cantera/base/utilities.h"
|
#include "cantera/base/utilities.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
@ -25,7 +28,7 @@ SolidTransport::SolidTransport() :
|
||||||
m_Ndiff(0),
|
m_Ndiff(0),
|
||||||
m_Ediff(0),
|
m_Ediff(0),
|
||||||
m_sp(0),
|
m_sp(0),
|
||||||
m_Alam(0),
|
m_Alam(-1.0),
|
||||||
m_Nlam(0),
|
m_Nlam(0),
|
||||||
m_Elam(0)
|
m_Elam(0)
|
||||||
{
|
{
|
||||||
|
|
@ -42,7 +45,7 @@ SolidTransport::SolidTransport(const SolidTransport& right) :
|
||||||
m_Ndiff(0),
|
m_Ndiff(0),
|
||||||
m_Ediff(0),
|
m_Ediff(0),
|
||||||
m_sp(0),
|
m_sp(0),
|
||||||
m_Alam(0),
|
m_Alam(-1.0),
|
||||||
m_Nlam(0),
|
m_Nlam(0),
|
||||||
m_Elam(0)
|
m_Elam(0)
|
||||||
{
|
{
|
||||||
|
|
@ -70,15 +73,56 @@ SolidTransport& SolidTransport::operator=(const SolidTransport& b)
|
||||||
m_Elam = b.m_Elam;
|
m_Elam = b.m_Elam;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
|
||||||
//====================================================================================================================
|
}
|
||||||
Transport* SolidTransport::duplMyselfAsTransport() const
|
//====================================================================================================================
|
||||||
{
|
Transport *SolidTransport::duplMyselfAsTransport() const
|
||||||
return new SolidTransport(*this);
|
{
|
||||||
}
|
SolidTransport* tr = new SolidTransport(*this);
|
||||||
//====================================================================================================================
|
return (dynamic_cast<Transport *>(tr));
|
||||||
void SolidTransport::setParameters(const int n, const int k, const doublereal* const p)
|
}
|
||||||
{
|
|
||||||
|
//====================================================================================================================
|
||||||
|
// 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) {
|
switch (n) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -103,67 +147,131 @@ void SolidTransport::setParameters(const int n, const int k, const doublereal* c
|
||||||
}
|
}
|
||||||
|
|
||||||
m_work.resize(m_thermo->nSpecies());
|
m_work.resize(m_thermo->nSpecies());
|
||||||
}
|
|
||||||
//====================================================================================================================
|
}
|
||||||
/*
|
|
||||||
* Compute the mobilities of the species from the diffusion coefficients,
|
/****************** ionConductivity ******************************/
|
||||||
* using the Einstein relation.
|
|
||||||
*/
|
// Returns the ionic conductivity of the phase
|
||||||
void SolidTransport::getMobilities(doublereal* const mobil)
|
/*
|
||||||
{
|
* 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) {
|
||||||
getMixDiffCoeffs(mobil);
|
getMixDiffCoeffs(mobil);
|
||||||
doublereal t = m_thermo->temperature();
|
doublereal t = m_thermo->temperature();
|
||||||
doublereal c1 = ElectronCharge / (Boltzmann * t);
|
doublereal c1 = ElectronCharge / (Boltzmann * t);
|
||||||
for (size_t k = 0; k < m_thermo->nSpecies(); k++) {
|
for (size_t k = 0; k < m_thermo->nSpecies(); k++) {
|
||||||
mobil[k] *= c1;
|
mobil[k] *= c1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//====================================================================================================================
|
}
|
||||||
/*
|
//====================================================================================================================
|
||||||
* Thermal Conductivity.
|
/*
|
||||||
* \f[
|
* The diffusion coefficients are computed from
|
||||||
* \lambda = A T^n \exp(-E/RT)
|
*
|
||||||
* \f]
|
* \f[
|
||||||
*/
|
* D_k = A_k T^{n_k} \exp(-E_k/RT).
|
||||||
doublereal SolidTransport::thermalConductivity()
|
* \f]
|
||||||
{
|
*
|
||||||
doublereal t = m_thermo->temperature();
|
* The diffusion coefficients are only non-zero for species for
|
||||||
return m_Alam * pow(t, m_Nlam) * exp(-m_Elam/t);
|
* which parameters have been specified using method
|
||||||
}
|
* setParameters.
|
||||||
//====================================================================================================================
|
*/
|
||||||
/*
|
void SolidTransport::getMixDiffCoeffs(doublereal* const d) {
|
||||||
* The diffusion coefficients are computed from
|
|
||||||
*
|
|
||||||
* \f[
|
|
||||||
* D_k = A_k T^{n_k} \exp(-E_k/RT).
|
|
||||||
* \f]
|
|
||||||
*
|
|
||||||
* The diffusion coefficients are only non-zero for species for
|
|
||||||
* which parameters have been specified using method
|
|
||||||
* setParameters.
|
|
||||||
*/
|
|
||||||
void SolidTransport::getMixDiffCoeffs(doublereal* const d)
|
|
||||||
{
|
|
||||||
doublereal temp = m_thermo->temperature();
|
|
||||||
size_t nsp = m_thermo->nSpecies();
|
size_t nsp = m_thermo->nSpecies();
|
||||||
for (size_t k = 0; k < nsp; k++) {
|
for (size_t k = 0; k < nsp; k++) {
|
||||||
d[k] = 0.0;
|
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
|
/* Set transport model parameters. This method may be
|
||||||
* overloaded in subclasses to set model-specific parameters.
|
* 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()) {
|
||||||
if (!ready()) {
|
m_thermo = &thermo;
|
||||||
m_thermo = &thermo;
|
//m_nmin = m_thermo->nSpecies();
|
||||||
m_nsp = m_thermo->nSpecies();
|
}
|
||||||
} else
|
else {
|
||||||
|
int newNum = thermo.nSpecies();
|
||||||
|
int oldNum = m_thermo->nSpecies();
|
||||||
|
if (newNum != oldNum) {
|
||||||
throw CanteraError("Transport::setThermo",
|
throw CanteraError("Transport::setThermo",
|
||||||
"the phase object cannot be changed after "
|
"base object cannot be changed after "
|
||||||
"the transport manager has been constructed.");
|
"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
|
doublereal Transport::err(const std::string& msg) const
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,19 @@
|
||||||
|
|
||||||
#include "cantera/numerics/polyfit.h"
|
#include "cantera/numerics/polyfit.h"
|
||||||
#include "MMCollisionInt.h"
|
#include "MMCollisionInt.h"
|
||||||
|
|
||||||
#include "cantera/base/xml.h"
|
#include "cantera/base/xml.h"
|
||||||
#include "cantera/base/XML_Writer.h"
|
#include "cantera/base/XML_Writer.h"
|
||||||
#include "cantera/transport/TransportParams.h"
|
#include "cantera/transport/TransportParams.h"
|
||||||
#include "cantera/transport/LiquidTransportParams.h"
|
#include "cantera/transport/LiquidTransportParams.h"
|
||||||
#include "cantera/transport/LiquidTranInteraction.h"
|
#include "cantera/transport/LiquidTranInteraction.h"
|
||||||
|
#include "cantera/transport/SolidTransportData.h"
|
||||||
#include "cantera/base/global.h"
|
#include "cantera/base/global.h"
|
||||||
#include "cantera/thermo/IdealGasPhase.h"
|
#include "cantera/thermo/IdealGasPhase.h"
|
||||||
#include "cantera/base/ctml.h"
|
#include "cantera/base/ctml.h"
|
||||||
#include "cantera/base/stringUtils.h"
|
#include "cantera/base/stringUtils.h"
|
||||||
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
@ -220,6 +223,8 @@ TransportFactory::TransportFactory() :
|
||||||
m_tranPropMap["speciesDiffusivity"] = TP_DIFFUSIVITY;
|
m_tranPropMap["speciesDiffusivity"] = TP_DIFFUSIVITY;
|
||||||
m_tranPropMap["hydrodynamicRadius"] = TP_HYDRORADIUS;
|
m_tranPropMap["hydrodynamicRadius"] = TP_HYDRORADIUS;
|
||||||
m_tranPropMap["electricalConductivity"] = TP_ELECTCOND;
|
m_tranPropMap["electricalConductivity"] = TP_ELECTCOND;
|
||||||
|
m_tranPropMap["defectDiffusivity"] = TP_DEFECTDIFF;
|
||||||
|
m_tranPropMap["defectActivity"] = TP_DEFECTCONC;
|
||||||
|
|
||||||
m_LTRmodelMap[""] = LTP_TD_CONSTANT;
|
m_LTRmodelMap[""] = LTP_TD_CONSTANT;
|
||||||
m_LTRmodelMap["constant"] = 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
|
make one of several transport models, and return a base class
|
||||||
single transport property as a function of temperature
|
pointer to it. This method operates at the level of a
|
||||||
and possibly composition.
|
single transport property as a function of temperature
|
||||||
*/
|
and possibly composition.
|
||||||
LTPspecies* TransportFactory::newLTP(const XML_Node& trNode, std::string& name,
|
*/
|
||||||
TransportPropertyType tp_ind, thermo_t* thermo)
|
LTPspecies* TransportFactory::newLTP(const XML_Node &trNode, const std::string &name,
|
||||||
{
|
TransportPropertyType tp_ind, thermo_t* thermo)
|
||||||
|
{
|
||||||
LTPspecies* ltps = 0;
|
LTPspecies* ltps = 0;
|
||||||
std::string model = lowercase(trNode["model"]);
|
std::string model = lowercase(trNode["model"]);
|
||||||
switch (m_LTRmodelMap[model]) {
|
switch (m_LTRmodelMap[model]) {
|
||||||
|
|
@ -395,9 +401,11 @@ Transport* TransportFactory::newTransport(const std::string& transportModel,
|
||||||
initTransport(tr, phase, 0, log_level);
|
initTransport(tr, phase, 0, log_level);
|
||||||
break;
|
break;
|
||||||
case cSolidTransport:
|
case cSolidTransport:
|
||||||
tr = new SolidTransport;
|
|
||||||
tr->setThermo(*phase);
|
tr = new SolidTransport;
|
||||||
break;
|
initSolidTransport(tr, phase, log_level);
|
||||||
|
tr->setThermo(*phase);
|
||||||
|
break;
|
||||||
case cDustyGasTransport:
|
case cDustyGasTransport:
|
||||||
tr = new DustyGasTransport;
|
tr = new DustyGasTransport;
|
||||||
gastr = new MultiTransport;
|
gastr = new MultiTransport;
|
||||||
|
|
@ -642,27 +650,75 @@ void TransportFactory::setupLiquidTransport(std::ostream& flog, thermo_t* thermo
|
||||||
XML_Node& transportNode = phase_database->child("transport");
|
XML_Node& transportNode = phase_database->child("transport");
|
||||||
getLiquidInteractionsTransportData(transportNode, log, trParam.thermo->speciesNames(), trParam);
|
getLiquidInteractionsTransportData(transportNode, log, trParam.thermo->speciesNames(), 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
|
// Prepare to build a new transport manager for solids
|
||||||
* populate the species-dependent data structure.
|
/*
|
||||||
*
|
* @param flog Reference to the ostream for writing log info
|
||||||
* @param tr Pointer to the Transport manager
|
* @param thermo Pointer to the %ThermoPhase object
|
||||||
* @param thermo Pointer to the ThermoPhase object
|
* @param log_level log level
|
||||||
* @param mode Chemkin compatible mode or not. This alters the specification of the
|
* @param trParam SolidTransportParams structure to be filled up with information
|
||||||
* collision integrals. defaults to no.
|
*/
|
||||||
* @param log_level Defaults to zero, no logging
|
void TransportFactory::setupSolidTransport(std::ostream &flog, thermo_t* thermo, int log_level,
|
||||||
*
|
SolidTransportData& trParam) {
|
||||||
* In DEBUG_MODE, this routine will create the file transport_log.xml
|
|
||||||
* and write informative information to it.
|
const XML_Node* phase_database = &thermo->xml();
|
||||||
*/
|
|
||||||
void TransportFactory::initTransport(Transport* tran,
|
// constant mixture attributes
|
||||||
thermo_t* thermo, int mode, int log_level)
|
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.
|
||||||
|
*
|
||||||
|
* @param tr Pointer to the Transport manager
|
||||||
|
* @param thermo Pointer to the ThermoPhase object
|
||||||
|
* @param mode Chemkin compatible mode or not. This alters the specification of the
|
||||||
|
* collision integrals. defaults to no.
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
void TransportFactory::initTransport(Transport* tran,
|
||||||
|
thermo_t* thermo, int mode, int log_level) {
|
||||||
|
|
||||||
ScopedLock transportLock(transport_mutex);
|
ScopedLock transportLock(transport_mutex);
|
||||||
|
|
||||||
const std::vector<const XML_Node*> & transport_database = thermo->speciesData();
|
const std::vector<const XML_Node*> & transport_database = thermo->speciesData();
|
||||||
|
|
||||||
GasTransportParams trParam;
|
GasTransportParams trParam;
|
||||||
|
|
@ -725,7 +781,47 @@ void TransportFactory::initLiquidTransport(Transport* tran,
|
||||||
#endif
|
#endif
|
||||||
return;
|
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,
|
void TransportFactory::fitCollisionIntegrals(ostream& logfile,
|
||||||
GasTransportParams& tr,
|
GasTransportParams& tr,
|
||||||
|
|
@ -1058,9 +1154,10 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
|
||||||
XML_Node& tranTypeNode = transportNode.child(iChild);
|
XML_Node& tranTypeNode = transportNode.child(iChild);
|
||||||
std::string nodeName = tranTypeNode.name();
|
std::string nodeName = tranTypeNode.name();
|
||||||
|
|
||||||
trParam.mobilityRatio.resize(nsp*nsp,0);
|
trParam.mobilityRatio.resize(nsp*nsp,0);
|
||||||
trParam.selfDiffusion.resize(nsp,0);
|
trParam.selfDiffusion.resize(nsp,0);
|
||||||
ThermoPhase* temp_thermo = trParam.thermo;
|
ThermoPhase *temp_thermo = trParam.thermo;
|
||||||
|
|
||||||
|
|
||||||
if (tranTypeNode.hasChild("compositionDependence")) {
|
if (tranTypeNode.hasChild("compositionDependence")) {
|
||||||
//compDepNode contains the interaction model
|
//compDepNode contains the interaction model
|
||||||
|
|
@ -1154,6 +1251,85 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp
|
||||||
return;
|
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
|
* Polynomial fitting
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ static void printUsage()
|
||||||
|
|
||||||
#include "cantera/Interface.h"
|
#include "cantera/Interface.h"
|
||||||
#include "cantera/kinetics.h"
|
#include "cantera/kinetics.h"
|
||||||
#include "kinetics/ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
#include "kinetics/solveSP.h"
|
#include "cantera/kinetics/solveSP.h"
|
||||||
|
|
||||||
using namespace Cantera;
|
using namespace Cantera;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ static void printUsage()
|
||||||
|
|
||||||
#include "cantera/Interface.h"
|
#include "cantera/Interface.h"
|
||||||
#include "cantera/kinetics.h"
|
#include "cantera/kinetics.h"
|
||||||
#include "kinetics/ImplicitSurfChem.h"
|
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||||
#include "kinetics/solveSP.h"
|
#include "cantera/kinetics/solveSP.h"
|
||||||
|
|
||||||
using namespace Cantera;
|
using namespace Cantera;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue