Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
327 commits
Select commit Hold shift + click to select a range
510a91c
debug
Nov 10, 2025
0940e0a
state default must be None not False
Nov 10, 2025
b9a169b
sdebug
Nov 10, 2025
ca10607
sdebug
Nov 10, 2025
c99b369
try relative path for wd_cfs
Nov 10, 2025
d0a2a3c
use model_root_object as state base
Nov 10, 2025
4079863
use model_root_object as state base
Nov 10, 2025
25729bd
oops use object notation
Nov 10, 2025
8a9d27c
try in object path and undo guesing from root object
Nov 10, 2025
0c7b78d
why were there commas there?
Nov 10, 2025
4578636
debug
Nov 10, 2025
a37a7f1
better handling of push registers
Nov 10, 2025
c5055ef
fix parent clean up syntax
Nov 10, 2025
770214c
wrong function
Nov 10, 2025
da368ea
need to pass in opseq
Nov 10, 2025
066d467
correct name
Nov 10, 2025
dc437b5
activities also passed in
Nov 10, 2025
cf8cf11
one lingering state object reference fixed
Nov 10, 2025
7ce534e
another lingering state object reference fixed
Nov 10, 2025
98dfea6
another lingering state object reference fixed
Nov 10, 2025
2f9a93c
more quiet
Nov 10, 2025
98fb885
more quieter still
Nov 10, 2025
e2fbd84
withdraw 10% not 90%
Nov 12, 2025
ea359d6
updated json to run dynamic withdrawal
rburghol Dec 1, 2025
ce10810
mo changes
rburghol Dec 1, 2025
1497d1e
more testing cases
Dec 1, 2025
4182dc7
debug
Dec 10, 2025
5f4fa60
debug
Dec 10, 2025
51748ff
debug
Dec 10, 2025
a7cc7a6
debug
Dec 10, 2025
ab100b6
debug
Dec 10, 2025
ff6163a
debug
Dec 12, 2025
6a318d4
debug
Dec 12, 2025
f9ca6da
debug
Dec 12, 2025
1996bca
debug
Dec 12, 2025
be1e938
debug
Dec 12, 2025
fc78f4a
debug
Dec 12, 2025
8881a27
debug
Dec 12, 2025
0097594
Move get_ix_path to state object and use numpy array tuple handler to…
Dec 12, 2025
953376c
items are a dictionary must refer to state also
Dec 12, 2025
4050a29
use correct method syntac
Dec 12, 2025
2e27c2d
can we return unicode or None?
Dec 12, 2025
704e6fb
more debug
Dec 17, 2025
d816181
provide OVOL to state for use in specl
Dec 17, 2025
7cd18af
ref ovol3 in equation for withdrawal
Dec 17, 2025
e0a07b0
corrected bad overwrite of demand o1,... and set test flow to ivol
Dec 18, 2025
08ca68e
debug
Dec 19, 2025
5d5891d
debug
Dec 19, 2025
167a62a
debug
Dec 19, 2025
37c5b0f
debug
Dec 19, 2025
1fb6e64
do not convert ivol in state transactions, if ops need conversions th…
Dec 19, 2025
2ae811a
added an extra equation
rburghol Dec 29, 2025
21cef61
removed deprecated column
Dec 29, 2025
003ddea
Merge branch 'develop-state-class' of github.com:HARPgroup/HSPsquared…
Dec 29, 2025
a3ce2fc
madapt sedtrn to new state object
Dec 29, 2025
92b7fca
io_manager was no longer used
Dec 29, 2025
0be33d4
io_manager was no longer used
Dec 29, 2025
d499de3
one more state migration fix
Dec 29, 2025
89c003f
migrate RQUAL to new format
Dec 30, 2025
c7ccff7
debug off
Dec 30, 2025
7916fec
debug off
Dec 30, 2025
f59f92c
debug off
Dec 30, 2025
705f355
test no om
Dec 30, 2025
5702caf
reenable om
Dec 30, 2025
95b5f70
debug off
Dec 30, 2025
9cd4d7c
debug off
Dec 30, 2025
d034b05
added refresh for uci only command
Dec 31, 2025
53b077a
added a long running version of UCI
rburghol Dec 31, 2025
c4c0959
Merge branch 'develop-state-class' of github.com:HARPgroup/HSPsquared…
Dec 31, 2025
f891529
dont remove existing h5
Dec 31, 2025
1760357
add info
Dec 31, 2025
70ba943
add info
Dec 31, 2025
f1103a9
update uci test
rburghol Dec 31, 2025
5f8a6d6
replace Dict to make explicit reference that hopefully numba will run…
Jan 5, 2026
7ea20fe
test different declaration style
Jan 5, 2026
42826d8
test different declaration style - fixe
Jan 5, 2026
ed13ec7
new declarations ready for model run testin
Jan 5, 2026
aa787de
removed extraneous package indicator since it is aliased
Jan 5, 2026
2b2bd27
add state_ix initialization
Jan 5, 2026
2225002
go to all numba types for number arrays
Jan 5, 2026
550874e
muste use numpy types when casting to numba arrays?
Jan 5, 2026
39ce8f7
use numpy types during resize too
Jan 5, 2026
0d50083
change all OM indices to 64 bit
Jan 5, 2026
a039364
timer debugging added
Jan 6, 2026
17dde1d
remove unused import
Jan 6, 2026
5670b61
detailed state tracking 1
Jan 6, 2026
372431a
detailed state tracking 2
Jan 6, 2026
7b26504
test caching objecdt in function
Jan 6, 2026
fa645cc
different reference will work?
Jan 6, 2026
3adaad0
set initial values externally
Jan 6, 2026
9468566
test simpler implementation
Jan 6, 2026
7e44c77
test simpler implementation
Jan 6, 2026
f019206
add num_ops
Jan 6, 2026
7f2042c
simpler spec
Jan 6, 2026
61ac913
simpler spec
Jan 6, 2026
fb71314
no complex setting in init
Jan 6, 2026
ffddc64
no complex setting in init
Jan 6, 2026
33ac79e
no complex setting in init
Jan 6, 2026
d9001b7
no complex setting in init
Jan 6, 2026
e728ae7
what happens if we dont return it?
Jan 6, 2026
fb36864
numba as source not types
Jan 6, 2026
175aed4
numba as source not types
Jan 6, 2026
ea92501
return nothing
Jan 6, 2026
9d6e7da
pass atts
Jan 6, 2026
a6cdeb1
pass atts
Jan 6, 2026
75e31f9
pass atts and return
Jan 6, 2026
8bad920
pass atts and return
Jan 6, 2026
9361030
try to use cache=true cause the google AI said it should work even th…
Jan 6, 2026
075d8b3
this is why you dont trust the silly AI
Jan 6, 2026
92e9abf
can compile state_init_true?
Jan 6, 2026
b60d263
can compile state_init_true?
Jan 6, 2026
aeb3c7e
can compile state_init_true?
Jan 6, 2026
1a87893
can compile state_context_hsp2
Jan 6, 2026
e6b4662
more info
Jan 6, 2026
f31ef35
no njit
Jan 6, 2026
01b4da9
remove redundant path creation
Jan 6, 2026
b4f8293
info
Jan 6, 2026
c414585
info
Jan 6, 2026
c40c0aa
eval prep with state as non jit
Jan 6, 2026
a2db292
eval prep with state as non jit
Jan 6, 2026
10da314
state class lite compiled and returned what is time impact?
Jan 6, 2026
fb22f75
also must compile state_class
Jan 6, 2026
2b09ca8
add field to lite
Jan 6, 2026
f3176c2
add field to lite
Jan 6, 2026
cfe0b7b
add field to lite
Jan 6, 2026
0a8f3d8
add field to lite
Jan 6, 2026
19d01b5
add field to lite
Jan 6, 2026
abd0bbe
add remaining needed fields to lite
Jan 6, 2026
5674ce0
add contextual fields to lite
Jan 6, 2026
4f0fc2f
where is lite
Jan 6, 2026
2ac85a9
now use lite with copier at start
Jan 6, 2026
500933a
typo
Jan 6, 2026
e27a153
typo
Jan 6, 2026
4ce465c
use non method function
Jan 6, 2026
6cf1552
dont forget to copy all needed
Jan 6, 2026
efc3f1b
de ubg and copy hsp active or not
Jan 6, 2026
162725e
jit off
Jan 6, 2026
923f9b3
debug
Jan 6, 2026
bf5bbe5
jit on, removed context call since that is a double function that is …
Jan 6, 2026
fc112df
info
Jan 6, 2026
3323804
info
Jan 6, 2026
7016e7e
add actual defaults
Jan 6, 2026
84d10b2
add model_root_name!
Jan 6, 2026
75131dc
use old function
Jan 6, 2026
eed2c12
copy root name
Jan 6, 2026
f365fcd
numbaize old support function
Jan 6, 2026
cb32862
no jit on base state class to speed up
Jan 6, 2026
17e21cc
use correct term
Jan 6, 2026
97baab9
cleaned up imports
Jan 7, 2026
1203557
better memory handling
Jan 7, 2026
1170c64
missing import
Jan 7, 2026
1dc0001
missing import
Jan 7, 2026
ea180cd
timer
Jan 7, 2026
a8f0103
need to pass state
Jan 7, 2026
70fdba5
nreposition
Jan 7, 2026
9205c57
oops overwrote state
Jan 7, 2026
4eebe6a
dont pass timer
Jan 7, 2026
480fa09
restore main.py and add timing alerts
Jan 7, 2026
1c6ab62
create timer
Jan 7, 2026
9f9ab0f
import def
Jan 7, 2026
c4d976b
fix args
Jan 7, 2026
dbb51d4
add numba compatible small state
Jan 7, 2026
2a1844b
add segments
Jan 7, 2026
8f5d9b4
reduce args for this empty function
Jan 7, 2026
8c37013
isable jit for debug
Jan 7, 2026
74c2ec4
isable jit for debug
Jan 7, 2026
563c858
debug
Jan 7, 2026
a92d57d
debug
Jan 7, 2026
005aa9b
need to include other pointer
Jan 7, 2026
b7c6942
need to include other pointer
Jan 7, 2026
57640e9
debug off
Jan 7, 2026
9008810
njiton
Jan 7, 2026
c826e9f
debug
Jan 7, 2026
251761b
jit on
Jan 7, 2026
0afb066
debug less
Jan 7, 2026
8a87929
debug less
Jan 7, 2026
42fdb4c
debug
Jan 7, 2026
77e6a74
debug
Jan 7, 2026
fe0b1bd
debug
Jan 7, 2026
6dd19b6
debug
Jan 7, 2026
417cfd8
handle other dict append too
Jan 7, 2026
f6680f8
oops missing arg
Jan 7, 2026
9dfaa64
oops missing arg
Jan 7, 2026
cffa44e
wrong target
Jan 7, 2026
39b9df9
wrong target
Jan 7, 2026
e101c8d
less debug
Jan 7, 2026
bb3eebd
jit fn to see if key exists in state
Jan 8, 2026
4eef404
jit part of fn to measure speed
Jan 8, 2026
54d1b4a
jit part of fn to measure speed
Jan 8, 2026
a401615
jit part of fn to measure speed
Jan 8, 2026
6c9806a
jit set value
Jan 8, 2026
b6c67a7
jit set value not append
Jan 8, 2026
ffc4bba
jit set value not append
Jan 8, 2026
5859220
return not set in ref
Jan 8, 2026
0911864
use np array
Jan 8, 2026
16cd73f
use DataFrame to as_nparray
Jan 8, 2026
66962c4
must call as function
Jan 8, 2026
1cde96a
make all ixs as df then convert
Jan 8, 2026
30502e9
import df
Jan 8, 2026
278de38
convert all to df
Jan 8, 2026
4f311c2
add a timer to single section
Jan 8, 2026
15d32e2
make timer a separate function file
Jan 8, 2026
667d7fa
missing import
Jan 8, 2026
d3cc126
debug
Jan 8, 2026
c575a78
debug timing
Jan 8, 2026
dfe6b31
debug timing
Jan 8, 2026
1df85cd
disambiguate
Jan 8, 2026
d11cd06
use faster state path check
Jan 8, 2026
321a917
include fn
Jan 8, 2026
469343f
debug less
Jan 8, 2026
46150bf
use fn in sim timer
Jan 8, 2026
2633f71
debugless
Jan 8, 2026
dafe319
less verbose
Jan 8, 2026
639b6e6
less verbose
Jan 8, 2026
b37f90d
less verbose
Jan 8, 2026
15f5dc8
less verbose
Jan 8, 2026
6f7bfd4
ad big test data set
Jan 9, 2026
fc0b362
debug
Jan 9, 2026
d868f28
replace nuneeded link
Jan 9, 2026
f0d49a5
debug
Jan 9, 2026
d5784b7
good WD test
Jan 9, 2026
b851d5b
good WD test
Jan 9, 2026
e8134bb
info
Jan 9, 2026
8158666
info
Jan 9, 2026
8fd53a0
debug
Jan 9, 2026
d791160
debug
Jan 9, 2026
f89c64a
do not conert ep_list to numpy cuz it is text!
Jan 9, 2026
ea37f23
debug
Jan 9, 2026
1675434
debug
Jan 9, 2026
e5194a8
debug
Jan 9, 2026
82d4a39
debug
Jan 9, 2026
89b9d33
copy domain too!
Jan 9, 2026
4eb1707
debug off
Jan 9, 2026
9b996dd
debug off
Jan 9, 2026
189b77f
debug off
Jan 9, 2026
4d57370
return on zero op type
Jan 9, 2026
74701bd
return on -1 initialize op_lists as such
Jan 9, 2026
46fb0af
debug
Jan 9, 2026
df32f75
multi dim not scalar
Jan 9, 2026
35adb5f
multi dim not scalar
Jan 9, 2026
058937f
check comparator efficiency
Jan 9, 2026
10254be
tiny withdrawal
Jan 9, 2026
459c1c6
Merge branch 'develop' into develop-state-class
rburghol Jan 9, 2026
9b636ca
rename import
Jan 9, 2026
4194fd9
Merge branch 'develop-state-class' of github.com:HARPgroup/HSPsquared…
Jan 9, 2026
aba5236
add import
Jan 9, 2026
aa601af
use non obj function version
Jan 9, 2026
a87371a
use non obj function version
Jan 9, 2026
c35d974
make sure all are jitted
Jan 9, 2026
a4549e5
dont jit stuff that shouldnt be!
Jan 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 55 additions & 81 deletions src/hsp2/hsp2/HYDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
"""


from numpy import zeros, any, full, nan, array, int64, arange, asarray
from numpy import zeros, any, full, nan, array, int64, arange
from pandas import DataFrame
from math import sqrt, log10
from numba import njit, types
from numba import njit
from numba.typed import List
from hsp2.hsp2.utilities import initm, make_numba_dict

# the following imports added by rb to handle dynamic code and special actions
from hsp2.state.state import hydr_get_ix, hydr_init_ix, hydr_state_vars
from hsp2.hsp2.om import pre_step_model, step_model, model_domain_dependencies
from hsp2.state.state import hydr_get_ix, get_state_ix
from hsp2.hsp2.om import pre_step_model, step_model
from numba.typed import Dict


Expand All @@ -36,7 +36,7 @@
MAXLOOPS = 100 # newton method exit tolerance


def hydr(io_manager, siminfo, parameters, ts, ftables, state):
def hydr(siminfo, parameters, ts, ftables, state):
"""find the state of the reach/reservoir at the end of the time interval
and the outflows during the interval

