forked from respec/HSPsquared
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Class for runtime simulation of RCHRES
- Add base scalar class properties (that will be saved to state)
- Must also add holders for outdgt, o, odz, ovol, oseff, od1, od2, outdgt, colind (other that are indexed by
nexits) - Add to
rchres.pycode base in folderclasses - Add import directives to
rchres.pyfile
Test run
- Classes are located in
develop-hydrclassbranch https://github.com/HARPgroup/HSPsquared/tree/develop-hydrclass - Must first run the setup and test code from parent issue ModelBase: Base
njitclass for abstracting model execution #110 and the setupModelRCHREScode above
Make Model
# a model can be created and have its props set manually if desired
# m3 = ModelRCHRES()
# but a Handler class is much better as it can automate everything including QA checks and type formatting
props = {'path':'/RCHRESR001', 'ROVOL':43.1, 'RO':12.75, 'nexits':1 }
m3 = ModelRCHRES()
hm3 = HandlerRCHRES(props)
hm3.set_props(m3)
hm3.init_nexits(m3)
# now set this manually for any tests
state_ix[1] = 7.5
state_paths['/RCHRESR001/IVOL'] = 7.5
state_paths['/RCHRESR001/O1'] = 0.0
# prepare the model for having all configuration
hm3.prep_run(m3)
# Create a run list
rchres_list = [ m3 ]
obj_ist = numba.typed.List(rchres_list )
# Set the state info
for i in range(len(obj_ist)):
obj_ist[i].state_paths = state_paths
obj_ist[i].state_ix = state_ix
Assembling a run list
# Note: this fails when passing to numba.typed, because the objects are mixed
ref_list = [m1, m2, m3]
# this works:
rchres_list = [ m3 ]
obj_ist = numba.typed.List(rchres_list )
# Now test
# Set the state info and shared ts
for i in range(len(obj_ist)):
obj_ist[i].state_paths = state_paths
obj_ist[i].state_ix = state_ix
obj_ist[i].ts = ts
start = time.time();iteration_test(obj_ist, 300000 );end = time.time()
print(len(obj_ist), "Dict components took" , end - start, "seconds")
m1.value;m2.value;m3.value
Performance Tests
State IX
- use integer index
# now set this manually for the test
state_ix[1] = 7.5
start = time.time();iteration_test(obj_ist, 300000 );end = time.time()
print(len(obj_ist), "Dict components took" , end - start, "seconds")
m3.ovol[0]
State_paths
- use path based data
state_paths['/RCHRESR001/IVOL'] = 7.5
start = time.time();iteration_test(obj_ist, 300000 );end = time.time()
print(len(obj_ist), "Dict components took" , end - start, "seconds")
m3.ovol[0]
Local refs
- must read and write to state at beginning and end of step
- Or, may just write at end, and use prior steps state from object at beginning
- so could be beneficial if variables are used many time in operations since remote reads would cost? (think iterative solutions)
Metadata
Metadata
Assignees
Labels
No labels