Ask Your Question
2

find var number for user model

asked 2013-03-07 15:40:15 -0500

AdamF gravatar image

Is there any way to use python to find the starting var number for a user-written model? It seems like you should be able to provide the name of the user model and get PSSE to tell you where the vars are for that model.

edit retag flag offensive close merge delete

Comments

Hi Adam I saw some ways to get info on built in models: https://psspy.org/psse-help-forum/question/656/accessing-model-index-values-eg-var-nums-from-python/, but not for user-written ones. What is your method for accessing through the user interface right now?

JervisW gravatar imageJervisW ( 2013-03-08 18:30:48 -0500 )edit
1

Currently, we place the user models at the beginning of the dyre file in a certain order so that we can just count the var locations and know where they are stored. This practice dates back a long ways and I'm looking for a more flexible way to find these var locations so that we don't have to ...

AdamF gravatar imageAdamF ( 2013-03-15 08:17:52 -0500 )edit
1

... worry about the dyre order anymore. I just thought of one way to do it: we could have a python script look through the vars and find unique sets of consecutive var values that would correspond to certain models. These models don't changes very often so this might actually be a workable fix.

AdamF gravatar imageAdamF ( 2013-03-15 08:19:50 -0500 )edit

Are you able to post some pseudo-code showing how you might go about it?

JervisW gravatar imageJervisW ( 2013-03-15 19:53:01 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
1

answered 2016-09-21 05:35:41 -0500

perolofl gravatar image

You get the starting indices for user-written models in the same way as for library models! There is no difference between library models and user-written models in this subject.

Just use the appropriate API to get the starting index, e,g, mdlind or swsmind. A summary of available API's are shown in https://psspy.org/psse-help-forum/question/656/accessing-model-index-values-eg-var-nums-from-python/

Often things are much easier than people assume!

edit flag offensive delete link more
0

answered 2013-08-01 18:35:53 -0500

EBahr gravatar image

updated 2013-08-01 18:36:16 -0500

What I have done for a similar situation is modify my FORTRAN code to output something that is easy to parse from the output of the DOCU command.

Here is an example grabbed from one of my user models:

SUBROUTINE MYPROGRAM( II, JJ, KK, LL )
INCLUDE 'COMON4.INS'    

IF (MODE .EQ. 5) THEN
    CALL DOCUHD(*9999)

    WRITE(IPRT, 1114) 'CON', jj
    WRITE(IPRT, 1114) 'ICON', ii
    WRITE(IPRT, 1114) 'VAR', ll
    WRITE(IPRT, 1114) 'STATE', kk

1114    FORMAT(T5,'MY PROGRAMS starting ',A5, ' is ',I7)
ENDIF

Then I would just use regex to look for "MY PROGRAMS starting VAR is" in the DOCU output, and grab the VAR from there. It's not pretty, but it works.

edit flag offensive delete link more
0

answered 2013-08-04 23:00:23 -0500

Eli Pack gravatar image

I'd try using the "docu" function. In the following example, I report all models connected to bus 12345. This will generate a report in PSSE, which should list the data used by the model.

psspy.bsys(1,0,[0.0,0.0],0,[],1,[12345],0,[],0,[])
psspy.docu(1,0,[0,3,2])

If you want to use the starting VAR number in the same script, you'll want to redirect the output of PSSE reports and parse the text. Look up the psspy.report_output function.

edit flag offensive delete link more

Comments

JervisW gravatar imageJervisW ( 2013-08-08 21:41:55 -0500 )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

1 follower

Stats

Asked: 2013-03-07 15:40:15 -0500

Seen: 1,903 times

Last updated: Sep 21 '16