This is a tutorial to show you how to setup the heated square cavity tutorial with Salome-CFD and Code Saturne.
Here’s the video:
This tutorial is using Code_Saturne 7.0.4. Some differences might appear if you are using an older or more recent version.
The PDF for this tutorial is available here:
https://www.code-saturne.org/cms/web/sites/default/files/07_HeatedSquareCavityFlow.pdf
The code and model is available here: https://github.com/CyprienRusu/Feaforall/tree/master/Code%20Saturne%20Tutorials/heated_cavity
Main Steps of this Simulation
Create the Model and the Mesh
- 1 m x 1 m x 0.01 m
- element size = 0.0125
- number of elements = 80
- Create groups
In Code_Saturne GUI
- Define the Mesh
- Mesh -> Boundary Zones
- Incompressible
- Laminar
Body Forces > Gravity -9.81 m/s2 for gy
Volume Conditions -> Activate Initialisation
Density> User Law
Reference = 1.2039 kg/m3
Viscosity
Reference = 1.83e-5 Pa.s
Specific Heat
Cp 1004.84 J/kg/K
Thermal Conductivity
Reference Value Lambda = 0.0259 W/m/K
Boundary conditions
- Symmetry Plane -> Symmetry
- Others-> Walls
- Symmetry planes —> nothing to setup
- Adiabatic Walls —> Prescribed Flux = 0
- Hot Wall —> Prescribed Value = 303.15
- Cold Wall —> Prescribed Value = 293.15
Time Settings
- Time varying (Adaptive)
- Velocity-Pressure Algorithm SIMPLEC
- Number of Time steps = 450
User Routines:
Place the following file in the SRC folder (Link)
Here’s the code for the cs_user_physical_properties user routine (C Language):
void cs_user_physical_properties(cs_domain_t *domain) { CS_NO_WARN_IF_UNUSED(domain); /* Check fields exists */ if (CS_F_(rho) == NULL) bft_error(__FILE__, __LINE__, 0,_("error rho not variable\n")); const cs_lnum_t n_cells = cs_glob_mesh->n_cells; cs_real_t *cpro_rho = CS_F_(rho)->val; const cs_real_t *cvar_temp = CS_F_(t)->val; const cs_real_t *grav = cs_glob_physical_constants->gravity; const cs_real_t ro0 = cs_glob_fluid_properties->ro0; const cs_real_t cp0 = cs_glob_fluid_properties->cp0; const cs_real_t lambda0 = cs_glob_fluid_properties->lambda0; const cs_real_t viscl0 = cs_glob_fluid_properties->viscl0; /* Value of the imposed Rayleigh number */ const cs_real_t Ra = 1.e6; /* The givens of the problem */ const cs_real_t L = 1.0, T_hot = 303.15, T_cold = 293.15; const cs_real_t g = sqrt(cs_math_sq(grav[0]) + cs_math_sq(grav[1]) + cs_math_sq(grav[2])); const cs_real_t beta = lambda0 * viscl0 * Ra / (cs_math_sq(ro0) * cp0 * g * pow(L,3) * (T_hot - T_cold)); /* Compute density in all cells */ cs_real_t min_rho = 1.e15, max_rho = 0.; for (cs_lnum_t cell_id = 0; cell_id < n_cells; cell_id++) { const cs_real_t temp_cell = cvar_temp[cell_id]; cpro_rho[cell_id] = ro0 * (1. - beta * (temp_cell - T_cold)); min_rho = fmin(cpro_rho[cell_id], min_rho); max_rho = fmax(cpro_rho[cell_id], max_rho); } if (cs_glob_rank_id >= 0) { cs_parall_min(1, CS_REAL_TYPE, &min_rho); cs_parall_max(1, CS_REAL_TYPE, &max_rho); } bft_printf("min_rho %f max_rho %f\n", min_rho, max_rho); }
You should now be able to launch the calculation and get results
Results:
Check the PDF of the tutorial for more details!
https://www.code-saturne.org/cms/web/sites/default/files/07_HeatedSquareCavityFlow.pdf
The code and model is available here: https://github.com/CyprienRusu/Feaforall/tree/master/Code%20Saturne%20Tutorials/heated_cavity
Hope it helps! Let me know if you have questions!
Cyprien “Finally got that Simulation working after so long…” Rusu
Leave a Reply