Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unfortunately the function

def dynamic_values(bus, id, plant_type, model_quantity):

presented in answer 1 above is not working as intended. It will not only return all CONs for the called plant model but also for all remaining CONs up to the maximum number in PSS/E. For example for 50000 bus size up to 320000 CONS are allowed. Call of dsrval will only through an exception for invalid indices, e.g. index 320001!

The function will work if you add an argument stating the number of CONs for the dynamic model which is referenced in the function call, for example 14 for GENROU model. The returned list should then be restricted to the first 14 CONs from the starting index.

Unfortunately the function

def dynamic_values(bus, id, plant_type, model_quantity):

presented in answer 1 above is not working as intended. It will not only return all CONs for the called plant model but also for all remaining CONs up to the maximum number in PSS/E. For example for 50000 bus size up to 320000 CONS are allowed. Call of dsrval will only through an exception for invalid indices, e.g. index 320001!

The function will work if you add an use NCON or NICON argument stating in mdlind to get the number of CONs for CONs/ICONs used by the dynamic model which is referenced in the function call, model, for example 14 for GENROU model. The returned list should then be restricted to the first 14 CONs from the starting index.

Unfortunately the function

def dynamic_values(bus, id, plant_type, model_quantity):

presented in answer 1 above is not working as intended. It will not only return all CONs for the called plant model but also for all remaining CONs up to the maximum number in PSS/E. For example for 50000 bus size up to 320000 CONS are allowed. Call of dsrval will only through an exception for invalid indices, e.g. index 320001!

The function will work if you use NCON or NICON argument in mdlind to get the number of CONs/ICONs used by the model, for example 14 for GENROU model. The returned list should then be restricted to the first 14 CONs from the starting index.

The following code will return al quantities for a model:

def plantdynamic_values(bus, id, type, quantity):
    """
    Returns the complete list of model quantities for the plant type at the
    machine requested:

    type:
    'GEN', 'COMP', 'STAB', 'EXC', 'GOV', 'TLC', 'MINXL', 'MAXXL'
    quantity:
    'CON', 'STATE', 'VAR', 'ICON'

    """
    if quantity not in ['CON','ICON','VAR','STATE']:
        print 'Invalid quantity for model plantdynamic_values:',quantity
        return

    # get starting index and number of constants.
    ierr,index = psspy.mdlind(bus, id, type, quantity)
    if ierr==1 or ierr==2: print 'Machine at bus %s id %s not in network' % (bus,id)
    if ierr==3: print "Machine at bus %s id %s: Invalid value %s of ’STRING1’ " % (bus,id,type)
    ierr,ncons = psspy.mdlind(bus, id, type, 'N'+quantity)
    values = []
    # get all values for this model and store the value.
    for i in range(ncons):
        if quantity=='ICON':
            ierr, value = psspy.dsival(quantity, index+i)
            if ierr==3: ierr, value = psspy.dscval(quantity, index+i)
        else: ierr, value = psspy.dsrval(quantity, index+i)
        if ierr==0: values.append(value)
    return values

Unfortunately the function

def dynamic_values(bus, id, plant_type, model_quantity):

presented in answer 1 above is not working as intended. It will not only return all CONs for the called plant model but also for all remaining CONs up to the maximum number in PSS/E. For example for 50000 bus size up to 320000 CONS are allowed. Call of dsrval will only through an exception for invalid indices, e.g. index 320001!

The function will work if you use NCON or NICON argument in mdlind to get the number of CONs/ICONs used by the model, for example 14 for GENROU model. The returned list should then be restricted to the first 14 CONs from the starting index.

The following code will return al quantities for a model:

def plantdynamic_values(bus, id, type, quantity):
    """
    Returns the complete list of model quantities for the plant type at the
    machine requested:

    type:
    'GEN', 'COMP', 'STAB', 'EXC', 'GOV', 'TLC', 'MINXL', 'MAXXL'
    quantity:
    'CON', 'STATE', 'VAR', 'ICON'

    """
    if quantity not in ['CON','ICON','VAR','STATE']:
        print 'Invalid quantity for model plantdynamic_values:',quantity
        return

    # get starting index and number of constants.
    ierr,index = psspy.mdlind(bus, id, type, quantity)
    if ierr==1 or ierr==2: print 'Machine at bus %s id %s not in network' % (bus,id)
    if ierr==3: print "Machine at bus %s id %s: Invalid value %s of ’STRING1’ " % (bus,id,type)
    ierr,ncons = psspy.mdlind(bus, id, type, 'N'+quantity)
    values = []
    # get all values for this model and store the value.
    for i in range(ncons):
        if quantity=='ICON':
            ierr, value = psspy.dsival(quantity, index+i)
            if ierr==3: ierr, value = psspy.dscval(quantity, index+i)
        else: ierr, value = psspy.dsrval(quantity, index+i)
        if ierr==0: values.append(value)
    return values

