csdms / help-desk

The CSDMS Help Desk. Ask questions. Get answers (about CSDMS products and services).
MIT License
6 stars 1 forks source link

BMI for a Water System Reservoir Model #217

Open pdmich opened 1 year ago

pdmich commented 1 year ago

First of all, we're new to BMI, so please excuse the ignorance. We're working on a bmi adapter for water systems model (MODSIM). These models traditionally consist of "nodes" which can be reservoirs, inflow points, water system demands (etc.), and then "links" which connect the nodes together and define the flow paths in the system. Looking though the documentation and examples, I'm not quite sure how to fit in some of the BMI logic into this model. For example, the "get_value" or "set_value" logic seems to only have parameters for variable name and an array. If you had a variable "reservoir_storage", but your model had 20 reservoir nodes, are there ways to specify which specific reservoir you want to interact with based on some id other than the variable? Using the current non-bmi version of the model, you can do this, and it is pretty useful. Maybe you would need to use some the "grid" logic in bmi for this? Or do you have to just use the array indices? I noticed in the MODFLOW implementation, they added an additional function "get_value_address" which seems to use some other logic to do this, but that doesn't seem to be part of the standard library. Any help or examples on how we should tackle this would be much appreciated, thanks!

mdpiper commented 11 months ago

👋 @pdmich! I agree with what you've described. The key, which you've hit on, is that the BMI doesn't preclude helper functions. For your "reservoir_storage" example variable, you would get/set values on it by indexing, optionally using a helper function to translate between identifiers from the model and array indices in the BMI for the model.

Does this make sense? Please let me know what you think. (I'll try to be better about responding in a timely fashion.)

Tagging @mcflugen in case I missed anything.