Skip to content

ModelRCHRES #111

@rburghol

Description

@rburghol

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.py code base in folder classes
  • Add import directives to rchres.py file

Test run

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions