SPH for Newtonian fluids with wall boundaries and suspensions of spherical particles, implemented in CUDA.
Developed by Adolfo Vázquez-Quesada.
mail: a.vazquez-quesada@fisfun.uned.es
-
Host variables and functions are declared in class_system.h. Each function is defined in its own file, specifically in system_* files.
-
Device variables and functions are declared in kernel_functions.h. Each function is defined in its own file, specifically in kernel_* files.
-
In config.h we can define if the real variables are float or double.
-
main.cu is the main file of the code.
The compilation is done with the makefile file. To compile, just write the following command in the command line:
make
The file SPH_program will be created, which is the executable.
If you want to clean everthing before compiling again, just do
make clean
You need to have the following files in the same directory (with the exact names shown below):
- SPH_program: the executable.
- input: a file containing the program inputs.
To run the program, execute:
./SPH_program
N -> Number of particles in each direction (in a rectangular grid)
L -> Box length in each direction.
dim -> Number of dimensions
dt -> Time step
Nsteps -> Number of steps
overlap -> rcut / dx (where dx = L/N)
rho -> fluid density
c -> Speed of sound
P0 -> parameter of the equation of state
eta -> shear viscosity
zeta -> bulk viscosity
ext_force_type -> Type of external force:
0: No external force
1: Constant force
2: sine force
3: force to simulate inverse Poiseuille flow
ext_force -> External force vector
freq_micro -> Frequency to write micro file.
freq_macro -> Frequency to write macro file.
freq_walls -> Frequency to write walls file.
freq_colloids -> Frequency to write colloids file.
wall -> walls are normal to the y-direction.
0: no walls
1: walls
Vwall_bottom -> x-velocity of the bottom wall.
Vwall_top -> x-velocity of the top wall.
N_colloids -> Number of colloidal particles.
coll_R -> Colloids radius.
coll_rho -> Colloids density.
coll_move ->
0: colloids are moving.
1: colloids are not moving.
coll_x -> Position of one colloid. Put as many coll_x as needed.
coll_repulsion_cuton -> Cut-on of the repulsion force between colloids.
F0_repulsion -> Magnitude of the repulsion force.
tau_repulsion -> Tau parameter of the repulsion force (related to the cut-off radius of the repulsion force).
new_sim ->
0: new simulation.
1: existing simulation (the orientation of the magnetic field is not currently read in this option)
micro:
-- 2D --
1 -> Particle id
2 -> x
3 -> y
4 -> vel x
5 -> vel y
6 -> mass
7 -> density
8 -> pressure
9 -> type of particle
-- 3D --
1 -> Particle id
2 -> x
3 -> y
4 -> z
5 -> vel x
6 -> vel y
7 -> vel z
8 -> mass
9 -> density
10 -> pressure
11 -> type of particle
walls:
-- 2D --
1 -> Step
2 -> force x on bottom wall
3 -> force y on bottom wall
4 -> force x on top wall
5 -> force y on top wall
-- 3D --
1 -> Step
2 -> force x on bottom wall
3 -> force y on bottom wall
4 -> force z on bottom wall
5 -> force x on top wall
6 -> force y on top wall
7 -> force z on top wall
colloids:
-- 2D --
1 -> x
2 -> y
3 -> vel x
4 -> vel y
5 -> ang vel
6 -> force x
7 -> force y
8 -> torque
-- 3D --
1 -> x
2 -> y
3 -> z
4 -> vel x
5 -> vel y
6 -> vel z
7 -> ang vel x
8 -> ang vel y
9 -> ang vel z
10 -> force x
11 -> force y
12 -> force z
13 -> torque x
14 -> torque y
15 -> torque z
macro:
1 -> Step
2 -> Total kinetic energy
1.- Use the same input file of the initial simulation (or some variation of it).
2.- In the input file: new_sim 1
3.- If your simulation includes colloid particles, you must specify in the input file the positions of the colloids at the last timestep of the previous simulation. These can be obtained from the final colloids file.
4.- From the final micro file, create a file 'input_particles.in' with the following columns:
--- 2D --
1.- x
2.- y
3.- Vel x
4.- Vel y
5.- mass
6.- type of particle
--- 3D --
1.- x
2.- y
3.- z
4.- Vel x
5.- Vel y
6.- Vel z
7.- mass
8.- type of particle
5.- Run the simulation