CFPRIME OCRMON                                                          OCRMON      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
C                                                                       OCRMON      3
       SUBROUTINE OCRMON (DELT)                                         OCRMON      4
CD                                                                      OCRMON      5
CD  This subroutine monitors the operation of overcurrent relays        OCRMON      6
CD  during the time simulation.                                         OCRMON      7
CD                                                                      OCRMON      8
CD  Routine Inputs:                                                     OCRMON      9
CD  DELT   : Integration step size in seconds                           OCRMON     10
CD                                                                      OCRMON     11
C---------------------------------------------------------------------  OCRMON     12
C                                                        Include files  OCRMON     13
C                                                                       OCRMON     14
      INCLUDE 'PARX.INS'                                                OCRMON     15
      INCLUDE 'CNPT.INS'                                                OCRMON     16
      INCLUDE 'CNAUTO.INS'                                              OCRMON     17
      INCLUDE 'CNVOLT.INS'                                              OCRMON     18
      INCLUDE 'CNFLAG.INS'                                              OCRMON     19
      INCLUDE 'CNB4.INS'                                                OCRMON     20
      INCLUDE 'CNB19.INS'                                               OCRMON     21
      INCLUDE 'CNUNIT.INS'                                              OCRMON     22
      INCLUDE 'CNSTN.INS'                                               OCRMON     23
      INCLUDE 'CNIPTR.INS'                                              OCRMON     24
C---------------------------------------------------------------------  OCRMON     25
C                                                      Local Variables  OCRMON     26
C                                                                       OCRMON     27
       REAL          TT(2)                                              OCRMON     28
       COMPLEX       PQ                                                 OCRMON     29
       CHARACTER*2   CID                                                OCRMON     30
C                                                                       OCRMON     31
       EQUIVALENCE (PQ, TT(1), PP), (TT(2), QQ)                         OCRMON     32
C---------------------------------------------------------------------  OCRMON     33
C                                                       Initialization  OCRMON     34
      LDEB=.FALSE.                                                      OCRMON     35
C                                                                       OCRMON     36
C---------------------------------------------------------------------  OCRMON     37
C                                          Process one relay at a time  OCRMON     38
C                                                                       OCRMON     39
       DO 5000 II = LOCRE, NOCRE                                        OCRMON     40
         JJ = IDATPT(II)                                                OCRMON     41
         KK = JJ + 28                                                   OCRMON     42
         IRLSTA = IADATA(JJ + 18)                                       OCRMON     43
C                                Local and remote tripping is complete  OCRMON     44
C                                                   Process next relay  OCRMON     45
         IF (IRLSTA .EQ. 4) GOTO 5000                                   OCRMON     46
C                                                                       OCRMON     47
         NRMRLY = IADATA(JJ + 4)                                        OCRMON     48
C                                             Local branch has tripped  OCRMON     49
C                                       Remote tripping is in progress  OCRMON     50
         IF (IRLSTA .EQ. 3) GOTO 4000                                   OCRMON     51
C                                                                       OCRMON     52
         IBUS = IADATA(JJ + 1)                                          OCRMON     53
         JBUS = IADATA(JJ + 2)                                          OCRMON     54
         NLFI = NOLD(IBUS)                                              OCRMON     55
         NLFJ = NOLD(JBUS)                                              OCRMON     56
         NI3 = IBUS * 3                                                 OCRMON     57
         NJ3 = JBUS * 3                                                 OCRMON     58
         ITFK = IADATA(JJ + 3)                                          OCRMON     59
         CALL UNPACK (CID, JJJ, ITFK)                                   OCRMON     60
C                                              Breaker timer is active  OCRMON     61
         IF (IRLSTA .EQ. 2) GOTO 4500                                   OCRMON     62
C                                               Compute branch current  OCRMON     63
         CUROLD = ADATA(JJ + 28)                                        OCRMON     64
         PQ = VOLT(IBUS)                                                OCRMON     65
         EIR = PP                                                       OCRMON     66
         EII = QQ                                                       OCRMON     67
         PQ = VOLT(JBUS)                                                OCRMON     68
         EJR = PP                                                       OCRMON     69
         EJI = QQ                                                       OCRMON     70
         GIJ = ADATA(JJ + 23)                                           OCRMON     71
         BIJ = ADATA(JJ + 24)                                           OCRMON     72
         GIO = ADATA(JJ + 25)                                           OCRMON     73
         BIO = ADATA(JJ + 26)                                           OCRMON     74
         GT = GIJ + GIO                                                 OCRMON     75
         BT = BIJ + BIO                                                 OCRMON     76
         C1R = EIR * GT - EII * BT                                      OCRMON     77
         C1I = EIR * BT + EII * GT                                      OCRMON     78
         C2R = EJR * GIJ - EJI * BIJ                                    OCRMON     79
         C2I = EJR * BIJ + EJI * GIJ                                    OCRMON     80
         CTR = C1R - C2R                                                OCRMON     81
         CTI = C1I - C2I                                                OCRMON     82
         CURR = SQRT (CTR * CTR + CTI * CTI)                            OCRMON     83
         ADATA(JJ + 28) = CURR                                          OCRMON     84
