Simplification -
Took out vcs_TV.cpp method for calculating TV problems. It was a duplicate.
This commit is contained in:
parent
8e4a122cad
commit
582816d3f7
8 changed files with 45 additions and 230 deletions
|
|
@ -2,3 +2,4 @@ Makefile
|
|||
*.d
|
||||
.depends
|
||||
TODO.txt
|
||||
old
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ endif
|
|||
|
||||
ifeq ($(do_VCSnonideal), 1)
|
||||
VCSNONIDEAL_OBJ = vcs_solve_TP.o vcs_VolPhase.o vcs_solve.o vcs_prob.o \
|
||||
vcs_TP.o vcs_TV.o vcs_report.o vcs_util.o \
|
||||
vcs_TP.o vcs_report.o vcs_util.o \
|
||||
vcs_IntStarStar.o vcs_DoubleStarStar.o vcs_elem.o \
|
||||
vcs_elem_rearrange.o vcs_MultiPhaseEquil.o \
|
||||
vcs_nasa_poly.o vcs_nondim.o vcs_Exception.o \
|
||||
vcs_funcVtot.o vcs_inest.o vcs_rearrange.o \
|
||||
vcs_inest.o vcs_rearrange.o \
|
||||
vcs_root1d.o vcs_rxnadj.o \
|
||||
vcs_SpeciesProperties.o vcs_equilibrate.o \
|
||||
vcs_prep.o vcs_species_thermo.o vcs_Gibbs.o \
|
||||
|
|
|
|||
|
|
@ -1,112 +0,0 @@
|
|||
/* ======================================================================= */
|
||||
/* -------------------------------------------------- */
|
||||
/* | RCS Head Information on zuzax.pchem.sandia.gov | */
|
||||
/* -------------------------------------------------- */
|
||||
/* $RCSfile$ */
|
||||
/* $Author$ */
|
||||
/* $Date$ */
|
||||
/* $Revision$ */
|
||||
/* ======================================================================= */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "vcs_solve.h"
|
||||
#include "vcs_internal.h"
|
||||
#include "vcs_VolPhase.h"
|
||||
#include "vcs_species_thermo.h"
|
||||
|
||||
namespace VCSnonideal {
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* vcs_TV:
|
||||
*
|
||||
* Solve an equilibrium problem at a particular fixed temperature
|
||||
* and volume.
|
||||
* This is done as a root finder problem, solving repetative
|
||||
* calls to solve_TP.
|
||||
*
|
||||
* ipr = 1 -> Print results to standard output
|
||||
* 0 -> don't report on anything
|
||||
* ip1 = 1 -> Print intermediate results.
|
||||
* maxit -> Maximum number of iterations for the algorithm
|
||||
* T = Temperature (Kelvin)
|
||||
* Pres = Pressure (units specififed by if__ variable)
|
||||
*/
|
||||
int VCS_SOLVE::vcs_TV(int ipr, int ip1, int maxit, double T_arg, double VolRequest)
|
||||
{
|
||||
int iconv, varID;
|
||||
double Pmin, Pmax, Preturn;
|
||||
VCS_FUNC_PTR func;
|
||||
|
||||
/*
|
||||
* Store the temperature in the private global variables
|
||||
*/
|
||||
T = T_arg;
|
||||
|
||||
/*
|
||||
* Set the unknown variable to the pressure
|
||||
*/
|
||||
varID = 1;
|
||||
|
||||
/*
|
||||
* Set the function to the volume function
|
||||
*/
|
||||
func = vcs_funcVtot;
|
||||
|
||||
/*
|
||||
* Set max and min Pressures
|
||||
*/
|
||||
Pmin = 0.0;
|
||||
Pmax = 1.0E30;
|
||||
Preturn = 1.0;
|
||||
|
||||
iconv = vcsUtil_root1d(Pmin, Pmax, maxit, func, (void *) this,
|
||||
VolRequest, varID, &Preturn);
|
||||
|
||||
/*
|
||||
* Return the convergence success flag.
|
||||
*/
|
||||
return iconv;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* vcs_VolTotal
|
||||
*
|
||||
* This function calculates the partial molar volume
|
||||
* for all species, kspec, in the thermo problem
|
||||
* at the temperature TKelvin and pressure, Pres, pres is in atm.
|
||||
* And, it calculates the total volume of the combined system.
|
||||
*
|
||||
* Input
|
||||
* iphase
|
||||
* TKelvin
|
||||
* pres
|
||||
* w[] => vector containing the current mole numbers.
|
||||
*
|
||||
* Output
|
||||
* VolPM[] => For species in all phase, the entries are the
|
||||
* partial molar volumes
|
||||
* return value = Total volume of the phase in L**3 / MOL_UNITS
|
||||
*
|
||||
* (L and MOL_UNITS determined from global units value if__)
|
||||
*/
|
||||
double VCS_SOLVE::vcs_VolTotal(double tkelvin, double pres, double w[],
|
||||
double volPM[])
|
||||
{
|
||||
double volTot = 0.0;
|
||||
for (int iphase = 0; iphase < NPhase; iphase++) {
|
||||
vcs_VolPhase *Vphase = VPhaseList[iphase];
|
||||
Vphase->setState_TP(tkelvin, pres);
|
||||
Vphase->setMolesFromVCS(w);
|
||||
double volp = Vphase->VolPM_calc();
|
||||
(void) Vphase->sendToVCSVolPM(volPM);
|
||||
volTot += volp;
|
||||
}
|
||||
return volTot;
|
||||
}
|
||||
/**************************************************************************/
|
||||
}
|
||||
|
||||
|
|
@ -74,15 +74,6 @@ namespace VCSnonideal {
|
|||
#define VCS_FAILED_LOOKUP -5
|
||||
#define VCS_MP_FAIL -6
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Problem Types
|
||||
*/
|
||||
#define VCS_PROBTYPE_TP 0
|
||||
#define VCS_PROBTYPE_TV 1
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
@ -93,6 +84,7 @@ namespace VCSnonideal {
|
|||
|
||||
#define VCS_MAX_NAME_LEN_P1 32
|
||||
|
||||
#define VCS_PROBTYPE_TP 0
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
/**
|
||||
* @file vcs_funcVtot.cpp
|
||||
* Routine to calculate tht total volume of an extrinsic system.
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
/*
|
||||
* Copywrite (2006) Sandia Corporation. Under the terms of
|
||||
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
|
||||
* U.S. Government retains certain rights in this software.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "vcs_solve.h"
|
||||
#include "vcs_internal.h"
|
||||
|
||||
#define TOL_CONV 1.0E-5
|
||||
|
||||
namespace VCSnonideal {
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* vcs_funcVtot:
|
||||
*
|
||||
* This is the rootfinder function call for the function vcs_TV().
|
||||
*
|
||||
*/
|
||||
double vcs_funcVtot(double xval, double Vtarget, int varID, void *fptrPassthrough, int *err)
|
||||
{
|
||||
VCS_SOLVE *vptr = (VCS_SOLVE *) fptrPassthrough;
|
||||
static int first_time = TRUE;
|
||||
int retn;
|
||||
double vol;
|
||||
if (varID == 0) {
|
||||
vptr->T = xval;
|
||||
} else if (varID == 1) {
|
||||
vptr->Pres = xval;
|
||||
}
|
||||
#ifdef DEBUG_MODE
|
||||
retn = vptr->vcs_TP(1, 1, 10000, vptr->T, vptr->Pres);
|
||||
#else
|
||||
retn = vptr->vcs_TP(0, 0, 10000, vptr->T, vptr->Pres);
|
||||
#endif
|
||||
if (retn != VCS_SUCCESS) {
|
||||
plogf("vcs_funcVtot ERROR: vcs_TP returned error condition, %d\n",
|
||||
retn);
|
||||
*err = retn;
|
||||
}
|
||||
vol = vptr->vcs_VolTotal(vptr->T, vptr->Pres, VCS_DATA_PTR(vptr->soln),
|
||||
VCS_DATA_PTR(vptr->VolPM));
|
||||
#ifdef DEBUG_MODE
|
||||
vptr->vcs_report(retn);
|
||||
#endif
|
||||
|
||||
|
||||
if (first_time) {
|
||||
first_time = FALSE;
|
||||
vptr->iest = FALSE;
|
||||
}
|
||||
return (vol - Vtarget);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
}
|
||||
|
||||
|
|
@ -102,29 +102,6 @@ namespace VCSnonideal {
|
|||
double T_Time_vcs;
|
||||
};
|
||||
|
||||
//! This is the rootfinder function call for the function vcs_TV()
|
||||
/*!
|
||||
* The function is of type VCS_FUNC_PTR
|
||||
* It's the function call for the vcs_TV().
|
||||
* Solves for the total volume of the system, by first calculating
|
||||
* the equilibrium wrt T,P.
|
||||
* Routine then returns
|
||||
*
|
||||
* \f[
|
||||
* f(x) = V(T,P) - Vtarget
|
||||
* \f]
|
||||
*
|
||||
* @param xval Currently value of the independent variable
|
||||
* @param Vtarget Target value of the volume
|
||||
* @param varID If 0, xval is temperature, If 1, xval is pressure.
|
||||
* @param fptrPassthrough Pointer to VCS_SOLVE object
|
||||
* @param err Return 0 for success. Anything else is an error code.
|
||||
*
|
||||
*/
|
||||
double vcs_funcVtot(double xval, double Vtarget, int varID,
|
||||
void *fptrPassthrough, int *err);
|
||||
|
||||
|
||||
//! Returns the value of the gas constant in the units specified by parameter
|
||||
/*!
|
||||
* @param mu_units Specifies the units.
|
||||
|
|
|
|||
|
|
@ -387,18 +387,9 @@ namespace VCSnonideal {
|
|||
* a 2x2 Newton's method, using loops over vcs_TP() to
|
||||
* calculate the residual and Jacobian)
|
||||
*/
|
||||
switch (vprob->prob_type) {
|
||||
case VCS_PROBTYPE_TP:
|
||||
iconv = vcs_TP(ipr, ip1, maxit, vprob->T, vprob->Pres);
|
||||
break;
|
||||
case VCS_PROBTYPE_TV:
|
||||
iconv = vcs_TV(ipr, ip1, maxit, vprob->T, vprob->Vol);
|
||||
break;
|
||||
default:
|
||||
plogf("Unknown or unimplemented problem type: %d\n",
|
||||
vprob->prob_type);
|
||||
return VCS_PUB_BAD;
|
||||
}
|
||||
|
||||
iconv = vcs_TP(ipr, ip1, maxit, vprob->T, vprob->Pres);
|
||||
|
||||
|
||||
/*
|
||||
* If requested to print anything out, go ahead and do so;
|
||||
|
|
@ -994,9 +985,7 @@ namespace VCSnonideal {
|
|||
|
||||
return VCS_SUCCESS;
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// Initialize the internal counters
|
||||
/*
|
||||
* Initialize the internal counters containing the subroutine call
|
||||
|
|
@ -1023,6 +1012,43 @@ namespace VCSnonideal {
|
|||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* vcs_VolTotal
|
||||
*
|
||||
* This function calculates the partial molar volume
|
||||
* for all species, kspec, in the thermo problem
|
||||
* at the temperature TKelvin and pressure, Pres, pres is in atm.
|
||||
* And, it calculates the total volume of the combined system.
|
||||
*
|
||||
* Input
|
||||
* iphase
|
||||
* TKelvin
|
||||
* pres
|
||||
* w[] => vector containing the current mole numbers.
|
||||
*
|
||||
* Output
|
||||
* VolPM[] => For species in all phase, the entries are the
|
||||
* partial molar volumes
|
||||
* return value = Total volume of the phase in L**3 / MOL_UNITS
|
||||
*
|
||||
* (L and MOL_UNITS determined from global units value if__)
|
||||
*/
|
||||
double VCS_SOLVE::vcs_VolTotal(double tkelvin, double pres, double w[],
|
||||
double volPM[])
|
||||
{
|
||||
double volTot = 0.0;
|
||||
for (int iphase = 0; iphase < NPhase; iphase++) {
|
||||
vcs_VolPhase *Vphase = VPhaseList[iphase];
|
||||
Vphase->setState_TP(tkelvin, pres);
|
||||
Vphase->setMolesFromVCS(w);
|
||||
double volp = Vphase->VolPM_calc();
|
||||
(void) Vphase->sendToVCSVolPM(volPM);
|
||||
volTot += volp;
|
||||
}
|
||||
return volTot;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@ public:
|
|||
|
||||
int vcs_evalSS_TP(int ipr, int ip1, double Temp, double pres);
|
||||
void vcs_fePrep_TP(void);
|
||||
int vcs_TV(int ipr, int ip1, int maxit, double T, double VolRequest);
|
||||
double vcs_VolTotal(double, double, double [], double []);
|
||||
|
||||
int vcs_prep_oneTime(int printLvl);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue