Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46274
| Date | 2013-05-28 07:14 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Python for IPSA (Power flow analysis) |
| References | <6288a409-db46-4987-91a7-2f3dd65b42dc@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2292.1369739691.3114.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web