C---------------------------------------------------------------------  OCRMON     85
C                                             Relay is in standby mode  OCRMON     86
C                                                                       OCRMON     87
         IF (IADATA(JJ + 18) .EQ. 0) THEN                               OCRMON     88
C                                    Set to operation mode if required  OCRMON     89
           IF (ADATA(JJ + 28) .GT. ADATA(JJ + 5)) THEN                  OCRMON     90
             IADATA(JJ + 18) = 1                                        OCRMON     91
             WRITE (IU6, 7000) NLFI, INAME(NI3 - 2), INAME(NI3 - 1),    OCRMON     92
     +                         INAME(NI3), NLFJ, INAME(NJ3 - 2),        OCRMON     93
     +                         INAME(NJ3 - 1), INAME(NJ3), CID          OCRMON     94
             WRITE (IU6, 7100) TS                                       OCRMON     95
           ENDIF                                                        OCRMON     96
C                                                   Process next relay  OCRMON     97
           GOTO 5000                                                    OCRMON     98
         ENDIF                                                          OCRMON     99
C---------------------------------------------------------------------  OCRMON    100
C                                           Relay is in operating mode  OCRMON    101
C                                                                       OCRMON    102
         CRATIO = CUROLD / ADATA(JJ + 5)                                OCRMON    103
         IF (CUROLD .LT. ADATA (JJ + 5)) THEN                           OCRMON    104
           IF (ADATA(JJ + 6) .GT. 0.0) THEN                             OCRMON    105
             ADATA(JJ + 19) = ADATA(JJ + 19) - DELT *                   OCRMON    106
     +                        (1.0 - CRATIO * CRATIO) / ADATA(JJ + 6)   OCRMON    107
             IF (ADATA(JJ + 19) .GT. 0.0) GOTO 5000                     OCRMON    108
           ENDIF                                                        OCRMON    109
C                                                Reset to standby mode  OCRMON    110
           ADATA(JJ + 18) = 0                                           OCRMON    111
           ADATA(JJ + 19) = 0                                           OCRMON    112
           WRITE (IU6, 7000) NLFI, INAME(NI3 - 2), INAME(NI3 - 1),      OCRMON    113
     +                       INAME(NI3), NLFJ, INAME(NJ3 - 2),          OCRMON    114
     +                       INAME(NJ3 - 1), INAME(NJ3), CID            OCRMON    115
           WRITE (IU6, 7200) TS                                         OCRMON    116
           GOTO 5000                                                    OCRMON    117
C                                                                       OCRMON    118
         ELSE                                                           OCRMON    119
C                                          Compute time to close relay  OCRMON    120
           NPOINT = IADATA(JJ + 22)                                     OCRMON    121
C                                                                       OCRMON    122
2100       IOFFSE = 5                                                   OCRMON    123
           DO 2200 IJ = 1, NPOINT                                       OCRMON    124
             IOFFSE = IOFFSE + 2                                        OCRMON    125
             IF (CRATIO .LT. ADATA(JJ + IOFFSE)) THEN                   OCRMON    126
               ISECT = IJ                                               OCRMON    127
               GOTO 2300                                                OCRMON    128
             ENDIF                                                      OCRMON    129
2200       CONTINUE                                                     OCRMON    130
           ISECT = NPOINT                                               OCRMON    131
C                                                        Interpolation  OCRMON    132
2300       IF (ISECT .EQ. 1) THEN                                       OCRMON    133
             SLOPE = (3600.0 - ADATA(JJ + 8)) /                         OCRMON    134
     +               (1.0 - ADATA (JJ + 7))                             OCRMON    135
             TCLOSE = 3600.0 - (1.0 - CRATIO) * SLOPE                   OCRMON    136
           ELSE IF (ISECT .EQ. NPOINT) THEN                             OCRMON    137
             TCLOSE = ADATA(JJ + 4 + NPOINT * 2)                        OCRMON    138
           ELSE                                                         OCRMON    139
             IPTR = JJ + 2 + ISECT * 2                                  OCRMON    140
             SLOPE = (ADATA(IPTR + 2) - ADATA(IPTR + 4)) /              OCRMON    141
     +               (ADATA(IPTR + 1) - ADATA(IPTR + 3))                OCRMON    142
             TCLOSE = ADATA(IPTR + 2) -                                 OCRMON    143
     +                (ADATA(IPTR + 1) - CRATIO) * SLOPE                OCRMON    144
           ENDIF                                                        OCRMON    145
C                                                            Integrate  OCRMON    146
           ADATA(JJ + 19) = ADATA(JJ + 19) + DELT / TCLOSE              OCRMON    147
