Esempio n. 1
0
 def solve_odes_reinit(self):
     """
     Reinitialize the cvode solver to start again
     """
     self.initial_t = self.times[0]
     self.solver = sc_ode('cvode', self.f_conc1_odes,
                          max_steps=50000, lband=1, uband=1)
     self.solver.init_step(self.step_old_time, self.step_old_sol)
     self.solver_sp1 = sc_ode('cvode', self.f_conc1_odes_sp1,
                          max_steps=50000, lband=1, uband=1)
     self.solver_sp1.init_step(self.step_old_time_sp1, self.step_old_sol_sp1)
     self.solver_sp2 = sc_ode('cvode', self.f_conc1_odes_sp2,
                          max_steps=50000, lband=1, uband=1)
     self.solver_sp2.init_step(self.step_old_time_sp2, self.step_old_sol_sp2)
Esempio n. 2
0
    def solve_ode_init(self):
        """
        Initialize the ode solver
        """
        self.initial_t = self.times(0)
        self.step_old_time = self.initial_t
        # storage for solution
        self.solstoreind = 0
        if self.timesteps + 1 > MAX_STORE_LENGTH:
            self.solpart = np.empty((MAX_STORE_LENGTH, self.nr_cell), float)
        else:
            self.sol = np.empty((self.timesteps + 1, self.nr_cell), float)
            self.solpart = self.sol
        self.solpart[0, :] = self.init_conc[:]
        self.ret_y = np.empty(self.nr_cell, float)
        self.__tmp_flux_edge = np.zeros(self.nr_cell + 1, float)
        self.tstep = 0
        self.step_old_sol = self.solpart[0]

        self.solver = sc_ode(
            "cvode", self.f_conc_ode, min_step_size=1e-8, rtol=1e-6, atol=1e-6, max_steps=50000, lband=1, uband=1
        )
        print(self.step_old_time)
        self.solver.init_step(self.step_old_time, self.init_conc)
        self.initialized = True
Esempio n. 3
0
 def solve_ode_init(self):
     """
     Initialize the ode solver
     """
     self.initial_t = 0.
     self.step_old_time = self.initial_t
     n_cells = len(self.init_conc)
     self.ret_y = np.empty(n_cells, float)
     self.__tmp_flux_edge = np.empty(n_cells+1, float)
     self.tstep = 0
     self.step_old_sol = np.empty(n_cells, float)
     self.step_old_sol[:] = self.init_conc[:]
     
     self.solver = sc_ode('cvode', self.f_conc1_ode,
                          min_step_size=1e-9,
                          first_step_size=1e-16,
                          rtol=1e-6, atol=1e-10,
                          max_steps=50000, lband=1, uband=1)
     self.solver.init_step(self.step_old_time, self.init_conc)
     self.initialized = True