- Timestamp:
- Feb 13, 2015, 4:58:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/anuga/structures/internal_boundary_functions.py
r9657 r9673 401 401 """ 402 402 403 def __init__(self, pump_capacity, hw_to_start_pumping, verbose=True): 404 """ 405 @param pump_capacity m^3/s 406 407 """ 403 def __init__(self, domain, pump_capacity, hw_to_start_pumping, hw_to_stop_pumping, 404 initial_pump_rate=0., pump_rate_of_increase = 1.0e+100, 405 pump_rate_of_decrease = 1.0e+100, verbose=True): 406 """ 407 @param domain ANUGA domain 408 @param pump_capacity (m^3/s) 409 @param hw_to_start_pumping Turn pumps on if hw exceeds this (m) 410 @param hw_to_stop_pumping Turn pumps off if hw below this (m) 411 @param initial_pump_rate rate of pumps at start of simulation (m^3/s) 412 @param pump_rate_of_increase Accelleration of pump rate when turning on (m^3/s/s) 413 @param pump_rate_of_decrease Decelleration of pump rate when turning off (m^3/s/s) 414 @param verbose 415 """ 416 408 417 self.pump_capacity = pump_capacity 409 418 self.hw_to_start_pumping = hw_to_start_pumping 419 self.hw_to_stop_pumping = hw_to_stop_pumping 420 421 self.pump_rate_of_increase = pump_rate_of_increase 422 self.pump_rate_of_decrease = pump_rate_of_decrease 423 424 self.domain=domain 425 self.last_time_called = domain.get_time() 426 self.time = domain.get_time() 427 428 if hw_to_start_pumping < hw_to_stop_pumping: 429 raise Exception('hw_to_start_pumping should be >= hw_to_stop_pumping') 430 431 if initial_pump_rate > pump_capacity: 432 raise Exception('Initial pump rate is > pump capacity') 433 434 if ((self.pump_rate_of_increase < 0.) | (self.pump_rate_of_decrease < 0.)): 435 raise Exception('Pump rates of increase / decrease MUST be non-negative') 436 437 if ( (pump_capacity < 0.) | (initial_pump_rate < 0.) ): 438 raise Exception('Pump rates cannot be negative') 439 440 self.pump_rate = initial_pump_rate 410 441 411 442 if verbose: … … 419 450 def __call__(self, hw_in, tw_in): 420 451 """ 421 @param hw_in The stage (or energy) at the headwater site 422 @param tw_in The stage (or energy) at the tailwater site 423 """ 424 425 if(hw_in > self.hw_to_start_pumping): 426 Q = self.pump_capacity 452 @param hw_in The stage (or energy) at the headwater site (m) 453 @param tw_in The stage (or energy) at the tailwater site (m) 454 """ 455 456 # Compute the time since last called, so we can increase / decrease the pump rate if needed 457 self.time = self.domain.get_time() 458 if self.time > self.last_time_called: 459 dt = self.time - self.last_time_called 460 self.last_time_called = self.time 427 461 else: 428 Q = 0. 429 430 return Q 431 462 dt = 0. 463 if self.time != self.last_time_called: 464 print self.time 465 print self.last_time_called 466 print self.time - self.last_time_called 467 raise Exception('Impossible timestepping, ask Gareth') 468 469 # Increase / decrease the pump rate if needed 470 if hw_in < self.hw_to_stop_pumping: 471 self.pump_rate = max(0., self.pump_rate - dt*self.pump_rate_of_decrease) 472 elif hw_in > self.hw_to_start_pumping: 473 self.pump_rate = min(self.pump_capacity, self.pump_rate + dt*self.pump_rate_of_increase) 474 475 return self.pump_rate 476
Note: See TracChangeset
for help on using the changeset viewer.