Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The best way to get these variables is by using docu. I know that you said that you don't want to use it, but it's the only solution that I know about.

You'll have to capture the standard output into a string, and then parse the string for the values you want. Not a pretty solution.

I wrote about redirecting the output into a string here: http://www.whit.com.au/blog/2013/07/check-for-network-solution-convergence/

The short of it is, you'll need to use the StringIO - it behaves like a file, but stores anything written to a string.

Then once you've got the string, you'll need to parse the result. The PSS/E output isn't easily machine readable. So there is a challenge ahead for you!

click to hide/show revision 2
Correction you CAN read CON values directly from psse.

(edit - thanks @Yagna)

The best way to get these variables is by using docu. I know that 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 said that can use the combination of mdlind and dsrval to collect any value you don't want 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 use it, but it's the only solution that I know about.

You'll have 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 capture the standard output into a string, and then parse the string for the values you want. Not a pretty solution.

I wrote about redirecting the output into a string here: http://www.whit.com.au/blog/2013/07/check-for-network-solution-convergence/

The short of it is, you'll read 'ICON' type values, you'd need to write the character_or_integer_icon function. Because both dsrival and dscval use the StringIO - it behaves like a file, but stores anything written to a string.

Then once you've got the string, ICON string as their quantity name. The only way you'll need to parse the result. The PSS/E output isn't easily machine readable. So there know if they are different is a challenge ahead by checking for you!

an error ierr=3 or by using some smarts based on the requested plant_type.