-
Notifications
You must be signed in to change notification settings - Fork 1
/
poisseuille.py
70 lines (47 loc) · 1.72 KB
/
poisseuille.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from __future__ import print_function
import espressomd
from espressomd import shapes
from espressomd import lb
from espressomd import lbboundaries
import numpy as np
import argparse
print( " " )
print( "===================================================" )
print( "= Lattice-Boltzmann Fluid =" )
print( "===================================================" )
print( " " )
print( "Program Information: \n" )
print( espressomd.code_info.features() )
system = espressomd.System()
system.time_step = 0.01
system.cell_system.skin = 0.2
box_l = 32
system.box_l = [box_l, box_l, box_l]
# the force density on the fluid nodes
force_density=0.001
lbf = lb.LBFluid_GPU(agrid=1, dens=1, visc=1, tau=0.01, ext_force=[force_density, 0, 0])
system.actors.add(lbf)
system.thermostat.set_lb(kT=0)
# create the boundary "shape"
upper_wall=shapes.Wall(normal=[0,1,0], dist=1.5)
lower_wall=shapes.Wall(normal=[0,-1,0], dist=-(box_l-1.5))
# from these shapes, define the LB boundary
upper_bound=lbboundaries.LBBoundary(shape=upper_wall)
lower_bound=lbboundaries.LBBoundary(shape=lower_wall)
system.lbboundaries.add(upper_bound)
system.lbboundaries.add(lower_bound)
# save the center x-velocity in this file
center_output = open("center_velocity.dat", "w")
max_time=1000
for i in range(max_time):
system.integrator.run(500)
print("Running simulation, step: {}/{}\r".format(i,max_time))
vx=(lbf[box_l/2, box_l/2, box_l/2].velocity[0])
center_output.write("{}\n".format(vx))
# save the x-velocity of a "line" of fluid
profile_output = open("profile_velocity.dat", "w")
for i in range(box_l):
vx=(lbf[0, i, 0].velocity[0])
profile_output.write("{} \t {}\n".format(i,vx))
center_output.close()
profile_output.close()