Open rburghol opened 5 months ago
Created model_order_recursive()
, which is based almost verbatim on model_tokenizer_recursive()
but with no calls to tokenize or load. Test the existing base routine for the ability to trace requirements for only a sub-section with an end point:
model_object_cache
model_object
argumentmodel_object_cache
argmodel_exec_list
- mel = []
model_touch_list
- mtl = []
Runit
variable from the outlet watershed
# run the first 43 lines of
mel = []
mtl = []
outlet_runit_object = model_object_cache['/STATE/RCHRES_R001/Runit']
model_order_recursive(outlet_runit_object, model_object_cache, mel, mtl)
print(mel)
[233, 231, 48, 32, 235, 236, 31, 73, 57, 238, 239, 56, 95, 79, 241, 242, 78, 117, 101, 244, 245, 100, 139, 123, 247, 248, 122, 161, 145, 250, 251, 144, 183, 167, 253, 254, 166, 172, 173, 182, 186, 150, 151, 160, 164, 128, 129, 138, 142, 106, 107, 116, 120, 84, 85, 94, 98, 205, 189, 256, 257, 188, 227, 211, 259, 260, 210, 216, 217, 226, 230, 194, 195, 204, 208, 62, 63, 72, 76, 37, 38, 47, 232]
trib_area_sqmi
, which is influenced by all of the nested tributaries own drainage_area_sqmi
equations.drainage_area_sqmi
equation from a headwater catchment, which will only be influenced by the elements of area in the local catchement since nothing is upstream of it:
mtl = []
mel = []
headwater_area_object = model_object_cache['/STATE/RCHRES_R001/nhd_8566779/nhd_8566793/nhd_8566791/drainage_area_sqmi']
model_order_recursive(headwater_area_object, model_object_cache, mel, mtl)
# see the names/paths
print(mel)
[227, 211, 259, 260, 210, 216, 217, 226]
This is provisionally completed pending review of PR #150
def model_order_recursive(model_object, model_object_cache, model_exec_list, model_touch_list = []):
model_exec_list
andmodel_touch_list
in placemodel_domain_dependencies()
domain_exec_list = model_domain_dependencies([the state dict], [domain, i.e. common path root], [end point names (to appens to root)] )
The STATE operational model system provides for "dependency execution" which assembles a list of integer IDs ordered according to their components data dependency (from independent to dependent variables), in order to insure proper order execution.
Currently, this is done in the same function that tokenizes all operational model and special action objects. But it would be best if there were a function to do this to allow us to extract different "execution chains" for a given endpoint to avoid redundant executions and the potential for erroneous data due to executing code outside of it's model domain.
Conceptual Example
What are the special actions/OM ops that must be executed each timestep for
OD
(withdrawal) duringHYDR
simulation in a givenRCHRES 1
?RCHRES 1
:/STATE/RCHRES_R001
OVOL
: value of outflow from the previous timestep inRCHRES 1
OD = demand
: theOD
input (OD1
,OD2
,OD3
) is the demand for water from theRCHRES
at the current timestepmonth
: the numerical index for current timestep month (1-12)RCHRES 1
contains a water withdrawal intake with the following components:flowby = 10.0
: a constant, in cfs, indicating the minimum value of instream flow that must pass the intakeavailable_flow
:OVOL - flowby
;demand_monthly
: a table that contains a monthly varying base demand[ 1: 2.0, 2: 2.0, 3: 2.2, 4: 2.2, 5: 2.2, 6: 2.3, 7:2.4, 8:2.4, 9: 2.1, 10: 2.1, 11: 2.0, 12: 2.0 ]
demand
: a lookup with the demand sent to theRCHRES
demand = min(demand_monthly, available_flow)
OD1 = demand
month
: self-explanatoryflowby
: in this case it is a single numerical value, and thus depends on no variableOVOL
since it is from the last time stepHYDR
:OD = demand
: theOD
input (OD1
,OD2
,OD3
) is the demand for water from theRCHRES
at the current timestep Since the allowable withdrawal amount varies as a function of a monthly minimum flow requirement (i.e. a "flow-by")OD
must be calculated afterdemand_monthly
,flowby
andavailable_flow
. Similarly,available_flow
must be calculated afterflowby
.Code
Example: Find
SEDTRN
related executables in a singleRCHRES
viamodel_order_recursive()
Extra testing output to show details of dependencies.