Skip to content

Commit f516fc1

Browse files
committed
[Fluid] Adding low Mach example
1 parent d29844e commit f516fc1

10 files changed

+11160
-0
lines changed

fluid_dynamics/validation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This folder contains the validation cases:
44

55
- [Body-fitted 100 Re cylinder](https://github.com/KratosMultiphysics/Examples/blob/master/fluid_dynamics/validation/body_fitted_cylinder_100Re/README.md)
66
- [Embedded moving cylinder](https://github.com/KratosMultiphysics/Examples/tree/master/fluid_dynamics/validation/embedded_moving_cylinder/README.md)
7+
- [Low Mach thermally driven cavity](https://github.com/KratosMultiphysics/Examples/tree/master/fluid_dynamics/validation/low_mach_thermally_driven_cavity/README.md)
78
- [Transonic flow around a NACA0012 profile](https://github.com/KratosMultiphysics/Examples/tree/master/fluid_dynamics/validation/compressible_naca_0012_Ma_0.8/README.md)
89
- [Multistage transonic flow around a NACA0012 profile](https://github.com/KratosMultiphysics/Examples/tree/master/fluid_dynamics/validation/multistage_compressible_naca_0012_Ma_0.8/README.md)
910
- [Transonic flow around a NACA0012 profile at a 3° angle](https://github.com/KratosMultiphysics/Examples/tree/master/fluid_dynamics/validation/compressible_naca_0012_Ma_0.8_aoa_3/README.md)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Low Mach thermally driven cavity
2+
3+
**Author:** [Rubén Zorrilla](https://github.com/rubenzorrilla)
4+
5+
**Kratos version:** 10.0
6+
7+
**Source files:** [Low Mach thermally driven cavity](https://github.com/KratosMultiphysics/Examples/tree/master/fluid_dynamics/validation/low_mach_thermally_driven_cavity/source)
8+
9+
## Case Specification
10+
This example solves the well-known thermally driven cavity flow using a low Mach approximation compressible Navier-Stokes solver.
11+
12+
The problem geometry consists in a 1 x 1 m cavity. No-slip boundary conditions are imposed in all the cavity walls. The initial temperature is 600 ºK. The left wall temperature is set to 960 ºK while the right one is set to 240 ºK. Adiabatic conditions are weakly enforced in top and bottom walls. Pressure is fixed to zero in the top right corner. The fluid is initially at rest so the fluid flow is induced by the thermal effect only. The initial thermodinamic pressure is 101325.0 _Pa_. Gravity (body force) is set to 2.40690342 _m/s<sup>2</sup>_ Note that the material and boundary conditions are set such that the Prandtl number is 0.71 and the Rayleight number is 10<sup>6</sup>.
13+
14+
Concerning the material, a Newtonian fluid with the characteristic parameters listed below is used.
15+
* Dynamic viscosity (&mu;): 1e-03 _Kg/m·s_
16+
* Thermal conductivity (&kappa;): 1.41479 _Kg·m/s<sup>3</sup>·K_
17+
* Specific heat (c<sub>p<{/sub}>): 1.0045e3 _J/Kg·K_
18+
* Heat capacity ratio (&gamma;): 1.4
19+
20+
The time step is 0.25 seconds, while the total simulation time is 30.0 seconds, which is enough to reach an (almost) steady state solution.
21+
22+
## Results
23+
The problem is solved using an ASGS stabilised monolithic formulation. A 50x50 divisions structured mesh made up with linear quadrilateral elements is used.
24+
25+
<p align="center">
26+
<img src="data/low_mach_thermally_driven_cavity_p.gif" alt="Low Mach thermally driven cavity pressure field [Pa]." style="width: 600px;"/>
27+
</p>
28+
29+
<p align="center">
30+
<img src="data/low_mach_thermally_driven_cavity_v.gif" alt="Low Mach thermally driven cavity velocity field [m/s]." style="width: 600px;"/>
31+
</p>
32+
33+
<p align="center">
34+
<img src="data/low_mach_thermally_driven_cavity_t.gif" alt="Low Mach thermally driven cavity temperature field [K]." style="width: 600px;"/>
35+
</p>
36+
37+
<p align="center">
38+
<img src="data/low_mach_thermally_driven_cavity_rho.gif" alt="Low Mach thermally driven cavity density field [Kg/m<sup>3</sup>]." style="width: 600px;"/>
39+
</p>
40+
8.05 MB
Loading
9.13 MB
Loading
9.67 MB
Loading
10.1 MB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"properties" : [{
3+
"model_part_name" : "FluidModelPart",
4+
"properties_id" : 0,
5+
"Material" : null
6+
},{
7+
"model_part_name" : "FluidModelPart.FluidParts_Fluid",
8+
"properties_id" : 1,
9+
"Material" : {
10+
"constitutive_law" : {
11+
"name" : "Newtonian2DLaw"
12+
},
13+
"Variables" : {
14+
"CONDUCTIVITY" : 1.41479,
15+
"SPECIFIC_HEAT" : 1.0045e3,
16+
"DYNAMIC_VISCOSITY" : 1.0e-3,
17+
"HEAT_CAPACITY_RATIO" : 1.4
18+
},
19+
"Tables" : null
20+
}
21+
}]
22+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import sys
2+
import time
3+
import importlib
4+
5+
import KratosMultiphysics
6+
import KratosMultiphysics.FluidDynamicsApplication as KratosCFD
7+
8+
def CreateAnalysisStageWithFlushInstance(cls, global_model, parameters):
9+
class AnalysisStageWithFlush(cls):
10+
11+
def __init__(self, model,project_parameters, flush_frequency=10.0):
12+
super().__init__(model,project_parameters)
13+
self.flush_frequency = flush_frequency
14+
self.last_flush = time.time()
15+
sys.stdout.flush()
16+
17+
def Initialize(self):
18+
super().Initialize()
19+
sys.stdout.flush()
20+
21+
def ModifyAfterSolverInitialize(self):
22+
super().ModifyAfterSolverInitialize()
23+
24+
# Initialize temperature field
25+
t_0 = 600.0
26+
for node in self.model.GetModelPart("FluidModelPart.FluidParts_Fluid").Nodes:
27+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 0, t_0)
28+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 1, t_0)
29+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 2, t_0)
30+
31+
t_left = 960
32+
for node in self.model.GetModelPart("FluidModelPart.NoSlip2D_Left").Nodes:
33+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 0, t_left)
34+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 1, t_left)
35+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 2, t_left)
36+
37+
t_right = 240
38+
for node in self.model.GetModelPart("FluidModelPart.NoSlip2D_Right").Nodes:
39+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 0, t_right)
40+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 1, t_right)
41+
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 2, t_right)
42+
43+
def FinalizeSolutionStep(self):
44+
super().FinalizeSolutionStep()
45+
46+
if self.parallel_type == "OpenMP":
47+
now = time.time()
48+
if now - self.last_flush > self.flush_frequency:
49+
sys.stdout.flush()
50+
self.last_flush = now
51+
52+
return AnalysisStageWithFlush(global_model, parameters)
53+
54+
if __name__ == "__main__":
55+
56+
with open("ProjectParameters.json", 'r') as parameter_file:
57+
parameters = KratosMultiphysics.Parameters(parameter_file.read())
58+
59+
analysis_stage_module_name = parameters["analysis_stage"].GetString()
60+
analysis_stage_class_name = analysis_stage_module_name.split('.')[-1]
61+
analysis_stage_class_name = ''.join(x.title() for x in analysis_stage_class_name.split('_'))
62+
63+
analysis_stage_module = importlib.import_module(analysis_stage_module_name)
64+
analysis_stage_class = getattr(analysis_stage_module, analysis_stage_class_name)
65+
66+
global_model = KratosMultiphysics.Model()
67+
simulation = CreateAnalysisStageWithFlushInstance(analysis_stage_class, global_model, parameters)
68+
simulation.Run()
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
{
2+
"analysis_stage" : "KratosMultiphysics.FluidDynamicsApplication.fluid_dynamics_analysis",
3+
"problem_data" : {
4+
"problem_name" : "low_mach_cavity",
5+
"parallel_type" : "OpenMP",
6+
"echo_level" : 0,
7+
"start_time" : 0.0,
8+
"end_time" : 30.0
9+
},
10+
"output_processes" : {
11+
"gid_output" : [{
12+
"python_module" : "gid_output_process",
13+
"kratos_module" : "KratosMultiphysics",
14+
"process_name" : "GiDOutputProcess",
15+
"Parameters" : {
16+
"model_part_name" : "FluidModelPart.fluid_computational_model_part",
17+
"postprocess_parameters" : {
18+
"result_file_configuration" : {
19+
"gidpost_flags" : {
20+
"GiDPostMode" : "GiD_PostBinary",
21+
"WriteDeformedMeshFlag" : "WriteDeformed",
22+
"WriteConditionsFlag" : "WriteConditions",
23+
"MultiFileFlag" : "SingleFile"
24+
},
25+
"file_label" : "time",
26+
"output_control_type" : "time",
27+
"output_interval" : 0.5,
28+
"body_output" : true,
29+
"node_output" : false,
30+
"skin_output" : false,
31+
"plane_output" : [],
32+
"nodal_results" : ["VELOCITY","PRESSURE","TEMPERATURE","DENSITY"],
33+
"nodal_nonhistorical_results" : ["NODAL_AREA"],
34+
"gauss_point_results" : []
35+
},
36+
"point_data_configuration" : []
37+
},
38+
"output_name" : "gid_output/low_mach_cavity"
39+
}
40+
}]
41+
},
42+
"solver_settings" : {
43+
"model_part_name" : "FluidModelPart",
44+
"domain_size" : 2,
45+
"solver_type" : "low_mach",
46+
"material_import_settings" : {
47+
"materials_filename" : "FluidMaterials.json"
48+
},
49+
"echo_level" : 1,
50+
"compute_reactions" : false,
51+
"maximum_iterations" : 10,
52+
"relative_velocity_tolerance" : 0.001,
53+
"absolute_velocity_tolerance" : 1e-5,
54+
"relative_pressure_tolerance" : 0.001,
55+
"absolute_pressure_tolerance" : 1e-5,
56+
"relative_temperature_tolerance" : 0.001,
57+
"absolute_temperature_tolerance" : 1e-5,
58+
"volume_model_part_name" : "FluidParts_Fluid",
59+
"skin_parts" : ["NoSlip2D_Left","NoSlip2D_Right","NoSlip2D_Top","NoSlip2D_Bottom"],
60+
"no_skin_parts" : [],
61+
"time_scheme" : "bdf2",
62+
"time_stepping" : {
63+
"automatic_time_step" : false,
64+
"time_step" : 0.25
65+
},
66+
"formulation" : {
67+
"element_type" : "qsvms"
68+
},
69+
"reform_dofs_at_each_step" : false,
70+
"model_import_settings" : {
71+
"input_type" : "use_input_model_part"
72+
},
73+
"thermodynamic_pressure_settings" : {
74+
"flow_type" : "closed",
75+
"value": 101325.0
76+
}
77+
},
78+
"processes" : {
79+
"initial_conditions_process_list" : [],
80+
"boundary_conditions_process_list" : [{
81+
"python_module" : "apply_noslip_process",
82+
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication",
83+
"process_name" : "ApplyNoSlipProcess",
84+
"Parameters" : {
85+
"model_part_name" : "FluidModelPart.NoSlip2D_Left"
86+
}
87+
},{
88+
"python_module" : "apply_noslip_process",
89+
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication",
90+
"process_name" : "ApplyNoSlipProcess",
91+
"Parameters" : {
92+
"model_part_name" : "FluidModelPart.NoSlip2D_Right"
93+
}
94+
},{
95+
"python_module" : "apply_noslip_process",
96+
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication",
97+
"process_name" : "ApplyNoSlipProcess",
98+
"Parameters" : {
99+
"model_part_name" : "FluidModelPart.NoSlip2D_Top"
100+
}
101+
},{
102+
"python_module" : "apply_noslip_process",
103+
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication",
104+
"process_name" : "ApplyNoSlipProcess",
105+
"Parameters" : {
106+
"model_part_name" : "FluidModelPart.NoSlip2D_Bottom"
107+
}
108+
},{
109+
"python_module" : "assign_scalar_variable_process",
110+
"kratos_module" : "KratosMultiphysics",
111+
"process_name" : "AssignScalarVariableProcess",
112+
"Parameters" : {
113+
"model_part_name" : "FluidModelPart.NoSlip2D_Left",
114+
"variable_name" : "TEMPERATURE",
115+
"interval" : [0.0,"End"],
116+
"constrained" : true,
117+
"value" : 960.0
118+
}
119+
},{
120+
"python_module" : "assign_scalar_variable_process",
121+
"kratos_module" : "KratosMultiphysics",
122+
"process_name" : "AssignScalarVariableProcess",
123+
"Parameters" : {
124+
"model_part_name" : "FluidModelPart.NoSlip2D_Right",
125+
"variable_name" : "TEMPERATURE",
126+
"interval" : [0.0,"End"],
127+
"constrained" : true,
128+
"value" : 240.0
129+
}
130+
},{
131+
"python_module" : "assign_scalar_variable_process",
132+
"kratos_module" : "KratosMultiphysics",
133+
"process_name" : "AssignScalarVariableProcess",
134+
"Parameters" : {
135+
"model_part_name" : "FluidModelPart.PressureConstraints2D_TopRightCorner",
136+
"variable_name" : "PRESSURE",
137+
"interval" : [0.0,"End"],
138+
"constrained" : true,
139+
"value" : 0.0
140+
}
141+
}],
142+
"gravity" : [{
143+
"python_module" : "assign_vector_by_direction_process",
144+
"kratos_module" : "KratosMultiphysics",
145+
"process_name" : "AssignVectorByDirectionProcess",
146+
"Parameters" : {
147+
"model_part_name" : "FluidModelPart.FluidParts_Fluid",
148+
"variable_name" : "BODY_FORCE",
149+
"modulus" : 2.40690342,
150+
"constrained" : false,
151+
"direction" : [0.0,-1.0,0.0]
152+
}
153+
}],
154+
"auxiliar_process_list" : []
155+
},
156+
"modelers" : [{
157+
"name" : "Modelers.KratosMultiphysics.ImportMDPAModeler",
158+
"parameters" : {
159+
"input_filename" : "low_mach_cavity",
160+
"model_part_name" : "FluidModelPart"
161+
}
162+
}]
163+
}

0 commit comments

Comments
 (0)