Simulating a 3D Rayleigh-Bénard convection? #67
Unanswered
sidmishfpl1801
asked this question in
Q&A
Replies: 3 comments
-
|
Try this: https://youtu.be/CgeEg0mnIY8 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hi @qwerty740, there is a Rayleigh-Benard setup already present in the samples. I can try to better explain it with comments. in //#define BENCHMARKand uncomment #define VOLUME_FORCE
#define TEMPERATURE
#define INTERACTIVE_GRAPHICSHere is the more detailed setup: void main_setup() { // Rayleigh-Benard convection
// ######################################################### define simulation box size, viscosity and volume force ############################################################################
/*
// define simulation parameters in SI units
const float si_L = 1.0f; // length scale [m]
const float si_u = 1.0f; // some velocity [m/s]
const float si_nu = 1.48E-5f; // kinematic shear viscosity [m²/s]
const float si_rho = 0.997E3f; // density [kg/m³]
const float si_T_avg = 273.0f; // average temperature in Kelvin [K]
const float si_T_hot = 293.0f; // hot side temperature in Kelvin [K]
const float si_T_cold = 253.0f; // cold side temperature in Kelvin [K]
const float si_alpha = ...; // thermal diffusion coefficient [m²/s]
const float si_beta = ...; // thermal expansion coefficient [1/K]
// define 4 independent simulation parameters in LBM units
const float L = 256.0f; // length scale
const float u = 0.1f; // velocity
const float rho = 1.0f; // density (always has to be 1 in LBM units)
const float T_avg = 1.0f; // average temperature (always has to be 1 in LBM units)
const float w = (float)L/3.0f;
units.set_m_kg_s(L, u, rho, si_L, si_u, si_rho); // can be used to convert evertything except temperature
const float K = si_T/T; // Kelvin unit conversion factor
// convert remaining quantities to LBM units
const float nu = units.nu(si_nu); // kinematic shear viscosity
const float T_hot = si_T_hot/K;
const float T_cold = si_T_cold/K;
const float alpha = si_alpha*units.si_t(1.0f)/sq(units.si_x(1.0f));
const float beta = si_beta*K;
/**/
// next is the LBM constructor; here you set all simulation pparameters in LBM units
LBM lbm(/*resolution in x*/ 256u, /*resolution in y*/ 256u, /*resolution in z*/ 64u, /*kinematic shear viscosity (nu) in LBM units*/ 0.02f, /*volume force (gravity) in x*/ 0.0f, /*volume force in y*/ 0.0f, /*volume force in z*/ -0.001f, /*surface tension (unused here, leave at 0*/ 0.0f, /*thermal diffusion coefficient in LBM units*/ 1.0f, /*thermal expansion coefficient in LBM units*/ 1.0f);
// initialize geometry and boundaries in simulation box; the following loop iterates over the entire grid, and at each grid point (x, y, z)=n you can set density lbm.rho[n] (=1 if not set otherwise), velocity lbm.u.x[n] / lbm.u.y[n] / lbm.u.z[n] (=1 if not set otherwise) and temperature lbm.T[n] (=1 if not set otherwise)
// #############################################################################################################################################################################################
const ulong N=lbm.get_N(); const uint Nx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz(); for(ulong n=0ull; n<N; n++) { uint x=0u, y=0u, z=0u; lbm.coordinates(n, x, y, z);
// ########################################################################### define geometry #############################################################################################
lbm.u.x[n] = random_symmetric(0.015f); // initialize velocity field with some noise
lbm.u.y[n] = random_symmetric(0.015f);
lbm.u.z[n] = random_symmetric(0.015f);
if(z==1u) { // set temperature boundaries at bottom of simulation box
lbm.T[n] = 1.75f;
lbm.flags[n] = TYPE_T;
} else if(z==Nz-2u) { // set temperature boundaries at top of simulation box
lbm.T[n] = 0.25f;
lbm.flags[n] = TYPE_T;
}
if(z==0u||z==Nz-1u) lbm.flags[n] = TYPE_S; // very top and bottom need to be solid; lateral boundaries remain periodic
} // #########################################################################################################################################################################################
lbm.run(); // run simulation with interactive graphics mode, don't write any data to the hard drive
// alternatively: analyze simulation data
//lbm.run(0); // initialize simulation
//while(lbm.get_t()<10000u) {
// lbm.T.write_device_to_vtk(); // write temperature field to binary .vtk file in bin/export/T-000000000.vtk with the number automatically being set to the LBM time step
// //lbm.T.read_from_device(); // alternatively: look at only certain temperature values on the grid
// //println(to_string(lbm.T[lbm.index(x, y, z)])); // print temperature at coordinates (x, y, z) in console
// lbm.run(10u); // run some number of time steps
//}
} /**/Then compile and run, and press |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
checkout the paper for comparision: DOI 10.1140/epje/i2012-12058-1 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Can anyone please guide me how can one run simulations for Rayleigh Bernard convection.
like how to
3.Define the boundary conditions:
4.Choose simulation parameters: such as the fluid viscosity and thermal conductivity, the timestep size, and the number of iterations to run.
5.Set up the simulation in FluidX3D:
6.Analyze the simulation results:
Beta Was this translation helpful? Give feedback.
All reactions