|
|
@@ -95,13 +95,28 @@ int maxCurvIndex(const double* y, const size_t nt, |
|
|
|
return(pos); |
|
|
|
} |
|
|
|
|
|
|
|
//double isothermPosition(const double* y, const double T, const size_t nt, |
|
|
|
// const size_t nvar, const double* x, const size_t nPts){ |
|
|
|
// double pos=x[nPts-1]; |
|
|
|
// size_t j; |
|
|
|
// for (size_t i = 1; i <nPts; i++) { |
|
|
|
// j=i*nvar+nt; |
|
|
|
// if (y[j]<=T) { |
|
|
|
// pos=x[i]; |
|
|
|
// break; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// return(pos); |
|
|
|
//} |
|
|
|
|
|
|
|
//******************* scan the temperature from left to right ******************// |
|
|
|
double isothermPosition(const double* y, const double T, const size_t nt, |
|
|
|
const size_t nvar, const double* x, const size_t nPts){ |
|
|
|
double pos=x[nPts-1]; |
|
|
|
double pos=x[0]; |
|
|
|
size_t j; |
|
|
|
for (size_t i = 1; i <nPts; i++) { |
|
|
|
for (size_t i = 0; i <nPts; i++) { |
|
|
|
j=i*nvar+nt; |
|
|
|
if (y[j]<=T) { |
|
|
|
if (y[j]>=T) { |
|
|
|
pos=x[i]; |
|
|
|
break; |
|
|
|
} |
|
|
@@ -833,7 +848,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data){ |
|
|
|
//dHvl= 5.2053e07*pow(1-Tr,0.3199 - 0.212*Tr + 0.25795*Tr*Tr)/18.01; //J/kg latent heat of vaporization of water |
|
|
|
|
|
|
|
double Tr = T(1)/540.2; //Reduced Temperature:Droplet Temperature divided by critical temperature of liquid n-heptane, Source:NIST |
|
|
|
dHvl = 5.366e5*exp(-0.2831*Tr) * pow((1-Tr),0.2831); //Unit:J/kg, latent heat of vaporization of liquid n-heptane, Source: NIST |
|
|
|
dHvl = 5.366e5*exp(-0.2831*Tr) * pow((1-Tr),0.2831); //Unit:J/kg, latent heat of vaporization of liquid n-heptane, Source: NIST |
|
|
|
|
|
|
|
/*Following section is related to the property of water*/ |
|
|
|
//rhol = 997.0; |
|
|
@@ -880,8 +895,8 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data){ |
|
|
|
/*Following using the Antoine Parameters to calculate the pressure of volatile component(n-heptane)*/ |
|
|
|
//Antoine parameter from NIST website |
|
|
|
double p_i=0.0 ; |
|
|
|
p_i = 1.0e5*pow(10,4.02832-(1268.636/(T(1)-56.199))) ; //FOR N-HEPTANE |
|
|
|
//p_i = 1.0e3*pow(2.71828,16.7-(4060.0/(T(1)-37.0))); //FOR WATER |
|
|
|
p_i = 1.0e5*pow(10,4.02832-(1268.636/(T(1)-56.199))) ; //unit:Pa,FOR N-HEPTANE |
|
|
|
//p_i = 1.0e3*pow(2.71828,16.7-(4060.0/(T(1)-37.0))); //Unit:Pa,FOR WATER |
|
|
|
Yres(1,k_drop)=Y(1,k_drop) - p_i * data->gas->molecularWeight(k_drop-1) |
|
|
|
/ P(1) / data->gas->meanMolecularWeight(); |
|
|
|
|
|
|
@@ -1553,3 +1568,50 @@ void floorSmallValue(UserData data, N_Vector* y) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void resetTolerance(UserData data, N_Vector* y,N_Vector* atolv) |
|
|
|
{ |
|
|
|
double* ydata; |
|
|
|
realtype* atolvdata; |
|
|
|
ydata = N_VGetArrayPointer_OpenMP(*y); |
|
|
|
atolvdata = N_VGetArrayPointer_OpenMP(*atolv); |
|
|
|
double relTol,radTol,tempTol,presTol,massFracTol,bathGasTol,mdotTol; |
|
|
|
double maxT=0.00, ignT=1800; |
|
|
|
relTol = 1.0e-03 ; |
|
|
|
radTol = 1.0e-05 ; |
|
|
|
tempTol = 1.0e-01 ; |
|
|
|
presTol = 1.0e00 ; |
|
|
|
massFracTol = 1.0e-08; |
|
|
|
bathGasTol = 1.0e-04 ; |
|
|
|
mdotTol = 1.0e-09 ; |
|
|
|
|
|
|
|
|
|
|
|
/*Get the maximum Tempture*/ |
|
|
|
for (size_t i =1;i <= data->npts;i++){ |
|
|
|
if(T(i) > maxT){ |
|
|
|
maxT = T(i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*reset the tolerance when maxT > ignT*/ |
|
|
|
if(maxT >= ignT){ |
|
|
|
data->relativeTolerance = relTol; |
|
|
|
|
|
|
|
for(size_t i =1; i<=data->npts; i++){ |
|
|
|
atolT(i) = tempTol; |
|
|
|
atolR(i) = radTol ; |
|
|
|
atolP(i) = presTol ; |
|
|
|
atolMdot(i) = mdotTol ; |
|
|
|
|
|
|
|
for(size_t k =1; k<= data->nsp; k++){ |
|
|
|
if(k!=data->k_bath){ |
|
|
|
atolY(i,k) = massFracTol; |
|
|
|
}else{ |
|
|
|
atolY(i,k) = bathGasTol; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|