aboutsummaryrefslogtreecommitdiff
path: root/ldc_2d.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-06-22 19:59:36 +0200
committerAdrian Kummerlaender2019-06-22 19:59:36 +0200
commite096aca2a38141ff0f3e78f3ebadd7a58760f7a6 (patch)
treef503e577d8bfd2df0ad832d2140b8bb41472e970 /ldc_2d.py
parent4df2d7678755c652f7af3d579a812dfc091a00e6 (diff)
downloadsymlbm_playground-e096aca2a38141ff0f3e78f3ebadd7a58760f7a6.tar
symlbm_playground-e096aca2a38141ff0f3e78f3ebadd7a58760f7a6.tar.gz
symlbm_playground-e096aca2a38141ff0f3e78f3ebadd7a58760f7a6.tar.bz2
symlbm_playground-e096aca2a38141ff0f3e78f3ebadd7a58760f7a6.tar.lz
symlbm_playground-e096aca2a38141ff0f3e78f3ebadd7a58760f7a6.tar.xz
symlbm_playground-e096aca2a38141ff0f3e78f3ebadd7a58760f7a6.tar.zst
symlbm_playground-e096aca2a38141ff0f3e78f3ebadd7a58760f7a6.zip
Add interactive 2D LDC notebook, fix material initialization
Diffstat (limited to 'ldc_2d.py')
-rw-r--r--ldc_2d.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/ldc_2d.py b/ldc_2d.py
index 40edf89..8268e10 100644
--- a/ldc_2d.py
+++ b/ldc_2d.py
@@ -1,15 +1,19 @@
import numpy
import time
+from string import Template
import matplotlib
-import matplotlib.pyplot as plt
matplotlib.use('AGG')
+import matplotlib.pyplot as plt
from simulation import Lattice, Geometry
from symbolic.generator import LBM
import symbolic.D2Q9 as D2Q9
+lid_speed = 0.1
+relaxation_time = 0.52
+
def MLUPS(cells, steps, time):
return cells * steps / time * 1e-6
@@ -33,16 +37,18 @@ def cavity(geometry, x, y):
else:
return 1
-boundary = """
+boundary = Template("""
if ( m == 2 ) {
u_0 = 0.0;
u_1 = 0.0;
}
if ( m == 3 ) {
- u_0 = 0.1;
+ u_0 = $lid_speed;
u_1 = 0.0;
}
-"""
+""").substitute({
+ 'lid_speed': lid_speed
+})
nUpdates = 100000
nStat = 5000
@@ -58,7 +64,7 @@ lattice = Lattice(
geometry = Geometry(256, 256),
moments = lbm.moments(optimize = False),
- collide = lbm.bgk(f_eq = lbm.equilibrium(), tau = 0.52),
+ collide = lbm.bgk(f_eq = lbm.equilibrium(), tau = relaxation_time),
boundary_src = boundary)