Expand All @@ -48,7 +48,9 @@ def hydr(io_manager, siminfo, parameters, ts, ftables, state):
state is a dictionary that contains all dynamic code dictionaries such as:
- specactions is a dictionary with all special actions
"""

# TBD: These operations are all preparatory in nature, and will be replaced by code
# in the RCHRES_handler class, which will set properties on RCHRES_class for fast
# and concide run-time execution and memory management.
steps = siminfo["steps"] # number of simulation points
uunits = siminfo["units"]
nexits = int(parameters["PARAMETERS"]["NEXITS"])
Expand Down Expand Up @@ -140,41 +142,21 @@ def hydr(io_manager, siminfo, parameters, ts, ftables, state):
#######################################################################################
# the following section (1 of 3) added to HYDR by rb to handle dynamic code and special actions
#######################################################################################
# state_info is some generic things about the simulation
# must be numba safe, so we don't just pass the whole state which is not
state_info = Dict.empty(key_type=types.unicode_type, value_type=types.unicode_type)
state_info["operation"], state_info["segment"], state_info["activity"] = (
state["operation"],
state["segment"],
state["activity"],
)
state_info["domain"], state_info["state_step_hydr"], state_info["state_step_om"] = (
state["domain"],
state["state_step_hydr"],
state["state_step_om"],
)
hsp2_local_py = state["hsp2_local_py"]
hsp2_local_py = state.hsp2_local_py
# It appears necessary to load this here, instead of from main.py, otherwise,
# _hydr_() does not recognize the function state_step_hydr()?
if hsp2_local_py != False:
from hsp2_local_py import state_step_hydr
else:
from hsp2.state.state_fn_defaults import state_step_hydr
# initialize the hydr paths in case they don't already reside here
hydr_init_ix(state, state["domain"])
# must split dicts out of state Dict since numba cannot handle mixed-type nested Dicts
state_ix, dict_ix, ts_ix = state["state_ix"], state["dict_ix"], state["ts_ix"]
state_paths = state["state_paths"]
ep_list = (
hydr_state_vars()
) # define all eligibile for state integration in state.py
# note: calling dependencies with 4th arg = True grabs only "runnable" types, which can save time
# in long simulations, as iterating through non-runnables like Constants consumes time.
model_exec_list = model_domain_dependencies(
state, state_info["domain"], ep_list, True
)
model_exec_list = asarray(model_exec_list, dtype="i8") # format for use in numba
op_tokens = state["op_tokens"]
from hsp2.state.state_definitions import state_step_hydr
# note: get executable dynamic operation model components
# TBD: this will be set as a property on each RCHRES object when we move to a class framework
activity_path = state.domain + "/" + 'HYDR'
#print("HYDR activity_path", activity_path)
activity_id = get_state_ix(state.state_paths, activity_path)
model_exec_list = state.op_exec_lists[activity_id]
#print("model_exec_list", model_exec_list)
#print(state.domain, "HYDR called with", state.domain, len(model_exec_list), "op elements.")
#######################################################################################

# Do the simulation with _hydr_ (ie run reaches simulation code)
Expand All @@ -187,14 +169,9 @@ def hydr(io_manager, siminfo, parameters, ts, ftables, state):
funct,
Olabels,
OVOLlabels,
state_info,
state_paths,
state_ix,
dict_ix,
ts_ix,
state,
state_step_hydr,
op_tokens,
model_exec_list,
model_exec_list
)

if "O" in ts:
Expand All @@ -206,12 +183,10 @@ def hydr(io_manager, siminfo, parameters, ts, ftables, state):
parameters["PARAMETERS"]["ROS"] = ui["ROS"]
for i in range(nexits):
parameters["PARAMETERS"]["OS" + str(i + 1)] = ui["OS" + str(i + 1)]
# copy back (modified) operational element data
state["state_ix"], state["dict_ix"], state["ts_ix"] = state_ix, dict_ix, ts_ix
return errors, ERRMSGS


@njit(cache=True)
#@njit(cache=True)
def _hydr_(
ui,
ts,
Expand All @@ -221,17 +196,11 @@ def _hydr_(
funct,
Olabels,
OVOLlabels,
state_info,
state_paths,
state_ix,
dict_ix,
ts_ix,
state,
state_step_hydr,
op_tokens,
model_exec_list,
model_exec_list
):
errors = zeros(int(ui["errlen"])).astype(int64)

steps = int(ui["steps"]) # number of simulation steps
delts = ui["delt"] * 60.0 # seconds in simulation interval
uunits = ui["uunits"]
Expand Down Expand Up @@ -368,19 +337,24 @@ def _hydr_(
# other initial vars
rovol = 0.0
volev = 0.0
IVOL0 = ts["IVOL"] # the actual inflow in simulation native units

#######################################################################################
# the following section (2 of 3) added by rb to HYDR, this one to prepare for dynamic state including special actions
#######################################################################################
hydr_ix = hydr_get_ix(state_ix, state_paths, state_info["domain"])
hydr_ix = hydr_get_ix(state, state.domain)
# these are integer placeholders faster than calling the array look each timestep
# TBD: These will be replaced by class properties in HYDR_class
o1_ix, o2_ix, o3_ix, ivol_ix = (
hydr_ix["O1"],
hydr_ix["O2"],
hydr_ix["O3"],
hydr_ix["IVOL"],
)
ovol1_ix, ovol2_ix, ovol3_ix = (
hydr_ix["OVOL1"],
hydr_ix["OVOL2"],
hydr_ix["OVOL3"],
)
ro_ix, rovol_ix, volev_ix, vol_ix = (
hydr_ix["RO"],
hydr_ix["ROVOL"],
Expand All @@ -389,12 +363,16 @@ def _hydr_(
)
# handle varying length outdgt
out_ix = arange(nexits)
ovol_ix = arange(nexits)
if nexits > 0:
out_ix[0] = o1_ix
ovol_ix[0] = ovol1_ix
if nexits > 1:
out_ix[1] = o2_ix
ovol_ix[1] = ovol2_ix
if nexits > 2:
out_ix[2] = o3_ix
ovol_ix[2] = ovol3_ix
#######################################################################################

# HYDR (except where noted)
Expand All @@ -408,40 +386,45 @@ def _hydr_(
#######################################################################################
# the following section (3 of 3) added by rb to accommodate dynamic code, operations models, and special actions
#######################################################################################
# set state_ix with value of local state variables and/or needed vars
# Note: we pass IVOL0, not IVOL here since IVOL has been converted to different units
state_ix[ro_ix], state_ix[rovol_ix] = ro, rovol
# set state.state_ix with value of local state variables and/or needed vars
state.state_ix[ro_ix], state.state_ix[rovol_ix] = ro, rovol
di = 0
for oi in range(nexits):
state_ix[out_ix[oi]] = outdgt[oi]
state_ix[vol_ix], state_ix[ivol_ix] = vol, IVOL0[step]
state_ix[volev_ix] = volev
# Write OVOL for use in equations/specacts. Note: this must be improved! too much code...
state.state_ix[ovol_ix[oi]] = ovol[oi]

state.state_ix[vol_ix], state.state_ix[ivol_ix] = vol, IVOL[step]
state.state_ix[volev_ix] = volev
# - these if statements may be irrelevant if default functions simply return
# when no objects are defined.
if state_info["state_step_om"] == "enabled":
pre_step_model(model_exec_list, op_tokens, state_ix, dict_ix, ts_ix, step)
if state_info["state_step_hydr"] == "enabled":
if state.state_step_om == "enabled":
pre_step_model(model_exec_list, state.op_tokens, state.state_ix, state.dict_ix, state.ts_ix, step)

if state.state_step_hydr == "enabled":
state_step_hydr(
state_info, state_paths, state_ix, dict_ix, ts_ix, hydr_ix, step
state, step
)
if state_info["state_step_om"] == "enabled":

if state.state_step_om == "enabled":
# print("trying to execute state_step_om()")
# model_exec_list contains the model exec list in dependency order
# now these are all executed at once, but we need to make them only for domain end points
#if step < 2:
# print("Calling step_model with", len(model_exec_list), "out of", len(state.op_tokens), "tokens")
step_model(
model_exec_list, op_tokens, state_ix, dict_ix, ts_ix, step
model_exec_list, state.op_tokens, state.state_ix, state.dict_ix, state.ts_ix, step
) # traditional 'ACTIONS' done in here
if (state_info["state_step_hydr"] == "enabled") or (
state_info["state_step_om"] == "enabled"
if (state.state_step_hydr == "enabled") or (
state.state_step_om == "enabled"
):
# Do write-backs for editable STATE variables
# OUTDGT is writeable
for oi in range(nexits):
outdgt[oi] = state_ix[out_ix[oi]]
outdgt[oi] = state.state_ix[out_ix[oi]]
# IVOL is writeable.
# Note: we must convert IVOL to the units expected in _hydr_
# maybe routines should do this, and this is not needed (but pass VFACT in state)
IVOL[step] = state_ix[ivol_ix] * VFACT
IVOL[step] = state.state_ix[ivol_ix]
# End dynamic code step()
#######################################################################################

Expand Down Expand Up @@ -866,12 +849,3 @@ def expand_HYDR_masslinks(flags, parameters, dat, recs):
rec["SVOL"] = dat.SVOL
recs.append(rec)
return recs


def hydr_load_om(state, io_manager, siminfo):
for i in hydr_state_vars():
state["model_data"][seg_name][i] = {
"object_class": "ModelVariable",
"name": i,
"value": 0.0,
}
57 changes: 9 additions & 48 deletions src/hsp2/hsp2/RQUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import numpy as np
from numba import njit, types
from numba.typed import Dict
from numpy import full, zeros, asarray
from numpy import full, zeros

from hsp2.hsp2.RQUAL_Class import RQUAL_Class
from hsp2.hsp2.utilities import initm, initmd, make_numba_dict

# the following imports added to handle special actions
from hsp2.state.state import rqual_init_ix, rqual_state_vars
from hsp2.hsp2.om import model_domain_dependencies
from hsp2.state.state import get_state_ix

ERRMSGS_oxrx = (
"OXRX: Warning -- SATDO is less than zero. This usually occurs when water temperature is very high (above ~66 deg. C). This usually indicates an error in input GATMP (or TW, if HTRCH is not being simulated).",
Expand Down Expand Up @@ -251,33 +250,10 @@ def rqual(
#######################################################################################
# the following section (1 of 3) added to RQUAL by pbd to handle special actions
#######################################################################################
# state_info is some generic things about the simulation
# must be numba safe, so we don't just pass the whole state which is not
state_info = Dict.empty(key_type=types.unicode_type, value_type=types.unicode_type)
state_info["operation"], state_info["segment"], state_info["activity"] = (
state["operation"],
state["segment"],
state["activity"],
)
state_info["domain"], state_info["state_step_hydr"], state_info["state_step_om"] = (
state["domain"],
state["state_step_hydr"],
state["state_step_om"],
)
# must split dicts out of state Dict since numba cannot handle mixed-type nested Dicts
# initialize the rqual paths in case they don't already reside here
rqual_init_ix(state, state["domain"])
state_ix, dict_ix, ts_ix = state["state_ix"], state["dict_ix"], state["ts_ix"]
state_paths = state["state_paths"]
op_tokens = state["op_tokens"]
# Aggregate the list of all RQUAL end point dependencies
ep_list = (
rqual_state_vars()
) # define all eligibile for state integration in state.py
model_exec_list = model_domain_dependencies(
state, state_info["domain"], ep_list, True
)
model_exec_list = asarray(model_exec_list, dtype="i8")
# Aggregate the list of all SEDTRN end point dependencies
activity_path = state.domain + "/" + 'SEDTRN'
activity_id = get_state_ix(state.state_paths, activity_path)
model_exec_list = state.op_exec_lists[activity_id]
#######################################################################################

# ---------------------------------------------------------------------
Expand All @@ -292,12 +268,7 @@ def rqual(
ui_plank,
ui_phcarb,
ts,
state_info,
state_paths,
state_ix,
dict_ix,
ts_ix,
op_tokens,
state,
model_exec_list,
)

Expand Down Expand Up @@ -364,12 +335,7 @@ def _rqual_run(
ui_plank,
ui_phcarb,
ts,
state_info,
state_paths,
state_ix,
dict_ix,
ts_ix,
op_tokens,
state,
model_exec_list,
):
nutrx_errors = zeros((0), dtype=np.int64)
Expand All @@ -382,12 +348,7 @@ def _rqual_run(
# run WQ simulation:
RQUAL.simulate(
ts,
state_info,
state_paths,
state_ix,
dict_ix,
ts_ix,
op_tokens,
state,
model_exec_list,
)

Expand Down
Loading
Loading