C                                               Start breaker timer or  OCRMON    148
C                                               Process the next relay  OCRMON    149
           IF (ADATA(JJ + 19) .LT. 1.0) GOTO 5000                       OCRMON    150
C                                                                       OCRMON    151
           ADATA(JJ + 19) = 1.0                                         OCRMON    152
           IADATA(JJ + 18) = 2                                          OCRMON    153
           WRITE (IU6, 7000) NLFI, INAME(NI3 - 2), INAME(NI3 - 1),      OCRMON    154
     +                       INAME(NI3), NLFJ, INAME(NJ3 - 2),          OCRMON    155
     +                       INAME(NJ3 - 1), INAME(NJ3), CID            OCRMON    156
           WRITE (IU6, 7300) TS                                         OCRMON    157
C                                                    Set the times for  OCRMON    158
C                                            local and remote tripping  OCRMON    159
           ADATA(JJ + 20) = TS + ADATA(JJ + 17) - 0.5 * DELT            OCRMON    160
           IF (NRMRLY .NE. 0) CALL RTIMER (KK, NRMRLY)                  OCRMON    161
C                                                                       OCRMON    162
         ENDIF                                                          OCRMON    163
C---------------------------------------------------------------------  OCRMON    164
C                                         Update remote breaker timers  OCRMON    165
C                            Check for time out of local breaker timer  OCRMON    166
C                                   and trip local breaker if required  OCRMON    167
C                                                                       OCRMON    168
4500     IF (TS .LT. ADATA(JJ + 20)) GOTO 5000                          OCRMON    169
C                                                                       OCRMON    170
         IF (IASWX .EQ. 0) THEN                                         OCRMON    171
           WRITE (ISWFA, 6100) TS                                       OCRMON    172
           NAWR = NAWR + 1                                              OCRMON    173
           IASWX = 1                                                    OCRMON    174
         ENDIF                                                          OCRMON    175
C                                                                       OCRMON    176
         IADATA(JJ + 18) = 3                                            OCRMON    177
         WRITE (IU6, 7000) NLFI, INAME(NI3 - 2), INAME(NI3 - 1),        OCRMON    178
     +                     INAME(NI3), NLFJ, INAME(NJ3 - 2),            OCRMON    179
     +                     INAME(NJ3 - 1), INAME(NJ3), CID              OCRMON    180
         WRITE (IU6, 7400) TS                                           OCRMON    181
         NJSELI = IADATA(JJ + 27)                                       OCRMON    182
         IF (NJSELI .NE. 0) THEN                                        OCRMON    183
           WRITE (ISWFA, 6200) IBUS, JBUS, CID                          OCRMON    184
         ELSE                                                           OCRMON    185
           WRITE (ISWFA, 6300) IBUS, JBUS, CID                          OCRMON    186
         ENDIF                                                          OCRMON    187
         NAWR = NAWR + 1                                                OCRMON    188
C---------------------------------------------------------------------  OCRMON    189
C                                     Check timers for remote tripping  OCRMON    190
C                                                                       OCRMON    191
4000     IF (NRMRLY .NE. 0) THEN                                        OCRMON    192
C                                                                       OCRMON    193
           IPOINT = 21                                                  OCRMON    194
           CALL RETRIP (KK, JJ, NRMRLY, IPOINT)                         OCRMON    195
           IF (IADATA(JJ + 21) .EQ. -1) IADATA(JJ + 18) = 4             OCRMON    196
C                                                                       OCRMON    197
         ENDIF                                                          OCRMON    198
C                                                                       OCRMON    199
5000   CONTINUE                                                         OCRMON    200
C---------------------------------------------------------------------  OCRMON    201
C                                                 Formats and messages  OCRMON    202
C                                                                       OCRMON    203
6100   FORMAT (F10.5)                                                   OCRMON    204
6200   FORMAT ('DPIA', 2I5, 1X, A2)                                     OCRMON    205
6300   FORMAT ('DLIA', 2I5, 1X, A2)                                     OCRMON    206
C                                                                       OCRMON    207
7000   FORMAT (' *** OCRE CIRCUIT FROM: ', I6, 1X, 3A4, '  TO: ',       OCRMON    208
     +         I6, 1X, 3A4, '  ID: ', A2)                               OCRMON    209
7100   FORMAT ('     SET TO OPERATING MODE AT TIME = ', F8.4)           OCRMON    210
7200   FORMAT ('     SET TO STANDBY MODE AT TIME = ', F8.4)             OCRMON    211
7300   FORMAT ('     BREAKER TIMER STARTED AT TIME = ', F8.4)           OCRMON    212
7400   FORMAT ('     TRIPPED AT TIME = ', F8.4)                         OCRMON    213
C---------------------------------------------------------------------  OCRMON    214
       RETURN                                                           OCRMON    215
       END                                                              OCRMON    216
