CFPRIME IPZMON                                                          IPZMON      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
      SUBROUTINE IPZMON(K,IDISW)                                        IPZMON      3
CD                                                                      IPZMON      4
CD  THIS SUBROUTINE CHECKS THE TRIPPING STATUS OF DISTANCE RELAYS.      IPZMON      5
CD                                                                      IPZMON      6
      INCLUDE 'PARX.INS'                                                IPZMON      7
      INCLUDE 'CNPT.INS'                                                IPZMON      8
      INCLUDE 'CNAUTO.INS'                                              IPZMON      9
      INCLUDE 'CNVOLT.INS'                                              IPZMON     10
      INCLUDE 'CNFLAG.INS'                                              IPZMON     11
      INCLUDE 'CNB4.INS'                                                IPZMON     12
      INCLUDE 'CNB19.INS'                                               IPZMON     13
      INCLUDE 'CNUNIT.INS'                                              IPZMON     14
C                                                                       IPZMON     15
      LOGICAL IDISW                                                     IPZMON     16
      CHARACTER*2 CID                                                   IPZMON     17
C                                                                       IPZMON     18
      COMPLEX VOLTK                                                     IPZMON     19
      DIMENSION VOLTX(2)                                                IPZMON     20
      EQUIVALENCE (VOLTK,VOLTX(1)),(VOLTX(1),VREAL),(VOLTX(2),VIMAG)    IPZMON     21
C                                                                       IPZMON     22
      LDEB=.FALSE.                                                      IPZMON     23
C                                                                       IPZMON     24
      ICD1 = IADATA(K+1)                                                IPZMON     25
      ICD3 = IADATA(K+5)                                                IPZMON     26
      ICD4 = IADATA(K+7)                                                IPZMON     27
C                                                                       IPZMON     28
C       IF ICD1 = 4  BOTH LOCAL AND ROMTED TRIPPING HAVE BEEN COMPLETED,IPZMON     29
C                    LOCAL BREAKER RECLOSED.                            IPZMON     30
C                                                                       IPZMON     31
      IF(ICD1 .EQ. 4)GOTO 2400                                          IPZMON     32
C * * *                                                                 IPZMON     33
C * * * IF ICD1 = 3, BOTH LOCAL AND REMOTE TRIPPING HAVE BEEN COMPLETED IPZMON     34
C * * *                                                                 IPZMON     35
      IF(ICD1 .EQ. 3) GO TO 2350                                        IPZMON     36
C * * *                                                                 IPZMON     37
C * * *  IF ICD1 = 2 LOCAL TRIPPING IS COMPLETE BUT TRANSFER            IPZMON     38
C * * *  IS STILL IN PROGRESS                                           IPZMON     39
C * * *                                                                 IPZMON     40
      IF(ICD1 .EQ. 2)GO TO 2300                                         IPZMON     41
C * * *                                                                 IPZMON     42
C * * * TEST FOR FIRST TEN CYCLE BYPASS                                 IPZMON     43
C * * *                                                                 IPZMON     44
C      IF(MRELAY .EQ. 1 .AND. TS .LE. 10.)GO TO 2400                    IPZMON     45
C * * *                                                                 IPZMON     46
C * * *  DISTANCE RELAYS                                                IPZMON     47
C * * *                                                                 IPZMON     48
      IBUS = IADATA(K+2)                                                IPZMON     49
      JBUS = IADATA(K+3)                                                IPZMON     50
      ITFK = IADATA(K+4)                                                IPZMON     51
      CALL UNPACK (CID, JJJ, ITFK)                                      IPZMON     52
C                                                                       IPZMON     53
      TTRIP = ADATA(K+12)                                               IPZMON     54
      BTRIP = ADATA(K+17)                                               IPZMON     55
C                                                                       IPZMON     56
      GIJ = ADATA(K+21)                                                 IPZMON     57
      BIJ = ADATA(K+22)                                                 IPZMON     58
      GIO = ADATA(K+23)                                                 IPZMON     59
      BIO = ADATA(K+24)                                                 IPZMON     60
      GJO = ADATA(K+25)                                                 IPZMON     61
      BJO = ADATA(K+26)                                                 IPZMON     62
C                                                                       IPZMON     63
      VOLTK=VOLT(IBUS)                                                  IPZMON     64
      EI = VREAL                                                        IPZMON     65
      FI = VIMAG                                                        IPZMON     66
      VOLTK=VOLT(JBUS)                                                  IPZMON     67
      EJ = VREAL                                                        IPZMON     68
      FJ = VIMAG                                                        IPZMON     69
