Skip to content

Commit 373b4d7

Browse files
Improved calculation of Cp and Cv in two-phase region
1 parent b0133d0 commit 373b4d7

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Data_Generation/DataGenerator_NICFD.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DataGenerator_CoolProp(DataGenerator_Base):
4747
"""
4848
_Config:Config_NICFD
4949
fluid = None
50-
__accepted_phases:list[int] = [CoolP.iphase_gas, CoolP.iphase_supercritical_gas, CoolP.iphase_supercritical]
50+
__accepted_phases:list[int] = [CoolP.iphase_gas, CoolP.iphase_supercritical_gas, CoolP.iphase_supercritical,CoolP.iphase_supercritical_liquid]
5151
# Pressure and temperature limits
5252
__use_PT:bool = DefaultSettings_NICFD.use_PT_grid
5353
__T_min:float = DefaultSettings_NICFD.T_min
@@ -172,7 +172,6 @@ def PreprocessData(self):
172172
X_max = self.__rho_max
173173
Y_min = self.__e_min
174174
Y_max = self.__e_max
175-
176175
X_range = (X_min - X_max) * np.cos(np.linspace(0, 0.5*np.pi, self.__Np_X)) + X_max
177176
Y_range = np.linspace(Y_min, Y_max, self.__Np_Y)
178177
self.__X_grid, self.__Y_grid = np.meshgrid(X_range, Y_range)
@@ -542,6 +541,19 @@ def __EntropicEoS(self, s:float, rho:float, e:float, derivs:dict, state_vector_s
542541
dhdP_rho = dhde_rho * (1 / dPde_rho)
543542
dsdrho_P = dsdrho_e - dPdrho_e * (1 / dPde_rho) * dsde_rho
544543
dsdP_rho = dsde_rho / dPde_rho
544+
545+
X = self.fluid.Q()
546+
self.fluid.update(CoolP.PQ_INPUTS, Pressure, 1)
547+
cp_vap = self.fluid.cpmass()
548+
cv_vap = self.fluid.cvmass()
549+
rho_vap = self.fluid.rhomass()
550+
self.fluid.update(CoolP.PQ_INPUTS, Pressure,0)
551+
cp_liq = self.fluid.cpmass()
552+
cv_liq = self.fluid.cvmass()
553+
alpha=X*rho / rho_vap
554+
Cp = alpha * cp_vap + (1-alpha)*cp_liq
555+
Cv = alpha * cv_vap + (1-alpha)*cv_liq
556+
self.fluid.update(CoolP.DmassUmass_INPUTS, rho, e)
545557
else:
546558
dPde_rho = self.fluid.first_partial_deriv(CP.iP, CP.iUmass, CP.iDmass)
547559
dPdrho_e = self.fluid.first_partial_deriv(CP.iP, CP.iDmass, CP.iUmass)

0 commit comments

Comments
 (0)