Python for IPSA (Power flow analysis)

D

Debbie

Hi there,
I am new to Python, and wondering if you could help me with python based coding for the IPSA (Power system analysis software). I have a electrical distribution network with generators, buses and loads, on which I am performing the load flow analysis every 1 hour for a period of 1 year.

The code to perform instantaneous load/power flow analysis is given below. I need to modify it such that I can perform this load flow analysis every 1hour for a period of 1 year. Please help.

from ipsa import *

ipsasys = IscInterface()
net = ipsasys.ReadFile("refinery.iif")
bok = net.DoLoadFlow();
if bok:
busbars = net.GetBusbars()
print "Load Flow results:"
print ""
print "BusName Vmag(kV)"
print "===================="
for bus in busbars.itervalues():
name = bus.GetName()
vm = bus.GetVoltageMagnitudekV()
res = "%-8s %10.5f" % (name, vm)
print res
else:
print "Load Flow failed!"

Regards,
Debbie
 
D

Dave Angel

Hi there,
I am new to Python,

Welcome. Could you tell us a little about yourself, such as whether
you've experience in a few other languages, or if Python is your first
programming experience? Also, what version of Python (presumably 2.7 or
2.6) and what OS ?
and wondering if you could help me with python based coding for the IPSA (Power system analysis software). I have a electrical distribution network with generators, buses and loads, on which I am performing the load flow analysis every 1 hour for a period of 1 year.

The code to perform instantaneous load/power flow analysis is given below. I need to modify it such that I can perform this load flow analysis every 1 hour for a period of 1 year. Please help.

from ipsa import *

I have no idea what functionality is in ipsa, so this whole message is a
guess. First question is whether the ReadFile() below and the
DoLoadFlow() read the whole year's data, or data for a particular hour.
And if the latter, how do you get the next set of data?

ipsasys = IscInterface()
net = ipsasys.ReadFile("refinery.iif")
bok = net.DoLoadFlow();
if bok:
busbars = net.GetBusbars()
print "Load Flow results:"
print ""
print "BusName Vmag(kV)"
print "===================="
for bus in busbars.itervalues():
name = bus.GetName()
vm = bus.GetVoltageMagnitudekV()
res = "%-8s %10.5f" % (name, vm)
print res
else:
print "Load Flow failed!"

Regards,
Debbie

First you want to make a function to print out a particular hour's data.
That might turn out to be something like:

def one_hour(net):
busbars = net.GetBusbars()
print "Load Flow results:"
print ""
print "BusName Vmag(kV)"
print "===================="
for bus in busbars.itervalues():
name = bus.GetName()
vm = bus.GetVoltageMagnitudekV()
res = "%-8s %10.5f" % (name, vm)
print res

(Just pasted from your code, I added in the probable parameter to the
definition)

Now your main function might be something like:


def main(filename):
ipsasys = IscInterface()
net = ipsasys.ReadFile(filename)

#if net gets you data for one hour, figure out how
#to get the data for the whole year, in the form
#of a list or an iterator called nets

bok = net.DoLoadFlow();
if bok:
for net in nets:
one_hour(net)

else:
print "Load Flow failed!"


#and your top-level code is:
main("refinery.iif")


As to ordering in the source file, put the import first:
from ipsa import *

then your function definitions one_hour() and main(), then
your top-level code.
 
R

Robert Marshall

Hi there, I am new to Python, and wondering if you could help me with
python based coding for the IPSA (Power system analysis software). I
have a electrical distribution network with generators, buses and
loads, on which I am performing the load flow analysis every 1 hour
for a period of 1 year.

The code to perform instantaneous load/power flow analysis is given
below. I need to modify it such that I can perform this load flow
analysis every 1 hour for a period of 1 year. Please help.

from ipsa import *

ipsasys = IscInterface()
net = ipsasys.ReadFile("refinery.iif")
bok = net.DoLoadFlow();
if bok:
busbars = net.GetBusbars() ....
for bus in busbars.itervalues():
name = bus.GetName() ...
else:
print "Load Flow failed!"

I think Dave's suggestions are useful, a few years ago I was one of the
developers for the IPSA python API, I'm not sure how things have moved
on since then but you need somewhere to incorporate some time modelling
- at the moment I'm not sure how and if that was done. In any case I
doubt if the simulation would give rigourous results over a simulation
period of that length

Is what you really have a set of iif files with current voltages over a
set of periods within that year, if so you need to iterate though those,
loading each one and doing individual load flows.

IPSA has a linkedin discussion group and current IPSA developers will I
think respond to you there (if you have an account)

Robert
 
S

steve.ingram

Hi there,

I am new to Python, and wondering if you could help me with python based coding for the IPSA (Power system analysis software). I have a electrical distribution network with generators, buses and loads, on which I am performing the load flow analysis every 1 hour for a period of 1 year.



The code to perform instantaneous load/power flow analysis is given below.. I need to modify it such that I can perform this load flow analysis every1 hour for a period of 1 year. Please help.



from ipsa import *



ipsasys = IscInterface()

net = ipsasys.ReadFile("refinery.iif")

bok = net.DoLoadFlow();

if bok:

busbars = net.GetBusbars()

print "Load Flow results:"

print ""

print "BusName Vmag(kV)"

print "===================="

for bus in busbars.itervalues():

name = bus.GetName()

vm = bus.GetVoltageMagnitudekV()

res = "%-8s %10.5f" % (name, vm)

print res

else:

print "Load Flow failed!"



Regards,

Debbie

Hi Debbie,

Just found your question. I work for Ipsa and, among other things, provide support for the scripting side.

The quickest way to achieve what you want is to adjust the loads on the network and perform a load flow. The sequence would be roughly as follows;

for hours in year():
# set load values
loads = net.GetLoads()
for load in loads().itervalues:
# set new value for each load to represent the next hour of data
load.SetDValue(IscLoad.ReactiveMVAr, next_MVAr_value)
load.SetDValue(IscLoad.RealMW, next_MW_value)

net.DoLoadFlow()
# do something with these results

The above code obviously won't work and will need tweaking, but should giveyou the idea. The next version of Ipsa (2.3.2) will have load profiles in so will give a different way of achieving the same results, as well as speed improvements.

As Robert mentioned, the best place for Ipsa support is to go onto the website (www.ipsa-power.com) and check the Support of Education pages or check the LinkedIn group Ipsa Power Software Group at http://www.linkedin.com/groups/IPSA-Power-Software-4860907

Hope this helps,

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top