|
|
@@ -80,7 +80,6 @@ void REGRID(double* ydata,double* ydotdata,UserData data){ |
|
|
|
} |
|
|
|
|
|
|
|
INTERPO(ydata,ydotdata,nvar,nPts,XNEW,XOLD); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -148,7 +147,7 @@ double maxTemperature(const double* y,const size_t nt,const size_t nvar ,size_t |
|
|
|
} |
|
|
|
return(maxT); |
|
|
|
} |
|
|
|
|
|
|
|
//Index here is 1-based |
|
|
|
int maxTemperatureIndex(const double* y,const size_t nt,const size_t nvar ,size_t nPts){ |
|
|
|
double maxT = 0.0e0; |
|
|
|
double TempT = 0.0e0; |
|
|
@@ -671,7 +670,6 @@ int initializePsiGrid(double* ydata, double* psidata, UserData data){ |
|
|
|
int setInitialCondition(N_Vector* y, |
|
|
|
N_Vector* ydot, |
|
|
|
UserData data){ |
|
|
|
|
|
|
|
double* ydata; |
|
|
|
double* ydotdata; |
|
|
|
double* psidata; |
|
|
@@ -1108,9 +1106,9 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data){ |
|
|
|
/*Update specific heat:Cpl for liquid proprane&n-heptane&dodecane*/ |
|
|
|
/*Based on the existiong data,a linear expression is used*/ |
|
|
|
// Cpl= 12.10476*T(1) - 746.60143; // Unit:J/(kg*K), Need to be improved later |
|
|
|
Cpl[0] = 2.423*T(1)+1661.074; //Unit:J/(kg*K),range:1atm,propane |
|
|
|
Cpl[1] = 3.336*T(1)+1289.5; //Unit:J/(kg*K),range:1atm,n-Heptane |
|
|
|
//Cpl[1] = 3.815*T(1)+1081.8; //Unit:J/(kg*K),range:1atm,n-Dodecane |
|
|
|
//Cpl[0] = 2.423*T(1)+1661.074; //Unit:J/(kg*K),range:1atm,propane |
|
|
|
Cpl[0] = 3.336*T(1)+1289.5; //Unit:J/(kg*K),range:1atm,n-Heptane |
|
|
|
Cpl[1] = 3.815*T(1)+1081.8; //Unit:J/(kg*K),range:1atm,n-Dodecane |
|
|
|
double Cp_l = 0.0; |
|
|
|
for(size_t i=0;i<=1;i++){ |
|
|
|
Cp_l=Cp_l+Cpl[i]*data->dropMassFrac[i]; |
|
|
@@ -1137,9 +1135,9 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data){ |
|
|
|
|
|
|
|
/*Following section is related to the property of liquid n-heptane and n-dodecane (mainly density rho)*/ |
|
|
|
/*Density of these two species should be temperature dependent*/ |
|
|
|
data->dropDens[0] = -1.046*T(1)+823.794; //Unit:kg/m^3,density of propane @1atm |
|
|
|
data->dropDens[1] = -0.858*T(1)+933.854; //Unit:kg/m^3,density of n-Heptane @1atm |
|
|
|
//data->dropDens[1] = -0.782*T(1)+979.643; //Unit:kg/m^3,density of n-Dodecane @1atm |
|
|
|
//data->dropDens[0] = -1.046*T(1)+823.794; //Unit:kg/m^3,density of propane @1atm |
|
|
|
data->dropDens[0] = -0.858*T(1)+933.854; //Unit:kg/m^3,density of n-Heptane @1atm |
|
|
|
data->dropDens[1] = -0.782*T(1)+979.643; //Unit:kg/m^3,density of n-Dodecane @1atm |
|
|
|
//rhol = data->dropRho; //Unit:kg/m^3 |
|
|
|
rhol = 0.0; |
|
|
|
for(size_t i=0;i<=1;i++){ |
|
|
@@ -1149,7 +1147,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data){ |
|
|
|
|
|
|
|
aream= calc_area(R(1),&m); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************/ |
|
|
|
/*Calculate values at j=2's m and mhalf*****************************/ |
|
|
|
|
|
|
@@ -1209,7 +1207,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data){ |
|
|
|
///Yres(1,k)=innerMassFractionsData[k-1]- |
|
|
|
/// Y(1,k)- |
|
|
|
/// (YVmhalf(k)*areamhalf)/Mdot(1); |
|
|
|
//Yres(1,k)=Y(1,k)*Mdot(1) + YVmhalf(k)*areamhalf; |
|
|
|
|
|
|
|
//} |
|
|
|
//else{ |
|
|
|
// //Yres(1,k)=Y(1,k)-innerMassFractionsData[k-1]; |
|
|
@@ -1793,11 +1791,8 @@ void getTimescale(UserData data, N_Vector* y){ |
|
|
|
for(k=1;k<= nsp;k++){ |
|
|
|
data->time_scale(i,k) = concentra(k)/(wdot_mass(k)+ 1.00e-16) ; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -1836,7 +1831,6 @@ void printTimescaleOutput(double t,N_Vector* y,FILE* output,UserData data) |
|
|
|
fprintf(output, "\n"); |
|
|
|
} |
|
|
|
fprintf(output, "\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void floorSmallValue(UserData data, N_Vector* y) |
|
|
@@ -1915,3 +1909,75 @@ void resetTolerance(UserData data, N_Vector* y,N_Vector* atolv) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void getReactions(UserData data,N_Vector* y,FILE* output){ |
|
|
|
double Tmax; |
|
|
|
double* ydata; |
|
|
|
//double deltaT = 400.0; |
|
|
|
//int i = 0; |
|
|
|
size_t nRxns; |
|
|
|
int index; |
|
|
|
nRxns = data->gas->nReactions(); |
|
|
|
//DEBUG |
|
|
|
printf("Total Number of Rxns:%zu \n",nRxns); |
|
|
|
double fwdROP[nRxns],revROP[nRxns],netROP[nRxns]; |
|
|
|
std::string* rxnArr = new std::string[nRxns]; |
|
|
|
/*DEBUG*/ |
|
|
|
printf("Memory Allocation for Rxns Array Succeed!\n"); |
|
|
|
ydata = N_VGetArrayPointer_OpenMP(*y); |
|
|
|
Tmax = maxTemperature(ydata,data->nt,data->nvar,data->npts); |
|
|
|
//get the rxns' equation array |
|
|
|
for(size_t ii=0;ii<nRxns;ii++){ |
|
|
|
rxnArr[ii]= data->gas->reactionString(ii); |
|
|
|
} |
|
|
|
if(Tmax>=(data->initialTemperature+data->deltaT)){ |
|
|
|
index = maxTemperatureIndex(ydata,data->nt,data->nvar,data->npts); |
|
|
|
setGas(data,ydata,index); |
|
|
|
/*Get forward/reverse/net rate of progress of rxns*/ |
|
|
|
data->gas->getRevRatesOfProgress(revROP); |
|
|
|
data->gas->getFwdRatesOfProgress(fwdROP); |
|
|
|
data->gas->getNetRatesOfProgress(netROP); |
|
|
|
for(size_t j=0 ; j<nRxns; j++){ |
|
|
|
fprintf(output,"%30s\t",rxnArr[j]); |
|
|
|
fprintf(output,"%15.9e\t%15.9e\t%15.9e\t\n",fwdROP[j],revROP[j],netROP[j]); |
|
|
|
} |
|
|
|
fprintf(output, "\n"); |
|
|
|
fclose(output); |
|
|
|
} |
|
|
|
delete[] rxnArr; |
|
|
|
} |
|
|
|
|
|
|
|
void getSpecies(UserData data,N_Vector* y,FILE* output){ |
|
|
|
double Tmax; |
|
|
|
double* ydata; |
|
|
|
//double deltaT = 400.0; |
|
|
|
//int i = 0; |
|
|
|
int index; |
|
|
|
double fwdROP[data->nsp],revROP[data->nsp],netROP[data->nsp]; |
|
|
|
std::string* spArr = new std::string[data->nsp]; |
|
|
|
/*DEBUG*/ |
|
|
|
printf("Memory Allocation for Species Array Succeed!\n"); |
|
|
|
ydata = N_VGetArrayPointer_OpenMP(*y); |
|
|
|
Tmax = maxTemperature(ydata,data->nt,data->nvar,data->npts); |
|
|
|
//get the species name array |
|
|
|
for(size_t ii=0;ii<data->nsp;ii++){ |
|
|
|
spArr[ii]= data->gas->speciesName(ii); |
|
|
|
} |
|
|
|
|
|
|
|
if(Tmax>=(data->initialTemperature+data->deltaT)){ |
|
|
|
//i = i + 1 ; |
|
|
|
index = maxTemperatureIndex(ydata,data->nt,data->nvar,data->npts); |
|
|
|
setGas(data,ydata,index); |
|
|
|
/*Get forward/reverse/net rate of progress of rxns*/ |
|
|
|
data->gas->getDestructionRates(revROP); |
|
|
|
data->gas->getCreationRates(fwdROP); |
|
|
|
data->gas->getNetProductionRates(netROP); |
|
|
|
/*Print data to the pertinent output file*/ |
|
|
|
for(size_t j=0 ; j<data->nsp; j++){ |
|
|
|
fprintf(output,"%15s\t",spArr[j]); |
|
|
|
fprintf(output,"%15.9e\t%15.9e\t%15.9e\t\n",fwdROP[j],revROP[j],netROP[j]); |
|
|
|
} |
|
|
|
fprintf(output, "\n"); |
|
|
|
fclose(output); |
|
|
|
} |
|
|
|
delete[] spArr; |
|
|
|
} |