def example_2(c, xc, tc): """ example #2: r = 0.83333 (example 10.3, table 10.4) :param c: coefficient :param xc: count of point on Ox axis :param tc: count of point on time axis """ Solve.solve_exercise(lambda: ExplicitScheme.solve( lambda x: 4 * x - 4 * x ** 2, 0, 0, 1, 0.33333, c, xc, tc ), plot_projection_res=True, print_res=True, ain=100)
def example(c, xc, tc): """ example #1: (example 10.4, table 10.5) :param c: coefficient :param xc: count of point on Ox axis :param tc: count of point on time axis """ Solve.solve_exercise(lambda: ExplicitScheme.solve( lambda x: math.sin(math.pi * x) + math.sin(3 * math.pi * x), 0, 0, 1, 0.1, c, xc, tc ), plot_projection_res=True, print_res=True, ain=100)
def ex2(h, tol, max_steps): """ example #2: (example 10.6, table 10.7) :param h: step :param tol: maximum delta :param max_steps: max count of steps """ Solve.solve_exercise(lambda: Dirichlel.solve_diff( lambda x, u, i, j: u[i, j + 1], lambda x: 180, lambda x: 80, lambda x: 0, 4, 4, h, tol, max_steps ), plot_projection_res=True, ain=15, print_res=True)
def ex1(h, tol, max_steps): """ example #1: (example 10.5, table 10.6) :param h: step :param tol: maximum delta :param max_steps: max count of steps """ Solve.solve_exercise(lambda: Dirichlel.solve( lambda x: 20, lambda x: 180, lambda x: 80, lambda x: 0, 4, 4, h, tol, max_steps ), plot_projection_res=True, ain=15, print_res=True)
def ex2(h, tol, max_steps): """ example #2: (example 10.6, table 10.7) :param h: step :param tol: maximum delta :param max_steps: max count of steps """ Solve.solve_exercise(lambda: Dirichlel.solve_diff( lambda x, u, i, j: u[i, j + 1], lambda x: 180, lambda x: 80, lambda x: 0, 4, 4, h, tol, max_steps), plot_projection_res=True, ain=15, print_res=True)
def ex1(h, tol, max_steps): """ example #1: (example 10.5, table 10.6) :param h: step :param tol: maximum delta :param max_steps: max count of steps """ Solve.solve_exercise( lambda: Dirichlel.solve(lambda x: 20, lambda x: 180, lambda x: 80, lambda x: 0, 4, 4, h, tol, max_steps), plot_projection_res=True, ain=15, print_res=True)
def ex3(c, a, l, msc, xc, tc): Solve.solve_exercise(lambda: FiniteDifference.solve( lambda z: a * math.sin(math.pi / l * msc * z), lambda z: 0, 1, 0.5, c, xc, tc ), plot_projection_res=True, ain=15) def analytic_solve(func, x_boundary, t_boundary, x_points_count, t_points_count): x_step = x_boundary / (x_points_count - 1) t_step = t_boundary / (t_points_count - 1) x = [i * x_step for i in range(x_points_count)] t = [i * t_step for i in range(t_points_count)] u = pylab.zeros((t_points_count, x_points_count)) for i in range(t_points_count): for j in range(x_points_count): u[i][j] = func(x[j], t[i]) return x, t, u Solve.solve_exercise(lambda: analytic_solve( lambda z, temp: a * math.sin(math.pi / l * z * msc) * math.cos(math.pi / l * msc * c * temp), 1, 0.5, xc, tc ), plot_projection_res=True, ain=15)
def ex3(c, a, l, msc, xc, tc): Solve.solve_exercise(lambda: FiniteDifference.solve( lambda z: a * math.sin(math.pi / l * msc * z), lambda z: 0, 1, 0.5, c, xc, tc), plot_projection_res=True, ain=15) def analytic_solve(func, x_boundary, t_boundary, x_points_count, t_points_count): x_step = x_boundary / (x_points_count - 1) t_step = t_boundary / (t_points_count - 1) x = [i * x_step for i in range(x_points_count)] t = [i * t_step for i in range(t_points_count)] u = pylab.zeros((t_points_count, x_points_count)) for i in range(t_points_count): for j in range(x_points_count): u[i][j] = func(x[j], t[i]) return x, t, u Solve.solve_exercise(lambda: analytic_solve( lambda z, temp: a * math.sin(math.pi / l * z * msc) * math.cos( math.pi / l * msc * c * temp), 1, 0.5, xc, tc), plot_projection_res=True, ain=15)
def ex2(c, xc, tc): Solve.solve_exercise(lambda: FiniteDifference.solve( lambda z: z if 0 <= z <= 3 / 5 else 1.5 - 1.5 * z, lambda z: 0, 1, 0.5, c, xc, tc), plot_projection_res=True, ain=150)
def ex1(c, xc, tc): Solve.solve_exercise(lambda: FiniteDifference.solve( lambda z: math.sin(math.pi * z) + math.sin(2 * math.pi * z), lambda z: 0, 1, 0.5, c, xc, tc), plot_projection_res=True, ain=15)
def ex2(c, xc, tc): Solve.solve_exercise(lambda: FiniteDifference.solve( lambda z: z if 0 <= z <= 3 / 5 else 1.5 - 1.5 * z, lambda z: 0, 1, 0.5, c, xc, tc ), plot_projection_res=True, ain=150)
def ex1(c, xc, tc): Solve.solve_exercise(lambda: FiniteDifference.solve( lambda z: math.sin(math.pi * z) + math.sin(2 * math.pi * z), lambda z: 0, 1, 0.5, c, xc, tc ), plot_projection_res=True, ain=15)