Ask Your Question
0

PSS/E User-written misc. model crashes

asked 2020-11-02 08:07:50 -0600

likethevegetable gravatar image

updated 2020-11-05 09:14:34 -0600

I made a simple miscellaneous dynamics model to trip branch 222 to 333 '1' at 0.15 seconds, this action is currently commented out to help you see where it is. The model works if these lines are commented out as I can see the print outs, so in effect, I have gotten a hello world model to work. However, when the lines are enabled (i.e. trying to get the model to do what I want), I get a crash.

returned non-zero exit status -1073741819

I believe the crash occurs after leaving the subroutine because I can see 'About to return' before it crashes.

Note I am running with a Python 2.7 script using PSS/E v33.

Any ideas?

          SUBROUTINE KMODL(KM,ISLOT)
          INTEGER KM, ISLOT, IDEF, IERR, MODE
          REAL BVOLT, TOIME, RDEF
          INTEGER, DIMENSION(6):: INTGAR
          REAL, DIMENSION(15):: REALAR
          CALL GETDEFAULTINT(IDEF)
          CALL GETDEFAULTREAL(RDEF)
          INTGAR = IDEF
          REALAR = RDEF
          IF (MODE.LT.4) THEN
               CALL DSRVAL('TIME', 1, TOIME, IERR)
                IF (TOIME.GT.0.15) THEN
                    WRITE(*, *) 'About to trip'
C                   INTGAR(1) = 0               
C                           CALL BRANCH_CHNG(222, 333, '1', INTGAR, REALAR, IERR)
                                    WRITE(*, *) 'Tripped'
               END IF
          END IF
             WRITE(*, *) 'About to return'
          RETURN  
          END

EDIT:

I was able to trip a branch using the LINTRP model. First, I had to move the FORTRAN source code file into my PSSLIB folder before compiling into a .dll, and modify as shown below. My .dyr file looked like:

1 'USRMSC' 'KMODL' 512 0 3 0 0 0 222 333 '1' /kmodl

  SUBROUTINE KMODL(KM,ISLOT)
  INCLUDE 'COMON4.INS'
      IMPLICIT NONE
  INTEGER:: KM, ISLOT, I, IERR
  REAL:: TOIME
  EXTERNAL LINTRP
      I = STRTCCT(4,ISLOT)
  IF (MODE.LT.4) THEN
       CALL DSRVAL('TIME', 1, TOIME, IERR)
        IF (TOIME.GT.0.15) THEN
            WRITE(*, *) 'About to trip'
            CALL LINTRP(I)
            WRITE(*, *) 'Tripped'
       END IF
  END IF
     WRITE(*, *) 'About to return'
  RETURN
  END

EDIT

I'm testing on the examples that come with PSS/E. An interesting observation I made. Pausing the simulation one time-step before the tripping occurs fixes it.

Works

psspy.run(option=1, tpause=0.1)
psspy.run(tpause=0.145)
ierr = psspy.set_model_debug_output_flag(1)
psspy.run(tpause=1)

Crashes

psspy.run(option=1, tpause=0.1)
psspy.run(tpause=1)
edit retag flag offensive close merge delete

Comments

This seems like a lot of hassle just to simulate a branch trip. Why not just run the simulation using Python and then use the Python function psspy.dist_branch_trip()?

jfconroy gravatar imagejfconroy ( 2020-11-03 02:44:21 -0600 )edit

Because I want to learn how to make a dynamics model, and can use psspy already. I actually first attempted to use the FORTRAN `CALL DIST_BRANCH_TRIPAPI(IBUS, JBUS, ID, IERR)` in the model but that resulted in the same crash.

likethevegetable gravatar imagelikethevegetable ( 2020-11-03 06:28:20 -0600 )edit

This seems to be an unusual reason to use a dynamic model, but good luck with your endeavours nonetheless.

jfconroy gravatar imagejfconroy ( 2020-11-03 07:30:31 -0600 )edit

When someone wants to learn something, they start small and build their way up. That is what I am doing. The end goal is to design a cross trip scheme dynamics model. So the first step is being able to trip a branch within the dynamics model, not psspy. Ever heard of minimal working examples?

likethevegetable gravatar imagelikethevegetable ( 2020-11-03 08:03:48 -0600 )edit

The simulation time is available in dynamic simulation variable TIME so you can skip the call of DSRVAL and use TIME directly in the IF-statement. Also add logic to only process in mode 3 and to only call subroutine LINTRP one time. Now LINTRP will be called every time step after t=0.15.

perolofl gravatar imageperolofl ( 2020-11-03 10:41:20 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2022-05-09 20:49:08 -0600

haveityourwa gravatar image

updated 2022-05-09 20:51:30 -0600

Hey I am not sure if this is the cause of the crash, and I know that this is 2 years after you posted the question but I found that in order to Call certain commands within FORTRAN I needed to enter the PFMODE and then run it and then re enter the DSMODE, otherwise the simulation would crash before the next timestep. Like so

CALL PFMODE(IERR)
CALL BRANCH_CHNG(222, 333, '1', INTGAR, REALAR, IERR)
CALL DSMODE(FALSE, IERR)

This may be worth looking into for others who are having a similar issue. I think it is likely that anything that uses Chapter 2 Power Flow Data commands within the FORTRAN code would likely need to be called this way. I believe that the reason why it works when you run the simulation to the time at which the trip will occur is that, when it pauses the simulation it enters the PFMODE and when you start running to the next simulation time by using the RUN command it re enteres DSMODE, I need to confirm this in the documentation though.

edit flag offensive delete link more

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: 2020-11-02 08:07:50 -0600

Seen: 1,139 times

Last updated: May 09 '22