Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46272 > unrolled thread

Python for IPSA (Power flow analysis)

Started byDebbie <dia.sussex@gmail.com>
First post2013-05-28 03:00 -0700
Last post2013-05-29 01:51 -0700
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Python for IPSA (Power flow analysis) Debbie <dia.sussex@gmail.com> - 2013-05-28 03:00 -0700
    Re: Python for IPSA (Power flow analysis) Dave Angel <davea@davea.name> - 2013-05-28 07:14 -0400
    Re: Python for IPSA (Power flow analysis) Robert Marshall <spam@capuchin.co.uk> - 2013-05-28 13:08 +0100
    Re: Python for IPSA (Power flow analysis) steve.ingram@tnei.co.uk - 2013-05-29 01:51 -0700

#46272 — Python for IPSA (Power flow analysis)

FromDebbie <dia.sussex@gmail.com>
Date2013-05-28 03:00 -0700
SubjectPython for IPSA (Power flow analysis)
Message-ID<6288a409-db46-4987-91a7-2f3dd65b42dc@googlegroups.com>
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()
    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

[toc] | [next] | [standalone]


#46274

FromDave Angel <davea@davea.name>
Date2013-05-28 07:14 -0400
Message-ID<mailman.2292.1369739691.3114.python-list@python.org>
In reply to#46272
On 05/28/2013 06:00 AM, Debbie wrote:
> 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.

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#46278

FromRobert Marshall <spam@capuchin.co.uk>
Date2013-05-28 13:08 +0100
Message-ID<87zjvfnw73.fsf@capuchin.co.uk>
In reply to#46272
On Tue, May 28 2013, Debbie <dia.sussex@gmail.com> wrote:

> 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
-- 
La grenouille songe..dans son château d'eau
Links and things http://rmstar.blogspot.com/

[toc] | [prev] | [next] | [standalone]


#46360

Fromsteve.ingram@tnei.co.uk
Date2013-05-29 01:51 -0700
Message-ID<09f09e22-626c-4b49-a80f-8259bdf2adac@googlegroups.com>
In reply to#46272
On Tuesday, May 28, 2013 11:00:42 AM UTC+1, Debbie wrote:
> 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()
> 
>     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 give you 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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web