First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
3

Is there any way to export to excel LOSSES of all the branches of a system?

asked Sep 2 '13

anonymous user

Anonymous

updated Sep 9 '13

Hi,

I am new with PSSE and python. I am trying to export to excel a list with the losses in a system. If It is possible I would like to get losses in each bus connection. I have tried with caspy but I don´t know how to get losses from branches. Anyone of you could give me an idea?

Thank you very much!

* I have problems to post a comment* Thank you very much! very useful and helpful answer.

3 answers

Sort by » oldest newest most voted
4

answered Sep 3 '13

jsexauer gravatar image

updated Apr 9 '14

This will do what you're looking for. Refer to chapter 8 Subsystem Data Retrieval, specifically the bit on Branch Flow data, for more info. Keep in mind the "-1" subsystem is the entire case.

ierr, loss = psspy.aflowreal(-1, 2, 1, 1, 'PLOSS')
ierr, toBus = psspy.aflowint(-1, 2, 1, 1, 'TONUMBER')
ierr, fromBus = psspy.aflowint(-1, 2, 1, 1, 'FROMNUMBER')
ierr, brnID = psspy.aflowchar(-1, 2, 1, 1, 'ID')

csv = 'ToBus, FromBus, ID, PLOSS\n'
for fields in zip(toBus[0], fromBus[0], brnID[0],loss[0]):
    csv += ','.join(map(str,fields)) + '\n'
print csv
with open('output.csv','w') as f:
    f.write(csv)
link
1

answered Apr 7 '14

EBahr gravatar image

updated Apr 10 '14

Unfortunately I don't think you can extract that type of calculated data from caspy.

Also, see below for a slight variation to @jsexauer's answer. This version will make sure the branch is only documented once. Otherwise if you tried to calculate total system losses, it would be double what it should be.

ierr, loss = psspy.aflowreal(-1, 2, 1, 1, 'PLOSS')
ierr, toBus = psspy.aflowint(-1, 2, 1, 1, 'TONUMBER')
ierr, fromBus = psspy.aflowint(-1, 2, 1, 1, 'FROMNUMBER')
ierr, brnID = psspy.aflowchar(-1, 2, 1, 1, 'ID')
branches = []

csv = 'ToBus, FromBus, ID, PLOSS\n'
for i in range(len(loss[0])):
    if not (toBus[0][i],fromBus[0][i],brnID[0][i]) in branches:
        csv += '%i,%i,%s,%f\n' % (toBus[0][i], fromBus[0][i], brnID[0][i],loss[0][i])
        branches.append((fromBus[0][i],toBus[0][i],brnID[0][i]))
print csv
with open('c:\\output.csv','w') as f:
    f.write(csv)
link

Comments

good catch, thanks

jsexauer gravatar imagejsexauer (Apr 9 '14)
0

answered Apr 2 '14

Towana gravatar image

Thanks it was interesting..... But i did not get results in excel file, it is possible? If yes, how we can do it? Thanks in advance

link

Comments

double click on the csv file.

jconto gravatar imagejconto (Apr 3 '14)

Edited answer to save results to a file, output.csv

jsexauer gravatar imagejsexauer (Apr 7 '14)

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: Sep 2 '13

Seen: 2,143 times

Last updated: Apr 10 '14