-
Notifications
You must be signed in to change notification settings - Fork 44
LBPM Tutorial, Step 6. Simulating 2 phase flow
In this step of the LBPM tutorial we provide an overview of the approach to simulate two-fluid flow using a color lattice Boltzmann model. An overview of the color model implemented within LBPM is available from McClure et al.. Note that while the model formulation is the same, the implementation details used within LBPM have changed considerably since the time of publication. This is due to more recent performance optimizations, particularly to achieve the highest possible performance based on the evolution of GPU architectures and the vastly diminished relative performance for CPU cores. Simulations of 2-phase flow are performed using lbpm_color_simulator
To set parameters for a two-phase flow with the color model, we add a Color section to input.db.
Color {
tauA = 0.7; // relaxation time for fluid A (labeled as "1")
tauB = 0.7; // relaxation time for fluid B (labeled as "2")
rhoA = 1.0; // density for fluid A (in lattice units)
rhoB = 1.0; // density for fluid B (in lattice units)
alpha = 1e-3; // controls the surface tension
beta = 0.95; // controls the interface width
F = 0, 0, 0 // controls the external force
Restart = false // initialize simulation from restart file?
timestepMax = 10000 // maximum number of timesteps to perform before exit
ComponentLabels = 0 // number of immobile component labels in the input image
ComponentAffinity = -1.0 // wetting condition for each immobile component
}
These set the essential parameters for the color model, which govern the fluid viscosities, densities and interfacial tension. If you choose not to set these parameters yourself, LBPM will set them for you by trying to make reasonable guesses. If you want to run interesting simulations, you should plan to set the input parameters yourself. Some general guidance follows:
- the relaxation times
tauAandtauBshould be between0.7and1.5 - the fluid densities
rhoAandrhoBshould be between0.01and1.0 - the interfacial tension parameter
alphashould be less than5.0e-3 - the interfacial width parameter
betashould be less than1.0 - the magnitude of the external force vector
Fshould be less than1.0e-3and greater than1.0e-7
It is quite possible that you will obtain reasonable results simulating slightly outside of the suggested range. However, it is also possible that the method could become unstable and generate nan. If you want to push the boundaries, be sure to monitor your simulation to make sure it has not failed.
The ComponentLabels and ComponentAffinity fields should be comma separated lists of equal length. There is a one-to-one mapping between the two lists. In this case there is only one immobile (i.e. "solid") label in the input image. Setting ComponentAffinity = -1.0 will make fluid component B the wetting fluid. ComponentAffinity
can be assigned any value between -1.0 and 1.0. Based on ComponentLabels = 0, all voxels labeled as 0 will be assigned a wetting value of -1.0 during the simulation.
Monitoring simulation results is best achieved by relying on internal in situ analysis capabilities supported by LBPM. In addition to setting physical parameters in the Color section of the input file, lbpm_color_simulator relies on an Analysis database structure. A fairly minimal choice is as follows
Analysis {
analysis_interval = 1000 // Frequency to perform analysis
visualization_interval = 100000 // Frequency to write visualization data
restart_interval = 1000000 // Frequency to write restart data
restart_file = "Restart" // Filename to use for restart file (will append rank)
N_threads = 4 // Number of threads to use for analysis
load_balance = "independent" // Load balance method to use: "none", "default", "independent"
}
In this case there are essentially three key parameters that a user might potentially want to change. These are
-
analysis_intervaldetermines the timestep interval to simulate before re-analyzing the simulation state -
visualization_intervaldetermines the timestep interval to simulate before writing visualization data -
restart_intervaldetermines how often to write LBM distributions to a checkpoint file so that the simulation can be restarted.
Visualization options are provided based on an associated section within the input file
Visualization {
write_silo = true // write SILO databases with assigned variables
save_8bit_raw = true // write labeled 8-bit binary files with phase assignments
save_phase_field = true // save phase field within SILO database
save_pressure = false // save pressure field within SILO database
save_velocity = false // save velocity field within SILO database
}
More detailed information on these capabilities will be covered in subsequent parts of the tutorial.
There are a variety of ways to run lbpm_color_simulator
- periodic boundary condition with external forcing
- pressure boundary condition with constant values
- pressure boundary condition that varies linearly in time
- boundary condition with constant volumetric flux
Before we run the Color simulation, we first discuss ways to establish initial conditions.