Ask Your Question
2

PSSPY.(what?) Reactive power

asked 2013-04-04 05:55:59 -0500

Hector gravatar image

updated 2013-04-04 06:11:26 -0500

I am using PSSE33. I need to know the API for Python to modify the reactive power of any type of bus (load or no-load, generator, non-generator) from a list of buses.

In addition, I wonder if it's better to modify shunt adjustments or to modify the reactive power load.

edit retag flag offensive close merge delete

Comments

@Hector, what is the outcome you are after here?

JervisW gravatar imageJervisW ( 2013-04-04 19:26:37 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-04-04 19:31:56 -0500

JervisW gravatar image

updated 2013-04-05 17:15:45 -0500

There is more than one right way to do it. What are you trying to achieve @Hector?

Different buses will require different types of control.

  • PQ where you can directly control the Power and Reactive Power; and
  • PV where you can control the Power and Voltage. The reactive power will change to support the set voltage.

I'm sure you already know the above, but some other students reading might not.

Are you writing a QV Curve generator?

Here is some starter code:

def main():
  """Add a constant 20MVAr load to these buses."""

  buses = [101, 102, 103] # these should be PQ type buses
  for bus in buses
    load = {'ql': 20} # Constant MVAr
    add_load_to(bus, load)

and if you were curious about where that add_load_to function comes from? Here is the code.

import uuid

def add_load_to(bus, load):
  """Create a load (can be negative) and add to bus.
     Returns load dictionary with new id ('id') and bus number ('i') set
  """
  newid = available_load_id(bus)
  psspy.load_data_3(
             bus,
             id=newid,
             realar1=load.get('pl', 0)    # set PL [default 0]
             realar2=load.get('ql', 0)    # set QL [default 0]
  )
  load['id'] = newid
  load['i'] = bus
  return load

def available_load_id(bus):
  """Returns a random available load id for a bus."""
  taken_ids = load_ids_for_bus(bus)
  while True:
    newid = uuid.uuid4().hex[:2]
    if newid not in taken_ids: 
      break
  return newid


def load_ids_for_bus(target_bus):
  """returns existing load ids in a list for a bus."""
  buses, ierr = psspy.aloadint(
             -1,                # all buses
             flag=4,            # for all loads
             string=["NUMBER"]) # get bus number
  ids, ierr = psspy.aloadchar(
             -1,                # all buses
             flag=4,            # for all loads
             string=["ID"])     # get load id

  # converts [[101], [102]] and [['1'], ['2']] to [[101, '1'], [102, '2']]
  allbuses = zip(zip(*buses)[0], zip(*ids)[0])
  return [id for (bus, id) in allbuses if target_bus == bus]

I didn't test this code out with PSSE. I think it should work though.

(edit) Compare using add_load_to with load_data_3 or load_data_4:

load = {'ql': 20}
add_load_to(102, load)

# versus

psspy.load_data_4(102, '1 ', realar2=20)

The problem with load_data_4 is that if there is already a load with id '1 ' then it will be overwritten, add_load_to never overwrites a load because it creates a new unique load id for you.

edit flag offensive delete link more

Comments

That's good. I have to define "`add_load_to`" for Python, isn't it? Now I have found the function "`load_data_4`" from PSSE to do the same. I am using it but id does not work. I get this in the prompt:

Hector gravatar imageHector ( 2013-04-05 08:43:14 -0500 )edit

ierr = psspy.load_data_4(x, 1, [1,1,1,1,0,0], [20,20,0,0,0,0]) File ".\psspy.py", line 22150, in load_data_4 TypeError: must be string, not int I don't understand what argument should be a string. In the API document for `load_data_4` there is no string.

Hector gravatar imageHector ( 2013-04-05 08:44:22 -0500 )edit

I fixed it. The second argument is a string: '1'.

Hector gravatar imageHector ( 2013-04-05 08:53:14 -0500 )edit

yep the second argument is a string, I believe you can still use `load_data_3` in PSSE33 is that right? So unless I make a mistake in my code (it isn't tested) it should work fine. so my function `add_load_to` is a wrapper for `load_data_x` where `x` can be 3 or 4.

JervisW gravatar imageJervisW ( 2013-04-05 17:10:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2013-04-04 05:55:59 -0500

Seen: 1,722 times

Last updated: Apr 05 '13