For some scripts in ResSim, if you are trying to pull in an external variable or a value from a state variable, you may need to tell ResSim what to assign to the variable if no value is available.
As an example, the code below brings in the variable of a "slave" state variable named "storingstor".
varsv = network.getStateVariable("storingstor")
varsv_prev = varsv.getPreviousValue(currentRuntimestep)
If there is no value or the value is undefined, you need to tell ResSim what to do.
Below are a few examples:
Example 1:
if not varsv_prev:
varsv_prev = 0
This code seems to work for some cases, but it appears that ResSim will sometimes see the value as being undefined. When this occurs, I recommend using one of the two examples below.
Example 2:
from hec.script.Constants import UNDEFINED
if varsv_prev == UNDEFINED:
varsv_prev = 0
Example 3:
from hec.lang.Const import is Undefined
if isUndefined(varsv_prev):
varsv_prev = 0
As an example, the code below brings in the variable of a "slave" state variable named "storingstor".
varsv = network.getStateVariable("storingstor")
varsv_prev = varsv.getPreviousValue(currentRuntimestep)
If there is no value or the value is undefined, you need to tell ResSim what to do.
Below are a few examples:
Example 1:
if not varsv_prev:
varsv_prev = 0
This code seems to work for some cases, but it appears that ResSim will sometimes see the value as being undefined. When this occurs, I recommend using one of the two examples below.
Example 2:
from hec.script.Constants import UNDEFINED
if varsv_prev == UNDEFINED:
varsv_prev = 0
Example 3:
from hec.lang.Const import is Undefined
if isUndefined(varsv_prev):
varsv_prev = 0
Comments
Post a Comment