C                                                                       IPZMON     70
      GT=GIJ+GIO                                                        IPZMON     71
      BT=BIJ+BIO                                                        IPZMON     72
      C1R=EI*GT-FI*BT                                                   IPZMON     73
      C1I=EI*BT+FI*GT                                                   IPZMON     74
      C2R=EJ*GIJ-FJ*BIJ                                                 IPZMON     75
      C2I=EJ*BIJ+FJ*GIJ                                                 IPZMON     76
      CTR=C1R-C2R                                                       IPZMON     77
      CTI=C1I-C2I                                                       IPZMON     78
      IF( ABS(CTR)+ ABS(CTI).EQ. 0.0) CTR=0.0001                        IPZMON     79
      ZR=(EI*CTR+FI*CTI)/(CTR*CTR+CTI*CTI)                              IPZMON     80
      ZI=(FI*CTR-EI*CTI)/(CTR*CTR+CTI*CTI)                              IPZMON     81
      BRAD2 = ADATA(K+16)                                               IPZMON     82
C * * *                                                                 IPZMON     83
C * * * BYPASS ZONE 2 LOGIC IF NO DATA (I.E., IF BRAD2 = 0.).           IPZMON     84
C * * *                                                                 IPZMON     85
      IF(BRAD2.EQ.0.) GO TO 1350                                        IPZMON     86
      BRC = ADATA(K+14)                                                 IPZMON     87
      BXC = ADATA(K+15)                                                 IPZMON     88
      ZBAPP2=(ZR-BRC)*(ZR-BRC)+(ZI-BXC)*(ZI-BXC)                        IPZMON     89
C      IF (ZBAPP2.LE.BRAD2) GO TO 1100                                  IPZMON     90
C      IF(BZDLY.LT.0.) GO TO 1350                                       IPZMON     91
C                                                                       IPZMON     92
C      BZDLY=-1.0                                                       IPZMON     93
C      ADATA(K+15) = BRAD2                                              IPZMON     94
C      ADATA(K+12) = BZDLY                                              IPZMON     95
C      GO TO 1350                                                       IPZMON     96
C 1100 IF (BZDLY .EQ. -1.0) GO TO 1300                                  IPZMON     97
C      ADATA(K+15) = BRAD2                                              IPZMON     98
C      ADATA(K+12) = BZDLY                                              IPZMON     99
C      IF(BZDLY.GT.TS+0.0001) GO TO 1250                                IPZMON    100
C                                                                       IPZMON    101
C      GOTO 1750                                                        IPZMON    102
C 1250 CONTINUE                                                         IPZMON    103
C      IF ((ICD3.EQ.1).AND.(BZDLY.LT.DNXRLY)) DNXRLY=BZDLY              IPZMON    104
C      GO TO 1350                                                       IPZMON    105
C 1300 BZDLY=BTRIP+TS                                                   IPZMON    106
C      IF(BTRIP.EQ.0.0) GO TO 1750                                      IPZMON    107
C      IF ((ICD3.EQ.1).AND.(BZDLY.LT.DNXRLY)) DNXRLY=BZDLY              IPZMON    108
C      ADATA(K+15) = BRAD2                                              IPZMON    109
C      ADATA(K+12) = BZDLY                                              IPZMON    110
C                                                                       IPZMON    111
C    THE OLD CODES ARE BEING REPLACED BY THE FOLLOWINGS                 IPZMON    112
C                                                                       IPZMON    113
      IF(ZBAPP2 .LE. BRAD2)THEN                                         IPZMON    114
        IF(ADATA(K+18).EQ.-1.0)THEN                                     IPZMON    115
         ADATA(K+18)=BTRIP+TS                                           IPZMON    116
         IF(BTRIP.EQ.0.0)GOTO 1750                                      IPZMON    117
        ELSE                                                            IPZMON    118
         IF(ADATA(K+18).LE.TS+0.0001)GOTO 1750                          IPZMON    119
        ENDIF                                                           IPZMON    120
      ELSE                                                              IPZMON    121
        IF(ADATA(K+18).GE.0.0)ADATA(K+18)=-1.0                          IPZMON    122
      ENDIF                                                             IPZMON    123
C                                                                       IPZMON    124
 1350 TRAD2 = ADATA(K+11)                                               IPZMON    125
