Adapting zero removal rate case to case when RR is an array
This commit is contained in:
parent
c8f2b32fef
commit
9712ffc8ae
1 changed files with 18 additions and 6 deletions
|
|
@ -1055,8 +1055,15 @@ class _ConcentrationModelBase:
|
|||
"""
|
||||
V = self.room.volume
|
||||
RR = self.removal_rate(time)
|
||||
|
||||
return (self.population.people_present(time) / (RR * V) +
|
||||
|
||||
if isinstance(RR, np.ndarray):
|
||||
invRR = np.empty(RR.shape, dtype=np.float64)
|
||||
invRR[RR == 0.] = np.nan
|
||||
invRR[RR != 0.] = 1. / RR[RR != 0.]
|
||||
else:
|
||||
invRR = np.nan if RR == 0. else 1. / RR
|
||||
|
||||
return (self.population.people_present(time) * invRR / V +
|
||||
self.min_background_concentration()/self.normalization_factor())
|
||||
|
||||
@method_cache
|
||||
|
|
@ -1139,11 +1146,16 @@ class _ConcentrationModelBase:
|
|||
delta_time = time - t_last_state_change
|
||||
|
||||
fac = np.exp(-RR * delta_time)
|
||||
|
||||
if isinstance(RR, float) and RR == 0:
|
||||
curr_conc_state = delta_time * self.population.people_present(time) / self.room.volume
|
||||
if isinstance(RR, np.ndarray):
|
||||
curr_conc_state = np.empty(RR.shape, dtype=np.float64)
|
||||
curr_conc_state[RR == 0.] = delta_time * self.population.people_present(time) / (
|
||||
self.room.volume[RR == 0.] if isinstance(self.room.volume,np.ndarray) else self.room.volume)
|
||||
curr_conc_state[RR != 0.] = self._normed_concentration_limit(next_state_change_time)[RR != 0.] * (1 - fac[RR != 0.])
|
||||
else:
|
||||
curr_conc_state = self._normed_concentration_limit(next_state_change_time) * (1 - fac)
|
||||
if RR == 0.:
|
||||
curr_conc_state = delta_time * self.population.people_present(time) / self.room.volume
|
||||
else:
|
||||
curr_conc_state = self._normed_concentration_limit(next_state_change_time) * (1 - fac)
|
||||
|
||||
return curr_conc_state + conc_at_last_state_change * fac
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue