tcfd_tests_neumann-c_v=0.1.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-c_v=0.1.py (2583B)
       ---
            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 orig = sphere.sim("neumann", fluid = True)
           14 cleanup(orig)
           15 orig.defaultParams(mu_s = 0.4, mu_d = 0.4)
           16 orig.defineWorldBoundaries([0.4, 0.4, 1], dx = 0.1)
           17 orig.initFluid(mu = 8.9e-4)
           18 #orig.initFluid(mu = 0.0)
           19 orig.initTemporal(total = 0.05, file_dt = 0.005, dt = 1.0e-4)
           20 orig.c_v[0] = 0.1
           21 #orig.c_phi[0] = 0.1
           22 py = sphere.sim(sid = orig.sid, fluid = True)
           23 orig.bc_bot[0] = 1      # No-flow BC at bottom (Neumann)
           24 #orig.run(dry=True)
           25 orig.run(verbose=False)
           26 #orig.run(device=2)
           27 #orig.writeVTKall()
           28 py.readlast(verbose = False)
           29 zeros = numpy.zeros((orig.num))
           30 py.readlast(verbose = False)
           31 compareNumpyArraysClose(zeros, py.p_f, "Conservation of pressure:",
           32         tolerance = 1.0e-5)
           33 
           34 # Fluid flow along z should be very small
           35 if ((numpy.abs(py.v_f[:,:,:,:]) < 1.0e-6).all()):
           36     print("Flow field:\t\t" + passed())
           37 else:
           38     print("Flow field:\t\t" + failed())
           39     print(numpy.min(py.v_f))
           40     print(numpy.mean(py.v_f))
           41     print(numpy.max(py.v_f))
           42     raise Exception("Failed")
           43 
           44 print('''# Neumann bottom, Dirichlet top BC.
           45 # Gravity, pressure gradients => transient flow''')
           46 orig = sphere.sim("neumann", fluid = True)
           47 orig.defaultParams(mu_s = 0.4, mu_d = 0.4)
           48 orig.defineWorldBoundaries([0.4, 0.4, 1], dx = 0.1)
           49 orig.initFluid(mu = 8.9e-4)
           50 #orig.initTemporal(total = 0.05, file_dt = 0.005, dt = 1.0e-4)
           51 #orig.initTemporal(total = 0.05, file_dt = 0.005, dt = 0.001)
           52 orig.initTemporal(total = 0.5, file_dt = 0.05, dt = 1.0e-4)
           53 py = sphere.sim(sid = orig.sid, fluid = True)
           54 orig.g[2] = -10.0
           55 orig.c_v[0] = 0.1
           56 orig.bc_bot[0] = 1      # No-flow BC at bottom (Neumann)
           57 #orig.run(dry=True)
           58 orig.run(verbose=False)
           59 #orig.run(device=2)
           60 #orig.writeVTKall()
           61 py.readlast(verbose = False)
           62 #ideal_grad_p_z = numpy.linspace(
           63 #        orig.p_f[0,0,0] + orig.L[2]*orig.rho_f*numpy.abs(orig.g[2]),
           64 #        orig.p_f[0,0,-1], orig.num[2])
           65 ideal_grad_p_z = numpy.linspace(
           66         orig.p_f[0,0,0] + (orig.L[2]-orig.L[2]/orig.num[2])*orig.rho_f*numpy.abs(orig.g[2]),
           67         orig.p_f[0,0,-1], orig.num[2])
           68 compareNumpyArraysClose(ideal_grad_p_z, py.p_f[0,0,:],
           69         "Pressure gradient:\t", tolerance=1.0)
           70 
           71 # Fluid flow along z should be very small
           72 if ((numpy.abs(py.v_f[:,:,:,2]) < 1.0e-4).all()):
           73     print("Flow field:\t\t" + passed())
           74 else:
           75     print("Flow field:\t\t" + failed())
           76     raise Exception("Failed")
           77 
           78 #orig.cleanup()