tcfd_tests_neumann_darcy.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
---
tcfd_tests_neumann_darcy.py (1180B)
---
1 #!/usr/bin/env python
2 from pytestutils import *
3
4 import sphere
5 import sys
6 import numpy
7 import matplotlib.pyplot as plt
8
9 print('### CFD tests - Dirichlet/Neumann BCs ###')
10
11 print('''# Neumann bottom, Dirichlet top BC.
12 # No gravity, no pressure gradients => no flow''')
13
14 orig = sphere.sim("neumann", fluid = True)
15 cleanup(orig)
16 orig.defaultParams(mu_s = 0.4, mu_d = 0.4)
17 orig.defineWorldBoundaries([0.4, 0.4, 1], dx = 0.1)
18 orig.initFluid(cfd_solver = 1)
19 orig.initTemporal(total = 0.05, file_dt = 0.005, dt = 1.0e-4)
20 py = sphere.sim(sid = orig.sid, fluid = True)
21 orig.bc_bot[0] = 1 # No-flow BC at bottom (Neumann)
22 #orig.run(dry=True)
23 orig.run(verbose=False)
24 #orig.writeVTKall()
25 py.readlast(verbose = False)
26 zeros = numpy.zeros((orig.num))
27 py.readlast(verbose = False)
28 compareNumpyArraysClose(zeros, py.p_f, "Conservation of pressure:",
29 tolerance = 1.0e-5)
30
31 # Fluid flow along z should be very small
32 if ((numpy.abs(py.v_f[:,:,:,:]) < 1.0e-6).all()):
33 print("Flow field:\t\t" + passed())
34 else:
35 print("Flow field:\t\t" + failed())
36 print(numpy.min(py.v_f))
37 print(numpy.mean(py.v_f))
38 print(numpy.max(py.v_f))
39 raise Exception("Failed")
40
41 orig.cleanup()