def test_iteration(self): Constants.n = 10 Constants.tau = 0.1 t = 1.8 print "----------------------------------------------" print "pradedama nuo: " print "----------------------------------------------" u_now = Functions.u_exact_range(t) Helpers.pretty_print_complex(u_now) u_new_expected = Functions.u_exact_range(t + Constants.tau) u_new_actual = Algorithm._iteration_block(u_now, t) print "----------------------------------------------" print "lauktas rezultatas: " print "----------------------------------------------" Helpers.pretty_print_complex(u_new_expected) print "----------------------------------------------" print "gautas rezultatas: " print "----------------------------------------------" Helpers.pretty_print_complex(u_new_actual) print "Max netiktis: ", Functions.u_error(u_new_actual, t) self.assertTrue(True)
def test_iteration_precision(self): t = 0.8 Constants.n = 10 Constants.tau = 1.0 errors = [] for i in range(0, 5): u_now = Functions.u_exact_range(t) # tikslios reiksmes dabartiniu laiko momentu u_next = Algorithm._iteration_block(u_now, t) # isskaiciuotos reikmes sekanciu laiko momentu errors.append(Functions.u_error(u_next, t + Constants.tau)) # netiktis Constants.n *= 3 Constants.tau /= 3 Helpers.pretty_print_complex(errors) self.assertTrue(True)