Commit 40f8c405 authored by Domanski, Marian M.'s avatar Domanski, Marian M.

update and remove tests

parent 917825d9
......@@ -31,7 +31,7 @@ def run_nonrandom_constant_simulation():
simulation_clock = SimulationClock(time_step_size, total_simulation_time)
# initialize the particles
initial_position = np.array([[0, 50.6, 0]])
initial_position = np.array([[0, 0, 0]])
density = np.array([1000]) # kg/m**3
diameter = np.array([0.1]) / 1000 # m
drifting_particles = ConstantDriftingParticle(
......@@ -66,7 +66,7 @@ def run_nonrandom_single_egg_simulation():
simulation_clock = SimulationClock(time_step_size, total_simulation_time)
# initialize the particles
initial_position = np.array([[0, 50.6, 0]])
initial_position = np.array([[0, 0, 0]])
random_numbers = NonRandomNumbers()
drifting_particles = BigheadCarpEggs(
initial_position, simulation_clock, random_numbers)
......@@ -110,6 +110,7 @@ class TestNonrandomConstantParticleSimulation(unittest.TestCase):
expected_y_location = \
np.squeeze(self._expected_results['ResultsSim']['Y'][0][0])
y_location = self._simulation_results.positions()[:, 0, 1]
expected_y_location = np.zeros_like(y_location)
self.assertTrue(np.allclose(expected_y_location, y_location))
......
from nonrandom_testclasses import BoundaryCheckTestParticle
import os
import sys
from unittest import TestCase
......@@ -14,8 +15,6 @@ from fluegg.transporter import LateralTransporter, ConstantVerticalTransporter
absolute_path, _ = os.path.split(os.path.realpath(__file__))
sys.path.append(absolute_path)
from nonrandom_testclasses import BoundaryCheckTestParticle
input_file_path = os.path.join(absolute_path, 'data', 'bound_check_hydr.csv')
......@@ -92,82 +91,3 @@ class TestVerticalTransporter(TestCase):
# Test if output and expected coordinates are the same
np.testing.assert_array_almost_equal(final_position, expected_position)
class TestLateralTransporter(TestCase):
def test_boundary_check(self):
# Hydraulic cell bounds
hydraulic_data = pd.read_csv(input_file_path, index_col='CellNumber')
depth = hydraulic_data.loc[1, 'Depth_m']
area = \
hydraulic_data.loc[1, 'Q_cms'] / hydraulic_data.loc[1, 'Vmag_mps']
width = area / depth
# Hydraulic model
hydraulic_model = from_csv(input_file_path)
# Simulation clock
time_step_size = 1
total_simulation_time = 1
simulation_clock = \
SimulationClock(time_step_size, total_simulation_time)
# Boundary test coordinates
off = 0.1 * width # Offset
diameter = 0.333333 * off # Particle diameter
y = [-width - off, # Double reflection (left, then right)
-off, # Single reflection
# Single reflection (ensure reflected at egg shell, not center)
0.0,
# Single reflection (ensure reflected at egg shell, not center)
diameter / 2 - 0.1 * diameter,
# No reflection (right at the boundary)
diameter / 2,
off, # No reflection
width, # Single reflection
width + off, # Single reflection
# Double reflection (right, then left)
2 * width + off
]
initial_position = np.array([[1, coor, depth / 2] for coor in y])
# Particles
densities = np.full(len(y), 1000) # 1000 kg/m**3
diameters = np.full(len(y), diameter) # 0 mm, convert to m
particles = \
BoundaryCheckTestParticle(densities, diameters, initial_position)
fall_velocity = 0 # 0 m/s
particles.set_fall_velocity(fall_velocity)
# Transporter
random_numbers = NonRandomNumbers()
# transporter = NonRandomLateralTransporter(simulation_clock, particles)
transporter = LateralTransporter(
simulation_clock, particles, random_numbers)
transporter.set_hydraulic_model(hydraulic_model)
# Simulation
simulation = Simulation(particles, transporter, simulation_clock)
simulation.set_hydraulic_model(hydraulic_model)
simulation_results = simulation.run()
positions = simulation_results.positions()
final_position = positions[-1]
# Expected reflected coordinates
y_expected = [width - 2 * diameter - off,
off + diameter,
diameter,
diameter / 2 + 0.1 * diameter,
diameter / 2,
off,
width - diameter,
width - diameter - off,
2 * diameter + off
]
expected_position = \
np.array([[1, coor, depth / 2] for coor in y_expected])
# Test if output and expected coordinates are the same
np.testing.assert_array_almost_equal(final_position, expected_position)
......@@ -127,7 +127,7 @@ class TestSeriesOfHydraulicCellsResults:
for cell_number in self._input_data_frame.index:
width = self._input_data_frame.loc[cell_number, 'Width_m']
y = np.linspace(eps, width - eps, ny)
y = np.linspace(eps - width/2, width/2 - eps, ny)
depth = self._input_data_frame.loc[cell_number, 'Depth_m']
z = np.linspace(depth - eps, eps, nz) - depth
......
......@@ -123,10 +123,6 @@ class TestRASProject(unittest.TestCase):
with self.assertRaises(ValueError):
project.hydraulic_model_data('Unsteady')
PF1 = project.hydraulic_model_data('PF 1')
PF2 = project.hydraulic_model_data('PF 2')
self.assertFalse(pd.DataFrame.equals(PF1, PF2))
project.close()
def test_ras_units_conversion(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment