Skip to content

Commit 5ff7c85

Browse files
Merge pull request #1 from su2code/fix_LUT_twophase
Two-phase tabulation for NICFD
2 parents 928ba2e + 40f2aef commit 5ff7c85

40 files changed

Lines changed: 4552 additions & 566 deletions

.github/workflows/regression.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Pre Cleanup
21-
uses: docker://ghcr.io/su2code/su2_dataminer_test
21+
uses: docker://ghcr.io/su2code/su2_dataminer_test:v2
2222
with:
2323
entrypoint: /bin/rm
2424
args: -rf src/
2525

2626
- name: Run regression tests
27-
uses: docker://ghcr.io/su2code/su2_dataminer_test
27+
uses: docker://ghcr.io/su2code/su2_dataminer_test:v2
2828
with:
2929
args: -b ${{ github.ref }} -s run_regression.py
3030

3131
- name: Post Cleanup
32-
uses: docker://ghcr.io/su2code/su2_dataminer_test
32+
uses: docker://ghcr.io/su2code/su2_dataminer_test:v2
3333
with:
3434
entrypoint: /bin/rm
3535
args: -rf src/
@@ -39,18 +39,18 @@ jobs:
3939
runs-on: ubuntu-latest
4040
steps:
4141
- name: Pre Cleanup
42-
uses: docker://ghcr.io/su2code/su2_dataminer_test
42+
uses: docker://ghcr.io/su2code/su2_dataminer_test:v2
4343
with:
4444
entrypoint: /bin/rm
4545
args: -rf src/
4646

4747
- name: MLPCpp integration tests
48-
uses: docker://ghcr.io/su2code/su2_dataminer_test
48+
uses: docker://ghcr.io/su2code/su2_dataminer_test:v2
4949
with:
5050
args: -b ${{ github.ref }} -s MLPCpp_tests.py -m main
5151

5252
- name: Post Cleanup
53-
uses: docker://ghcr.io/su2code/su2_dataminer_test
53+
uses: docker://ghcr.io/su2code/su2_dataminer_test:v2
5454
with:
5555
entrypoint: /bin/rm
5656
args: -rf src/

Common/DataDrivenConfig.py

Lines changed: 186 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ class Config_NICFD(Config):
5757
# Fluid definition settings
5858
__fluid_names:list[str] = ["MM"] # List of fluid names used for data generation.
5959
__fluid_string:str="MM" # Fluid string for defining the abstract state in CoolProp
60+
61+
__calc_transport_properties:bool = False
62+
__viscosity_model:str = DefaultSettings_NICFD.viscosity_model
63+
__conductivity_model:str = DefaultSettings_NICFD.conductivity_model
64+
65+
# Phases to include in fluid data.
66+
__gasphase:bool = True
67+
__twophase:bool = False
68+
__liquidphase:bool = False
69+
__supercritical:bool = True
70+
6071
__EOS_type:str=DefaultSettings_NICFD.EOS_type # Equation of state used by CoolProp
6172
__fluid_mole_fractions:list[float] = [1.0] # Mole fractions for components in fluid mixture.
6273
__use_PT:bool = DefaultSettings_NICFD.use_PT_grid # Use a pressure-temperature based grid for fluid training data.
@@ -78,7 +89,7 @@ class Config_NICFD(Config):
7889
_state_vars:list[str] = ["s", "T","p","c2"] # State variable names for which the physics-informed MLP is trained.
7990

8091
# Table Generation Settings
81-
92+
__Table_discretization:str = DefaultSettings_NICFD.tabulation_method
8293
__Table_base_cell_size:float = None # Table base cell size per table level.
8394
__Table_ref_cell_size:float = None # Refined cell size per table level.
8495
__Table_ref_radius:float = None # Refinement radius within which refined cell size is applied.
@@ -151,6 +162,15 @@ def PrintBanner(self):
151162
print("Density range: %.2f kg/m3 -> %.2f kg/m3 (%i steps)" % (self.__Rho_lower, self.__Rho_upper, self.__Np_P))
152163
print("")
153164
print("State variables considered during physics-informed learning: "+", ".join((v for v in self._state_vars)))
165+
166+
if self.__twophase:
167+
print("Including two-phase fluid data.")
168+
if self.__calc_transport_properties:
169+
print("Including transport properties in fluid data.")
170+
if self.__twophase:
171+
print("Two-phase conductivity model: %s" % self.__conductivity_model)
172+
print("Two-phase viscosity model: %s" % self.__viscosity_model)
173+
154174
return
155175