Unfortunately the function

def dynamic_values(bus, id, plant_type, model_quantity):

presented in answer 1 above is not working as intended. It will not only return all CONs for the called plant model but also for all remaining CONs up to the maximum number in PSS/E. For example for 50000 bus size up to 320000 CONS are allowed. Call of dsrval will only through an exception for invalid indices, e.g. index 320001!

The function will work if you use NCON or NICON argument in mdlind to get the number of CONs/ICONs used by the model, for example 14 for GENROU model. The returned list should then be restricted to the first 14 CONs from the starting index.

The following code will return al all quantities for a model:

def plantdynamic_values(bus, id, type, quantity):
    """
    Returns the complete list of model quantities for the plant type at the
    machine requested:

    type:
    'GEN', 'COMP', 'STAB', 'EXC', 'GOV', 'TLC', 'MINXL', 'MAXXL'
    quantity:
    'CON', 'STATE', 'VAR', 'ICON'

    """
    if quantity not in ['CON','ICON','VAR','STATE']:
        print 'Invalid quantity for model plantdynamic_values:',quantity
        return

    # get starting index and number of constants.
    ierr,index = psspy.mdlind(bus, id, type, quantity)
    ierr,ncons = psspy.mdlind(bus, id, type, 'N'+quantity)
    values = []
    # get all values for this model and store the value.
    for i in range(ncons):
        if quantity=='ICON':
            ierr, value = psspy.dsival(quantity, index+i)
            if ierr==3: ierr, value = psspy.dscval(quantity, index+i)
        else: ierr, value = psspy.dsrval(quantity, index+i)
        if ierr==0: values.append(value)
    return values

Unfortunately the function

def dynamic_values(bus, id, plant_type, model_quantity):

presented in answer 1 above is not working as intended. It will not only return all CONs for the called plant model but also for all remaining CONs up to the maximum number in PSS/E. For example for 50000 bus size up to 320000 CONS are allowed. Call of dsrval will only through an exception for invalid indices, e.g. index 320001!

The function will work if you use NCON or NICON argument in mdlind to get the number of CONs/ICONs used by the model, for example 14 for GENROU model. The returned list should then be restricted to the first 14 CONs from the starting index.

The following code will return all quantities for a model:

def plantdynamic_values(bus, id, type, quantity):
  """
 Returns the complete list of model quantities for the plant type at the
 machine requested:

 type:
 'GEN', 'COMP', 'STAB', 'EXC', 'GOV', 'TLC', 'MINXL', 'MAXXL'
 quantity:
 'CON', 'STATE', 'VAR', 'ICON'

 """
    if quantity not in ['CON','ICON','VAR','STATE']:
        print 'Invalid quantity for model plantdynamic_values:',quantity
        return

    # get starting index and number of constants.
 ierr,index = psspy.mdlind(bus, id, type, quantity)
 if ierr==1 or ierr==2: print 'Machine at bus %s id %s not in network' % (bus,id)
if ierr==3: print "Machine at bus %s id %s: Invalid value %s of ’STRING1’ " % (bus,id,type)
if ierr==5: print "Machine at bus %s id %s: Invalid value %s of ’STRING2’ " % (bus,id,quantity)
if ierr>0: return []
ierr,ncons = psspy.mdlind(bus, id, type, 'N'+quantity)
 values = []
 # get all values for this model and store the value.
 for i in range(ncons):
     if quantity=='ICON':
         ierr, value = psspy.dsival(quantity, index+i)
         if ierr==3: ierr, value = psspy.dscval(quantity, index+i)
     else: ierr, value = psspy.dsrval(quantity, index+i)
     if ierr==0: values.append(value)
 return values