import util
from solvers.crank_nicolson import solve_crank_nicolson, solve_crank_nicolson_improved
from solvers.explicit import solve_explicit
from solvers.implicit import solve_implicit, solve_implicit_improved
from solvers.theoretical import solve_theoretical
from util import Grid

solvers = [
  solve_explicit,
  solve_implicit,
  solve_implicit_improved,
  solve_crank_nicolson,
  solve_crank_nicolson_improved,
]


def test_all():
  grid = Grid(16, 128)

  reference = solve_theoretical(grid)

  print()
  print(grid)

  for solver in solvers:
    solution = solver(grid)

    mse = util.mse(reference, solution)
    mae = util.mae(reference, solution)

    print(f'{solver.__name__:30} {mse:.4e}   {mae:.4e}')
