PSS/E User-written misc. model crashes

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

likethevegetable gravatar image

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

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 -0500 )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 -0500 )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 -0500 )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 -0500 )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 -0500 )edit