Ask Your Question
1

Is there a python function to return plant model con data in dynamic case model?

asked 2013-08-01 08:40:58 -0600

Yagna gravatar image

I am looking to evaluate the con data of plant models in dynamic file and I would like to be able to return this to a variable and if it is wrong then, use the function "changeplmodcon()"

edit retag flag offensive close merge delete

Comments

Thank you ! That was exactly what I was looking for.

Yagna gravatar imageYagna ( 2013-08-01 20:36:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-08-01 18:19:33 -0600

EBahr gravatar image

updated 2013-08-07 18:49:47 -0600

Take a look at the answer to this post: https://psspy.org/psse-help-forum/question/656/accessing-model-index-values-eg-var-nums-from-python/


After seeing what you actually want to do, try something similar to the following:

#THIS CODE WILL SET THE CON(J+5) TO 0.0 IF THE VALUE OF THAT CON IS GREATER THAN 0.0
#   FOR ALL GENROU MODELS IN THE CASE

#MODIFY BSYS TO A DEFINED SUBSYSTEM IF YOU DON'T WANT TO RUN ON ENTIRE CASE
BSYS = -1
ierr, buses = psspy.amachint(BSYS,4,'NUMBER')
ierr, ids = psspy.amachchar(BSYS,4,'ID')
for i in range(len(buses[0])):
    ierr, model_name = psspy.mdlnam(buses[0][i],ids[0][i],'GEN')
    if ierr:
        continue
    #CHANGE 'GENROU' TO WHATEVER MODEL YOU ARE LOOKING FOR
    if 'GENROU' in model_name:
        ierr, con_index = psspy.mdlind(buses[0][i], ids[0][i], 'GEN', 'CON')
        ierr, con_num = psspy.mdlind(buses[0][i], ids[0][i], 'GEN', 'NCON')
        cons = []
        for i in range(con_num - 1):
            ierr, con_val = psspy.dsrval('CON', con_index + i)
            cons.append([con_index + i, con_val])

        #NOT REALLY SURE WHERE YOU ARE GOING TO TAKE THIS, BUT YOU COULD DO SOMETHING LIKE THIS:
        if cons[5][1] > 0:
            NEW_VAL = 0.0
            psspy.change_con(cons[5][0],NEW_VAL)

I have no idea what you are planning on doing with this, but hopefully this code will help out a bit. I found the 'dsrval' command in the API, so parsing wasn't necessary. to change the con, use the 'change_con' command.

edit flag offensive delete link more

Comments

@EBahr Is there a way I can return the con data of a dynamic data to an array or variable ? I just do not want to print the con data on the screen. I would like to use the data to verify against a set of criteria

Yagna gravatar imageYagna ( 2013-08-05 13:47:34 -0600 )edit

@Yagna Without writing your own script to do so, I don't think so. I would think it would be pretty easy to write a regex parser to put the data you want into arrays though. Also, does this need to be after the dynamics data has been loaded into your case? Couldn't you just do your validation...

EBahr gravatar imageEBahr ( 2013-08-06 09:45:28 -0600 )edit

... on your .dyr file?

EBahr gravatar imageEBahr ( 2013-08-06 09:45:41 -0600 )edit

@EBahr I am very new to python and not quite familiar with regex parser. I have thousands of generator data that I would like to verify and the dyr file is very huge and contains every possible model for tens of thousands of machines. I just want to pick the generators of few model types and

Yagna gravatar imageYagna ( 2013-08-06 10:09:39 -0600 )edit

verify. I could find all the right tools and functions for this purpose except for the "data retrieval" part. So could you give me an example code to parse the output of dlst so that a 2D array with [CON no., CON val] can be created. That would be very helpful! or any other suggestion.

Yagna gravatar imageYagna ( 2013-08-06 10:13:37 -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: 2013-08-01 08:40:58 -0600

Seen: 3,373 times

Last updated: Aug 07 '13