C                                                                       IPZMON    126
C       BYPASS ZONE 1 LOGIC IF NO DATA (I.E., IF TRAD2 = 0.).           IPZMON    127
C                                                                       IPZMON    128
      IF(TRAD2.EQ.0.) GO TO 2400                                        IPZMON    129
      TRC = ADATA(K+9)                                                  IPZMON    130
      TXC = ADATA(K+10)                                                 IPZMON    131
      ZTAPP2=(ZR-TRC)*(ZR-TRC)+(ZI-TXC)*(ZI-TXC)                        IPZMON    132
C      IF (ZTAPP2.LE.TRAD2) GO TO 1450                                  IPZMON    133
C      IF(TZDLY.LT.0.) GO TO 1700                                       IPZMON    134
C      TZDLY=-1.0                                                       IPZMON    135
C      GO TO 1700                                                       IPZMON    136
C 1450 IF (TZDLY .EQ. -1.0) GO TO 1650                                  IPZMON    137
C      IF(TZDLY.GT.TS+0.0001) GO TO 1600                                IPZMON    138
C 1500 CONTINUE                                                         IPZMON    139
C      GO TO 1750                                                       IPZMON    140
C 1600 CONTINUE                                                         IPZMON    141
C      IF ((ICD3.EQ.1).AND.(TZDLY.LT.DNXRLY)) DNXRLY=TZDLY              IPZMON    142
C      GO TO 1700                                                       IPZMON    143
C 1650 TZDLY=TTRIP+TS                                                   IPZMON    144
C      IF(TTRIP.EQ.0.0) GO TO 1500                                      IPZMON    145
C      IF ((ICD3.EQ.1).AND.(TZDLY.LT.DNXRLY)) DNXRLY=TZDLY              IPZMON    146
C 1700 ADATA(K+10) = TRAD2                                              IPZMON    147
C      ADATA(K+12) = TZDLY                                              IPZMON    148
C      GO TO 2400                                                       IPZMON    149
C                                                                       IPZMON    150
C   THE OLD CODES ARE REPLACED BY THE FOLLOWINGS                        IPZMON    151
C                                                                       IPZMON    152
      IF(ZTAPP2 .LE. TRAD2)THEN                                         IPZMON    153
        IF(ADATA(K+13).EQ.-1.0)THEN                                     IPZMON    154
         ADATA(K+13)=TTRIP+TS                                           IPZMON    155
         IF(TTRIP.EQ.0.0)GOTO 1750                                      IPZMON    156
        ELSE                                                            IPZMON    157
         IF(ADATA(K+13).LE.TS+0.0001)GOTO 1750                          IPZMON    158
        ENDIF                                                           IPZMON    159
      ELSE                                                              IPZMON    160
        IF(ADATA(K+13).GE.0.0)ADATA(K+13)=-1.0                          IPZMON    161
        GOTO 2400                                                       IPZMON    162
      ENDIF                                                             IPZMON    163
C                                                                       IPZMON    164
 1750 ICD1=2                                                            IPZMON    165
      IADATA(K+1) = ICD1                                                IPZMON    166
                                                                        IPZMON    167
C                                                                       IPZMON    168
C   REMOTE RELAY ACTIVIATED, NOT ALL TRIPPED                            IPZMON    169
C                                                                       IPZMON    170
      IF(ICD4.NE.0)THEN                                                 IPZMON    171
        KADD=K+27                                                       IPZMON    172
        CALL RTIMER(KADD,ICD4)                                          IPZMON    173
      ENDIF                                                             IPZMON    174
C                                                                       IPZMON    175
      IF(ICD3 .EQ. 2) GO TO 2300                                        IPZMON    176
C                                                                       IPZMON    177
C    GET THE LINE INFORMATION AND WRITE INTO IU12                       IPZMON    178
C                                                                       IPZMON    179
       NJSELI=IADATA(K+27)                                              IPZMON    180
C                                                                       IPZMON    181
       IF(IASWX.EQ.0)THEN                                               IPZMON    182
        WRITE(ISWFA,4100)TS                                             IPZMON    183
 4100   FORMAT(F10.5)                                                   IPZMON    184
        NAWR=NAWR+1                                                     IPZMON    185
        IASWX=1                                                         IPZMON    186
       ENDIF                                                            IPZMON    187
