Ask Your Question
1

How can I get dynamic control on python?

asked 2013-09-09 02:16:05 -0500

newbee123 gravatar image

Hello.

I am trying to use python to control generator trip while fault is initialized and cleared. I want to trip the generators if the angle spread runs out of limit after the fault is cleared, but I cannot figure out how to do it on python.

I have been doing this simulation on pss/e interface with excel and matlab. But I think there must be a better way with python only.

https://psspy.org/psse-help-forum/question/1118/dynamic-simulations-using-python/

This article has been very interesting and helpful, but I want to learn more about dynamic control. How can I fetch angle spread and calculate the data without any help from matlab or excel?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-09-12 12:05:39 -0500

EBahr gravatar image

updated 2013-09-13 13:53:19 -0500

I think for this application it would be best to write a custom USRMDL in Fortran. This is probably more work if you don't know Fortran, but it has the benefit of running in real time and would probably be the most accurate simulation you could achieve.

Another option that I have never tested but may be worth looking at is to try using the CHNVAL function. Pause the simulation at any timestep you would like, check the channel values of your choice, then make any decisions based on that. From the API:

7.24 CHNVAL Use this API to return the present value of the simulation variable assigned to a specified output channel. Python syntax: ierr, rval = chnval(n)

You could also post process, like JervisW suggests.


UPDATE I am not exactly sure what 'angle spread' is, so here is some Fortran code of my interpretation. I assumed it meant measure the bus angle between two buses, if it reached a certain value, then trip a generator. This code trips a bus, not a generator. I am not very experienced with Fortran, and I don't really know PSS/e internal variables and calls that well, but the following code does trip a generator bus if the angle spread between two buses goes above specified threshold.

FORTRAN:

      SUBROUTINE TRIPGEN(II,JJ,KK,LL)
      INCLUDE 'COMON4.INS'
C     ICON(II)=BUS 1
C     ICON(II+1)=BUS 2
C     ICON(II+2)=BUS 1 INTERNAL ID
C     ICON(II+3)=BUS 2 INTERNAL ID
C     ICON(II+4)=GEN BUS TO TRIP
C     ICON(II+5)=GEN BUS INTERNAL ID
C     ICON(II+6)=RUN FLAG (1=RUN, 0=DON'T RUN)

C     CON(JJ)=SPREAD VALUE

      REAL*4 ANGA, ANGB
      INTEGER*4 IERR

C     INIT CODE HERE 
      IF ( MODE .EQ. 1  .OR.  KPAUSE .EQ. 2 ) THEN
        IF (IFLAG) THEN
          CALL BSSEQN(ICON(II+4),ICON(II+5),*7)
1         CALL BSSEQN(ICON(II),ICON(II+2),*8)
2         CALL BSSEQN(ICON(II+1),ICON(II+3),*9)

          GO TO 100

7         WRITE ( ITERM, * ) 'BUS NUMBER ', ICON(II+4), ' NOT FOUND'
          ICON(II+6)=0
          GO TO 1        
8         WRITE ( ITERM, * ) 'BUS NUMBER ', ICON(II), ' NOT FOUND'
          ICON(II+6)=0
          GO TO 2
9         WRITE ( ITERM, * ) 'BUS NUMBER ', ICON(II+1), ' NOT FOUND'
          ICON(II+6)=0
        ENDIF
10    ENDIF

C     ONLY CALCULATE IF SOLUTION CONVERGED
      IF (IFLAG) THEN
        GO TO 50
      ELSE
        GO TO 100
      ENDIF

C     RETURN IF ERROR IN BUS NUMBERS
50    IF (ICON(II+6) .EQ. 0) THEN
        GO TO 100
      ENDIF

C     RUN CODE HERE        
      IF (MODE .EQ. 2) THEN
        CALL BUSDAT(ICON(II),'ANGLED',ANGA,IERR)
        CALL BUSDAT(ICON(II+1),'ANGLED',ANGB,IERR)
        ANGSPRD = ABS(ANGA-ANGB)
C        WRITE ( ITERM, * ) 'ANGLE SPREAD IS = ', ANGSPRD !USED FOR DEBUG
        IF (ANGSPRD .GT. CON(JJ)) THEN
            CALL BSDSCN(ICON(II+4))
            WRITE ( ITERM, * ) 'ANGLE SPREAD REACHED TOLERANCE, BUS ', ICON(II+4), ' TRIPPED'
            ICON(II+6)=0
        ENDIF
      ENDIF

100   RETURN           
      END

And here would be ...

(more)
edit flag offensive delete link more

Comments

I like the `CHNVAL` suggestion, good for finding values that exceed absolute thresholds, you could also take a series of points to get a trend. How does the USRMDL work? Would you write one for each of the generators that need to trip, and monitor a remote angle somewhere?

JervisW gravatar imageJervisW ( 2013-09-12 19:53:18 -0500 )edit

The code I posted could be recalled for each generator/bus combo. You would just need to add a .dyr call for each one.

EBahr gravatar imageEBahr ( 2013-09-13 13:54:18 -0500 )edit

Thank you! Thank you very much! You are so AWESOME! and another thanks to JervisW! You're idea for CHNVAL function has enlightened me!

newbee123 gravatar imagenewbee123 ( 2013-09-15 21:38:42 -0500 )edit

Thanks for the clue. It will be very helpful.

Majo021 gravatar imageMajo021 ( 2022-03-22 13:18:05 -0500 )edit
0

answered 2013-09-11 00:50:27 -0500

JervisW gravatar image

I don't have a deep level of experience with Dynamics, so I hope that someone can chime in and correct me if I'm wrong.

  • You cannot check the angles with Python while PSS/E is actually running the simulation. That means you'll need to stop simulating for a little bit and check the .out file for the monitored machine angles.

I propose something like this:

  1. Run for a short period of time after clearing fault (e.g. 1 second)
  2. Check the .out file using dyntools for the machine angle spread
  3. Either take action by tripping generators or continuing the study depending on the outcome of #2

Feel free to adjust the timing above, I've only used 1 second as a guide.

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

Stats

Asked: 2013-09-09 02:16:05 -0500

Seen: 2,104 times

Last updated: Sep 13 '13