tfluid_particle_interaction.py - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tfluid_particle_interaction.py (2532B)
---
1 #!/usr/bin/env python
2 import sphere
3 from pytestutils import *
4
5 sim = sphere.sim('fluid_particle_interaction', fluid=True)
6 sim.cleanup()
7
8 sim.defineWorldBoundaries([1.0, 1.0, 1.0], dx = 0.1)
9 sim.initFluid()
10 sim.rho[0] = 1000.0 # particle density = fluid density
11 sim.setDEMstepsPerCFDstep(100)
12
13
14 # No gravity, pressure gradient enforced by Dirichlet boundaries.
15 # The particle should be sucked towards the low pressure
16 print('# Test 1: Test pressure gradient force')
17 sim.p_f[:,:,0] = 10.0
18 sim.p_f[:,:,-1] = 1.0
19 sim.addParticle([0.5, 0.5, 0.5], 0.05)
20 sim.initTemporal(total=0.01, file_dt=0.001)
21
22 sim.run(verbose=False)
23 #sim.run(dry=True)
24 #sim.run(cudamemcheck=True)
25 #sim.writeVTKall()
26
27 sim.readlast()
28 test(sim.vel[0,2] > 0.0, 'Particle velocity:')
29
30
31
32 # Sidewards gravity, homogenous pressure, Neumann boundaries.
33 # Fluid should flow towards +x and drag particles in the same direction
34 print('# Test 2: Test fluid drag force')
35 sim.initFluid()
36 sim.zeroKinematics()
37 sim.g[0] = 10.0
38
39 sim.deleteParticle(0)
40 sim.addParticle([0.5, 0.5, 0.75], 0.05)
41 sim.addParticle([0.5, 0.5, 0.50], 0.05)
42 sim.addParticle([0.5, 0.5, 0.25], 0.05)
43
44 sim.initTemporal(total=0.0001, file_dt=0.00001)
45
46 sim.run(verbose=False)
47 #sim.writeVTKall()
48
49 sim.readlast()
50 test((sim.v_f[:,:,:,0] > 0.0).all(), 'Fluid velocity:')
51 test(sim.vel[0,0] > 0.0, 'Particle 0 velocity:')
52 test(sim.vel[1,0] > 0.0, 'Particle 1 velocity:')
53 test(sim.vel[2,0] > 0.0, 'Particle 2 velocity:')
54
55
56 '''
57 print('# Test 3: Test pressure gradient force, c = 0.1')
58 sim.p_f[:,:,0] = 10.0
59 sim.p_f[:,:,-1] = 1.0
60 sim.addParticle([0.5, 0.5, 0.5], 0.05)
61 sim.initTemporal(total=0.01, file_dt=0.001)
62 sim.c_grad_p[0] = 0.1
63
64 sim.run(verbose=False)
65 #sim.run(dry=True)
66 #sim.run(cudamemcheck=True)
67 #sim.writeVTKall()
68
69 sim.readlast()
70 test(sim.vel[0,2] > 0.0, 'Particle velocity:')
71
72
73
74 # Sidewards gravity, homogenous pressure, Neumann boundaries.
75 # Fluid should flow towards +x and drag particles in the same direction
76 print('# Test 4: Test fluid drag force, c = 0.1')
77 sim.initFluid()
78 sim.zeroKinematics()
79 sim.g[0] = 10.0
80 sim.c_grad_p[0] = 0.1
81
82 sim.deleteParticle(0)
83 sim.addParticle([0.5, 0.5, 0.75], 0.05)
84 sim.addParticle([0.5, 0.5, 0.50], 0.05)
85 sim.addParticle([0.5, 0.5, 0.25], 0.05)
86
87 sim.initTemporal(total=0.0001, file_dt=0.00001)
88
89 sim.run(verbose=False)
90 #sim.writeVTKall()
91
92 sim.readlast()
93 test((sim.v_f[:,:,:,0] > 0.0).all(), 'Fluid velocity:')
94 test(sim.vel[0,0] > 0.0, 'Particle 0 velocity:')
95 test(sim.vel[1,0] > 0.0, 'Particle 1 velocity:')
96 test(sim.vel[2,0] > 0.0, 'Particle 2 velocity:')
97 '''
98
99 sim.cleanup()