C                                                                       IPZMON    188
       IF(NJSELI.NE.0)THEN                                              IPZMON    189
        WRITE(ISWFA,4200)IBUS,JBUS,CID                                  IPZMON    190
 4200   FORMAT('DPIA',2I5,1X,A2)                                        IPZMON    191
       ELSE                                                             IPZMON    192
        WRITE(ISWFA,4300)IBUS,JBUS,CID                                  IPZMON    193
 4300   FORMAT('DLIA',2I5,1X,A2)                                        IPZMON    194
       ENDIF                                                            IPZMON    195
C                                                                       IPZMON    196
       NAWR=NAWR+1                                                      IPZMON    197
C                                                                       IPZMON    198
C   ACTIVIATE THE RECLOSING TIMER                                       IPZMON    199
C                                                                       IPZMON    200
      IF(ADATA(K+20).EQ.-1.0)ADATA(K+20)=ADATA(K+19)+TS                 IPZMON    201
C                                                                       IPZMON    202
C * * *                                                                 IPZMON    203
C * * * ICD4 IS THE NUMBER OF REMOTE RELAYS ATTACHED TO THIS LOCAL      IPZMON    204
C * * * RELAY.  TTIMR1 IS THE TRANSFER TRIP TIMER.                      IPZMON    205
C * * *                                                                 IPZMON    206
 2300 IF(ICD4.EQ.0) GO TO 2350                                          IPZMON    207
C                                                                       IPZMON    208
C * * *                                                                 IPZMON    209
C * * * PROCESS REMOTE RELAY LOGIC                                      IPZMON    210
C * * *                                                                 IPZMON    211
        IF(IADATA(K+1).EQ.2)THEN                                        IPZMON    212
          KADD=K+27                                                     IPZMON    213
          KBUS=K                                                        IPZMON    214
          IPOINT=8                                                      IPZMON    215
          CALL RETRIP(KADD,KBUS,ICD4,IPOINT)                            IPZMON    216
          IF(IADATA(KBUS+IPOINT).EQ.-1)THEN                             IPZMON    217
           ICD1=3                                                       IPZMON    218
           IF(ICD3.NE.1)ICD1=4                                          IPZMON    219
           IADATA(K+1) = ICD1                                           IPZMON    220
          ENDIF                                                         IPZMON    221
        ENDIF                                                           IPZMON    222
C                                                                       IPZMON    223
 2350 CONTINUE                                                          IPZMON    224
C                                                                       IPZMON    225
C    CHECK THE RECLOSING TIMER                                          IPZMON    226
C                                                                       IPZMON    227
      IF(ADATA(K+19).EQ.0.0)GOTO 2400                                   IPZMON    228
C                                                                       IPZMON    229
      IF(ICD3.EQ.1 .AND. ADATA(K+20).LE.TS)THEN                         IPZMON    230
C                                                                       IPZMON    231
C    GET THE LINE INFORMATION AND WRITE INTO IU12                       IPZMON    232
C                                                                       IPZMON    233
        NJSELI=IADATA(K+27)                                             IPZMON    234
C                                                                       IPZMON    235
        IF(IASWX.EQ.0)THEN                                              IPZMON    236
         WRITE(ISWFA,4100)TS                                            IPZMON    237
         NAWR=NAWR+1                                                    IPZMON    238
         IASWX=1                                                        IPZMON    239
        ENDIF                                                           IPZMON    240
C                                                                       IPZMON    241
        IF(NJSELI.NE.0)THEN                                             IPZMON    242
         WRITE(ISWFA,4400)IBUS,JBUS,CID                                 IPZMON    243
 4400    FORMAT('RPIA',2I5,1X,A2)                                       IPZMON    244
        ELSE                                                            IPZMON    245
         WRITE(ISWFA,4500)IBUS,JBUS,CID                                 IPZMON    246
 4500    FORMAT('RLIA',2I5,1X,A2)                                       IPZMON    247
        ENDIF                                                           IPZMON    248
C                                                                       IPZMON    249
        NAWR=NAWR+1                                                     IPZMON    250
C                                                                       IPZMON    251
C    RESET THE TRIP STATUS                                              IPZMON    252
C                                                                       IPZMON    253
       IADATA(K+1)=4                                                    IPZMON    254
       ADATA(K+20)=-1.0                                                 IPZMON    255
      ENDIF                                                             IPZMON    256
C                                                                       IPZMON    257
 2400 CONTINUE                                                          IPZMON    258
      RETURN                                                            IPZMON    259
      END                                                               IPZMON    260
                                                                        IPZMON    261
