travking fluid particle

This commit is contained in:
zomseffen 2021-12-20 17:21:46 +01:00
parent 8a5de47da3
commit 54bda855e5
10 changed files with 702 additions and 37 deletions

View file

@ -0,0 +1,29 @@
from FluidSim.FluidSimulator import FluidSimulator2D
import numpy as np
def test_stand_still():
fs = FluidSimulator2D(50, 50)
fs.array.has_fluid[10, 10] = True
for i in range(100):
fs.timestep(0)
assert fs.array.has_fluid[10, 10], "Fluid not on the same spot anymore"
assert np.sum(fs.array.has_fluid * 1.0) == 1.0, "Fluid amount changed"
def test_move_positive_x():
fs = FluidSimulator2D(50, 50)
fs.array.has_fluid[10, 10] = True
fs.array.u_x[10, 10] = 1.0
fs.array.u_x[11, 10] = 1.0
# fs.array.u_x[9, 10] = -1.0
for i in range(10):
fs.timestep(0)
assert np.sum(fs.array.has_fluid * 1.0) == 1.0, "Fluid amount changed"
assert fs.array.has_fluid[0, 10], "Fluid not on the right border"

View file

@ -0,0 +1,22 @@
from FluidSim.StaggeredArray import StaggeredArray2D
def test_staggered_array_2D():
sa = StaggeredArray2D(10, 10)
for x in range(11):
for y in range(10):
sa.u_x[x, y] = y
for x in range(10):
for y in range(11):
sa.u_y[x, y] = x
ux, uy = sa.get_velocity_arrays()
for x in range(10):
for y in range(10):
ux2, uy2 = sa.get_velocity(x, y)
assert ux[x, y] == ux2, 'value output should be consistent!'
assert uy[x, y] == uy2, 'value output should be consistent!'