def initialize_for_solve(self): self.func_wrappers() self.set_tol() # Flags to indicate whether jac and mas are provided self.ijac = int(hasattr(self, 'jac_f77_radau5')) self.imas = int(hasattr(self, 'mas_f77')) self.set_dummy_functions() ljac = self.neq if ((not hasattr(self, 'ml')) or \ (self.ml == self.neq)) else (self.ml + self.mu + 1) lmas = 0 if not self.imas else (self.neq \ if ((not hasattr(self, 'mlmas')) or (self.mlmas == self.neq)) \ else (self.mlmas + self.mumas + 1)) le = self.neq if ((not hasattr(self, 'ml')) or \ (self.ml == self.neq)) else (2*self.ml + self.mu + 1) self.lwork = self.neq * (ljac + lmas + 3 * le + 12) + 20 self.liwork = 3 * self.neq + 20 # Arrays to specify how the problem is to be solved. self.iwork = np.zeros(self.liwork, int) self.work = np.zeros(self.lwork, float) self.iwork[1] = getattr(self, 'nsteps', 0) self.work[1] = getattr(self, 'safety') self.work[6] = getattr(self, 'max_step', 0.) Solver.initialize_for_solve(self) # Common settings
def initialize_for_solve(self): self.func_wrappers() self.set_tol() # Flags to indicate whether jac and mas are provided self.ijac = int(hasattr(self, 'jac_f77_radau5')) self.imas = int(hasattr(self, 'mas_f77')) self.set_dummy_functions() ljac = self.neq if ((not hasattr(self, 'ml')) or \ (self.ml == self.neq)) else (self.ml + self.mu + 1) lmas = 0 if not self.imas else (self.neq \ if ((not hasattr(self, 'mlmas')) or (self.mlmas == self.neq)) \ else (self.mlmas + self.mumas + 1)) le = self.neq if ((not hasattr(self, 'ml')) or \ (self.ml == self.neq)) else (2*self.ml + self.mu + 1) self.lwork = self.neq*(ljac + lmas + 3*le + 12) + 20 self.liwork = 3*self.neq + 20 # Arrays to specify how the problem is to be solved. self.iwork = np.zeros(self.liwork, int) self.work = np.zeros(self.lwork, float) self.iwork[1] = getattr(self, 'nsteps', 0) self.work[1] = getattr(self, 'safety') self.work[6] = getattr(self, 'max_step', 0.) Solver.initialize_for_solve(self) # Common settings
def validate_data(self): # lower- & upper-bound for banded Jacobian in range [0, neq] for name in ('ml', 'mu', 'mlmas', 'mumas'): if hasattr(self, name): self._parameters[name]['range'] = (0, self.neq+1) has_banded_jac = hasattr(self, 'jac_banded') ml, mu = getattr(self, 'ml', None), getattr(self, 'mu', None) if has_banded_jac and ((ml is None) or (mu is None)): raise ValueError('"ml" and "mu" have to be provided when banded Jacobian matrix is involved! Your input is (%s, %s).' % (ml, mu)) return Solver.validate_data(self)
def validate_data(self): # lower- & upper-bound for banded Jacobian in range [0, neq] for name in ('ml', 'mu', 'mlmas', 'mumas'): if hasattr(self, name): self._parameters[name]['range'] = (0, self.neq + 1) has_banded_jac = hasattr(self, 'jac_banded') ml, mu = getattr(self, 'ml', None), getattr(self, 'mu', None) if has_banded_jac and ((ml is None) or (mu is None)): raise ValueError( '"ml" and "mu" have to be provided when banded Jacobian matrix is involved! Your input is (%s, %s).' % (ml, mu)) return Solver.validate_data(self)