def test_properties_dict(self): world = World() world.add(Fluid(Domain([16, 16])), physics=IncompressibleFlow()) world.add(Inflow(Sphere((8, 8), radius=4))) # world.add(ConstantDensity(box[0:2, 6:10], 1.0)) world.add(Fan(Sphere((10, 8), 5), [-1, 0])) struct.properties_dict(world.state)
def test_effects(self): world = World() fluid = world.add(Fluid(Domain([16, 16]))) fan = world.add(Fan(Sphere((10, 8), 5), [-1, 0])) obstacle = world.add(Obstacle(box[0:1, 0:1])) world.step(dt=1) world.step(dt=0.5) assert fluid.age == fan.age == obstacle.age == 1.5
def test_order(self): world = World() order = [] world.add( Inflow(box[0:0]), physics=CustomPhys('Inflow', order, [StateDependency('d', 'fan', blocking=True)])) world.add(Fan(box[0:0], 0), physics=CustomPhys('Fan', order, [])) world.step() numpy.testing.assert_equal(order, ['Fan', 'Inflow'])
def simulate(centers): world = World() fluid = world.add(Fluid(Domain([5, 4], boundaries=CLOSED, box=AABox(0, [40, 32])), buoyancy_factor=0.1, batch_size=centers.shape[0]), physics=IncompressibleFlow(pressure_solver=SparseCG(max_iterations=3))) world.add(Inflow(Sphere(center=centers, radius=3), rate=0.2)) world.add(Fan(Sphere(center=centers, radius=5), acceleration=[1.0, 0])) world.step(dt=1.5) world.step(dt=1.5) world.step(dt=1.5) print() return fluid.density.data[0, ...], fluid.velocity.unstack()[0].data[0, ...], fluid.velocity.unstack()[1].data[0, ...]
def test_cyclic_dependency(self): world = World() order = [] inflow = world.add(Inflow(box[0:0])) inflow.physics = CustomPhys( 'Inflow', order, [StateDependency('d', 'fan', blocking=True)]) fan = world.add(Fan(box[0:0], 0)) fan.physics = CustomPhys( 'Fan', order, [StateDependency('d', 'inflow', blocking=True)]) try: world.step() self.fail('Cycle not recognized.') except AssertionError: pass
def test_effects(self): world = World() world.add(Fluid(Domain([16, 16]))) world.add(Fan(Sphere((10, 8), 5), [-1, 0])) world.step() world.step()