Skip to content

Commit

Permalink
added 'acc_external_output_vector_2' to DMR
Browse files Browse the repository at this point in the history
  • Loading branch information
goujou committed Aug 9, 2021
1 parent b1a9492 commit 888173a
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/CompartmentalSystems/discrete_model_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ def from_Bs_and_net_Us(cls, start_values, times, Bs, net_Us):
return cls(times, Bs, xs)

@classmethod
def from_Bs_and_net_Us_2(cls, start_values, times, Bs, net_Us):
def from_Bs_and_Us_2(cls, start_values, times, Bs, Us):
"""
Bs State transition operators for one time step
"""
xs = cls._solve_2(start_values, Bs, net_Us)
return cls(times, Bs, xs)
xs = cls._solve_2(start_values, Bs, Us)
dmr = cls(times, Bs, xs)
dmr.Us = Us

return dmr

@classmethod
def from_fluxes(cls, start_values, times, net_Us, net_Fs, net_Rs):
Expand All @@ -96,18 +99,18 @@ def from_fluxes(cls, start_values, times, net_Us, net_Fs, net_Rs):
)

@classmethod
def from_fluxes_2(cls, start_values, times, net_Us, net_Fs, net_Rs):
def from_fluxes_2(cls, start_values, times, Us, Fs, Rs):
Bs = cls.reconstruct_Bs_without_xs_2(
start_values,
net_Us,
net_Fs,
net_Rs
Us,
Fs,
Rs
)
return cls.from_Bs_and_net_Us_2(
return cls.from_Bs_and_Us_2(
start_values,
times,
Bs,
net_Us
Us
)

@classmethod
Expand Down Expand Up @@ -345,6 +348,14 @@ def acc_external_output_vector(self):

return r

def acc_external_output_vector_2(self):
n = self.nr_pools
rho = np.array([1-B.sum(0).reshape((n,)) for B in self.Bs])
soln = self.solve()
r = rho * (soln[:-1] + self.Us)

return r

def acc_internal_flux_matrix(self):
# fixme mm 20-04-2020:
# potential gain by use of sparse matrices
Expand Down

0 comments on commit 888173a

Please sign in to comment.