Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestep benthic prey with fish #24

Merged
merged 5 commits into from
Feb 9, 2022

Conversation

mnlevy1981
Copy link
Collaborator

Rather than update biomass for benthic prey inside compute_tendencies(), that function now returns a tendency term for the benthic prey biomass.

Testing: I hard-coded the initial benthic prey biomass to 2.098534303641961e-03, which was the biomass in the shallowest column at the end of the first time step. When comparing to matlab results, the benthic_prey biomass is off by a full timestep, but everything else looks good:

group Matlab Value Python Value Rel Err
Sf 9.9993e-06 9.9993e-06 0.0000e+00
Sp 9.9978e-06 9.9978e-06 0.0000e+00
Sd 9.9978e-06 9.9978e-06 0.0000e+00
Mf 1.1076e-05 1.1076e-05 3.0590e-16
Mp 1.1076e-05 1.1076e-05 1.5295e-16
Md 1.1030e-05 1.1030e-05 3.0717e-16
Lp 1.0093e-05 1.0093e-05 3.3569e-16
Ld 9.9746e-06 9.9746e-06 0.0000e+00
benthic_prey 2.0985e-03 4.1871e-03 9.9523e-01

Still a draft because there is one kludgy line where I assume a single zooplankton when mapping fish indices from group dimension to fish dimension. Also, for the actual commit I used 2e-3 for initial benthic prey biomass, and I haven't generated new baselines from matlab yet.

Rather than updating benthic prey biomass early in compute_tendencies, we now
return benthic prey biomass tendency along with the fish biomass tendencies.

There is one kludge in process.compute_total_tendency() to address: I changed
the dimension of total_tendency from "fish" to "group", so there are now
indices for zooplankton and benthic_prey. When computing the tendency for fish,
though, we use some terms that still have dimension "fish", so we need to
convert the index space somehow. (Currently, I'm taking advantage of the single
zooplankton class to just set fish_i = i - 1 but that isn't a long-term
solution.)
test_init_tendency_arrays() was failing because I updated the size of arrays
with dimension "group"; test_update_benthic_prey() was failing because I
removed the _update_benthic_biomass() function from interface.py
Also, I added hooks for comparing multiple tests and updated the yaml file with
results from test_loc3.m
@mnlevy1981 mnlevy1981 mentioned this pull request Feb 3, 2022
3 tasks
in compute_total_tendency(), we are looping through member_obj_list instead of
fish_list, so we can access biomass[i,:] directly instead of relying on
biomass.sel(group=...)
compute_tracer_tendency() takes an additional argument named first_fish_id,
which is the index of the first fish in the group dimension. When looping over
enumerate(member_obj_link), i is the index of the object in the group dimension
so i - first_fish_id is the index into the fish dimension.
@mnlevy1981 mnlevy1981 marked this pull request as ready for review February 3, 2022 22:12
@mnlevy1981
Copy link
Collaborator Author

I addressed the concerns in the first post: c73da71 removes the kludge, and I was able to regenerate matlab solutions with the updated initial conditions. Differences in biomass after one year (in the first column):

group Matlab Value Python Value Rel Err
Sf 1.7696e-05 1.7696e-05 0.0000e+00
Sp 9.3653e-06 9.3653e-06 0.0000e+00
Sd 9.4481e-06 9.4481e-06 0.0000e+00
Mf 4.0856e-04 4.0856e-04 1.3269e-16
Mp 3.1926e-04 3.1926e-04 0.0000e+00
Md 3.1755e-04 3.1755e-04 1.7071e-16
Lp 4.7386e-04 4.7386e-04 0.0000e+00
Ld 2.2687e-04 2.2687e-04 7.1683e-16
benthic_prey 6.3646e-01 6.3646e-01 0.0000e+00

@matt-long this is ready for review / merging - I'm happy to respond to comments here or we can schedule a code walk-through if you prefer

@matt-long matt-long merged commit a5db290 into marbl-ecosys:main Feb 9, 2022
@mnlevy1981 mnlevy1981 deleted the timestep_bp_with_fish branch January 17, 2023 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants