def step_solver(self, mesh: Mesh, t_i_1: float, t_i: float, u_i_1: ndarray, u_i: ndarray): delta_i_1_i = (t_i - t_i_1) u_i_1_explicit = np.zeros(mesh.get_size()) self._operator[0].update_operator(t_i, mesh) self._operator[1].update_operator(t_i, mesh) self.modify_operators() self._operator[0].apply_boundary_condition( t_i_1=t_i_1, t_i=t_i, operator=self._operator[0], scheme_type=SchemeType.EXPLICIT) self._operator[1].apply_boundary_condition( t_i_1=t_i_1, t_i=t_i, operator=self._operator[1], scheme_type=SchemeType.IMPLICIT) np.copyto(u_i_1_explicit, self._operator[0].apply_explicit_operator(delta_i_1_i, u_i)) np.copyto( u_i_1, self._operator[1].apply_implicit_operator(delta_i_1_i, u_i_1_explicit)) self._operator[0].apply_boundary_condition_after_update( u_t=u_i_1, operator=self._operator[0]) self._operator[1].apply_boundary_condition_after_update( u_t=u_i_1, operator=self._operator[1])
def __init__(self, mesh_t: Mesh, mesh_x: Mesh, operators: List[LinearPDEOperator], scheme_type: SchemeType, bc_type: BoundaryConditionType, tc: TerminalCondition): self._operators = operators self._mesh_t = mesh_t self._mesh_x = mesh_x self._u_grid = np.zeros(shape=(mesh_x.get_size(), mesh_t.get_size())) if scheme_type == SchemeType.EXPLICIT: self._scheme = Schemes.ExplicitScheme(operators[0]) elif scheme_type == SchemeType.IMPLICIT: self._scheme = Schemes.ImplicitScheme(operators[0]) elif scheme_type == SchemeType.CRANK_NICOLSON: self._scheme = Schemes.ThetaScheme(operators, 0.5) else: raise ValueError("The operator type " + str(scheme_type)) self._bc = BoundaryCondition(bc_type) self._tc = tc
def __init__(self, mesh: Mesh, bc: BoundaryCondition): self._diagonal_upper = np.zeros(mesh.get_size() - 1) self._diagonal_lower = np.zeros(mesh.get_size() - 1) self._diagonal = np.zeros(mesh.get_size()) self._mesh = mesh self._bc = bc