iter
This commit is contained in:
@@ -32,8 +32,9 @@ def test_order(errors, next_params):
|
||||
|
||||
print(' ', ' -> '.join(map(str, param_chain)))
|
||||
e = np.array(error_chain, dtype=float)
|
||||
print(' ', ' '.join([f'{i:16.12f}' for i in e]))
|
||||
ed = e[:-1] / e[1:]
|
||||
print(' ', ' '.join([f'{i:6.2f}' for i in ed]))
|
||||
print(' ', ' '.join([f'{i:16.12f}' for i in ed]))
|
||||
|
||||
|
||||
def test_solver(solver, Is, Ks):
|
||||
@@ -61,14 +62,14 @@ def test_solver(solver, Is, Ks):
|
||||
print()
|
||||
print(solver.__name__)
|
||||
|
||||
print('O(h_x, h_t) MAEL SHOULD BE >=2')
|
||||
test_order(errors_mae_last, next_params=lambda params: (params[0] * 2, params[1] * 2))
|
||||
print('O(h_x, h_t) MAE SHOULD BE >=2')
|
||||
test_order(errors_mae, next_params=lambda params: (params[0] * 2, params[1] * 2))
|
||||
|
||||
print(f'O(h_x, h_t^2) MAEL SHOULD BE >=4')
|
||||
test_order(errors_mae_last, next_params=lambda params: (params[0] * 4, params[1] * 2))
|
||||
print(f'O(h_x, h_t^2) MAE SHOULD BE >=4')
|
||||
test_order(errors_mae, next_params=lambda params: (params[0] * 4, params[1] * 2))
|
||||
|
||||
print(f'O(h_x^2, h_t) MAEL SHOULD BE >=4')
|
||||
test_order(errors_mae_last, next_params=lambda params: (params[0] * 2, params[1] * 4))
|
||||
print(f'O(h_x^2, h_t) MAE SHOULD BE >=4')
|
||||
test_order(errors_mae, next_params=lambda params: (params[0] * 2, params[1] * 4))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -76,11 +77,11 @@ if __name__ == '__main__':
|
||||
# Ks = [4, 8, 16, 32, 64, 128, 256, 512]
|
||||
# Is = [4, 8, 16, 32, 64, 128, 256, 512]
|
||||
# Ks = [32, 64, 128, 256, 512, 1024, 2048, 4096]
|
||||
Is = [4, 8, 16, 32, 64]
|
||||
Ks = [32, 64, 128, 256, 512, 1024]
|
||||
Is = [4, 8, 16, 32, 64, 128, 256, 512, 1024]
|
||||
Ks = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]
|
||||
|
||||
test_solver(solve_explicit, Is, Ks)
|
||||
test_solver(solve_implicit, Is, Ks)
|
||||
# test_solver(solve_implicit, Is, Ks)
|
||||
test_solver(solve_implicit_improved, Is, Ks)
|
||||
test_solver(solve_crank_nicolson, Is, Ks)
|
||||
# test_solver(solve_crank_nicolson, Is, Ks)
|
||||
test_solver(solve_crank_nicolson_improved, Is, Ks)
|
||||
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user