156176

@@ -208,6 +228,137 @@ def SetEquationOfState(self, EOS_type_in:str=DefaultSettings_NICFD.EOS_type):
208228
self.__EOS_type=EOS_type_in.upper()
209229
return
210230

231+
def IncludeTransportProperties(self, calc_transport_properties:bool=False):
232+
"""Include transport properties in fluid data calculation
233+
234+
:param calc_transport_properties: evaluate transport properties, defaults to False
235+
:type calc_transport_properties: bool, optional
236+
"""
237+
self.__calc_transport_properties = calc_transport_properties
238+
return
239+
240+
def CalcTransportProperties(self):
241+
"""Whether transport properties are included in the fluid data set.
242+
243+
:return: calculation of transport properties.
244+
:rtype: bool
245+
"""
246+
return self.__calc_transport_properties
247+
248+
def SetConductivityModel(self, conductivity_model:str=DefaultSettings_NICFD.conductivity_model):
249+
"""Specify the two-phase conductivity model.
250+
251+
:param conductivity_model: two-phase conductivity model option, defaults to "volume"
252+
:type conductivity_model: str, optional
253+
:raises Exception: if the specified option is not supported.
254+
"""
255+
if conductivity_model not in DefaultSettings_NICFD.conductivity_models:
256+
raise Exception("Two-phase conductivity model should be one of the following: " + ",".join(c for c in DefaultSettings_NICFD.conductivity_models))
257+
self.__conductivity_model = conductivity_model
258+
if not self.TwoPhase():
259+
self.EnableTwophase(True)
260+
print("Two-phase conductivity model specified, including two-phase fluid data.")
261+
return
262+
263+
def GetConductivityModel(self):
264+
"""Get two-phase conductivity model.
265+
266+
:return: two-phase conductivity model option
267+
:rtype: str
268+
"""
269+
return self.__conductivity_model
270+
271+
def SetViscosityModel(self, viscosity_model:str=DefaultSettings_NICFD.viscosity_model):
272+
"""Specify the two-phase viscosity model.
273+
274+
:param viscosity_model: two-phase viscosity model option, defaults to "mcadams"
275+
:type viscosity_model: str, optional
276+
:raises Exception: if the specified option is not supported.
277+
"""
278+
if viscosity_model not in DefaultSettings_NICFD.viscosity_models:
279+
raise Exception("Two-phase viscosity model should be one of the following: " + ",".join(c for c in DefaultSettings_NICFD.viscosity_models))
280+
self.__viscosity_model = viscosity_model
281+
if not self.TwoPhase():
282+
self.EnableTwophase(True)
283+
print("Two-phase viscosity model specified, including two-phase fluid data.")
284+
return
285+
286+
def GetViscosityModel(self):
287+
"""Get two-phase viscosity model.
288+
289+
:return: two-phase viscosity model option
290+
:rtype: str
291+
"""
292+
return self.__viscosity_model
293+
294+
def EnableGasPhase(self, gas_phase:bool=True):
295+
"""Include thermophysical state data from the fluid in gas phase
296+
297+
:param gas_phase: include gas phase data, defaults to True
298+
:type gas_phase: bool, optional
299+
"""
300+
self.__gasphase = gas_phase
301+
return
302+
303+
def GasPhase(self):
304+
"""Whether thermophysical state data from the fluid in the gaseous phase are included.
305+
306+
:return: inclusion of gas phase data.
307+
:rtype: bool
308+
"""
309+
return self.__gasphase
310+
311+
def EnableSuperCritical(self, supercritical:bool=True):
312+
"""Include thermophysical state data of the fluid in supercritial, and of the supercritical gas and liquid phase if specified.
313+
314+
:param supercritical: include supercritical phase data, defaults to True
315+
:type supercritical: bool, optional
316+
"""
317+
self.__supercritical = supercritical
318+
return
319+
320+
def EnableTwophase(self, two_phase:bool=False):
321+
"""Include two-phase thermophysical data of the fluid.
322+
323+
:param two_phase: include two-phase data in fluid data, defaults to False
324+
:type two_phase: bool, optional
325+
"""
326+
self.__twophase = two_phase
327+
return
328+
329+
def EnableLiquidPhase(self, liquid_phase:bool=False):
330+
"""Include thermodynamic state data from fluid in the liquid phase.
331+
332+
:param liquid_phase: include liquid-phase data, defaults to False
333+
:type liquid_phase: bool, optional
334+
"""
335+
self.__liquidphase = liquid_phase
336+
return
337+
338+
def TwoPhase(self):
339+
"""Whether thermophysical state data from the fluid in the two-phase are included.
340+
341+
:return: inclusion of two-phase data.
342+
:rtype: bool
343+
"""
344+
return self.__twophase
345+
346+
def LiquidPhase(self):
347+
"""Whether thermophysical state data from the fluid in the liquid phase are included.
348+
349+
:return: inclusion of liquid phase data.
350+
:rtype: bool
351+
"""
352+
return self.__liquidphase
353+
354+
def SuperCritical(self):
355+
"""Whether thermophysical state data from the fluid in the supercritical phases are included.
356+
357+
:return: inclusion of supercritical phase data.
358+
:rtype: bool
359+
"""
360+
return self.__supercritical
361+
211362
def GetEquationOfState(self):
212363
"""Retrieve the equation of state backend used by CoolProp for fluid data calculations.
213364
@@ -262,9 +413,9 @@ def UseAutoRange(self, use_auto_range:bool=True):
262413
return
263414

264415
def GetAutoRange(self):
265-
"""Whether fluid data ranges are automatically determined by CoolProp
416+
"""The span of the thermodynamic state space is determined automatically.
266417
267-
:return: boolean if range is automatically determined
418+
:return: whether automatic ranging is used.
268419
:rtype: bool
269420
"""
270421
return self.__use_auto_range
@@ -358,9 +509,9 @@ def GetNpEnergy(self):
358509
def SetDensityBounds(self, Rho_lower:float=DefaultSettings_NICFD.Rho_min, Rho_upper:float=DefaultSettings_NICFD.Rho_max):
359510
"""Define the density bounds of the density-energy based fluid data grid.
360511
361-
:param Rho_lower: lower limit density value in kg/m3, defaults to DefaultSettings_NICFD.Rho_min
512+
:param Rho_lower: lower limit density value, defaults to DefaultSettings_NICFD.Rho_min
362513
:type Rho_lower: float, optional
363-
:param Rho_upper: upper limit for density in kg/m3, defaults to DefaultSettings_NICFD.Rho_max
514+
:param Rho_upper: upper limit for density, defaults to DefaultSettings_NICFD.Rho_max
364515
:type Rho_upper: float, optional
365516
:raises Exception: if lower value for density exceeds upper value.
366517
"""
@@ -489,6 +640,26 @@ def GetNpPressure(self):
489640
"""
490641
return self.__Np_P
491642

643+
def SetTableDiscretization(self, table_method:str=DefaultSettings_NICFD.tabulation_method):
644+
"""Specify how thermodynamic state space is discretized for look-up table.
645+
646+
:param table_method: discretization method, defaults to "cartesian"
647+
:type table_method: str, optional
648+
:raises Exception: if method is not supported
649+
"""
650+
if table_method not in DefaultSettings_NICFD.tabulation_options:
651+
raise Exception("Table discretization method should be one of the following: %s" % ",".join(t for t in DefaultSettings_NICFD.tabulation_options))
652+
self.__Table_discretization = table_method
653+
return
654+
655+
def GetTableDiscretization(self):
656+
"""Get thermodynamic state space discretization method.
657+
658+
:return: table discretization method.
659+
:rtype: str
660+
"""
661+
return self.__Table_discretization
662+
492663
def SetTableCellSize(self, base_cell_size:float, refined_cell_size:float=None):
493664
"""Define the base and optional refined 2D table cell sizes.
494665
@@ -1019,10 +1190,11 @@ def SetReactionMechanism(self, mechanism_input:str=DefaultSettings_FGM.reaction_
10191190
return
10201191

10211192
def GetReactionMechanism(self):
1022-
"""Get the reaction mechanism used for flamelet generation.
1023-
1193+
"""
1194+
Get the reaction mechanism used for flamelet generation.
10241195
:return: reaction mechanism name.
10251196
:rtype: str
1197+
10261198
"""
10271199
return self.__reaction_mechanism
10281200

@@ -1079,10 +1251,11 @@ def SetMixtureBounds(self, mix_lower:float=DefaultSettings_FGM.eq_ratio_min, mix
10791251
return
10801252

10811253
def GetMixtureBounds(self):
1082-
"""Get the mixture status bounds.
1083-
1254+
"""
1255+
Get the mixture status bounds.
10841256
:return: List containing lower and upper mixture status values.
10851257
:rtype: list[float]
1258+
10861259
"""
10871260
return [self.__mix_status_lower, self.__mix_status_upper]
10881261

@@ -1102,7 +1275,8 @@ def SetNpMix(self, input:int=DefaultSettings_FGM.Np_eq):
11021275
return
11031276

11041277
def GetNpMix(self):
1105-
"""Get the number of divisions between the lean and rich mixture status for flamelet generation.
1278+
"""
1279+
Get the number of divisions between the lean and rich mixture status for flamelet generation.
11061280
11071281
:return: number of divisions between rich and lean.
11081282
:rtype: int
@@ -1381,8 +1555,8 @@ def SetPassiveSpecies(self, passive_species:list[str]=[]):
13811555
"""
13821556
Set the passive transported species for which source terms should be saved in the manifold.
13831557
1384-
:param passive_species: list of species names.
1385-
:type passive_species: list[str]
1558+
:param __passive_species: list of species names.
1559+
:type __passive_species: list[str]
13861560
"""
13871561
self.__passive_species = passive_species
13881562
return

Common/Properties.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class EntropicVars(Enum):
6565
dsdp_rho=auto()
6666
dsdrho_p=auto()
6767
cp=auto()
68+
cv=auto()
69+
Enthalpy=auto()
70+
Conductivity=auto()
71+
ViscosityDyn=auto()
72+
VaporQuality=auto()
6873
N_STATE_VARS=auto()
6974

7075
class FGMVars(Enum):
@@ -137,6 +142,11 @@ class DefaultSettings_NICFD(DefaultProperties):
137142

138143
fluid_name:str = "Air"
139144
EOS_type:str = "HEOS"
145+
conductivity_models:list[str] = ["volume", "mass"]
146+
viscosity_models:list[str] = ["mcadams", "cicchitti", "dukler"]
147+
conductivity_model:str = "volume"
148+
viscosity_model:str = "mcadams"
149+
140150
use_PT_grid:bool = False
141151

142152
controlling_variables:list[str] = [EntropicVars.Density.name, \
@@ -152,6 +162,9 @@ class DefaultSettings_NICFD(DefaultProperties):
152162
config_type:str = "EntropicAI"
153163
supported_state_vars:list[str] = ["s","T","p","c2","dTdrho_e","dTde_rho","dpdrho_e","dpde_rho"]
154164
supported_backends:list[str] = ["HEOS","PR", "SRK", "IF97","REFPROP"]
165+
166+
tabulation_options:list[str] = ["cartesian","adaptive"]
167+
tabulation_method:str="cartesian"
155168

156169
class DefaultSettings_FGM(DefaultProperties):
157170
config_name:str = "config_FGM"
@@ -213,4 +226,5 @@ class DefaultSettings_FGM(DefaultProperties):
213226
"exponential" : tf.keras.activations.exponential,\
214227
"gelu" : tf.keras.activations.gelu,\
215228
"sigmoid" : tf.keras.activations.sigmoid,\
216-
"swish" : tf.keras.activations.swish}
229+
"swish" : tf.keras.activations.swish}
230+

0 commit comments

Comments
 (0)