Exemplo n.º 1
0
 def test_set_initial_distribution(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_WORLD)
     solver.SetModel(self.stoich_mat, tcoeff, propensity, dtcoeff,
                     dpropensity, dprop_sparsity)
     X0 = np.array([[0, 0]])
     p0 = np.array([1.0])
     s0 = np.array([0.0])
     solver.SetInitialDist(X0, p0, [s0] * 4)
Exemplo n.º 2
0
 def test_set_model(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_WORLD)
     solver.SetModel(num_parameters=4,
                     stoich_matrix=self.stoich_mat,
                     propensity_t=tcoeff,
                     propensity_x=propensity,
                     tv_reactions=list(range(4)),
                     d_propensity_t=dtcoeff,
                     d_propensity_t_sp=[[i] for i in range(4)],
                     d_propensity_x=None)
Exemplo n.º 3
0
 def test_set_initial_distribution(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_WORLD)
     solver.SetModel(num_parameters=4,
                     stoich_matrix=self.stoich_mat,
                     propensity_t=tcoeff,
                     propensity_x=propensity,
                     tv_reactions=list(range(4)),
                     d_propensity_t=dtcoeff,
                     d_propensity_t_sp=[[i] for i in range(4)],
                     d_propensity_x=None)
     X0 = np.array([[0, 0]])
     p0 = np.array([1.0])
     s0 = np.array([0.0])
     solver.SetInitialDist(X0, p0, [s0] * 4)
Exemplo n.º 4
0
 def test_solve_serial(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_SELF)
     solver.SetModel(self.stoich_mat, tcoeff, propensity, dtcoeff,
                     dpropensity, dprop_sparsity)
     solver.SetFspShape(simple_constr, init_bounds)
     X0 = np.array([[0, 0]])
     p0 = np.array([1.0])
     s0 = np.array([0.0])
     solver.SetInitialDist(X0, p0, [s0] * 4)
     solution = solver.Solve(10.0, 1.0e-4)
     prob = np.asarray(solution.GetProbViewer())
     self.assertAlmostEqual(prob.sum(), 1.0, 4)
     for i in range(0, 4):
         svec = np.asarray(solution.GetSensViewer(i))
         self.assertAlmostEqual(sum(svec), 0.0, 2)
         solution.RestoreSensViewer(i, svec)
Exemplo n.º 5
0
 def test_solve_serial(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_SELF)
     solver.SetModel(num_parameters=4,
                     stoich_matrix=self.stoich_mat,
                     propensity_t=tcoeff,
                     propensity_x=propensity,
                     tv_reactions=list(range(4)),
                     d_propensity_t=dtcoeff,
                     d_propensity_t_sp=[[i] for i in range(4)],
                     d_propensity_x=None)
     solver.SetFspShape(simple_constr, init_bounds)
     X0 = np.array([[0, 0]])
     p0 = np.array([1.0])
     s0 = np.array([0.0])
     solver.SetInitialDist(X0, p0, [s0] * 4)
     solution = solver.Solve(10.0, 1.0E-4)
     prob = np.asarray(solution.GetProbViewer())
     self.assertAlmostEqual(prob.sum(), 1.0, 4)
     for i in range(0, 4):
         svec = np.asarray(solution.GetSensViewer(i))
         self.assertAlmostEqual(sum(svec), 0.0, 2)
         solution.RestoreSensViewer(i, svec)
Exemplo n.º 6
0
 def test_set_shape(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_WORLD)
     solver.SetModel(self.stoich_mat, tcoeff, propensity, dtcoeff,
                     dpropensity)
     solver.SetFspShape(simple_constr, init_bounds)
Exemplo n.º 7
0
 def test_set_model(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_WORLD)
     solver.SetModel(self.stoich_mat, tcoeff, propensity, dtcoeff,
                     dpropensity, dprop_sparsity)
Exemplo n.º 8
0
 def test_serial_constructor(self):
     solver = sensfsp.SensFspSolverMultiSinks(mpi.COMM_SELF)
Exemplo n.º 9
0
for i in range(0, 4):
    dprop_sparsity[i][i] = 1

X0 = np.array([[0, 0]])
p0 = np.array([1.0])
s0 = np.array([0.0])

n_cells = 1000

t_meas = np.linspace(0, 10)
# %%

comm = mpi.COMM_WORLD
my_rank = comm.rank
# %%
my_solver = sensfsp.SensFspSolverMultiSinks(comm)
my_solver.SetModel(stoich_matrix, tcoeff, propensity, dtcoeff, dpropensity,
                   dprop_sparsity)
my_solver.SetFspShape(constr_fun=simple_constr, constr_bound=init_bounds)
my_solver.SetInitialDist(X0, p0, [s0] * 4)
my_solver.SetVerbosity(2)
solutions = my_solver.SolveTspan(t_meas, 1.0e-6)
# %%
# FIMs for observing both species
FIMatrices = []
for v in solutions:
    FIMatrices.append(v.ComputeFIM())

# %%
# FIMs for observing species 0
FIMatrices0 = []