VoxelEngine/tests/test_FluidSimulator.py
2021-12-20 17:21:46 +01:00

29 lines
768 B
Python

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"