|
|
@@ -1444,3 +1444,80 @@ void printGlobalVariables(double t, N_Vector* y, N_Vector* ydot, UserData data) |
|
|
|
//// Ydot(npts-1,k)=Ydot(npts,k); |
|
|
|
//// } |
|
|
|
////} |
|
|
|
|
|
|
|
|
|
|
|
/*Following functions are added to derive the characteristic time scale of species*/ |
|
|
|
void getTimescale(UserData data, N_Vector* y){ |
|
|
|
size_t i, k, nsp,npts ; |
|
|
|
nsp = data->nsp ; |
|
|
|
npts = data->npts ; |
|
|
|
double rho, wdot_mole[nsp], wdot_mass[nsp],MW[nsp],concentra[nsp]; |
|
|
|
//double time_scale[npts*nsp] ; |
|
|
|
|
|
|
|
double* ydata ; |
|
|
|
ydata = N_VGetArrayPointer_OpenMP(*y); //access the data stored in N_Vector* y |
|
|
|
|
|
|
|
for(i=1; i<= npts;i++){ |
|
|
|
setGas(data,ydata,i); //set the gas state at each grid point |
|
|
|
rho = data->gas->density(); //get the averaged density at each grid point, Unit:kg/m^3 |
|
|
|
data->gas->getNetProductionRates(wdot_mole) ; //Unit:kmol/(m^3 * s) |
|
|
|
|
|
|
|
for(k=1; k<= nsp; k++){ |
|
|
|
MW(k) = data->gas->molecularWeight(k-1) ; //Unit:kg/kmol |
|
|
|
} |
|
|
|
|
|
|
|
for(k=1; k<= nsp; k++){ |
|
|
|
wdot_mass(k) = wdot_mole(k) * MW(k) ; //Unit:kg/(m^3 * s) |
|
|
|
} |
|
|
|
|
|
|
|
for(k=1; k<= nsp; k++){ |
|
|
|
concentra(k) = Y(i,k) * rho ; //Unit:kg/m^3 |
|
|
|
} |
|
|
|
|
|
|
|
for(k=1;k<= nsp;k++){ |
|
|
|
data->time_scale(i,k) = concentra(k)/(wdot_mass(k)+ 1.00e-16) ; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void printTimescaleHeader(UserData data) |
|
|
|
{ |
|
|
|
fprintf((data->timescaleOutput), "%15s\t","#1"); |
|
|
|
for (size_t k = 1; k <=data->nsp+1; k++) { |
|
|
|
fprintf((data->timescaleOutput), "%15lu\t",k+1); |
|
|
|
} |
|
|
|
fprintf((data->timescaleOutput), "%15lu\n",data->nsp+3); |
|
|
|
|
|
|
|
|
|
|
|
fprintf((data->timescaleOutput), "%15s\t%15s\t%15s\t","#time","radius","Temp(K)"); |
|
|
|
//fprintf((data->output), "%15s\t%15s\t","radius(m)","Temp(K)"); |
|
|
|
for (size_t k = 1; k <=(data->nsp); k++) { |
|
|
|
fprintf((data->timescaleOutput), "%15s\t",data->gas->speciesName(k-1).c_str()); |
|
|
|
} |
|
|
|
//fprintf((data->output), "%15s\t","Pressure(Pa)"); |
|
|
|
//fprintf((data->timescaleOutput), "%15s\n",data->gas->speciesName(data->nsp-1).c_str()); |
|
|
|
//fprintf((data->output), "%15s\n","Mdot (kg/s)"); |
|
|
|
fprintf((data->timescaleOutput), "\n"); |
|
|
|
} |
|
|
|
|
|
|
|
void printTimescaleOutput(double t,N_Vector* y,FILE* output,UserData data) |
|
|
|
{ |
|
|
|
double* ydata; |
|
|
|
ydata = N_VGetArrayPointer_OpenMP(*y); |
|
|
|
|
|
|
|
for(size_t i=1 ; i<= data->npts; i++){ |
|
|
|
fprintf(output, "%15.9e\t%15.9e\t",t,R(i)); |
|
|
|
|
|
|
|
for(size_t k=1; k<=data->nsp;k++){ |
|
|
|
fprintf(output, "%15.9e\t",data->time_scale(i,k)); |
|
|
|
} |
|
|
|
fprintf(output, "\n"); |
|
|
|
} |
|
|
|
fprintf(output, "\n"); |
|
|
|
|
|
|
|
|
|
|
|
} |