def test_pumping_station_function(self): domain = self.create_domain(wallHeight=10., InitialOceanStage=4., InitialLandStage=0.) ps_function = pumping_station_function( domain=domain, pump_capacity=1.0, hw_to_start_pumping=0.0, hw_to_stop_pumping=-1.0, initial_pump_rate=0., pump_rate_of_increase = 1.0, pump_rate_of_decrease = 1.0, verbose=False) # Pump should be starting at zero assert(ps_function(1., 1.) == 0.) # As time increases, so will the pump rate domain.time = 0.5 assert(numpy.allclose(ps_function(1., 1.), 0.5)) assert(numpy.allclose(ps_function(1., 1.), 0.5)) domain.time = 0.75 assert(numpy.allclose(ps_function(1., 1.), 0.75)) # Pump rate maximum = 1.0 domain.time = 1.5 assert(numpy.allclose(ps_function(1., 1.), 1.0)) # Force the pump rate to zero, and it should start increasing as time # increases ps_function.pump_rate = 0. assert (ps_function(1., 1.) == 0.) domain.time = 1.75 assert (ps_function(1., 1.) == 0.25) domain.time = 2.5 assert (ps_function(1., 1.) == 1.0) # Can't increase any more domain.time = 3.0 assert (ps_function(1., 1.) == 1.0) # Let's try to decrease the pump assert (ps_function(-1.5, 1.) == 1.0) domain.time = 3.5 assert (ps_function(-1.5, 1.) == 0.5) domain.time = 3.9 assert (numpy.allclose(ps_function(-1.5, 1.), 0.1)) domain.time = 4.0 assert (numpy.allclose(ps_function(-1.5, 1.), 0.0)) domain.time = 5.0 assert (numpy.allclose(ps_function(-1.5, 1.), 0.0)) return
def setup_pumping_stations(domain, project): """ Extract pumping station data from project class and apply the internal boundary operator """ pumping_station_data = project.pumping_station_data for i in range(len(pumping_station_data)): # Extract pumping station parameters ps = pumping_station_data[i] label = ps[0] pump_capacity = ps[1] pump_rate_of_increase = ps[2] pump_rate_of_decrease = ps[3] hw_to_start_pumping = ps[4] hw_to_stop_pumping = ps[5] # Pumping station basin polygon + elevation are used elsewhere exchange_line_0 = su.read_polygon(ps[8]) exchange_line_1 = su.read_polygon(ps[9]) exchange_lines = [exchange_line_0, exchange_line_1] smoothing_timescale = ps[10] print 'Need to implement elevation data adjustments' # Function which computes Q pump_behaviour = pumping_station_function( domain=domain, pump_capacity=pump_capacity, hw_to_start_pumping=hw_to_start_pumping, hw_to_stop_pumping=hw_to_stop_pumping, initial_pump_rate=0., pump_rate_of_increase=pump_rate_of_increase, pump_rate_of_decrease=pump_rate_of_decrease ) # Add operator as side-effect of this operation pumping_station = Internal_boundary_operator( domain, pump_behaviour, exchange_lines=exchange_lines, enquiry_gap=0., apron = 0.0, smoothing_timescale=smoothing_timescale, compute_discharge_implicitly=False, logging=True, label=label, verbose=True) return
def test_pumping_station_function(self): domain = self.create_domain(wallHeight=10., InitialOceanStage=4., InitialLandStage=0.) ps_function = pumping_station_function(domain=domain, pump_capacity=1.0, hw_to_start_pumping=0.0, hw_to_stop_pumping=-1.0, initial_pump_rate=0., pump_rate_of_increase=1.0, pump_rate_of_decrease=1.0, verbose=False) # Pump should be starting at zero assert (ps_function(1., 1.) == 0.) # As time increases, so will the pump rate domain.time = 0.5 assert (numpy.allclose(ps_function(1., 1.), 0.5)) assert (numpy.allclose(ps_function(1., 1.), 0.5)) domain.time = 0.75 assert (numpy.allclose(ps_function(1., 1.), 0.75)) # Pump rate maximum = 1.0 domain.time = 1.5 assert (numpy.allclose(ps_function(1., 1.), 1.0)) # Force the pump rate to zero, and it should start increasing as time # increases ps_function.pump_rate = 0. assert (ps_function(1., 1.) == 0.) domain.time = 1.75 assert (ps_function(1., 1.) == 0.25) domain.time = 2.5 assert (ps_function(1., 1.) == 1.0) # Can't increase any more domain.time = 3.0 assert (ps_function(1., 1.) == 1.0) # Let's try to decrease the pump assert (ps_function(-1.5, 1.) == 1.0) domain.time = 3.5 assert (ps_function(-1.5, 1.) == 0.5) domain.time = 3.9 assert (numpy.allclose(ps_function(-1.5, 1.), 0.1)) domain.time = 4.0 assert (numpy.allclose(ps_function(-1.5, 1.), 0.0)) domain.time = 5.0 assert (numpy.allclose(ps_function(-1.5, 1.), 0.0)) return
def setup_pumping_stations(domain, project): """ Extract pumping station data from project class and apply the internal boundary operator """ pumping_station_data = project.pumping_station_data for i in range(len(pumping_station_data)): # Extract pumping station parameters ps = pumping_station_data[i] label = ps[0] pump_capacity = ps[1] pump_rate_of_increase = ps[2] pump_rate_of_decrease = ps[3] hw_to_start_pumping = ps[4] hw_to_stop_pumping = ps[5] # Pumping station basin polygon + elevation are used elsewhere exchange_line_0 = su.read_polygon(ps[8]) exchange_line_1 = su.read_polygon(ps[9]) exchange_lines = [exchange_line_0, exchange_line_1] smoothing_timescale = ps[10] print 'Need to implement elevation data adjustments' # Function which computes Q pump_behaviour = pumping_station_function( domain=domain, pump_capacity=pump_capacity, hw_to_start_pumping=hw_to_start_pumping, hw_to_stop_pumping=hw_to_stop_pumping, initial_pump_rate=0., pump_rate_of_increase=pump_rate_of_increase, pump_rate_of_decrease=pump_rate_of_decrease) # Add operator as side-effect of this operation pumping_station = Internal_boundary_operator( domain, pump_behaviour, exchange_lines=exchange_lines, enquiry_gap=0., apron=0.0, smoothing_timescale=smoothing_timescale, compute_discharge_implicitly=False, logging=True, label=label, verbose=True) return