Open rburghol opened 2 years ago
Spent some time locating the current php versions of these object classes
class modelObject {}
class modelSubObject extends modelObject {}
class broadCastObject extends modelSubObject {}
class dataMatrix extends modelSubObject {}
class modelContainer extends modelObject {}
See example for setting up objects in python: https://github.com/HARPgroup/pydro-tools/tree/main/OOP
Example:
available_mgd = (Qintake - flowby) / 1.547
Qintake = Qreach * 1.0
flowby =
0.9 * Qintake` available_mgd
= /OBJECTS/INTAKE_001/Equation/available_mgd
Qintake
= /OBJECTS/INTAKE_001/Equation/Qintake
flowby
= /OBJECTS/INTAKE_001/Equation/flowby
available_mgd
= /RESULTS/INTAKE_001/SPECL/available_mgd
Qintake
= /RESULTS/INTAKE_001/SPECL/Qintake
flowby
= /RESULTS/INTAKE_001/SPECL/flowby
ts
that is passed to the function:
ts["/RESULTS/INTAKE_001/SPECL/Qintake"][step] = ts["/RESULTS/RCHRES_001/SPECL/Qin"][step] * 1.0
ts["/RESULTS/INTAKE_001/SPECL/flowby"][step] = 0.9 * ts["/RESULTS/INTAKE_001/SPECL/Qintake"][step]
ts["/RESULTS/INTAKE_001/SPECL/available_mgd"][step] = ( ts["/RESULTS/INTAKE_001/SPECL/Qintake"][step] - ts["/RESULTS/INTAKE_001/SPECL/flowby"][step] ) / 1.547
Overview
Note that the previous implementation was fully object oriented, though since hsp2 uses the
numba
compiler to create faster execution we will make a hybrid to leverage the speed benefits. will be instantiated to process model inputs from JSON (or from UCI if we support that).numba
code.pre-step
,step
, andpost-step
utilities_specl.py
aspre_step_model()
,step_model()
, andpost_step_model()
step_[class name]
function must be defined in the class code file, and added to the(pre_,post_)step_model()
functionstep_equation()
step()
function, certain things benefit from happening in thepreStep()
andpostStep()
phases.preStep()
Example: ModelRegister classes can act as accumulators of data from multiple senders in a single time-step. For a register, it is desirable to reset to zero at the beginning of each timestep, thus, the reset to zero happens inpre_step_register()
.opcode
) foropcodes
, i.e.,opcodes["/SPECL/Equations/RCHRES_001/Qlocal"] = "sin(step)"
step
will be stored ints[/path_to_object/property_name][step]
hsp2
these are often simply held as variable values that exist only within the context of the function that is being executed. Thets
dictionary also has state, but presumably that state is only for things that are being logged, and in the interest of data storage, we may not want every single item to be logged, especially as sub-components grow larger. Thus it is theoretically possible that something is important enouh to be stored instate
, but not important enough to be logged every time step?ts
.ts
can contain data paths copied from the hdf5/TIMESERIES/
and/RESULTS/
ui
(named thusly because they are an excerpt fromuci
)ts
essentially provides state for all objects referenceable via unique paths, the state function of what an object framework provides is satisfied.numba
does in fact have some object support, using@jitclass
@jitclass
might be useable.@jitclass
object cannot be passed as arguments, so we would need to instantiate the objects inside of thespecl
routine (or whatever operational entities base we use).specl/entities
so would need to test.Tasks
Priority objects/method/functions to develop:
preStep()
, set these registers to zero:ts["/BROADCASTS/RCHRES_0001/hydroObject/ps_mgd"][step]
ts["/BROADCASTS/RCHRES_0001/hydroObject/ps_mgd"][step] += ts["/OBJECTS/OBJECT0001/ps_local_mgd"][step]