|
@@ -556,19 +556,9 @@ int setAlgebraicVariables(N_Vector *id, UserData data, const double *ydata) { |
|
|
// data->k_drop[0]=specIndex(data,specPtr[0]); |
|
|
// data->k_drop[0]=specIndex(data,specPtr[0]); |
|
|
// data->k_drop[1]=specIndex(data,specPtr[1]); |
|
|
// data->k_drop[1]=specIndex(data,specPtr[1]); |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < data->dropMole.size(); i++) { |
|
|
|
|
|
size_t index = 0; |
|
|
|
|
|
for (size_t k = 1; k <= data->nsp; k++) { |
|
|
|
|
|
if (data->gas->speciesName(k - 1) == data->dropSpec[i]) { |
|
|
|
|
|
index = k; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// size_t index = specIndex(data, data->dropSpec[i].c_str()); |
|
|
|
|
|
data->k_drop.push_back(index); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
printf("Oxidizer index: %lu\n", data->k_oxidizer); |
|
|
printf("Oxidizer index: %lu\n", data->k_oxidizer); |
|
|
printf("Bath gas index:%lu\n", data->k_bath); |
|
|
|
|
|
|
|
|
printf("Bath gas index: %lu\n", data->k_bath); |
|
|
printf("Droplet species index: "); |
|
|
printf("Droplet species index: "); |
|
|
|
|
|
|
|
|
for(auto & arg : data->k_drop){ |
|
|
for(auto & arg : data->k_drop){ |
|
@@ -1031,9 +1021,10 @@ int initializePsiEtaGrid(double *ydata, double *psidata, UserData data) { |
|
|
} |
|
|
} |
|
|
} else if (data->dropType == 1) { |
|
|
} else if (data->dropType == 1) { |
|
|
for (size_t i = data->l_npts - 1; i >= 1; i--) { |
|
|
for (size_t i = data->l_npts - 1; i >= 1; i--) { |
|
|
std::vector<double> moleFrac, moleFracp; |
|
|
|
|
|
moleFrac = getLiquidmolevec(data, ydata, i); |
|
|
|
|
|
moleFracp = getLiquidmolevec(data, ydata, i + 1); |
|
|
|
|
|
|
|
|
// std::vector<double> moleFrac, moleFracp; |
|
|
|
|
|
double moleFrac[2] ={},moleFracp[2]={}; |
|
|
|
|
|
getLiquidMoleVec(data, ydata, i,moleFrac); |
|
|
|
|
|
getLiquidMoleVec(data, ydata, i + 1,moleFracp); |
|
|
rho = getLiquidDensity(T(i), P(i), composition, moleFrac); |
|
|
rho = getLiquidDensity(T(i), P(i), composition, moleFrac); |
|
|
rhop = getLiquidDensity(T(i + 1), P(i + 1), composition, moleFracp); |
|
|
rhop = getLiquidDensity(T(i + 1), P(i + 1), composition, moleFracp); |
|
|
psi(i) = psi(i + 1) + (R(i + 1) - R(i)) * |
|
|
psi(i) = psi(i + 1) + (R(i + 1) - R(i)) * |
|
@@ -1721,7 +1712,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
std::vector<size_t> k_drop = data->k_drop; |
|
|
std::vector<size_t> k_drop = data->k_drop; |
|
|
std::vector<std::string> dropSpec = data->dropSpec; |
|
|
std::vector<std::string> dropSpec = data->dropSpec; |
|
|
std::vector<std::string> composition = components(data->dropType); |
|
|
std::vector<std::string> composition = components(data->dropType); |
|
|
std::vector<double> dropMole = data->dropMole; |
|
|
|
|
|
|
|
|
std::vector<double> dropMole = data->dropMole; //only for size determination |
|
|
|
|
|
|
|
|
ydata = N_VGetArrayPointer_OpenMP(y); |
|
|
ydata = N_VGetArrayPointer_OpenMP(y); |
|
|
ydotdata = N_VGetArrayPointer_OpenMP(ydot); |
|
|
ydotdata = N_VGetArrayPointer_OpenMP(ydot); |
|
@@ -1783,7 +1774,11 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
double mass, massDrop; |
|
|
double mass, massDrop; |
|
|
double sum, sum1, sum2, sum3; |
|
|
double sum, sum1, sum2, sum3; |
|
|
|
|
|
|
|
|
std::vector<double> vapheat, mole_,liquidCp,vapPres; |
|
|
|
|
|
|
|
|
// std::vector<double> vapheat, mole_,liquidCp,vapPres; |
|
|
|
|
|
double vapheat[2]={}; |
|
|
|
|
|
double mole_[2]={} ; |
|
|
|
|
|
double liquidCp[2]={}; |
|
|
|
|
|
double vapPres[2]={}; |
|
|
|
|
|
|
|
|
// size_t j, k; |
|
|
// size_t j, k; |
|
|
int m; |
|
|
int m; |
|
@@ -1799,7 +1794,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
Yres(1, k) = Ydot(1, k); |
|
|
Yres(1, k) = Ydot(1, k); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
|
|
|
|
|
|
} else if (dropType == 1) { |
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
if (k == k_drop[0]) { |
|
|
if (k == k_drop[0]) { |
|
|
Yres(1, k) = Y(2, k) - Y(1, k); |
|
|
Yres(1, k) = Y(2, k) - Y(1, k); |
|
@@ -1814,30 +1809,32 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
Mdotres(1) = Mdot(2) - Mdot(1); |
|
|
Mdotres(1) = Mdot(2) - Mdot(1); |
|
|
Tres(1) = T(2) - T(1); |
|
|
Tres(1) = T(2) - T(1); |
|
|
|
|
|
|
|
|
/*set governing equations at intermediate grid points */ |
|
|
|
|
|
massDrop = dropletmass(data, ydata); |
|
|
|
|
|
|
|
|
/*set governing equations at internal grid points */ |
|
|
|
|
|
massDrop = dropletmass(data, ydata,composition); |
|
|
if (dropType == 0) { |
|
|
if (dropType == 0) { |
|
|
|
|
|
//#pragma omp parallel |
|
|
|
|
|
/*Calculate values at j=2's m and mhalf****************/ |
|
|
|
|
|
aream = calc_area(R(1), &m); |
|
|
|
|
|
rhom = getLiquidDensity(T(1), P(1), composition); |
|
|
|
|
|
areamhalf = calc_area(HALF * (R(1) + R(2)), &m); |
|
|
|
|
|
areamhalfsq = areamhalf * areamhalf; |
|
|
|
|
|
setLiquidTransport(data, ydata, 1, composition, &rhomhalf, &lambdamhalf, &propYVmhalf); |
|
|
|
|
|
|
|
|
|
|
|
/*loop over internal liquid phase grid points *********/ |
|
|
for (size_t j = 2; j <= l_npts - 1; j++) { |
|
|
for (size_t j = 2; j <= l_npts - 1; j++) { |
|
|
/*Mass:*/ |
|
|
/*Mass:*/ |
|
|
/* ∂r/∂ψ = 1/ρA */ |
|
|
/* ∂r/∂ψ = 1/ρA */ |
|
|
dpsim = - (psi(j) - psi(j - 1)); |
|
|
|
|
|
dpsip = - (psi(j + 1) - psi(j)); |
|
|
|
|
|
dpsiav = - (HALF * (psi(j + 1) - psi(j - 1))); |
|
|
|
|
|
rho = getLiquidDensity(T(j), P(j), composition); |
|
|
|
|
|
rhom = getLiquidDensity(T(j - 1), P(j - 1), composition); |
|
|
|
|
|
rhophalf = getLiquidDensity(HALF * (T(j) + T(j + 1)), HALF * (P(j) + P(j + 1)), composition); |
|
|
|
|
|
rhomhalf = getLiquidDensity(HALF * (T(j) + T(j - 1)), HALF * (P(j) + P(j - 1)), composition); |
|
|
|
|
|
|
|
|
dpsim = -(psi(j) - psi(j - 1)); |
|
|
|
|
|
dpsip = -(psi(j + 1) - psi(j)); |
|
|
|
|
|
dpsiav = -(HALF * (psi(j + 1) - psi(j - 1))); |
|
|
|
|
|
|
|
|
|
|
|
area = calc_area(R(j), &m); |
|
|
Cpb = getLiquidCpb(T(j), P(j), composition); |
|
|
Cpb = getLiquidCpb(T(j), P(j), composition); |
|
|
lambdaphalf = getLiquidCond(HALF * (T(j) + T(j + 1)), HALF * (P(j) + P(j + 1)), composition); |
|
|
|
|
|
lambdamhalf = getLiquidCond(HALF * (T(j) + T(j - 1)), HALF * (P(j) + P(j - 1)), composition); |
|
|
|
|
|
|
|
|
rho = getLiquidDensity(T(j), P(j), composition); |
|
|
|
|
|
|
|
|
aream = calc_area(R(j - 1), &m); |
|
|
|
|
|
areamhalf = calc_area(HALF * (R(j) + R(j - 1)), &m); |
|
|
|
|
|
areaphalf = calc_area(HALF * (R(j + 1) + R(j)), &m); |
|
|
areaphalf = calc_area(HALF * (R(j + 1) + R(j)), &m); |
|
|
areamhalfsq = areamhalf * areamhalf; |
|
|
|
|
|
areaphalfsq = areaphalf * areaphalf; |
|
|
areaphalfsq = areaphalf * areaphalf; |
|
|
area = calc_area(R(j), &m); |
|
|
|
|
|
|
|
|
setLiquidTransport(data,ydata,j,composition,&rhophalf,&lambdaphalf,&propYVphalf) ; |
|
|
|
|
|
|
|
|
Rres(j) = ((R(j) - R(j - 1)) / dpsim) - massDrop * (TWO / (rhom * aream + rho * area)); |
|
|
Rres(j) = ((R(j) - R(j - 1)) / dpsim) - massDrop * (TWO / (rhom * aream + rho * area)); |
|
|
Mdotres(j) = Mdot(j + 1) - Mdot(j); |
|
|
Mdotres(j) = Mdot(j + 1) - Mdot(j); |
|
@@ -1847,11 +1844,20 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tranTerm = Tdot(j); |
|
|
tranTerm = Tdot(j); |
|
|
advTerm = psi(j) * (-Mdot(j)) / massDrop * (T(j) - T(j - 1)) / dpsim ; |
|
|
|
|
|
|
|
|
advTerm = psi(j) * (-Mdot(j)) / massDrop * (T(j) - T(j - 1)) / dpsim; |
|
|
diffTerm = 1 / (Cpb * massDrop * massDrop) * |
|
|
diffTerm = 1 / (Cpb * massDrop * massDrop) * |
|
|
(rhophalf * areaphalfsq * lambdaphalf * (T(j + 1) - T(j)) / dpsip - |
|
|
(rhophalf * areaphalfsq * lambdaphalf * (T(j + 1) - T(j)) / dpsip - |
|
|
rhomhalf * areamhalfsq * lambdamhalf * (T(j) - T(j - 1)) / dpsim) / dpsiav; |
|
|
rhomhalf * areamhalfsq * lambdamhalf * (T(j) - T(j - 1)) / dpsim) / dpsiav; |
|
|
Tres(j) = tranTerm - advTerm - diffTerm; |
|
|
Tres(j) = tranTerm - advTerm - diffTerm; |
|
|
|
|
|
|
|
|
|
|
|
/*Assign values evaluated at p and phalf to |
|
|
|
|
|
* m and mhalf to save some cpu cost:********/ |
|
|
|
|
|
areamhalf = areaphalf ; |
|
|
|
|
|
areamhalfsq = areaphalfsq ; |
|
|
|
|
|
aream = area; |
|
|
|
|
|
rhom = rho ; |
|
|
|
|
|
rhomhalf = rhophalf; |
|
|
|
|
|
lambdamhalf = lambdaphalf ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*Fill up the res at l_npts*/ |
|
|
/*Fill up the res at l_npts*/ |
|
@@ -1859,7 +1865,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
area = calc_area(R(l_npts), &m); |
|
|
area = calc_area(R(l_npts), &m); |
|
|
lambdamhalf = getLiquidCond(T(l_npts), P(l_npts), composition); |
|
|
lambdamhalf = getLiquidCond(T(l_npts), P(l_npts), composition); |
|
|
lambdaphalf = getGasCond(data, ydata, l_npts+1); |
|
|
lambdaphalf = getGasCond(data, ydata, l_npts+1); |
|
|
vapheat = getLiquidVH(P(l_npts+1), data->dropType); |
|
|
|
|
|
|
|
|
getLiquidVH(P(l_npts+1), data->dropType,vapheat); |
|
|
|
|
|
|
|
|
Rres(l_npts) = Mdot(l_npts) + rho * Rdot(l_npts) * area; |
|
|
Rres(l_npts) = Mdot(l_npts) + rho * Rdot(l_npts) * area; |
|
|
Mdotres(l_npts) = Mdot(l_npts + 1) - Mdot(l_npts); |
|
|
Mdotres(l_npts) = Mdot(l_npts + 1) - Mdot(l_npts); |
|
@@ -1870,11 +1876,20 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
Tres(l_npts) = lambdamhalf * (T(l_npts) - T(l_npts - 1)) / (R(l_npts) - R(l_npts - 1)) * area + |
|
|
Tres(l_npts) = lambdamhalf * (T(l_npts) - T(l_npts - 1)) / (R(l_npts) - R(l_npts - 1)) * area + |
|
|
Mdot(l_npts) * vapheat[0] - |
|
|
Mdot(l_npts) * vapheat[0] - |
|
|
lambdaphalf * (T(l_npts + 2) - T(l_npts + 1)) / (R(l_npts + 2) - R(l_npts + 1)) * area; |
|
|
lambdaphalf * (T(l_npts + 2) - T(l_npts + 1)) / (R(l_npts + 2) - R(l_npts + 1)) * area; |
|
|
} else { |
|
|
|
|
|
|
|
|
} else if (dropType == 1) { |
|
|
/*binary component case*/ |
|
|
/*binary component case*/ |
|
|
|
|
|
|
|
|
|
|
|
/*Calculate values at j=2's m and mhalf****************/ |
|
|
|
|
|
aream = calc_area(R(1), &m); |
|
|
|
|
|
rhom = getLiquidDensity(T(1), P(1), composition); |
|
|
|
|
|
areamhalf = calc_area(HALF * (R(1) + R(2)), &m); |
|
|
|
|
|
areamhalfsq = areamhalf * areamhalf; |
|
|
|
|
|
setLiquidTransport(data, ydata, 1, composition, &rhomhalf, &lambdamhalf, &propYVmhalf); |
|
|
|
|
|
//#pragma omp parallel |
|
|
/*implementation of liquid phase inner grid points*/ |
|
|
/*implementation of liquid phase inner grid points*/ |
|
|
for (size_t j = 2; j <= l_npts - 1; j++) { |
|
|
for (size_t j = 2; j <= l_npts - 1; j++) { |
|
|
mole_ = getLiquidmolevec(data, ydata, j); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getLiquidMoleVec(data, ydata, j,mole_); //get mole fraction vector array |
|
|
|
|
|
|
|
|
dpsim = - (psi(j) - psi(j - 1)); |
|
|
dpsim = - (psi(j) - psi(j - 1)); |
|
|
dpsip = - (psi(j + 1) - psi(j)); |
|
|
dpsip = - (psi(j + 1) - psi(j)); |
|
@@ -1886,36 +1901,20 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
cendfp = dpsim / (dpsip * dpsipm); |
|
|
cendfp = dpsim / (dpsip * dpsipm); |
|
|
/**************************************************/ |
|
|
/**************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
area = calc_area(R(j), &m); |
|
|
rho = getLiquidDensity(T(j), P(j), composition, mole_); |
|
|
rho = getLiquidDensity(T(j), P(j), composition, mole_); |
|
|
rhom = getLiquidDensity(T(j - 1), P(j - 1), composition, mole_); |
|
|
|
|
|
rhophalf = getLiquidDensity(HALF * (T(j) + T(j + 1)), HALF * (P(j) + P(j + 1)), composition, mole_); |
|
|
|
|
|
rhomhalf = getLiquidDensity(HALF * (T(j) + T(j - 1)), HALF * (P(j) + P(j - 1)), composition, mole_); |
|
|
|
|
|
|
|
|
|
|
|
Cpb = getLiquidCpb(T(j), P(j), composition, mole_); |
|
|
Cpb = getLiquidCpb(T(j), P(j), composition, mole_); |
|
|
liquidCp = getLiquidCp(T(j),P(j),composition); |
|
|
|
|
|
|
|
|
|
|
|
lambdaphalf = getLiquidCond(HALF * (T(j) + T(j + 1)), HALF * (P(j) + P(j + 1)), composition, mole_); |
|
|
|
|
|
lambdamhalf = getLiquidCond(HALF * (T(j) + T(j - 1)), HALF * (P(j) + P(j - 1)), composition, mole_); |
|
|
|
|
|
|
|
|
getLiquidCp(T(j),P(j),composition,liquidCp); |
|
|
|
|
|
|
|
|
aream = calc_area(R(j - 1), &m); |
|
|
|
|
|
areamhalf = calc_area(HALF * (R(j) + R(j - 1)), &m); |
|
|
|
|
|
|
|
|
setLiquidTransport(data, ydata, j, composition, &rhophalf, &lambdaphalf, &propYVphalf); |
|
|
areaphalf = calc_area(HALF * (R(j + 1) + R(j)), &m); |
|
|
areaphalf = calc_area(HALF * (R(j + 1) + R(j)), &m); |
|
|
areamhalfsq = areamhalf * areamhalf; |
|
|
|
|
|
areaphalfsq = areaphalf * areaphalf; |
|
|
areaphalfsq = areaphalf * areaphalf; |
|
|
area = calc_area(R(j), &m); |
|
|
|
|
|
|
|
|
|
|
|
Diffcoeffphalf = getLiquidmassdiff(data, ydata, j, HALF * (T(j) + T(j + 1))); |
|
|
|
|
|
Diffcoeffmhalf = getLiquidmassdiff(data, ydata, j, HALF * (T(j) + T(j - 1))); |
|
|
|
|
|
|
|
|
|
|
|
Rres(j) = ((R(j) - R(j - 1)) / dpsim) - massDrop * (TWO / (rhom * aream + rho * area)); |
|
|
Rres(j) = ((R(j) - R(j - 1)) / dpsim) - massDrop * (TWO / (rhom * aream + rho * area)); |
|
|
Mdotres(j) = Mdot(j + 1) - Mdot(j); |
|
|
Mdotres(j) = Mdot(j + 1) - Mdot(j); |
|
|
Pres(j) = P(j + 1) - P(j); |
|
|
Pres(j) = P(j + 1) - P(j); |
|
|
|
|
|
|
|
|
propYVphalf = (-Diffcoeffphalf * (Y(j + 1, k_drop[0]) - Y(j, k_drop[0])) / (R(j + 1) - R(j))); |
|
|
|
|
|
propYVmhalf = (-Diffcoeffmhalf * (Y(j, k_drop[0]) - Y(j - 1, k_drop[0])) / (R(j) - R(j - 1))); |
|
|
|
|
|
|
|
|
|
|
|
liquidCp = getLiquidCp(T(j),P(j),composition); |
|
|
|
|
|
/*species equation*/ |
|
|
|
|
|
|
|
|
/*species equation***********/ |
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
if (k != k_drop[0] && k != k_drop[1]) { |
|
|
if (k != k_drop[0] && k != k_drop[1]) { |
|
|
Yres(j, k) = Y(j, k) - Y(j - 1, k); |
|
|
Yres(j, k) = Y(j, k) - Y(j - 1, k); |
|
@@ -1927,23 +1926,37 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
- areamhalf * rhomhalf * propYVmhalf ) |
|
|
- areamhalf * rhomhalf * propYVmhalf ) |
|
|
/ dpsiav; |
|
|
/ dpsiav; |
|
|
Yres(j, k) = tranTerm - advTerm + diffTerm; |
|
|
Yres(j, k) = tranTerm - advTerm + diffTerm; |
|
|
} else{ |
|
|
|
|
|
|
|
|
} else if(k == k_drop[1]){ |
|
|
Yres(j,k) = ONE - Y(j,k_drop[0]); |
|
|
Yres(j,k) = ONE - Y(j,k_drop[0]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
/*energy equation*/ |
|
|
|
|
|
tranTerm = Tdot(j); |
|
|
|
|
|
advTerm = 1/massDrop *(psi(j)*(-Mdot(j)))* (T(j)-T(j-1))/(psi(j)-psi(j-1)); |
|
|
|
|
|
double diffTerm1 = 1/(Cpb*massDrop*massDrop) * ( (rhophalf*areaphalfsq*lambdaphalf*(T(j+1)-T(j))/(psi(j+1)-psi(j)) ) |
|
|
|
|
|
- (rhomhalf*areamhalfsq*lambdamhalf*(T(j)-T(j-1))/(psi(j)-psi(j-1)) ) ) /dpsiav; |
|
|
|
|
|
double diffTerm2 = area/(Cpb*massDrop)*rho*(cendfp*T(j+1)+cendfc*T(j)+cendfm*T(j-1)) * |
|
|
|
|
|
(HALF*((propYVphalf+propYVmhalf)*liquidCp[0]+(-propYVphalf-propYVmhalf)*liquidCp[1])) ; |
|
|
|
|
|
diffTerm = diffTerm1 - diffTerm2 ; |
|
|
|
|
|
Tres(j) = tranTerm - advTerm - diffTerm ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*energy equation***********/ |
|
|
|
|
|
tranTerm = Tdot(j); |
|
|
|
|
|
advTerm = 1 / massDrop * (psi(j) * (-Mdot(j))) * (T(j) - T(j - 1)) / dpsim; |
|
|
|
|
|
double diffTerm1 = 1 / (Cpb * massDrop * massDrop) * |
|
|
|
|
|
((rhophalf * areaphalfsq * lambdaphalf * (T(j + 1) - T(j)) / dpsip) |
|
|
|
|
|
- (rhomhalf * areamhalfsq * lambdamhalf * (T(j) - T(j - 1)) / dpsim )) / |
|
|
|
|
|
dpsiav; |
|
|
|
|
|
double diffTerm2 = area / (Cpb * massDrop) * rho * (cendfp * T(j + 1) + cendfc * T(j) + cendfm * T(j - 1)) * |
|
|
|
|
|
(HALF * ((propYVphalf + propYVmhalf) * liquidCp[0] + |
|
|
|
|
|
(-propYVphalf - propYVmhalf) * liquidCp[1])); |
|
|
|
|
|
diffTerm = diffTerm1 - diffTerm2; |
|
|
|
|
|
Tres(j) = tranTerm - advTerm - diffTerm; |
|
|
|
|
|
|
|
|
|
|
|
/*Assign values evaluated at p and phalf to |
|
|
|
|
|
* m and mhalf to save some cpu cost:********/ |
|
|
|
|
|
areamhalf = areaphalf ; |
|
|
|
|
|
areamhalfsq = areaphalfsq ; |
|
|
|
|
|
aream = area; |
|
|
|
|
|
rhom = rho ; |
|
|
|
|
|
rhomhalf = rhophalf; |
|
|
|
|
|
lambdamhalf = lambdaphalf ; |
|
|
|
|
|
propYVmhalf = propYVphalf ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*implementation of right boundary of liquid phase*/ |
|
|
/*implementation of right boundary of liquid phase*/ |
|
|
mole_ = getLiquidmolevec(data,ydata,l_npts); |
|
|
|
|
|
|
|
|
getLiquidMoleVec(data,ydata,l_npts,mole_); |
|
|
rho = getLiquidDensity(T(l_npts), P(l_npts), composition,mole_); |
|
|
rho = getLiquidDensity(T(l_npts), P(l_npts), composition,mole_); |
|
|
area = calc_area(R(l_npts), &m); |
|
|
area = calc_area(R(l_npts), &m); |
|
|
lambdamhalf = getLiquidCond(T(l_npts), P(l_npts), composition,mole_); |
|
|
lambdamhalf = getLiquidCond(T(l_npts), P(l_npts), composition,mole_); |
|
@@ -1953,7 +1966,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
getGasMassFlux(data,ydata,l_npts+1,YVphalf); |
|
|
getGasMassFlux(data,ydata,l_npts+1,YVphalf); |
|
|
|
|
|
|
|
|
Diffcoeffmhalf = getLiquidmassdiff(data, ydata, l_npts, HALF * (T(l_npts) + T(l_npts - 1))); |
|
|
Diffcoeffmhalf = getLiquidmassdiff(data, ydata, l_npts, HALF * (T(l_npts) + T(l_npts - 1))); |
|
|
vapheat = getLiquidVH(P(l_npts), data->dropType); |
|
|
|
|
|
|
|
|
getLiquidVH(P(l_npts), data->dropType,vapheat); |
|
|
|
|
|
|
|
|
Rres(l_npts) = Mdot(l_npts) + rho * Rdot(l_npts) * area; |
|
|
Rres(l_npts) = Mdot(l_npts) + rho * Rdot(l_npts) * area; |
|
|
Mdotres(l_npts) = Mdot(l_npts + 1) - Mdot(l_npts); |
|
|
Mdotres(l_npts) = Mdot(l_npts + 1) - Mdot(l_npts); |
|
@@ -1973,7 +1986,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*temperature formulation*/ |
|
|
|
|
|
|
|
|
/*enthalpy formulation*/ |
|
|
double epsilon = Y(l_npts + 1, k_drop[0]) + YVphalf[k_drop[0] - 1] * area / Mdot(l_npts); |
|
|
double epsilon = Y(l_npts + 1, k_drop[0]) + YVphalf[k_drop[0] - 1] * area / Mdot(l_npts); |
|
|
Tres(l_npts) = lambdamhalf * (T(l_npts) - T(l_npts - 1)) / (R(l_npts) - R(l_npts - 1)) * area |
|
|
Tres(l_npts) = lambdamhalf * (T(l_npts) - T(l_npts - 1)) / (R(l_npts) - R(l_npts - 1)) * area |
|
|
+ Mdot(l_npts) * (epsilon * vapheat[0] + (1 - epsilon) * vapheat[1]) |
|
|
+ Mdot(l_npts) * (epsilon * vapheat[0] + (1 - epsilon) * vapheat[1]) |
|
@@ -2045,11 +2058,6 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
|
|
|
|
|
|
/*******************************************************************/ |
|
|
/*******************************************************************/ |
|
|
/*Calculate values at j=l_npts+2 's m and mhalf*****************************/ |
|
|
/*Calculate values at j=l_npts+2 's m and mhalf*****************************/ |
|
|
// getTransport(data, ydata, 1, &rhomhalf, &lambdamhalf, YVmhalf); |
|
|
|
|
|
// areamhalf = calc_area(HALF * (R(1) + R(2)), &m); |
|
|
|
|
|
// aream = calc_area(R(1), &m); |
|
|
|
|
|
// areamhalfsq = areamhalf * areamhalf; |
|
|
|
|
|
|
|
|
|
|
|
getTransport(data, ydata, l_npts+1, &rhomhalf, &lambdamhalf, YVmhalf); |
|
|
getTransport(data, ydata, l_npts+1, &rhomhalf, &lambdamhalf, YVmhalf); |
|
|
areamhalf = calc_area(HALF * (R(l_npts+1) + R(l_npts+2)), &m); |
|
|
areamhalf = calc_area(HALF * (R(l_npts+1) + R(l_npts+2)), &m); |
|
|
aream = calc_area(R(l_npts+1), &m); |
|
|
aream = calc_area(R(l_npts+1), &m); |
|
@@ -2108,10 +2116,10 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
Yres(l_npts + 1, k_bath) = ONE - sum - Y(l_npts + 1, k_bath); |
|
|
Yres(l_npts + 1, k_bath) = ONE - sum - Y(l_npts + 1, k_bath); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*binary componet case for gas phase LHS boundary*/ |
|
|
|
|
|
|
|
|
/*binary componet case for gas phase L.H.S. boundary*/ |
|
|
if(dropType == 1){ |
|
|
if(dropType == 1){ |
|
|
mole_ = getLiquidmolevec(data,ydata,l_npts); |
|
|
|
|
|
vapPres = getVapPressure(data,ydata,l_npts+1,mole_); |
|
|
|
|
|
|
|
|
getLiquidMoleVec(data,ydata,l_npts,mole_) ; |
|
|
|
|
|
getVapPressure(data,ydata,l_npts+1,mole_,vapPres); |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < k_drop.size(); i++) { |
|
|
for (size_t i = 0; i < k_drop.size(); i++) { |
|
|
Yres(l_npts+1, k_drop[i]) = Y(l_npts+1, k_drop[i]) - vapPres[i] * data->gas->molecularWeight(k_drop[i] - 1) / |
|
|
Yres(l_npts+1, k_drop[i]) = Y(l_npts+1, k_drop[i]) - vapPres[i] * data->gas->molecularWeight(k_drop[i] - 1) / |
|
@@ -2194,6 +2202,7 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
/*Pressure:*/ |
|
|
/*Pressure:*/ |
|
|
Pres(l_npts+1) = P(l_npts+2) - P(l_npts+1); |
|
|
Pres(l_npts+1) = P(l_npts+2) - P(l_npts+1); |
|
|
/*Fill up res with governing equations at inner points:*************/ |
|
|
/*Fill up res with governing equations at inner points:*************/ |
|
|
|
|
|
//#pragma omp parallel |
|
|
for (size_t j = l_npts+2 ; j < npts; j++) { |
|
|
for (size_t j = l_npts+2 ; j < npts; j++) { |
|
|
|
|
|
|
|
|
/*evaluate various mesh differences*/// |
|
|
/*evaluate various mesh differences*/// |
|
@@ -2260,9 +2269,20 @@ int residue(double t, N_Vector y, N_Vector ydot, N_Vector res, void *user_data) |
|
|
tranTerm = Tdot(j); |
|
|
tranTerm = Tdot(j); |
|
|
sum = ZERO; |
|
|
sum = ZERO; |
|
|
sum1 = ZERO; |
|
|
sum1 = ZERO; |
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
|
|
|
sum = sum + wdot(k) * enthalpy(k); |
|
|
|
|
|
sum1 = sum1 + (Cp(k) / data->gas->molecularWeight(k - 1)) * HALF * (YVmhalf(k) + YVphalf(k)); |
|
|
|
|
|
|
|
|
// for (size_t k = 1; k <= nsp; k++) { |
|
|
|
|
|
// sum = sum + wdot(k) * enthalpy(k); |
|
|
|
|
|
// sum1 = sum1 + (Cp(k) / data->gas->molecularWeight(k - 1)) * HALF * (YVmhalf(k) + YVphalf(k)); |
|
|
|
|
|
// } |
|
|
|
|
|
if (data->rxns == 0) { |
|
|
|
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
|
|
|
// sum = sum; |
|
|
|
|
|
sum1 = sum1 + (Cp(k) / data->gas->molecularWeight(k - 1)) * HALF * (YVmhalf(k) + YVphalf(k)); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (data->rxns == 1) { |
|
|
|
|
|
for (size_t k = 1; k <= nsp; k++) { |
|
|
|
|
|
sum = sum + wdot(k) * enthalpy(k); |
|
|
|
|
|
sum1 = sum1 + (Cp(k) / data->gas->molecularWeight(k - 1)) * HALF * (YVmhalf(k) + YVphalf(k)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sum = sum * Cantera::GasConstant * T(j); |
|
|
sum = sum * Cantera::GasConstant * T(j); |
|
|
sum1 = sum1 * Cantera::GasConstant; |
|
|
sum1 = sum1 * Cantera::GasConstant; |
|
@@ -2913,82 +2933,6 @@ void getSpecies(UserData data, N_Vector *y, FILE *output) { |
|
|
delete[] spArr; |
|
|
delete[] spArr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
////rho : density of liquid phase |
|
|
|
|
|
//double getLiquidRho(double dropMole[],double temp,double pres){ |
|
|
|
|
|
// std::vector<std::string> fluids; |
|
|
|
|
|
// fluids.push_back("Propane"); |
|
|
|
|
|
// fluids.push_back("n-Heptane"); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> Temperature(1,temp),Pressure(1,pres); |
|
|
|
|
|
// std::vector<std::string> outputs; |
|
|
|
|
|
// outputs.push_back("D"); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> moles; |
|
|
|
|
|
// moles.push_back(dropMole[0]); |
|
|
|
|
|
// moles.push_back(dropMole[1]); |
|
|
|
|
|
// double density = CoolProp::PropsSImulti(outputs,"T",Temperature,"P",Pressure,"",fluids,moles)[0][0]; //Unit:kg/m^3 |
|
|
|
|
|
// |
|
|
|
|
|
// return density; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
////Cp,l : specific heat capacity at constant pressure of liquid phase |
|
|
|
|
|
//double getLiquidCp(double dropMole[],double temp,double pres){ |
|
|
|
|
|
// std::vector<std::string> fluids; |
|
|
|
|
|
// fluids.push_back("Propane"); |
|
|
|
|
|
// fluids.push_back("n-Heptane"); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> Temperature(1,temp),Pressure(1,pres); |
|
|
|
|
|
// std::vector<std::string> outputs; |
|
|
|
|
|
// outputs.push_back("CPMASS"); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> moles; |
|
|
|
|
|
// moles.push_back(dropMole[0]); |
|
|
|
|
|
// moles.push_back(dropMole[1]); |
|
|
|
|
|
// double cp = CoolProp::PropsSImulti(outputs,"T",Temperature,"P",Pressure,"",fluids,moles)[0][0]; //Unit:J/(kg*K) |
|
|
|
|
|
// |
|
|
|
|
|
// return cp; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
////Hv : heat of vaporization of liquid phase at constant pressure |
|
|
|
|
|
//double getLiquidHv(double dropMole[],double temp,double pres){ |
|
|
|
|
|
// std::vector<std::string> fluids; |
|
|
|
|
|
// fluids.push_back("Propane"); |
|
|
|
|
|
// fluids.push_back("n-Heptane"); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> Temperature(1,temp),Pressure(1,pres); |
|
|
|
|
|
// std::vector<std::string> outputs; |
|
|
|
|
|
// outputs.push_back("H"); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> moles; |
|
|
|
|
|
// moles.push_back(dropMole[0]); |
|
|
|
|
|
// moles.push_back(dropMole[1]); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> state1(1,1.0); |
|
|
|
|
|
// std::vector<double> state2(1,0.0); |
|
|
|
|
|
// |
|
|
|
|
|
// double H_V = CoolProp::PropsSImulti(outputs,"P",Pressure,"Q",state1,"",fluids,moles)[0][0]; //Unit:J/kg |
|
|
|
|
|
// double H_L = CoolProp::PropsSImulti(outputs,"P",Pressure,"Q",state2,"",fluids,moles)[0][0]; //Unit:J/kg |
|
|
|
|
|
// double delta_H = H_V - H_L; |
|
|
|
|
|
// |
|
|
|
|
|
// return delta_H; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
////MaxT : maximum allowed tempereture of liquid phase |
|
|
|
|
|
////Also the boiling point of more volitile component |
|
|
|
|
|
//double getLiquidMaxT(double dropMole[],double pres){ |
|
|
|
|
|
// std::vector<std::string> fluids; |
|
|
|
|
|
// fluids.push_back("Propane"); |
|
|
|
|
|
// //fluids.push_back("n-Heptane"); |
|
|
|
|
|
// |
|
|
|
|
|
// std::vector<double> Pressure(1,pres); |
|
|
|
|
|
// std::vector<std::string> outputs; |
|
|
|
|
|
// outputs.push_back("T"); |
|
|
|
|
|
// |
|
|
|
|
|
// double temperature = CoolProp::PropsSI(outputs[0], "P", Pressure[0],"Q",1.0,fluids[0]); |
|
|
|
|
|
// |
|
|
|
|
|
// return temperature; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
/*function overloading for single and bi-component*/ |
|
|
/*function overloading for single and bi-component*/ |
|
|
/*calculate the liquid phase density based on droplet type and T,P,X(Y)*/ |
|
|
/*calculate the liquid phase density based on droplet type and T,P,X(Y)*/ |
|
@@ -3001,10 +2945,12 @@ double getLiquidDensity(const double temp, const double pres, const std::vector< |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*binary component case*/ |
|
|
/*binary component case*/ |
|
|
double getLiquidDensity(const double temp, const double pres, std::vector<std::string> &composition, |
|
|
|
|
|
const std::vector<double> &mole) { |
|
|
|
|
|
|
|
|
double getLiquidDensity(const double temp, const double pres, |
|
|
|
|
|
const std::vector<std::string> &composition, |
|
|
|
|
|
const double mole_[]) { |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<std::string> outputs; |
|
|
std::vector<std::string> outputs; |
|
|
|
|
|
std::vector<double> mole ={mole_[0],mole_[1]}; |
|
|
outputs.push_back("D"); |
|
|
outputs.push_back("D"); |
|
|
|
|
|
|
|
|
double density = CoolProp::PropsSImulti(outputs, "T", Temperature, "P", Pressure, "", composition, |
|
|
double density = CoolProp::PropsSImulti(outputs, "T", Temperature, "P", Pressure, "", composition, |
|
@@ -3012,21 +2958,23 @@ double getLiquidDensity(const double temp, const double pres, std::vector<std::s |
|
|
return density; |
|
|
return density; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
double getLiquidCond(const double temp, const double pres, const std::vector<std::string> &composition) { |
|
|
|
|
|
|
|
|
double getLiquidCond(const double temp, const double pres, |
|
|
|
|
|
const std::vector<std::string> &composition) { |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
double k = CoolProp::PropsSI("conductivity", "T", Temperature[0], "P", Pressure[0], composition[0]); |
|
|
double k = CoolProp::PropsSI("conductivity", "T", Temperature[0], "P", Pressure[0], composition[0]); |
|
|
return k; //Unit:W/m/K (kg*m/s^3/K) |
|
|
return k; //Unit:W/m/K (kg*m/s^3/K) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*binary component case*/ |
|
|
/*binary component case*/ |
|
|
double getLiquidCond(const double temp, const double pres, std::vector<std::string> &composition, |
|
|
|
|
|
const std::vector<double> &mole) { |
|
|
|
|
|
|
|
|
double getLiquidCond(const double temp, const double pres, |
|
|
|
|
|
std::vector<std::string> &composition,const double mole_[]) { |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<std::string> outputs; |
|
|
std::vector<std::string> outputs; |
|
|
|
|
|
std::vector<double> mole = {mole_[0],mole_[1]}; |
|
|
outputs.push_back("conductivity"); |
|
|
outputs.push_back("conductivity"); |
|
|
|
|
|
|
|
|
double k = CoolProp::PropsSImulti(outputs, "T", Temperature, "P", Pressure, "", composition, |
|
|
|
|
|
mole)[0][0]; |
|
|
|
|
|
|
|
|
double k = CoolProp::PropsSImulti(outputs, "T", Temperature, "P", Pressure, |
|
|
|
|
|
"", composition,mole)[0][0]; |
|
|
return k; //Unit:W/m/K (kg*m/s^3/K) |
|
|
return k; //Unit:W/m/K (kg*m/s^3/K) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -3039,9 +2987,10 @@ double getLiquidCpb(const double temp,const double pres, const std::vector<std:: |
|
|
|
|
|
|
|
|
/*binary component case*/ |
|
|
/*binary component case*/ |
|
|
double getLiquidCpb(const double temp, const double pres, const std::vector<std::string> &composition, |
|
|
double getLiquidCpb(const double temp, const double pres, const std::vector<std::string> &composition, |
|
|
const std::vector<double> &mole) { |
|
|
|
|
|
|
|
|
const double mole_[]) { |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<std::string> outputs; |
|
|
std::vector<std::string> outputs; |
|
|
|
|
|
std::vector<double> mole = {mole_[0],mole_[1]}; |
|
|
outputs.push_back("Cpmass"); |
|
|
outputs.push_back("Cpmass"); |
|
|
|
|
|
|
|
|
double k = CoolProp::PropsSImulti(outputs, "T", Temperature, "P", Pressure, "", composition, |
|
|
double k = CoolProp::PropsSImulti(outputs, "T", Temperature, "P", Pressure, "", composition, |
|
@@ -3050,15 +2999,19 @@ double getLiquidCpb(const double temp, const double pres, const std::vector<std: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*get Cp vector for binary componet droplet*/ |
|
|
/*get Cp vector for binary componet droplet*/ |
|
|
std::vector<double> getLiquidCp(const double temp, const double pres, const std::vector<std::string> &composition){ |
|
|
|
|
|
std::vector<double> k ; |
|
|
|
|
|
|
|
|
void getLiquidCp(const double temp, const double pres, const std::vector<std::string> &composition, double liquidCp[]){ |
|
|
|
|
|
// std::vector<double> k ; |
|
|
double k_temp; |
|
|
double k_temp; |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
std::vector<double> Temperature(1, temp), Pressure(1, pres); |
|
|
for(auto & species : composition){ |
|
|
|
|
|
k_temp = CoolProp::PropsSI("Cpmass", "T", Temperature[0], "P", Pressure[0], species); |
|
|
|
|
|
k.push_back(k_temp) ; |
|
|
|
|
|
|
|
|
// for(auto & species : composition){ |
|
|
|
|
|
// k_temp = CoolProp::PropsSI("Cpmass", "T", Temperature[0], "P", Pressure[0], species); |
|
|
|
|
|
// liquidCp[] ; |
|
|
|
|
|
// } |
|
|
|
|
|
for(size_t i= 0;i < composition.size();i++){ |
|
|
|
|
|
k_temp = CoolProp::PropsSI("Cpmass", "T", Temperature[0], "P", Pressure[0], composition[i]); |
|
|
|
|
|
liquidCp[i] = k_temp ; |
|
|
} |
|
|
} |
|
|
return k; |
|
|
|
|
|
|
|
|
// return k; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3072,9 +3025,9 @@ double getGasCond(UserData data, double *ydata, size_t gridPoint) { |
|
|
|
|
|
|
|
|
/*latent heat of vaporizaiton*/ |
|
|
/*latent heat of vaporizaiton*/ |
|
|
/*unit: J/kg*/ |
|
|
/*unit: J/kg*/ |
|
|
std::vector<double> getLiquidVH(const double pres, const int dropType) { |
|
|
|
|
|
|
|
|
void getLiquidVH(const double pres, const int dropType, double vapheat[2]) { |
|
|
double H, H_V, H_L; |
|
|
double H, H_V, H_L; |
|
|
std::vector<double> vapheat; |
|
|
|
|
|
|
|
|
// double vapheat[2]={}; |
|
|
std::vector<std::string> fluids; |
|
|
std::vector<std::string> fluids; |
|
|
std::vector<double> Pressure(1, pres); |
|
|
std::vector<double> Pressure(1, pres); |
|
|
|
|
|
|
|
@@ -3085,37 +3038,24 @@ std::vector<double> getLiquidVH(const double pres, const int dropType) { |
|
|
H_V = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 1, fluids[0]); |
|
|
H_V = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 1, fluids[0]); |
|
|
H_L = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 0, fluids[0]); |
|
|
H_L = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 0, fluids[0]); |
|
|
H = H_V - H_L; |
|
|
H = H_V - H_L; |
|
|
vapheat.push_back(H); |
|
|
|
|
|
|
|
|
vapheat[0] = H; |
|
|
} else { |
|
|
} else { |
|
|
for (size_t i = 0; i < fluids.size(); i++) { |
|
|
for (size_t i = 0; i < fluids.size(); i++) { |
|
|
H_V = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 1, fluids[i]); |
|
|
H_V = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 1, fluids[i]); |
|
|
H_L = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 0, fluids[i]); |
|
|
H_L = CoolProp::PropsSI("H", "P", Pressure[0], "Q", 0, fluids[i]); |
|
|
H = H_V - H_L; |
|
|
H = H_V - H_L; |
|
|
vapheat.push_back(H); |
|
|
|
|
|
|
|
|
vapheat[i]=H; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return vapheat; //unit:J/kg |
|
|
|
|
|
|
|
|
// return vapheat; //unit:J/kg |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*convert mass fraction to mole fraction*/ |
|
|
|
|
|
/*size of both arrays should be identical*/ |
|
|
|
|
|
void mass2mole(const std::vector<double> &mass, std::vector<double> &mole, UserData data) { |
|
|
|
|
|
mole.reserve(mass.size()); |
|
|
|
|
|
double sum = 0.0; |
|
|
|
|
|
double x_temp; |
|
|
|
|
|
for (size_t i = 0; i < data->dropMole.size(); i++) { |
|
|
|
|
|
sum = sum + mass[i] / data->MW[i]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
x_temp = mass[0] / (data->MW[0] * sum); |
|
|
|
|
|
mole.push_back(x_temp); |
|
|
|
|
|
mole.push_back(ONE - x_temp); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*liquid mass diffusivity D for binary component case*/ |
|
|
/*liquid mass diffusivity D for binary component case*/ |
|
|
double getLiquidmassdiff(UserData data, double *ydata, size_t gridPoint, const double temp) { |
|
|
double getLiquidmassdiff(UserData data, double *ydata, size_t gridPoint, const double temp) { |
|
|
std::vector<double> V_ = {75.86, 162.34}; //molar volume at normal boiling point, unit: cm^3/mol |
|
|
std::vector<double> V_ = {75.86, 162.34}; //molar volume at normal boiling point, unit: cm^3/mol |
|
|
std::vector<double> visc_, mole_, mass_, D_inf_; |
|
|
|
|
|
|
|
|
std::vector<double> visc_, mass_, D_inf_; |
|
|
|
|
|
double mole_[2] ={} ; |
|
|
double visc_temp, D, Dinf_temp; |
|
|
double visc_temp, D, Dinf_temp; |
|
|
std::vector<std::string> composition = components(data->dropType); |
|
|
std::vector<std::string> composition = components(data->dropType); |
|
|
|
|
|
|
|
@@ -3123,13 +3063,13 @@ double getLiquidmassdiff(UserData data, double *ydata, size_t gridPoint, const d |
|
|
visc_temp = 1000.0 * CoolProp::PropsSI("V", "T", temp, "Q", 0, composition[i]); //unit: mPa*s |
|
|
visc_temp = 1000.0 * CoolProp::PropsSI("V", "T", temp, "Q", 0, composition[i]); //unit: mPa*s |
|
|
visc_.push_back(visc_temp); |
|
|
visc_.push_back(visc_temp); |
|
|
} |
|
|
} |
|
|
mole_ = getLiquidmolevec(data, ydata, gridPoint); |
|
|
|
|
|
|
|
|
getLiquidMoleVec(data, ydata, gridPoint,mole_); |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < data->dropMole.size(); i++) { |
|
|
for (size_t i = 0; i < data->dropMole.size(); i++) { |
|
|
if (i == 0) { |
|
|
if (i == 0) { |
|
|
Dinf_temp = 9.89e-8 * temp * pow(visc_[1], -0.907) * pow(V_[0], -0.45) * pow(V_[1], 0.265); |
|
|
Dinf_temp = 9.89e-8 * temp * pow(visc_[1], -0.907) * pow(V_[0], -0.45) * pow(V_[1], 0.265); |
|
|
D_inf_.push_back(Dinf_temp); |
|
|
D_inf_.push_back(Dinf_temp); |
|
|
} else { |
|
|
|
|
|
|
|
|
} else if (i == 1){ |
|
|
Dinf_temp = 9.89e-8 * temp * pow(visc_[0], -0.907) * pow(V_[1], -0.45) * pow(V_[0], 0.265); |
|
|
Dinf_temp = 9.89e-8 * temp * pow(visc_[0], -0.907) * pow(V_[1], -0.45) * pow(V_[0], 0.265); |
|
|
D_inf_.push_back(Dinf_temp); |
|
|
D_inf_.push_back(Dinf_temp); |
|
|
} |
|
|
} |
|
@@ -3139,40 +3079,6 @@ double getLiquidmassdiff(UserData data, double *ydata, size_t gridPoint, const d |
|
|
return (D / 10000); //unit:m^2/s |
|
|
return (D / 10000); //unit:m^2/s |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//double dropletmass(UserData data,double* ydata){ |
|
|
|
|
|
// double mass = 0.0 ; |
|
|
|
|
|
// double rho,rhop; |
|
|
|
|
|
// if (data->dropType==0){ |
|
|
|
|
|
// for (size_t i = data->l_npts-1; i>=1 ; i--) { |
|
|
|
|
|
// std::vector<std::string> str; |
|
|
|
|
|
// str.push_back("nHeptane"); |
|
|
|
|
|
// rho = getLiquidDensity(T(i), P(i), str); |
|
|
|
|
|
// rhop = getLiquidDensity(T(i + 1), P(i + 1), str); |
|
|
|
|
|
// mass = mass + (R(i + 1) - R(i)) * (rho * calc_area(R(i), &data->metric) + |
|
|
|
|
|
// rhop * calc_area(R(i + 1), &data->metric)) / TWO; |
|
|
|
|
|
// } |
|
|
|
|
|
// }else if(data->dropType==1){ |
|
|
|
|
|
// for (size_t i = data->l_npts-1; i>=1 ; i--){ |
|
|
|
|
|
// std::vector<std::string> str; |
|
|
|
|
|
// std::vector<double> massFrac,massFracp,moleFrac,moleFracp; |
|
|
|
|
|
// str.push_back("propane"); |
|
|
|
|
|
// str.push_back("nHeptane"); |
|
|
|
|
|
// for (size_t j = 0; j < data->dropMole.size(); j++){ |
|
|
|
|
|
// massFrac.push_back(Y(i,data->k_drop[j])); |
|
|
|
|
|
// massFracp.push_back(Y(i+1,data->k_drop[j])); |
|
|
|
|
|
// } |
|
|
|
|
|
// /*convert mass fraction to mole fraction*/ |
|
|
|
|
|
// mass2mole(massFrac,moleFrac,data); |
|
|
|
|
|
// mass2mole(massFracp,moleFracp,data); |
|
|
|
|
|
// rho = getLiquidDensity(T(i),P(i),str,moleFrac); |
|
|
|
|
|
// rhop = getLiquidDensity(T(i+1),P(i+1),str,moleFracp); |
|
|
|
|
|
// mass = mass +(R(i+1)-R(i))*(rho*calc_area(R(i),&data->metric)+rhop*calc_area(R(i+1),&data->metric))/TWO; |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// return mass ; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// List of fluid components per dropType |
|
|
// List of fluid components per dropType |
|
|
std::vector<std::string> components(int dropType) { |
|
|
std::vector<std::string> components(int dropType) { |
|
|
if (dropType == 0) { |
|
|
if (dropType == 0) { |
|
@@ -3184,52 +3090,56 @@ std::vector<std::string> components(int dropType) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*calculat droplet mass*/ |
|
|
/*calculat droplet mass*/ |
|
|
double dropletmass(UserData data, double *ydata) { |
|
|
|
|
|
|
|
|
double dropletmass(UserData data, double *ydata, const std::vector<std::string>& composition) { |
|
|
double mass = 0.0; |
|
|
double mass = 0.0; |
|
|
double rho, rhop; |
|
|
double rho, rhop; |
|
|
|
|
|
double areap = calc_area(R(data->l_npts),&data->metric); |
|
|
|
|
|
double moleFracp[2] = {}; |
|
|
|
|
|
double moleFrac[2] = {}; |
|
|
|
|
|
|
|
|
for (size_t i = data->l_npts - 1; i >= 1; i--) { |
|
|
|
|
|
std::vector<std::string> composition = components(data->dropType); |
|
|
|
|
|
|
|
|
if (data->dropType == 0){ |
|
|
|
|
|
rhop = getLiquidDensity(T(data->l_npts), P(data->l_npts), composition) ; |
|
|
|
|
|
}else if(data->dropType == 1){ |
|
|
|
|
|
getLiquidMoleVec(data, ydata, data->l_npts,moleFracp); |
|
|
|
|
|
rhop = getLiquidDensity(T(data->l_npts), P(data->l_npts), composition, moleFracp); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*loop over the internal grid points*/ |
|
|
|
|
|
for (size_t i = data->l_npts - 1; i >= 1; i--) { |
|
|
if (data->dropType == 0) { |
|
|
if (data->dropType == 0) { |
|
|
rho = getLiquidDensity(T(i), P(i), composition); |
|
|
rho = getLiquidDensity(T(i), P(i), composition); |
|
|
rhop = getLiquidDensity(T(i + 1), P(i + 1), composition); |
|
|
|
|
|
|
|
|
|
|
|
} else if (data->dropType == 1) { |
|
|
} else if (data->dropType == 1) { |
|
|
std::vector<double> moleFrac, moleFracp; |
|
|
|
|
|
moleFrac = getLiquidmolevec(data, ydata, i); |
|
|
|
|
|
moleFracp = getLiquidmolevec(data, ydata, i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getLiquidMoleVec(data, ydata, i,moleFrac); |
|
|
rho = getLiquidDensity(T(i), P(i), composition, moleFrac); |
|
|
rho = getLiquidDensity(T(i), P(i), composition, moleFrac); |
|
|
rhop = getLiquidDensity(T(i + 1), P(i + 1), composition, moleFracp); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
double area = calc_area(R(i), &data->metric); |
|
|
double area = calc_area(R(i), &data->metric); |
|
|
double areap = calc_area(R(i + 1), &data->metric); |
|
|
|
|
|
mass += (R(i + 1) - R(i)) * (rho * area + rhop * areap) / TWO; |
|
|
mass += (R(i + 1) - R(i)) * (rho * area + rhop * areap) / TWO; |
|
|
|
|
|
|
|
|
|
|
|
/*save the cpu time */ |
|
|
|
|
|
areap = area; |
|
|
|
|
|
rhop = rho; |
|
|
} |
|
|
} |
|
|
return mass; |
|
|
return mass; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::vector<double> getLiquidmassvec(UserData data, double *ydata, int gridPoint) { |
|
|
|
|
|
std::vector<double> mass_; |
|
|
|
|
|
mass_.push_back(Y(gridPoint, data->k_drop[0])); |
|
|
|
|
|
mass_.push_back(Y(gridPoint, data->k_drop[1])); |
|
|
|
|
|
return mass_; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<double> getLiquidmolevec(UserData data, double *ydata, int gridPoint) { |
|
|
|
|
|
std::vector<double> mass_, mole_; |
|
|
|
|
|
mass_ = getLiquidmassvec(data, ydata, gridPoint); |
|
|
|
|
|
mass2mole(mass_, mole_, data); |
|
|
|
|
|
return mole_; |
|
|
|
|
|
|
|
|
void getLiquidMoleVec(UserData data,double* ydata,int gridPoint,double mole_[]){ |
|
|
|
|
|
double sum=ZERO; |
|
|
|
|
|
double x_temp = ZERO; |
|
|
|
|
|
double mass[2] = {}; |
|
|
|
|
|
for (size_t i = 0; i < data->dropMole.size(); i++) { |
|
|
|
|
|
mass[i] = Y(gridPoint,data->k_drop[i]); |
|
|
|
|
|
} |
|
|
|
|
|
for (size_t i = 0; i < data->dropMole.size(); i++) { |
|
|
|
|
|
sum = sum + mass[i] / data->MW[i]; |
|
|
|
|
|
} |
|
|
|
|
|
x_temp = mass[0] / (data->MW[0] * sum); |
|
|
|
|
|
mole_[0] = x_temp; |
|
|
|
|
|
mole_[1] = (ONE - x_temp) ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*return droplet species vapor pressure at interface, unit:Pa*/ |
|
|
/*return droplet species vapor pressure at interface, unit:Pa*/ |
|
|
std::vector<double> getVapPressure(UserData data, double* ydata,int gridPoint,const std::vector<double> mole_){ |
|
|
|
|
|
std::vector<double> vapPres; |
|
|
|
|
|
vapPres.reserve(mole_.size()) ; |
|
|
|
|
|
std::vector<double> gamma_; |
|
|
|
|
|
|
|
|
void getVapPressure(UserData data, double* ydata,int gridPoint,const double mole_[], double vapPres[]){ |
|
|
|
|
|
double gamma_[2] = {}; |
|
|
getGamma(mole_,gamma_) ; |
|
|
getGamma(mole_,gamma_) ; |
|
|
//propane |
|
|
//propane |
|
|
double p1 = 1.0e5 * pow(10, 4.53678 - (1149.36 / (T(gridPoint) + 24.906))) * mole_[0] * |
|
|
double p1 = 1.0e5 * pow(10, 4.53678 - (1149.36 / (T(gridPoint) + 24.906))) * mole_[0] * |
|
@@ -3237,9 +3147,43 @@ std::vector<double> getVapPressure(UserData data, double* ydata,int gridPoint,co |
|
|
//heptane |
|
|
//heptane |
|
|
double p2 = 1.0e5 * pow(10, 4.02832 - (1268.636 / (T(gridPoint) - 56.199))) * mole_[1] * |
|
|
double p2 = 1.0e5 * pow(10, 4.02832 - (1268.636 / (T(gridPoint) - 56.199))) * mole_[1] * |
|
|
gamma_[1]; |
|
|
gamma_[1]; |
|
|
vapPres.push_back(p1); |
|
|
|
|
|
vapPres.push_back(p2); |
|
|
|
|
|
return vapPres; |
|
|
|
|
|
|
|
|
vapPres[0] = p1 ; |
|
|
|
|
|
vapPres[1] = p2 ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void setLiquidTransport(UserData data, |
|
|
|
|
|
double *ydata, |
|
|
|
|
|
int gridPoint, |
|
|
|
|
|
const std::vector<std::string> &composition, |
|
|
|
|
|
double *rho, |
|
|
|
|
|
double *lambda, |
|
|
|
|
|
double *YV) { |
|
|
|
|
|
double DiffCoeff; |
|
|
|
|
|
double molevec[2], molevecp[2], molevecAvg[2]; |
|
|
|
|
|
molevec[2] = molevecp[2] = molevecAvg[2] = {}; |
|
|
|
|
|
double TAvg = HALF * (T(gridPoint) + T(gridPoint + 1)); |
|
|
|
|
|
std::vector<std::string> outputs; |
|
|
|
|
|
outputs.push_back("conductivity"); |
|
|
|
|
|
std::vector<double> Temperature(1, TAvg), Pressure(1, P(gridPoint)); |
|
|
|
|
|
|
|
|
|
|
|
/*Calculate the density,heat conductivity and diffusion flux ******/ |
|
|
|
|
|
if (data->dropType == 0) { |
|
|
|
|
|
*rho = getLiquidDensity(TAvg, P(gridPoint), composition); |
|
|
|
|
|
*lambda = CoolProp::PropsSI("conductivity", "T", TAvg, "P", P(gridPoint), composition[0]); |
|
|
|
|
|
*YV = ZERO; |
|
|
|
|
|
} else if (data->dropType == 1) { |
|
|
|
|
|
getLiquidMoleVec(data, ydata, gridPoint, molevec); |
|
|
|
|
|
getLiquidMoleVec(data, ydata, gridPoint + 1, molevecp); |
|
|
|
|
|
for (size_t ii = 0; ii < data->dropMole.size(); ii++) { |
|
|
|
|
|
molevecAvg[ii] = HALF * (molevec[ii] + molevecp[ii]); |
|
|
|
|
|
} |
|
|
|
|
|
*rho = getLiquidDensity(TAvg, P(gridPoint), composition, molevecAvg); |
|
|
|
|
|
std::vector<double> mole = {molevecAvg[0], molevecAvg[1]}; |
|
|
|
|
|
*lambda = CoolProp::PropsSImulti(outputs, "T", Temperature, "P", Pressure, "", composition, mole)[0][0]; |
|
|
|
|
|
DiffCoeff = getLiquidmassdiff(data, ydata, gridPoint, TAvg); |
|
|
|
|
|
*YV = -DiffCoeff * (Y(gridPoint + 1, data->k_drop[0]) - Y(gridPoint, data->k_drop[0])) |
|
|
|
|
|
/ (R(gridPoint + 1) - R(gridPoint)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void printIddata(UserData data, double *iddata) { |
|
|
void printIddata(UserData data, double *iddata) { |
|
@@ -3270,7 +3214,7 @@ void printPsidata(UserData data, double* psidata) { |
|
|
file = fopen("psi.dat", "w"); |
|
|
file = fopen("psi.dat", "w"); |
|
|
// fprintf(file, "%15s\t%15s\t", "Rid", "Tid"); |
|
|
// fprintf(file, "%15s\t%15s\t", "Rid", "Tid"); |
|
|
for (size_t j = 1; j <= data->npts; j++) { |
|
|
for (size_t j = 1; j <= data->npts; j++) { |
|
|
fprintf(file, "%lu\t", j); |
|
|
|
|
|
|
|
|
fprintf(file, "%15.5e\t", (double)j); |
|
|
} |
|
|
} |
|
|
fprintf(file, "\n"); |
|
|
fprintf(file, "\n"); |
|
|
|
|
|
|
|
|