(edit - thanks @Yagna)
The best way to get these variables is by using DSRVL
.
Here is the function signature:
value = psspy.dsrval(name, index)
where the name
parameter can be:
TIME simulation time
DELT Simulation time step
STATE State variable values
CON Real model parameters
VAR Real model variable values
As @Yagna mentioned, you can use the combination of mdlind
and dsrval
to collect any value you wish:
def dynamic_values(bus, id, plant_type, model_quantity):
"""
Returns the complete list of model quantities for the plant type at the
machine requested:
plant_type:
'GEN', 'COMP', 'STAB', 'EXC', 'GOV', 'TLC', 'MINXL', 'MAXXL'
model_quantity:
'CON', 'STATE', 'VAR', 'ICON'
"""
index_lookup = {
'CON': psspy.dsrval,
'STATE': psspy.dsrval,
'VAR': psspy.dsrval,
'ICON': character_or_integer_icon}
# get starting index.
index = psspy.mdlind(bus, id, plant_type, model_quantity)
get_value = index_lookup(model_quantity)
values = []
# increase the index, and store the value until we get get all values.
while 1:
try:
_, value = get_value(model_quantity, index)
except psspy.PsseException, e:
if e.ierr == 2:
# no more data available.
break
else:
raise
values.append(value)
index += 1
return values
You can use the above function to get all of the values in the array
# a list of all CON values at machine on bus 100.
cons = dynamic_values(100, '1', 'GEN', 'CON')
If you also wanted to read 'ICON' type values, you'd need to write the character_or_integer_icon
function. Because both dsrival
and dscval
use the ICON
string as their quantity name. The only way you'll know if they are different is by checking for an error ierr=3 or by using some smarts based on the requested plant_type
.