EcohydrologyTeam / ClearWater-riverine

A 2D water quality transporter model to calculate conservative advection and diffusion of constituents from an unstructured grid of flows
MIT License
6 stars 0 forks source link

Speed up Boundary Conditions #50

Closed sjordan29 closed 10 months ago

sjordan29 commented 10 months ago

the boundary_conditions() method was extremely slow as referenced in #23. As the number of timesteps increased, setting up the boundary conditions became time-prohibitive. This change does the following:

  1. Massively speeds up the boundary conditions method (for our most recent plan 28, this took 38 minutes; now takes ~1 second) (#23)
  2. Aligns the boundary conditions to the model timesteps and performs linear interpolation if any values are missing (#19)

@jrutyna, I ran the pytests with these updates and got the following:

FAILED tests/test_final_mass.py::test_mass_end_plan02 - AssertionError: assert 5001.221843908841 == 5001.22184753418
FAILED tests/test_final_mass.py::test_mass_end_plan01 - AssertionError: assert 5024.4072146413555 == 5024.407064914703
FAILED tests/test_final_mass.py::test_mass_end_plan04 - AssertionError: assert 5001.021281938794 == 5001.021194458008
FAILED tests/test_final_mass.py::test_mass_end_plan05 - AssertionError: assert 1979.7318417885435 == 1979.7024101018906
FAILED tests/test_final_mass.py::test_mass_end_plan06 - AssertionError: assert 1116.356570489971 == 1993.1427031755447
FAILED tests/test_final_mass.py::test_mass_end_plan07 - AssertionError: assert 991.2460696157352 == 1727.1147887668121
FAILED tests/test_final_mass.py::test_mass_end_plan08 - AssertionError: assert 909.0417898887815 == 1725.6044437240234
FAILED tests/test_final_mass.py::test_mass_end_plan11 - AssertionError: assert 2098093.1549786166 == 1545432.6816056462

Looks to me like these are the same results I get without these changes, but want to confirm with you before merging into main.

sjordan29 commented 10 months ago

@jrutyna confirmed this is ok.