diff --git a/include/cantera/equil/vcs_DoubleStarStar.h b/include/cantera/equil/vcs_DoubleStarStar.h index c72376e8b..b7d1f661c 100644 --- a/include/cantera/equil/vcs_DoubleStarStar.h +++ b/include/cantera/equil/vcs_DoubleStarStar.h @@ -16,22 +16,17 @@ using std::size_t; //! A class for 2D double arrays stored in column-major //! (Fortran-compatible) form. /*! - * In this form, the data entry for an n row, m col - * matrix is - * index = i + (n-1) * j - * where - * Matrix[j][i] - * i = row - * j = column - * The way this is instantiated is via the constructor: - * DoubleStarStar Dmatrix(mcol, mrow); + * In this form, the data entry for an `n` row, `m` colum matrix is index = + * `i + (n-1) * j` where `Matrix[j][i]` references the element in row `i`, + * column `j`. * - * The way this is referenced is via the notation: - * Dmatrix[icol][irow] + * The way this is instantiated is via the constructor, + * DoubleStarStar Dmatrix(mcol, mrow)`. + * + * The way this is referenced is via the notation: `Dmatrix[icol][irow]`. */ class DoubleStarStar { - public: //! Default constructor. Create an empty array. @@ -39,30 +34,22 @@ public: //! Constructor. /*! - * Create an \c nrow by \c mcol double array, and initialize - * all elements to \c v. + * Create an `nrow` by `mcol` double array, and initialize all elements + * to `v`. * * @param mcol Number of columns * @param nrow Number of rows + * @param v value used to initialize elements */ DoubleStarStar(size_t mcol, size_t nrow, double v = 0.0); - //! copy constructor - /*! - * @param y object to be copied - */ DoubleStarStar(const DoubleStarStar& y); - - /// assignment operator - /*! - * @param y object to be copied - */ DoubleStarStar& operator=(const DoubleStarStar& y); - //! Resize the array, and fill the new entries with 'v' + //! Resize the array, and fill the new entries with `v` /*! - * @param mrow This is the number of columns in the new matrix - * @param ncol This is the number of rows + * @param mcol This is the number of columns in the new matrix + * @param nrow This is the number of rows * @param v Default fill value -> defaults to zero. */ void resize(size_t mcol, size_t nrow, double v = 0.0); @@ -83,19 +70,19 @@ public: */ const double* operator[](size_t jcol) const; - //! Returns a double ** pointer to the base address + //! Returns a `double**` pointer to the base address /*! - * This is the second way to get to the data - * This returns a double ** which can later be used in - * Dmatrix[icol][irow] notation to get to the data + * This is the second way to get to the data. This returns a `double**` + * which can later be used in `Dmatrix[icol][irow]` notation to get to + * the data. */ double* const* baseDataAddr(); - //! Returns a const double ** pointer to the base address + //! Returns a `const double**` pointer to the base address /*! - * This is the second way to get to the data - * This returns a double ** which can later be used in - * Dmatrix[icol][irow] notation to get to the data + * This is the second way to get to the data This returns a double ** + * which can later be used in `Dmatrix[icol][irow]` notation to get to + * the data. */ double const* const* constBaseDataAddr() const; @@ -125,5 +112,3 @@ private: } #endif - - diff --git a/include/cantera/equil/vcs_IntStarStar.h b/include/cantera/equil/vcs_IntStarStar.h index acb663940..231961c13 100644 --- a/include/cantera/equil/vcs_IntStarStar.h +++ b/include/cantera/equil/vcs_IntStarStar.h @@ -1,7 +1,5 @@ /** - * @file vcs_IntStarStar.h - * - * Header file for class IntStarStar + * @file vcs_IntStarStar.h Header file for class IntStarStar */ #ifndef VCS_INTSTARSTAR_H #define VCS_INTSTARSTAR_H @@ -15,19 +13,13 @@ using std::size_t; //! A class for 2D int arrays stored in column-major //! (Fortran-compatible) form. /*! - * In this form, the data entry for an n row, m col - * matrix is - * index = i + (n-1) * j - * where - * Matrix[j][i] - * i = row - * j = column + * In this form, the data entry for an `n` row, `m` colum matrix is index = + * `i + (n-1) * j` where `Matrix[j][i]` references the element in row `i`, + * column `j`. */ class IntStarStar { - public: - //! Default constructor. Create an empty array. IntStarStar(); @@ -38,19 +30,11 @@ public: * * @param mcol Number of columns * @param nrow Number of rows + * @param v value used to initialize elements */ IntStarStar(size_t mcol, size_t nrow, int v = 0); - //! Copy constructor - /*! - * @param y Object to be copied - */ IntStarStar(const IntStarStar& y); - - //! Assignment operator - /*! - * @param y Object to be copied - */ IntStarStar& operator=(const IntStarStar& y); //! Resize the array, and fill the new entries with 'v' @@ -69,15 +53,14 @@ public: //! Pointer to the top of the column /*! - * @param j Pointer to the top of the jth column + * @param jcol Pointer to the top of the jth column */ const int* operator[](size_t jcol) const; - //! Returns a int ** pointer to the base address + //! Returns a `int**` pointer to the base address /*! - * This is the second way to get to the data - * This returns a int ** which can later be used in - * Imatrix[icol][irow] notation to get to the data + * This is the second way to get to the data This returns a `int**` which + * can later be used in `Imatrix[icol][irow]` notation to get to the data */ int* const* baseDataAddr(); @@ -88,7 +71,8 @@ public: size_t nColumns() const; private: - //! Storage area for the matrix, layed out in Fortran style, row-inner, column outer format + //! Storage area for the matrix, layed out in Fortran style, row-inner, + //! column outer format /*! * Length = m_nrows * m_ncols */ @@ -110,4 +94,3 @@ private: } #endif - diff --git a/include/cantera/equil/vcs_SpeciesProperties.h b/include/cantera/equil/vcs_SpeciesProperties.h index 07fdc5d23..c4b2f2171 100644 --- a/include/cantera/equil/vcs_SpeciesProperties.h +++ b/include/cantera/equil/vcs_SpeciesProperties.h @@ -11,9 +11,9 @@ namespace VCSnonideal class VCS_SPECIES_THERMO; class vcs_VolPhase; +//! Properties of a single species. class vcs_SpeciesProperties { - public: size_t IndexPhase; size_t IndexSpeciesPhase; @@ -46,16 +46,10 @@ public: 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); }; diff --git a/include/cantera/equil/vcs_internal.h b/include/cantera/equil/vcs_internal.h index c4a74afbb..25bc45038 100644 --- a/include/cantera/equil/vcs_internal.h +++ b/include/cantera/equil/vcs_internal.h @@ -1,7 +1,7 @@ /** - * @file vcs_internal.h - * Internal declarations for the VCSnonideal package + * @file vcs_internal.h Internal declarations for the VCSnonideal package */ + /* * Copyright (2005) Sandia Corporation. Under the terms of * Contract DE-AC04-94AL85000 with Sandia Corporation, the @@ -14,7 +14,6 @@ #include #include "cantera/equil/vcs_defs.h" - #include "cantera/base/global.h" namespace VCSnonideal @@ -39,27 +38,16 @@ using Cantera::npos; //! Global hook for turning on and off time printing. /*! - * Default is to allow printing. But, you can assign this to zero - * globally to turn off all time printing. - * This is helpful for test suite purposes where you are interested - * in differences in text files. + * Default is to allow printing. But, you can assign this to zero globally to + * turn off all time printing. This is helpful for test suite purposes where + * you are interested in differences in text files. */ extern int vcs_timing_print_lvl; -/* - * Forward references - */ +// Forward references class VCS_SPECIES_THERMO; class VCS_PROB; -//! Amount of extra printing that is done while in debug mode. -/*! - * 0 -> none - * 1 -> some - * 2 -> alot (default) - * 3 -> everything - */ - //! Class to keep track of time and iterations /*! * class keeps all of the counters together. @@ -75,8 +63,7 @@ public: //! of vcs_TP() to solve for thermo equilibrium int Its; - //! Total number of optimizations of the - //! components basis set done + //! Total number of optimizations of the components basis set done int T_Basis_Opts; //! number of optimizations of the components basis set done @@ -108,7 +95,7 @@ public: double T_Time_vcs; }; -//! Returns the value of the gas constant in the units specified by parameter +//! Returns the value of the gas constant in the units specified by parameter /*! * @param mu_units Specifies the units. * - VCS_UNITS_KCALMOL: kcal gmol-1 K-1 @@ -136,7 +123,6 @@ double vcsUtil_gasConstant(int mu_units); * - 1 : Matrix is singular * - 0 : solution is OK * - * * @param c Matrix to be inverted. c is in fortran format, i.e., rows * are the inner loop. Row numbers equal to idem. * c[i+j*idem] = c_i_j = Matrix to be inverted: @@ -202,31 +188,24 @@ typedef double(*VCS_FUNC_PTR)(double xval, double Vtarget, //! One dimensional root finder /*! - * - * This root finder will find the root of a one dimensional - * equation - * + * This root finder will find the root of a one dimensional equation * \f[ * f(x) = 0 * \f] * where x is a bounded quantity: \f$ x_{min} < x < x_max \f$ * - * The functional to be minimized must have the following call - * structure: + * The function to be minimized must have the following call structure: * - * @verbatim - typedef double (*VCS_FUNC_PTR)(double xval, double Vtarget, - int varID, void *fptrPassthrough, - int *err); @endverbatim + * @code + * typedef double (*VCS_FUNC_PTR)(double xval, double Vtarget, + * int varID, void *fptrPassthrough, + * int *err); @endcode * - * xval is the current value of the x variable. Vtarget is the - * requested value of f(x), usually 0. varID is an integer - * that is passed through. fptrPassthrough is a void pointer - * that is passed through. err is a return error indicator. - * err = 0 is the norm. anything else is considered a fatal - * error. - * The return value of the function is the current value of - * f(xval). + * xval is the current value of the x variable. Vtarget is the requested + * value of f(x), usually 0. varID is an integer that is passed through. + * fptrPassthrough is a void pointer that is passed through. err is a return + * error indicator. err = 0 is the norm. anything else is considered a fatal + * error. The return value of the function is the current value of f(xval). * * @param xmin Minimum permissible value of the x variable * @param xmax Maximum permissible value of the x parameter @@ -242,69 +221,68 @@ typedef double(*VCS_FUNC_PTR)(double xval, double Vtarget, * This contains the root value. * @param printLvl Print level of the routine. * - * * Following is a nontrial example for vcs_root1d() in which the position of a * cylinder floating on the water is calculated. * - * @verbatim - #include - #include - - #include "equil/vcs_internal.h" - - const double g_cgs = 980.; - const double mass_cyl = 0.066; - const double diam_cyl = 0.048; - const double rad_cyl = diam_cyl / 2.0; - const double len_cyl = 5.46; - const double vol_cyl = Pi * diam_cyl * diam_cyl / 4 * len_cyl; - const double rho_cyl = mass_cyl / vol_cyl; - const double rho_gas = 0.0; - const double rho_liq = 1.0; - const double sigma = 72.88; - // Contact angle in radians - const double alpha1 = 40.0 / 180. * Pi; - - double func_vert(double theta1, double h_2, double rho_c) { - double f_grav = - Pi * rad_cyl * rad_cyl * rho_c * g_cgs; - double tmp = rad_cyl * rad_cyl * g_cgs; - double tmp1 = theta1 + sin(theta1) * cos(theta1) - 2.0 * h_2 / rad_cyl * sin(theta1); - double f_buoy = tmp * (Pi * rho_gas + (rho_liq - rho_gas) * tmp1); - double f_sten = 2 * sigma * sin(theta1 + alpha1 - Pi); - return f_grav + f_buoy + f_sten; - } - double calc_h2_farfield(double theta1) { - double rhs = sigma * (1.0 + cos(alpha1 + theta1)); - rhs *= 2.0; - rhs = rhs / (rho_liq - rho_gas) / g_cgs; - double sign = -1.0; - if (alpha1 + theta1 < Pi) sign = 1.0; - double res = sign * sqrt(rhs); - return res + rad_cyl * cos(theta1); - } - double funcZero(double xval, double Vtarget, int varID, void *fptrPassthrough, int *err) { - double theta = xval; - double h2 = calc_h2_farfield(theta); - return func_vert(theta, h2, rho_cyl); - } - int main () { - double thetamax = Pi; - double thetamin = 0.0; - int maxit = 1000; - int iconv; - double thetaR = Pi/2.0; - int printLvl = 4; - - iconv = VCSnonideal::vcsUtil_root1d(thetamin, thetamax, maxit, - funcZero, - (void *) 0, 0.0, 0, - &thetaR, printLvl); - printf("theta = %g\n", thetaR); - double h2Final = calc_h2_farfield(thetaR); - printf("h2Final = %g\n", h2Final); - return 0; - } @endverbatim + * @code + * #include + * #include * + * #include "equil/vcs_internal.h" + * + * const double g_cgs = 980.; + * const double mass_cyl = 0.066; + * const double diam_cyl = 0.048; + * const double rad_cyl = diam_cyl / 2.0; + * const double len_cyl = 5.46; + * const double vol_cyl = Pi * diam_cyl * diam_cyl / 4 * len_cyl; + * const double rho_cyl = mass_cyl / vol_cyl; + * const double rho_gas = 0.0; + * const double rho_liq = 1.0; + * const double sigma = 72.88; + * // Contact angle in radians + * const double alpha1 = 40.0 / 180. * Pi; + * + * double func_vert(double theta1, double h_2, double rho_c) { + * double f_grav = - Pi * rad_cyl * rad_cyl * rho_c * g_cgs; + * double tmp = rad_cyl * rad_cyl * g_cgs; + * double tmp1 = theta1 + sin(theta1) * cos(theta1) - 2.0 * h_2 / rad_cyl * sin(theta1); + * double f_buoy = tmp * (Pi * rho_gas + (rho_liq - rho_gas) * tmp1); + * double f_sten = 2 * sigma * sin(theta1 + alpha1 - Pi); + * return f_grav + f_buoy + f_sten; + * } + * double calc_h2_farfield(double theta1) { + * double rhs = sigma * (1.0 + cos(alpha1 + theta1)); + * rhs *= 2.0; + * rhs = rhs / (rho_liq - rho_gas) / g_cgs; + * double sign = -1.0; + * if (alpha1 + theta1 < Pi) sign = 1.0; + * double res = sign * sqrt(rhs); + * return res + rad_cyl * cos(theta1); + * } + * double funcZero(double xval, double Vtarget, int varID, void *fptrPassthrough, int *err) { + * double theta = xval; + * double h2 = calc_h2_farfield(theta); + * return func_vert(theta, h2, rho_cyl); + * } + * int main () { + * double thetamax = Pi; + * double thetamin = 0.0; + * int maxit = 1000; + * int iconv; + * double thetaR = Pi/2.0; + * int printLvl = 4; + * + * iconv = VCSnonideal::vcsUtil_root1d(thetamin, thetamax, maxit, + * funcZero, + * (void *) 0, 0.0, 0, + * &thetaR, printLvl); + * printf("theta = %g\n", thetaR); + * double h2Final = calc_h2_farfield(thetaR); + * printf("h2Final = %g\n", h2Final); + * return 0; + * } + * @endcode */ int vcsUtil_root1d(double xmin, double xmax, size_t itmax, VCS_FUNC_PTR func, void* fptrPassthrough, @@ -358,7 +336,6 @@ inline void vcs_dcopy(double* const vec_to, (length) * sizeof(double)); } - //! Copy an int vector /*! * @param vec_to Vector to copy into. This vector must be dimensioned @@ -414,7 +391,7 @@ inline void vcs_vdcopy(std::vector & vec_to, //! Copy one std integer vector into another /*! * This is an inlined function that uses memcpy. memcpy is probably - * the fastest way to do this. This routine requires the + * the fastest way to do this. * * @param vec_to Vector to copy into. This vector must be dimensioned * at least as large as the vec_from vector. @@ -451,8 +428,8 @@ double vcs_l2norm(const std::vector vec); //! Finds the location of the maximum component in a double vector /*! * @param x pointer to a vector of doubles - * @param xSize pointer to a vector of doubles used as a multiplier - * to x[] + * @param xSize pointer to a vector of doubles used as a multiplier to x[] + * before making the decision. Ignored if set to NULL. * @param j lowest index to search from * @param n highest index to search from * @return Return index of the greatest value on X(i) searched @@ -508,8 +485,7 @@ void vcs_print_stringTrunc(const char* str, size_t space, int alignment); //! Simple routine to check whether two doubles are equal up to //! roundoff error /*! - * Currently it's set to check for 10 digits of - * relative accuracy. + * Currently it's set to check for 10 digits of relative accuracy. * * @param d1 first double * @param d2 second double @@ -518,7 +494,6 @@ void vcs_print_stringTrunc(const char* str, size_t space, int alignment); */ bool vcs_doubleEqual(double d1, double d2); - //! Sorts a vector of ints in place from lowest to the highest values /*! * The vector is returned sorted from lowest to highest. @@ -534,7 +509,6 @@ void vcs_heapsort(std::vector &x); */ void vcs_orderedUnique(std::vector & xOrderedUnique, const std::vector & x); - } #endif diff --git a/include/cantera/equil/vcs_species_thermo.h b/include/cantera/equil/vcs_species_thermo.h index f0b7cb3ef..502359a14 100644 --- a/include/cantera/equil/vcs_species_thermo.h +++ b/include/cantera/equil/vcs_species_thermo.h @@ -15,33 +15,22 @@ namespace VCSnonideal class vcs_VolPhase; -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ -/* - * Models for the species standard state Naught temperature - * dependence - */ +// 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 - * - */ +// 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. +/*! + * 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 { @@ -49,216 +38,133 @@ class VCS_SPECIES_THERMO * All objects are public for ease of development */ public: - /** - * Index of the phase that this species belongs to. - */ + //! Index of the phase that this species belongs to. size_t IndexPhase; - /** - * Index of this species in the current phase. - */ + //! Index of this species in the current phase. size_t IndexSpeciesPhase; - /** - * Pointer to the owning phase object. - */ + //! 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_... - */ + //! 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) - */ + //! 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 - */ + //! 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 - */ + //! Base temperature used in the VCS_SS0_CONSTANT_CP model double SS0_T0; - /** - * Base enthalpy used in the VCS_SS0_CONSTANT_CP - * model - */ + //! Base enthalpy used in the VCS_SS0_CONSTANT_CP model double SS0_H0; - /** - * Base entropy used in the VCS_SS0_CONSTANT_CP - * model - */ + //! Base entropy used in the VCS_SS0_CONSTANT_CP model double SS0_S0; - /** - * Base heat capacity used in the VCS_SS0_CONSTANT_CP - * model - */ + //! 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 - */ + //! 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. - */ + + //! Pointer to a list of parameters that is malloced for complicated + //! reference state calculation. void* SS0_Params; - /** - * Integer value representing the star state model. - */ + + //! 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. - */ + //! 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_... - */ + //! 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. - */ + //! 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; + //! 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 - */ + //! 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. - */ + //! parameter that is used in the VCS_SSVOL_CONSTANT model. double SSStar_Vol0; - /** - * If true, this object will call Cantera to do its member - * calculations. - */ + //! 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. - */ + //! Duplication function for derived 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. + * for species, kspec, at the temperature TKelvin and pressure, Pres. * + * @param kspec species global index + * @param TKelvin Temperature in Kelvin + * @param pres pressure is given in units specified by if__ variable. * - * 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. + * @return 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 + * @param kglob species global index. + * @param TKelvin Temperature in Kelvin * - * - * Output - * return value = standard state free energy in Kelvin. + * @return 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 + * 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. + * @return 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 + * 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. + * @param kspec index 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 + * @return 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 diff --git a/src/equil/vcs_DoubleStarStar.cpp b/src/equil/vcs_DoubleStarStar.cpp index 2e0606d27..ead6bb44f 100644 --- a/src/equil/vcs_DoubleStarStar.cpp +++ b/src/equil/vcs_DoubleStarStar.cpp @@ -1,14 +1,13 @@ /** * @file vcs_DoubleStarStar.cpp * - * Header file for class DoubleStarStar + * Implementation file for class DoubleStarStar */ #include "cantera/equil/vcs_DoubleStarStar.h" namespace VCSnonideal { -//!Default constructor. Create an empty array. DoubleStarStar::DoubleStarStar() : m_nrows(0), m_ncols(0) @@ -17,10 +16,6 @@ DoubleStarStar::DoubleStarStar() : m_colAddr.clear(); } -/* - * Constructor. Create an \c m by \c n array, and initialize - * all elements to \c v. - */ DoubleStarStar::DoubleStarStar(size_t m, size_t n, double v) : m_nrows(n), m_ncols(m) @@ -33,7 +28,6 @@ DoubleStarStar::DoubleStarStar(size_t m, size_t n, double v) : } } -// copy constructor DoubleStarStar::DoubleStarStar(const DoubleStarStar& y) { m_nrows = y.m_nrows; @@ -48,7 +42,6 @@ DoubleStarStar::DoubleStarStar(const DoubleStarStar& y) } } -// assignment operator DoubleStarStar& DoubleStarStar::operator=(const DoubleStarStar& y) { if (&y == this) { @@ -67,13 +60,6 @@ DoubleStarStar& DoubleStarStar::operator=(const DoubleStarStar& y) return *this; } - -// resize the array, and fill the new entries with 'v' -/* - * @param n This is the number of rows - * @param m This is the number of columns in the new matrix - * @param v Default fill value -> defaults to zero. - */ void DoubleStarStar::resize(size_t m, size_t n, double v) { std::vector old_data; @@ -139,17 +125,14 @@ double const* const* DoubleStarStar::constBaseDataAddr() const return (double const* const*) &(m_colAddr[0]); } -// Number of rows size_t DoubleStarStar::nRows() const { return m_nrows; } -// Number of columns size_t DoubleStarStar::nColumns() const { return m_ncols; } } - diff --git a/src/equil/vcs_IntStarStar.cpp b/src/equil/vcs_IntStarStar.cpp index 76cfef9e7..81ef8d301 100644 --- a/src/equil/vcs_IntStarStar.cpp +++ b/src/equil/vcs_IntStarStar.cpp @@ -1,14 +1,10 @@ /** - * @file vcs_IntStarStar.cpp - * - * Header file for class IntStarStar + * @file vcs_IntStarStar.cpp Implementation of class IntStarStar */ #include "cantera/equil/vcs_IntStarStar.h" namespace VCSnonideal { - -//Default constructor. Create an empty array. IntStarStar::IntStarStar() : m_nrows(0), m_ncols(0) @@ -17,10 +13,6 @@ IntStarStar::IntStarStar() : m_colAddr.clear(); } -/* - * Constructor. Create an \c m by \c n array, and initialize - * all elements to \c v. - */ IntStarStar::IntStarStar(size_t m, size_t n, int v) : m_nrows(n), m_ncols(m) @@ -35,7 +27,6 @@ IntStarStar::IntStarStar(size_t m, size_t n, int v) : } } -// copy constructor IntStarStar::IntStarStar(const IntStarStar& y) { m_nrows = y.m_nrows; @@ -50,7 +41,6 @@ IntStarStar::IntStarStar(const IntStarStar& y) } } -// assignment operator IntStarStar& IntStarStar::operator=(const IntStarStar& y) { if (&y == this) { @@ -69,13 +59,6 @@ IntStarStar& IntStarStar::operator=(const IntStarStar& y) return *this; } - -//! resize the array, and fill the new entries with 'v' -/*! - * @param n This is the number of rows - * @param m This is the number of columns in the new matrix - * @param v Default fill value -> defaults to zero. - */ void IntStarStar::resize(size_t m, size_t n, int v) { std::vector old_data; @@ -134,18 +117,14 @@ int* const* IntStarStar::baseDataAddr() return (int* const*) &(m_colAddr[0]); } -/// Number of rows size_t IntStarStar::nRows() const { return m_nrows; } -/// Number of columns size_t IntStarStar::nColumns() const { return m_ncols; } } - - diff --git a/src/equil/vcs_SpeciesProperties.cpp b/src/equil/vcs_SpeciesProperties.cpp index 1e279a570..b598768d2 100644 --- a/src/equil/vcs_SpeciesProperties.cpp +++ b/src/equil/vcs_SpeciesProperties.cpp @@ -16,10 +16,6 @@ using namespace std; namespace VCSnonideal { -/***************************************************************************** - * - * constructor(): - */ vcs_SpeciesProperties::vcs_SpeciesProperties(size_t indexPhase, size_t indexSpeciesPhase, vcs_VolPhase* owning) : @@ -35,18 +31,10 @@ vcs_SpeciesProperties::vcs_SpeciesProperties(size_t indexPhase, { } -/****************************************************************************** - * - * destructor - */ vcs_SpeciesProperties::~vcs_SpeciesProperties() { } -/***************************************************************************** - * - * Copy Constructor vcs_SpeciesProperties - */ vcs_SpeciesProperties::vcs_SpeciesProperties(const vcs_SpeciesProperties& b) : IndexPhase(b.IndexPhase), IndexSpeciesPhase(b.IndexSpeciesPhase), @@ -63,10 +51,6 @@ vcs_SpeciesProperties::vcs_SpeciesProperties(const vcs_SpeciesProperties& b) : FormulaMatrixCol = b.FormulaMatrixCol; } -/***************************************************************************** - * - * Assignment operator for vcs_SpeciesProperties - */ vcs_SpeciesProperties& vcs_SpeciesProperties::operator=(const vcs_SpeciesProperties& b) { @@ -86,6 +70,4 @@ vcs_SpeciesProperties::operator=(const vcs_SpeciesProperties& b) return *this; } -/*****************************************************************************/ } - diff --git a/src/equil/vcs_equilibrate.cpp b/src/equil/vcs_equilibrate.cpp index 07e2f4368..3c649b08b 100644 --- a/src/equil/vcs_equilibrate.cpp +++ b/src/equil/vcs_equilibrate.cpp @@ -32,56 +32,6 @@ using namespace std; namespace Cantera { - -/* - * Set a single-phase chemical solution to chemical equilibrium. - * This is a convenience function that uses one or the other of - * the two chemical equilibrium solvers. - * - * @param s The object to set to an equilibrium state - * - * @param XY An integer specifying the two properties to be held - * constant. - * - * @param estimateEquil integer indicating whether the solver - * should estimate its own initial condition. - * If 0, the initial mole fraction vector - * in the %ThermoPhase object is used as the - * initial condition. - * If 1, the initial mole fraction vector - * is used if the element abundances are - * satisfied. - * if -1, the initial mole fraction vector - * is thrown out, and an estimate is - * formulated. - * - * @param printLvl Determines the amount of printing that - * gets sent to stdout from the vcs package - * (Note, you may have to compile with debug - * flags to get some printing). - * - * @param solver The equilibrium solver to use. If solver = 0, - * the ChemEquil solver will be used, and if - * solver = 1, the vcs_MultiPhaseEquil solver will - * be used (slower than ChemEquil, - * but more stable). If solver < 0 (default, then - * ChemEquil will be tried first, and if it fails - * vcs_MultiPhaseEquil will be tried. - * - * @param maxsteps The maximum number of steps to take to find - * the solution. - * - * @param maxiter For the MultiPhaseEquil solver only, this is - * the maximum number of outer temperature or - * pressure iterations to take when T and/or P is - * not held fixed. - * - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. The - * messages are written to a file in HTML format for viewing - * in a web browser. @see HTML_logs - */ int vcs_equilibrate(thermo_t& s, const char* XY, int estimateEquil, int printLvl, int solver, @@ -195,53 +145,6 @@ int vcs_equilibrate(thermo_t& s, const char* XY, return retn; } -// Set a multi-phase chemical solution to chemical equilibrium. -/* - * This function uses the vcs_MultiPhaseEquil interface to the - * vcs solver. - * The function uses the element abundance vector that is - * currently consistent with the composition within the phases - * themselves. Two other thermodynamic quantities, determined by the - * XY string, are held constant during the equilibration. - * - * @param s The object to set to an equilibrium state - * - * @param XY A character string specifying the two properties to - * be held constant - * - * @param estimateEquil integer indicating whether the solver - * should estimate its own initial condition. - * If 0, the initial mole fraction vector - * in the %ThermoPhase object is used as the - * initial condition. - * If 1, the initial mole fraction vector - * is used if the element abundances are - * satisfied. - * if -1, the initial mole fraction vector - * is thrown out, and an estimate is - * formulated. - * - * @param printLvl Determines the amount of printing that - * gets sent to stdout from the vcs package - * (Note, you may have to compile with debug - * flags to get some printing). - * - * @param maxsteps The maximum number of steps to take to find - * the solution. - * - * @param maxiter For the MultiPhaseEquil solver only, this is - * the maximum number of outer temperature or - * pressure iterations to take when T and/or P is - * not held fixed. - * - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. The - * messages are written to a file in HTML format for viewing - * in a web browser. @see HTML_logs - * - * @ingroup equilfunctions - */ int vcs_equilibrate(MultiPhase& s, const char* XY, int estimateEquil, int printLvl, int solver, doublereal tol, int maxsteps, int maxiter, @@ -251,56 +154,8 @@ int vcs_equilibrate(MultiPhase& s, const char* XY, int retn = vcs_equilibrate_1(s, ixy, estimateEquil, printLvl, solver, tol, maxsteps, maxiter, loglevel); return retn; -}; +} - -// Set a multi-phase chemical solution to chemical equilibrium. -/* - * This function uses the vcs_MultiPhaseEquil interface to the - * vcs solver. - * The function uses the element abundance vector that is - * currently consistent with the composition within the phases - * themselves. Two other thermodynamic quantities, determined by the - * XY string, are held constant during the equilibration. - * - * @param s The object to set to an equilibrium state - * - * @param XY An integer specifying the two properties to be held - * constant. - * - * @param estimateEquil integer indicating whether the solver - * should estimate its own initial condition. - * If 0, the initial mole fraction vector - * in the %ThermoPhase object is used as the - * initial condition. - * If 1, the initial mole fraction vector - * is used if the element abundances are - * satisfied. - * if -1, the initial mole fraction vector - * is thrown out, and an estimate is - * formulated. - * - * @param printLvl Determines the amount of printing that - * gets sent to stdout from the vcs package - * (Note, you may have to compile with debug - * flags to get some printing). - * - * @param maxsteps The maximum number of steps to take to find - * the solution. - * - * @param maxiter For the MultiPhaseEquil solver only, this is - * the maximum number of outer temperature or - * pressure iterations to take when T and/or P is - * not held fixed. - * - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. The - * messages are written to a file in HTML format for viewing - * in a web browser. @see HTML_logs - * - * @ingroup equilfunctions - */ int vcs_equilibrate_1(MultiPhase& s, int ixy, int estimateEquil, int printLvl, int solver, doublereal tol, int maxsteps, int maxiter, int loglevel) @@ -380,28 +235,6 @@ int vcs_equilibrate_1(MultiPhase& s, int ixy, return retn; } -//==================================================================================================================== -// Determine the phase stability of a single phase given the current conditions -// in a MultiPhase object -/* - * - * @param s The MultiPhase object to be set to an equilibrium state - * @param iphase Phase index within the multiphase object to be - * tested for stability. - * @param funcStab Function value that tests equilibrium. > 0 indicates stable - * < 0 indicates unstable - * - * @param printLvl Determines the amount of printing that - * gets sent to stdout from the vcs package - * (Note, you may have to compile with debug - * flags to get some printing). - * - * @param loglevel Controls amount of diagnostic output. loglevel - * = 0 suppresses diagnostics, and increasingly-verbose - * messages are written as loglevel increases. The - * messages are written to a file in HTML format for viewing - * in a web browser. @see HTML_logs - */ int vcs_determine_PhaseStability(MultiPhase& s, int iphase, double& funcStab, int printLvl, int loglevel) { @@ -443,5 +276,5 @@ int vcs_determine_PhaseStability(MultiPhase& s, int iphase, } return iStab; } -//==================================================================================================================== + } diff --git a/src/equil/vcs_root1d.cpp b/src/equil/vcs_root1d.cpp index b0c5b7201..fb86e17b3 100644 --- a/src/equil/vcs_root1d.cpp +++ b/src/equil/vcs_root1d.cpp @@ -8,7 +8,6 @@ * U.S. Government retains certain rights in this software. */ - #include "cantera/equil/vcs_internal.h" #include @@ -19,9 +18,7 @@ namespace VCSnonideal { #define TOL_CONV 1.0E-5 -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ + #ifdef DEBUG_MODE static void print_funcEval(FILE* fp, double xval, double fval, int its) { @@ -35,87 +32,7 @@ static void print_funcEval(FILE* fp, double xval, double fval, int its) fprintf(fp,"\n"); } #endif -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ -// One Dimensional Root Finder -/* - * - * vcs_root1d: - * - * - * - * Following is a nontrial example for vcs_root1d() where the buoyancy of a - * cylinder floating on water is calculated. - * - * @verbatim - * #include - * #include - * - * #include "equil/vcs_internal.h" - * - * const double g_cgs = 980.; - * const double mass_cyl = 0.066; - * const double diam_cyl = 0.048; - * const double rad_cyl = diam_cyl / 2.0; - * const double len_cyl = 5.46; - * const double vol_cyl = Pi * diam_cyl * diam_cyl / 4 * len_cyl; - * const double rho_cyl = mass_cyl / vol_cyl; - * const double rho_gas = 0.0; - * const double rho_liq = 1.0; - * const double sigma = 72.88; - * // Contact angle in radians - * const double alpha1 = 40.0 / 180. * Pi; - * - * using namespace Cantera; - * using namespace VCSnonideal; - * - * double func_vert(double theta1, double h_2, double rho_c) { - * double f_grav = - Pi * rad_cyl * rad_cyl * rho_c * g_cgs; - * double tmp = rad_cyl * rad_cyl * g_cgs; - * double tmp1 = theta1 + sin(theta1) * cos(theta1) - 2.0 * h_2 / rad_cyl * sin(theta1); - * double f_buoy = tmp * (Pi * rho_gas + (rho_liq - rho_gas) * tmp1); - * double f_sten = 2 * sigma * sin(theta1 + alpha1 - Pi); - * double f_net = f_grav + f_buoy + f_sten; - * return f_net; - * } - * double calc_h2_farfield(double theta1) { - * double rhs = sigma * (1.0 + cos(alpha1 + theta1)); - * rhs *= 2.0; - * rhs = rhs / (rho_liq - rho_gas) / g_cgs; - * double sign = -1.0; - * if (alpha1 + theta1 < Pi) sign = 1.0; - * double res = sign * sqrt(rhs); - * double h2 = res + rad_cyl * cos(theta1); - * return h2; - * } - * double funcZero(double xval, double Vtarget, int varID, void *fptrPassthrough, int *err) { - * double theta = xval; - * double h2 = calc_h2_farfield(theta); - * double fv = func_vert(theta, h2, rho_cyl); - * return fv; - * } - * - * int main () { - * - * double thetamax = Pi; - * double thetamin = 0.0; - * int maxit = 1000; - * int iconv; - * double thetaR = Pi/2.0; - * int printLvl = 4; - * - * iconv = VCSnonideal::vcsUtil_root1d(thetamin, thetamax, maxit, funcZero, - * (void *) 0, 0.0, 0, &thetaR, printLvl); - * printf("theta = %g\n", thetaR); - * double h2Final = calc_h2_farfield(thetaR); - * printf("h2Final = %g\n", h2Final); - * return 0; - * } - * @endverbatim - * - */ int vcsUtil_root1d(double xmin, double xmax, size_t itmax, VCS_FUNC_PTR func, void* fptrPassthrough, double FuncTargVal, int varID, @@ -499,6 +416,5 @@ QUAD_BAIL: #endif return retn; } -/*****************************************************************************/ -} +} diff --git a/src/equil/vcs_species_thermo.cpp b/src/equil/vcs_species_thermo.cpp index f42f9012f..7ba9f6ff7 100644 --- a/src/equil/vcs_species_thermo.cpp +++ b/src/equil/vcs_species_thermo.cpp @@ -1,6 +1,6 @@ /** - * @file vcs_species_thermo.cpp - * Implementation for the VCS_SPECIES_THERMO object. + * @file vcs_species_thermo.cpp Implementation for the VCS_SPECIES_THERMO + * object. */ /* * Copyright (2005) Sandia Corporation. Under the terms of @@ -8,8 +8,6 @@ * U.S. Government retains certain rights in this software. */ - - #include "cantera/equil/vcs_solve.h" #include "cantera/equil/vcs_species_thermo.h" #include "cantera/equil/vcs_defs.h" @@ -26,8 +24,6 @@ using namespace std; namespace VCSnonideal { - - VCS_SPECIES_THERMO::VCS_SPECIES_THERMO(size_t indexPhase, size_t indexSpeciesPhase) : @@ -56,19 +52,10 @@ VCS_SPECIES_THERMO::VCS_SPECIES_THERMO(size_t indexPhase, SS0_Pref = 1.01325E5; } - -/****************************************************************************** - * - * destructor - */ VCS_SPECIES_THERMO::~VCS_SPECIES_THERMO() { } -/***************************************************************************** - * - * Copy Constructor VCS_SPECIES_THERMO - */ VCS_SPECIES_THERMO::VCS_SPECIES_THERMO(const VCS_SPECIES_THERMO& b) : IndexPhase(b.IndexPhase), IndexSpeciesPhase(b.IndexSpeciesPhase), @@ -92,14 +79,9 @@ VCS_SPECIES_THERMO::VCS_SPECIES_THERMO(const VCS_SPECIES_THERMO& b) : UseCanteraCalls(b.UseCanteraCalls), m_VCS_UnitsFormat(b.m_VCS_UnitsFormat) { - SS0_Params = 0; } -/***************************************************************************** - * - * Assignment operator for VCS_SPECIES_THERMO - */ VCS_SPECIES_THERMO& VCS_SPECIES_THERMO::operator=(const VCS_SPECIES_THERMO& b) { @@ -137,38 +119,11 @@ VCS_SPECIES_THERMO::operator=(const VCS_SPECIES_THERMO& b) return *this; } -/****************************************************************************** - * - * duplMyselfAsVCS_SPECIES_THERMO(): (virtual) - * - * This routine can duplicate inherited objects given a base class - * pointer. It relies on valid copy constructors. - */ - VCS_SPECIES_THERMO* VCS_SPECIES_THERMO::duplMyselfAsVCS_SPECIES_THERMO() { return new VCS_SPECIES_THERMO(*this); } - -/************************************************************************** - * - * GStar_R_calc(); - * - * This function calculates the standard state Gibbs free energy - * for species, kspec, at the solution temperature TKelvin and - * solution pressure, Pres. - * - * - * Input - * kglob = species global index. - * 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. - */ double VCS_SPECIES_THERMO::GStar_R_calc(size_t kglob, double TKelvin, double pres) { @@ -202,19 +157,6 @@ double VCS_SPECIES_THERMO::GStar_R_calc(size_t kglob, double TKelvin, return fe; } -/************************************************************************** - * - * VolStar_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 m**3 per kmol. - * (VCS_UNITS_MKS) - */ double VCS_SPECIES_THERMO:: VolStar_calc(size_t kglob, double TKelvin, double presPA) { @@ -246,20 +188,6 @@ VolStar_calc(size_t kglob, double TKelvin, double presPA) return vol; } -/************************************************************************** - * - * G0_R_calc: - * - * This function calculates the naught state Gibbs free energy - * for species, kspec, at the temperature TKelvin - * - * Input - * kglob = species global index. - * TKelvin = Temperature in Kelvin - * - * Output - * return value = naught state free energy in Kelvin. - */ double VCS_SPECIES_THERMO::G0_R_calc(size_t kglob, double TKelvin) { #ifdef DEBUG_MODE @@ -304,25 +232,6 @@ double VCS_SPECIES_THERMO::G0_R_calc(size_t kglob, double TKelvin) return fe; } -/************************************************************************** - * - * eval_ac: - * - * This function evaluates the activity coefficient - * for species, kspec - * - * Input - * kglob -> integer value of the species in the global - * species list within VCS_GLOB. 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_GLOB - * - * - * Output - * return value = activity coefficient for species kspec - */ double VCS_SPECIES_THERMO::eval_ac(size_t kglob) { #ifdef DEBUG_MODE @@ -353,5 +262,4 @@ double VCS_SPECIES_THERMO::eval_ac(size_t kglob) return ac; } -/*****************************************************************************/ } diff --git a/src/equil/vcs_util.cpp b/src/equil/vcs_util.cpp index eca42a1bb..05441e558 100644 --- a/src/equil/vcs_util.cpp +++ b/src/equil/vcs_util.cpp @@ -19,96 +19,47 @@ using namespace std; namespace VCSnonideal { - -/***************************************************************************/ -/***************************************************************************/ -/***************************************************************************/ #ifndef USE_MEMSET void vcs_dzero(double* vector, int length) - -/************************************************************************** - * - * vcs_dzero: - * - * Zeroes a double vector - *************************************************************************/ { int i; for (i = 0; i < length; i++) { vector[i] = 0.0; } -} /* vcs_dzero() ***********************************************************/ +} #endif -/***************************************************************************/ -/***************************************************************************/ -/***************************************************************************/ + #ifndef USE_MEMSET void vcs_izero(int* vector, int length) - -/************************************************************************** - * - * vcs_izero: - * - * Zeroes an int vector - *************************************************************************/ { int i; for (i = 0; i < length; i++) { vector[i] = 0; } -} /* vcs_izero() ***********************************************************/ +} #endif -/***************************************************************************/ -/***************************************************************************/ -/***************************************************************************/ #ifndef USE_MEMSET void vcs_dcopy(double* const vec_to, const double* const vec_from, int length) - -/************************************************************************** - * - * vcs_dcopy: - * - * Copies a double vector - ***************************************************************************/ { int i; for (i = 0; i < length; i++) { vec_to[i] = vec_from[i]; } -} /* vcs_dzero() *************************************************************/ +} #endif -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ #ifndef USE_MEMSET void vcs_icopy(int* vec_to, int* vec_from, int length) - -/************************************************************************** - * - * vcs_icopy: - * - * copies an int vector - ***************************************************************************/ { int i; for (i = 0; i < length; i++) { vec_to[i] = vec_from[i]; } -} /* vcs_dzero() *************************************************************/ +} #endif -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ - #ifndef USE_MEMSET -/* - * vcs_vdzero - * - * zeroes a double vector - */ void vcs_vdzero(std::vector &vvv, int len) { if (len < 0) { @@ -133,16 +84,7 @@ double vcs_l2norm(const std::vector vec) return std::sqrt(sum / len); } -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ - #ifndef USE_MEMSET -/* - * vcs_vizero - * - * zeroes a double vector - */ void vcs_vizero(std::vector &vvv, int len) { if (len < 0) { @@ -154,15 +96,6 @@ void vcs_vizero(std::vector &vvv, int len) #endif #ifndef USE_MEMSET -/* - * vcs_vdcopy - * - * copies a vector of doubles to another vector of doubles - * - * @param vec_to Vector to be copied to - * @param vec_from Vector to be copied from - * @param length Length of the copy - */ void vcs_vdcopy(std::vector &vec_to, const std::vector & vec_from, int length) { @@ -171,15 +104,6 @@ void vcs_vdcopy(std::vector &vec_to, #endif #ifndef USE_MEMSET -/* - * vcs_vicopy - * - * copies a vector to another vector - * - * @param vec_to Vector to be copied to - * @param vec_from Vector to be copied from - * @param length Length of the copy - */ void vcs_vicopy(std::vector &vec_to, const std::vector & vec_from, int length) { @@ -187,18 +111,6 @@ void vcs_vicopy(std::vector &vec_to, } #endif -/* - * - * Finds the location of the maximum component in a double vector - * INPUT - * x(*) - Vector to search - * xSize(*) if nonnull, this is the multiplier vector to be - * multiplied into x(*) before making the decision. - * j <= i < n : i is the range of indices to search in X(*) - * - * RETURN - * return index of the greatest value on X(*) searched - */ size_t vcs_optMax(const double* x, const double* xSize, size_t j, size_t n) { size_t i; @@ -226,13 +138,6 @@ size_t vcs_optMax(const double* x, const double* xSize, size_t j, size_t n) } int vcs_max_int(const int* vector, int length) - -/************************************************************************** - * - * vcs_max_int: - * - * returns the maximum integer in a list. - ***************************************************************************/ { int i, retn; if (vector == NULL || length <= 0) { @@ -245,7 +150,6 @@ int vcs_max_int(const int* vector, int length) return retn; } -//==================================================================================================================== #ifdef DEBUG_HKM static void mlequ_matrixDump(double* c, int idem, int n) { @@ -275,7 +179,7 @@ static void mlequ_matrixDump(double* c, int idem, int n) } #endif -//==================================================================================================================== + //! Swap rows in the c matrix and the b rhs matrix /*! * @param c Matrix of size nxn, row first @@ -299,7 +203,7 @@ static void vcsUtil_swapRows(double* c, size_t idem, size_t n, double* b, std::swap(b[irowa + j * idem], b[irowb + j * idem]); } } -//==================================================================================================================== + //! Swap rows in the c matrix and the b rhs matrix to lower the condition number of the matrix /*! * @param c Matrix of size nxn, row first @@ -393,37 +297,7 @@ static void vcsUtil_mlequ_preprocess(double* c, size_t idem, size_t n, } } } -//==================================================================================================================== -// Invert an n x n matrix and solve m rhs's -/* - * Solve a square matrix with multiple right hand sides - * - * \f[ - * C X + B = 0; - * \f] - * - * This routine uses Gauss elimination and is optimized for the solution - * of lots of rhs's. A crude form of row pivoting is used here. - * The matrix C is destroyed. - * - * @return Routine returns an integer representing success: - * - 1 : Matrix is singular - * - 0 : solution is OK - * The solution x[] is returned in the matrix b. - * - * @param c Matrix to be inverted. c is in fortran format, i.e., rows - * are the inner loop. Row numbers equal to idem. - * c[i+j*idem] = c_i_j = Matrix to be inverted: i = row number - * j = column number - * @param idem number of row dimensions in c - * @param n Number of rows and columns in c - * @param b Multiple RHS. Note, b is actually the negative of - * most formulations. Row numbers equal to idem. - * b[i+j*idem] = b_i_j = vectors of rhs's: i = row number - * j = column number - * (each column is a new rhs) - * @param m number of rhs's - */ + int vcsUtil_mlequ(double* c, size_t idem, size_t n, double* b, size_t m) { size_t k; @@ -534,39 +408,9 @@ FOUND_PIVOT: } return 0; } -//==================================================================================================================== -// Linear equation solution by Gauss-Jordan elimination for multiple rhs vectors -/* - * Solve a square matrix with multiple right hand sides - * - * \f[ - * C X + B = 0; - * \f] - * - * This routine uses Gauss-Jordan elimination with full pivoting and is optimized for the solution - * of lots of rhs's. - * - * @return Routine returns an integer representing success: - * - 1 : Matrix is singular - * - 0 : solution is OK - * The solution x[] is returned in the matrix b. - * - * @param c Matrix to be inverted. c is in fortran format, i.e., rows - * are the inner loop. Row numbers equal to idem. - * c[i+j*idem] = c_i_j = Matrix to be inverted: i = row number - * j = column number - * @param idem number of row dimensions in c - * @param n Number of rows and columns in c - * @param b Multiple RHS. Note, b is actually the negative of - * most formulations. Row numbers equal to idem. - * b[i+j*idem] = b_i_j = vectors of rhs's: i = row number - * j = column number - * (each column is a new rhs) - * @param m number of rhs's - */ + int vcsUtil_gaussj(double* c, size_t idem, size_t n, double* b, size_t m) { - size_t i, j, k, l, ll; size_t irow = npos; size_t icol = npos; @@ -662,17 +506,7 @@ int vcsUtil_gaussj(double* c, size_t idem, size_t n, double* b, size_t m) } return 0; } -//==================================================================================================================== -// Returns the value of the gas constant in the units specified by a parameter -/* - * @param mu_units Specifies the units. - * - VCS_UNITS_KCALMOL: kcal gmol-1 K-1 - * - VCS_UNITS_UNITLESS: 1.0 K-1 - * - VCS_UNITS_KJMOL: kJ gmol-1 K-1 - * - VCS_UNITS_KELVIN: 1.0 K-1 - * - VCS_UNITS_MKS: joules kmol-1 K-1 = kg m2 s-2 kmol-1 K-1 - */ double vcsUtil_gasConstant(int mu_units) { double r; @@ -702,14 +536,6 @@ double vcsUtil_gasConstant(int mu_units) } void vcs_print_line(const char* string, int num) - -/************************************************************************** - * - * vcs_print_char: - * - * Print a line consisting of a multiple of the same string - * - ***************************************************************************/ { if (string) { for (int j = 0; j < num; j++) { @@ -789,23 +615,7 @@ const char* vcs_speciesType_string(int speciesStatus, int length) return sss; } -/************************************************************************ **/ - void vcs_print_stringTrunc(const char* str, size_t space, int alignment) - -/*********************************************************************** - * vcs_print_stringTrunc(): - * - * Print a string within a given space limit. This routine - * limits the amount of the string that will be printed to a - * maximum of "space" characters. - * - * str = String -> must be null terminated. - * space = space limit for the printing. - * alignment = 0 centered - * 1 right aligned - * 2 left aligned - ***********************************************************************/ { size_t i, ls = 0, rs = 0; size_t len = strlen(str); @@ -836,19 +646,7 @@ void vcs_print_stringTrunc(const char* str, size_t space, int alignment) } } -/*****************************************************************************/ -/*****************************************************************************/ -/*****************************************************************************/ - bool vcs_doubleEqual(double d1, double d2) - -/************************************************************************* - * vcs_doubleEqual() - * - * Simple routine to check whether two doubles are equal up to - * roundoff error. Currently it's set to check for 10 digits of - * accuracy. - *************************************************************************/ { double denom = fabs(d1) + fabs(d2) + 1.0; double fac = fabs(d1 - d2) / denom; @@ -858,13 +656,6 @@ bool vcs_doubleEqual(double d1, double d2) return true; } -//===================================================================================================================== -// Sorts a vector of ints in place from lowest to the highest values -/* - * The vector is returned sorted from lowest to highest. - * - * @param x Reference to a vector of ints. - */ void vcs_heapsort(std::vector & x) { int n = x.size(); @@ -909,12 +700,7 @@ void vcs_heapsort(std::vector & x) x[i] = rra; } } -//===================================================================================================================== -// Sorts a vector of ints and eliminates duplicates from the resulting list -/* - * @param xOrderedUnique Ordered vector of unique ints that were part of the original list - * @param x Reference to a constant vector of ints. - */ + void vcs_orderedUnique(std::vector & xOrderedUnique, const std::vector & x) { std::vector xordered(x); @@ -928,6 +714,5 @@ void vcs_orderedUnique(std::vector & xOrderedUnique, const std::vector } } } -//===================================================================================================================== }