-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from KratosMultiphysics/fluid/low-mach-cavity
[Fluid] Adding low Mach example
- Loading branch information
Showing
10 changed files
with
11,160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
fluid_dynamics/validation/low_mach_thermally_driven_cavity/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Low Mach thermally driven cavity | ||
|
||
**Author:** [Rubén Zorrilla](https://github.com/rubenzorrilla) | ||
|
||
**Kratos version:** 10.0 | ||
|
||
**Source files:** [Low Mach thermally driven cavity](https://github.com/KratosMultiphysics/Examples/tree/master/fluid_dynamics/validation/low_mach_thermally_driven_cavity/source) | ||
|
||
## Case Specification | ||
This example solves the well-known thermally driven cavity flow using a low Mach approximation compressible Navier-Stokes solver. | ||
|
||
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>. | ||
|
||
Concerning the material, a Newtonian fluid with the characteristic parameters listed below is used. | ||
* Dynamic viscosity (μ): 1e-03 _Kg/m·s_ | ||
* Thermal conductivity (κ): 1.41479 _Kg·m/s<sup>3</sup>·K_ | ||
* Specific heat (c<sub>p<{/sub}>): 1.0045e3 _J/Kg·K_ | ||
* Heat capacity ratio (γ): 1.4 | ||
|
||
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. | ||
|
||
## Results | ||
The problem is solved using an ASGS stabilised monolithic formulation. A 50x50 divisions structured mesh made up with linear quadrilateral elements is used. | ||
|
||
<p align="center"> | ||
<img src="data/low_mach_thermally_driven_cavity_p.gif" alt="Low Mach thermally driven cavity pressure field [Pa]." style="width: 600px;"/> | ||
</p> | ||
|
||
<p align="center"> | ||
<img src="data/low_mach_thermally_driven_cavity_v.gif" alt="Low Mach thermally driven cavity velocity field [m/s]." style="width: 600px;"/> | ||
</p> | ||
|
||
<p align="center"> | ||
<img src="data/low_mach_thermally_driven_cavity_t.gif" alt="Low Mach thermally driven cavity temperature field [K]." style="width: 600px;"/> | ||
</p> | ||
|
||
<p align="center"> | ||
<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;"/> | ||
</p> | ||
|
Binary file added
BIN
+8.05 MB
...on/low_mach_thermally_driven_cavity/data/low_mach_thermally_driven_cavity_p.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.13 MB
.../low_mach_thermally_driven_cavity/data/low_mach_thermally_driven_cavity_rho.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.67 MB
...on/low_mach_thermally_driven_cavity/data/low_mach_thermally_driven_cavity_t.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 MB
...on/low_mach_thermally_driven_cavity/data/low_mach_thermally_driven_cavity_v.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions
22
fluid_dynamics/validation/low_mach_thermally_driven_cavity/source/FluidMaterials.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"properties" : [{ | ||
"model_part_name" : "FluidModelPart", | ||
"properties_id" : 0, | ||
"Material" : null | ||
},{ | ||
"model_part_name" : "FluidModelPart.FluidParts_Fluid", | ||
"properties_id" : 1, | ||
"Material" : { | ||
"constitutive_law" : { | ||
"name" : "Newtonian2DLaw" | ||
}, | ||
"Variables" : { | ||
"CONDUCTIVITY" : 1.41479, | ||
"SPECIFIC_HEAT" : 1.0045e3, | ||
"DYNAMIC_VISCOSITY" : 1.0e-3, | ||
"HEAT_CAPACITY_RATIO" : 1.4 | ||
}, | ||
"Tables" : null | ||
} | ||
}] | ||
} |
68 changes: 68 additions & 0 deletions
68
fluid_dynamics/validation/low_mach_thermally_driven_cavity/source/MainKratos.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import sys | ||
import time | ||
import importlib | ||
|
||
import KratosMultiphysics | ||
import KratosMultiphysics.FluidDynamicsApplication as KratosCFD | ||
|
||
def CreateAnalysisStageWithFlushInstance(cls, global_model, parameters): | ||
class AnalysisStageWithFlush(cls): | ||
|
||
def __init__(self, model,project_parameters, flush_frequency=10.0): | ||
super().__init__(model,project_parameters) | ||
self.flush_frequency = flush_frequency | ||
self.last_flush = time.time() | ||
sys.stdout.flush() | ||
|
||
def Initialize(self): | ||
super().Initialize() | ||
sys.stdout.flush() | ||
|
||
def ModifyAfterSolverInitialize(self): | ||
super().ModifyAfterSolverInitialize() | ||
|
||
# Initialize temperature field | ||
t_0 = 600.0 | ||
for node in self.model.GetModelPart("FluidModelPart.FluidParts_Fluid").Nodes: | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 0, t_0) | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 1, t_0) | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 2, t_0) | ||
|
||
t_left = 960 | ||
for node in self.model.GetModelPart("FluidModelPart.NoSlip2D_Left").Nodes: | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 0, t_left) | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 1, t_left) | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 2, t_left) | ||
|
||
t_right = 240 | ||
for node in self.model.GetModelPart("FluidModelPart.NoSlip2D_Right").Nodes: | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 0, t_right) | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 1, t_right) | ||
node.SetSolutionStepValue(KratosMultiphysics.TEMPERATURE, 2, t_right) | ||
|
||
def FinalizeSolutionStep(self): | ||
super().FinalizeSolutionStep() | ||
|
||
if self.parallel_type == "OpenMP": | ||
now = time.time() | ||
if now - self.last_flush > self.flush_frequency: | ||
sys.stdout.flush() | ||
self.last_flush = now | ||
|
||
return AnalysisStageWithFlush(global_model, parameters) | ||
|
||
if __name__ == "__main__": | ||
|
||
with open("ProjectParameters.json", 'r') as parameter_file: | ||
parameters = KratosMultiphysics.Parameters(parameter_file.read()) | ||
|
||
analysis_stage_module_name = parameters["analysis_stage"].GetString() | ||
analysis_stage_class_name = analysis_stage_module_name.split('.')[-1] | ||
analysis_stage_class_name = ''.join(x.title() for x in analysis_stage_class_name.split('_')) | ||
|
||
analysis_stage_module = importlib.import_module(analysis_stage_module_name) | ||
analysis_stage_class = getattr(analysis_stage_module, analysis_stage_class_name) | ||
|
||
global_model = KratosMultiphysics.Model() | ||
simulation = CreateAnalysisStageWithFlushInstance(analysis_stage_class, global_model, parameters) | ||
simulation.Run() |
163 changes: 163 additions & 0 deletions
163
fluid_dynamics/validation/low_mach_thermally_driven_cavity/source/ProjectParameters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
{ | ||
"analysis_stage" : "KratosMultiphysics.FluidDynamicsApplication.fluid_dynamics_analysis", | ||
"problem_data" : { | ||
"problem_name" : "low_mach_cavity", | ||
"parallel_type" : "OpenMP", | ||
"echo_level" : 0, | ||
"start_time" : 0.0, | ||
"end_time" : 30.0 | ||
}, | ||
"output_processes" : { | ||
"gid_output" : [{ | ||
"python_module" : "gid_output_process", | ||
"kratos_module" : "KratosMultiphysics", | ||
"process_name" : "GiDOutputProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.fluid_computational_model_part", | ||
"postprocess_parameters" : { | ||
"result_file_configuration" : { | ||
"gidpost_flags" : { | ||
"GiDPostMode" : "GiD_PostBinary", | ||
"WriteDeformedMeshFlag" : "WriteDeformed", | ||
"WriteConditionsFlag" : "WriteConditions", | ||
"MultiFileFlag" : "SingleFile" | ||
}, | ||
"file_label" : "time", | ||
"output_control_type" : "time", | ||
"output_interval" : 0.5, | ||
"body_output" : true, | ||
"node_output" : false, | ||
"skin_output" : false, | ||
"plane_output" : [], | ||
"nodal_results" : ["VELOCITY","PRESSURE","TEMPERATURE","DENSITY"], | ||
"nodal_nonhistorical_results" : ["NODAL_AREA"], | ||
"gauss_point_results" : [] | ||
}, | ||
"point_data_configuration" : [] | ||
}, | ||
"output_name" : "gid_output/low_mach_cavity" | ||
} | ||
}] | ||
}, | ||
"solver_settings" : { | ||
"model_part_name" : "FluidModelPart", | ||
"domain_size" : 2, | ||
"solver_type" : "low_mach", | ||
"material_import_settings" : { | ||
"materials_filename" : "FluidMaterials.json" | ||
}, | ||
"echo_level" : 1, | ||
"compute_reactions" : false, | ||
"maximum_iterations" : 10, | ||
"relative_velocity_tolerance" : 0.001, | ||
"absolute_velocity_tolerance" : 1e-5, | ||
"relative_pressure_tolerance" : 0.001, | ||
"absolute_pressure_tolerance" : 1e-5, | ||
"relative_temperature_tolerance" : 0.001, | ||
"absolute_temperature_tolerance" : 1e-5, | ||
"volume_model_part_name" : "FluidParts_Fluid", | ||
"skin_parts" : ["NoSlip2D_Left","NoSlip2D_Right","NoSlip2D_Top","NoSlip2D_Bottom"], | ||
"no_skin_parts" : [], | ||
"time_scheme" : "bdf2", | ||
"time_stepping" : { | ||
"automatic_time_step" : false, | ||
"time_step" : 0.25 | ||
}, | ||
"formulation" : { | ||
"element_type" : "qsvms" | ||
}, | ||
"reform_dofs_at_each_step" : false, | ||
"model_import_settings" : { | ||
"input_type" : "use_input_model_part" | ||
}, | ||
"thermodynamic_pressure_settings" : { | ||
"flow_type" : "closed", | ||
"value": 101325.0 | ||
} | ||
}, | ||
"processes" : { | ||
"initial_conditions_process_list" : [], | ||
"boundary_conditions_process_list" : [{ | ||
"python_module" : "apply_noslip_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"process_name" : "ApplyNoSlipProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.NoSlip2D_Left" | ||
} | ||
},{ | ||
"python_module" : "apply_noslip_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"process_name" : "ApplyNoSlipProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.NoSlip2D_Right" | ||
} | ||
},{ | ||
"python_module" : "apply_noslip_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"process_name" : "ApplyNoSlipProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.NoSlip2D_Top" | ||
} | ||
},{ | ||
"python_module" : "apply_noslip_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"process_name" : "ApplyNoSlipProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.NoSlip2D_Bottom" | ||
} | ||
},{ | ||
"python_module" : "assign_scalar_variable_process", | ||
"kratos_module" : "KratosMultiphysics", | ||
"process_name" : "AssignScalarVariableProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.NoSlip2D_Left", | ||
"variable_name" : "TEMPERATURE", | ||
"interval" : [0.0,"End"], | ||
"constrained" : true, | ||
"value" : 960.0 | ||
} | ||
},{ | ||
"python_module" : "assign_scalar_variable_process", | ||
"kratos_module" : "KratosMultiphysics", | ||
"process_name" : "AssignScalarVariableProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.NoSlip2D_Right", | ||
"variable_name" : "TEMPERATURE", | ||
"interval" : [0.0,"End"], | ||
"constrained" : true, | ||
"value" : 240.0 | ||
} | ||
},{ | ||
"python_module" : "assign_scalar_variable_process", | ||
"kratos_module" : "KratosMultiphysics", | ||
"process_name" : "AssignScalarVariableProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.PressureConstraints2D_TopRightCorner", | ||
"variable_name" : "PRESSURE", | ||
"interval" : [0.0,"End"], | ||
"constrained" : true, | ||
"value" : 0.0 | ||
} | ||
}], | ||
"gravity" : [{ | ||
"python_module" : "assign_vector_by_direction_process", | ||
"kratos_module" : "KratosMultiphysics", | ||
"process_name" : "AssignVectorByDirectionProcess", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.FluidParts_Fluid", | ||
"variable_name" : "BODY_FORCE", | ||
"modulus" : 2.40690342, | ||
"constrained" : false, | ||
"direction" : [0.0,-1.0,0.0] | ||
} | ||
}], | ||
"auxiliar_process_list" : [] | ||
}, | ||
"modelers" : [{ | ||
"name" : "Modelers.KratosMultiphysics.ImportMDPAModeler", | ||
"parameters" : { | ||
"input_filename" : "low_mach_cavity", | ||
"model_part_name" : "FluidModelPart" | ||
} | ||
}] | ||
} |
Oops, something went wrong.