Ask Your Question
0

How to set a custom value of the .sav file using psspy

asked 2019-04-25 16:55:13 -0600

toderesa97 gravatar image

I have a program in python and I'd like to know if there are a sort of setters to set a value of a custom quantity or column given the corresponding id (targeting such device is not a problem).

Let's consider I want to change the value of bus base voltage (BASKV) but don't want to modify the rest. The most approachable way I've found is by invoking:

ierr = psspy.bus_data_3(ibus, intgar, realar, '')

but intgar and realar are arrays in python, and I would not like to put again the arrays with all of their values, but just modifying one. (BASKV, localed in REALAR(2)).

Can anyone shed some light on this? Thank you in advance.

According to the API of psspy

2.7. BUSDATA3 Use this API routine to modify the data of an existing bus in the working case, or to add a new bus to the working case (see PSSE Program Operation Manual, Bus Data).

Where:

Integer IBUS bus number (input; no default allowed).

Integer INTGAR (4) array of 4 elements specifying (input). INTGAR(1) IDE, bus type code (1 by default) INTGAR(2) AREA, area number (1 by default) INTGAR(3) ZONE, zone number (1 by default) INTGAR(4) OWNER, owner number (1 by default)

Real REALAR (7) array of 7 elements specifying (input). REALAR(1) BASKV, bus base voltage in kV (0.0 by default) REALAR(2) VM, bus voltage magnitude in pu (1.0 by default) REALAR(3) VA, bus voltage phase angle (0.0 by default) REALAR(4) NMAXV, normal bus voltage magnitude high limit in pu (1.1 by default) REALAR(5) NMINV, normal bus voltage magnitude low limit in pu (0.9 by default) REALAR(6) EMAXV, emergency bus voltage magnitude high limit in pu (1.1 by default) REALAR(7) EMINV, emergency bus voltage magnitude low limit in pu (0.9 by default)

Character*12 NAME bus name (input; blank by default).

Integer IERR error code (output). IERR = 0 no errors occurred IERR > 0 fatal error occurred IERR = 1 invalid bus number IERR = 2 bus table is full IERR = 3 working case is not initialized IERR = 5 prerequisite requirements for API are not met IERR = -1 data error, warning and information messages; one or more of: - Invalid base voltage. - Invalid bus type code. - Invalid area, zone or owner number. - Bus name is more than 12 characters. - New area number but bus is the area swing for its old area. - Bus type code is 3 but is not the swing bus for its area. - Area table is full. - Zone table is full. - Owner table is full. - High voltage limit is not greater than the low voltage limit. - Normal voltage limit is less restrictive than the emergency limit

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2019-04-26 12:08:06 -0600

acd1 gravatar image

updated 2019-04-26 12:10:54 -0600

Hi toderesa,

You can select specific items in the array with something like "realar1=100.0." Essentially you just put the name of the array followed by the (1-indexed) number of the parameter you want to modify from its default.

In your case, something like:

basekV = 500.0
ierr = psspy.bus_data_3(ibus, realar1=basekV)

Note that if you are modifying the 12 character name which is listed after the REALAR in the argument list, you will need to specify its argument name as well:

ierr = psspy.bus_data_3(ibus, realar1=basekV, name='MY NAME')

The following code will not work, since if you specify the name of one argument, you need to specify the name of any following arguments:

ierr = psspy.bus_data_3(ibus, realar1=basekV, 'MY NAME')

Hope that helps. Let me know if you have any issues; I didn't test any of this code.

edit flag offensive delete link more

Comments

Exactly what I was looking for! Thank you for your contribution!

toderesa97 gravatar imagetoderesa97 ( 2019-05-03 02:40:25 -0600 )edit
0

answered 2019-04-25 21:09:48 -0600

jconto gravatar image

updated 2019-05-01 16:15:01 -0600

Check the post "How to modify an existing case data?"

Changing one variable (or multiple) using the recording feature in PSSe will let you know what is the right function to use to execute such change and how to use default value variables (_i, _f,_s) to represent those variables that do not need to be changed. Since the recording creates a python code, open such file and re-use it in your code.

edit flag offensive delete link more

Comments

Such post does not help at all sir. I do not want to use PSS/E at all, but psspy, its associated library in python.

toderesa97 gravatar imagetoderesa97 ( 2019-04-26 02:52:57 -0600 )edit

You cannot use bus_data_3 outside PSSE to modify a saved case.

perolofl gravatar imageperolofl ( 2019-05-02 00:06:58 -0600 )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: 2019-04-25 16:55:13 -0600

Seen: 2,602 times

Last updated: May 01 '19