CFPRIME RCPINT                                                          RCPINT      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 RCPINT(IEBK)                                           RCPINT      3
CD                                                                      RCPINT      4
CD   THIS SUBROUTINE INITIALIZES THE RATE OF CHANGE OF POWER RELAY.     RCPINT      5
CD   IT ALSO SEARCHES THE REMOTE RELAY TABLES TO FIND THE INDICES OF    RCPINT      6
CD   THE REMOTE RELAYS FOR THIS RELAY.                                  RCPINT      7
CD                                                                      RCPINT      8
CD   ROUTINE OUTPUT:                                                    RCPINT      9
CD                                                                      RCPINT     10
CD   IEBK =0 NO ERROR                                                   RCPINT     11
CD   IEBK =1 WHEN                                                       RCPINT     12
CD   LINE OF THE RATE OF CHANGE OF POWER RELAY IS NOT FOUND             RCPINT     13
CD                                                                      RCPINT     14
CD   STEPS OF INITIALIZATION ARE:                                       RCPINT     15
CD                                                                      RCPINT     16
CD                                                                      RCPINT     17
CD     LRCRPA          Starting position of IDATPT array  of RCPR relay RCPINT     18
CD                     scheme, LRCRPA is in the common labelled PT of   RCPINT     19
CD                     include file CNPT.                               RCPINT     20
CD                                                                      RCPINT     21
CD     NRCPRA          Finishing position of IDATPT array of RCPR relay RCPINT     22
CD                     scheme, NRCPRA is in common labelled AUTO of     RCPINT     23
CD                     include file CNAUTO.                             RCPINT     24
CD                                                                      RCPINT     25
CD     let k = k-th RCPR RELAY                                          RCPINT     26
CD                                                                      RCPINT     27
CD     N = IDATPT(k)    IDATPT is the array that stores the start       RCPINT     28
CD                      position of the K-TH RCPR relay scheme data     RCPINT     29
CD                                                                      RCPINT     30
CD       IADATA(N+1)=ICD1R1  LOCAL RELAY TRIP STATUS                    RCPINT     31
CD                           = 1 RELAY NOT TRIP                         RCPINT     32
CD                           = 2 LOCAL RELAY TRIPPED, REMOTE RELAY IN   RCPINT     33
CD                               PROGRESS                               RCPINT     34
CD                           = 3 BOTH LOCAL AND REMOTE RELAY TRIPPED.   RCPINT     35
CD                           = 4 BOTH LOCAL AND REMOTE RELAY            RCPINT     36
CD                               TRIPPED,LOCAL LINE BRK RECLOSED.       RCPINT     37
CD                                                                      RCPINT     38
CD       IADATA(N+2)=IBUSR1  LEFT HAND SET BUS NO.                      RCPINT     39
CD                                                                      RCPINT     40
CD       IADATA(N+3)=JBUSR1  RIGHT HAND SIDE BUS NO.                    RCPINT     41
CD                                                                      RCPINT     42
CD       IADATA(N+4)=IPARR1  PARALLEL IDENTIFICATION FOR THE LINE       RCPINT     43
CD                                                                      RCPINT     44
CD       IADATA(N+5)=ICD2R1  TYPE OF RELAY MODEL                        RCPINT     45
CD                           = 5  R1 MODEL                              RCPINT     46
CD                           = 6  R2 MODEL                              RCPINT     47
CD                           = 7  R3 MODEL                              RCPINT     48
CD                                                                      RCPINT     49
CD       IADATA(N+6)=ICD3R1  =1 USE SIGNAL TO TRIP THE LINE             RCPINT     50
CD                           =2 DO NOT TRIP THE LINE, SIGNAL IS         RCPINT     51
CD                              USED FOR REMOTE TRIPPING.               RCPINT     52
CD                                                                      RCPINT     53
CD       IADATA(N+7)=ICD4R1   NO. OF REMOTE RELAY ATTACHED TO THE LOCAL RCPINT     54
CD                            RELAY                                     RCPINT     55
CD                                                                      RCPINT     56
CD       ADATA(N+8)=RBR1      R1 & R2 MODELS: RATE SETTLING (MW/SEC)    RCPINT     57
CD                 =RMAXR1    R3 MODEL: UPPER RATE LIMIT       (MW/SEC) RCPINT     58
CD                                                                      RCPINT     59
CD       ADATA(N+9)=RMINR1    R1 & R2 MODELS: UPPER RATE LIMIT (MW/SEC) RCPINT     60
CD                            LOWER = - UPPER                           RCPINT     61
CD                            R3 MODEL: LOWER RATE LIMIT (MW/SEC)       RCPINT     62
CD                                                                      RCPINT     63
CD       ADATA(N+10)=RSR1     RATE SETTING (COMMON TO ALL MODELS)       RCPINT     64
CD                            (MW/SEC)                                  RCPINT     65
CD                                                                      RCPINT     66
CD       ADATA(N+11)=BIASR1   FOR R1 & R2 MODELS: BAIS SETTING          RCPINT     67
CD                            FOR R3 MODEL: LEAVE BLANK                 RCPINT     68
CD                                                                      RCPINT     69
CD       ADATA(N+12)=PSR1     POWER LEVEL SETTING (MW)                  RCPINT     70
CD                                                                      RCPINT     71
CD       ADATA(N+13)=TCR1     INTEGRATOR TIME CONSTANT (SEC)            RCPINT     72
CD                                                                      RCPINT     73
CD       ADATA(N+14)=TDR1     FOR R1 & R2 MODELS: BLOCK RATE TIME       RCPINT     74
CD                            DELAY (CYCLES)                            RCPINT     75
CD                  =TER1     FOR R3 MODEL: ENABLE HOLD TIME DELAY      RCPINT     76
CD                            (CYCLES)                                  RCPINT     77
CD                                                                      RCPINT     78
CD       ADATA(N+15)=THR1     FOR R1 & R2 MODEL: BLANK                  RCPINT     79
CD                            FOR R3 MODEL: AUX RELAY TIME DELAY        RCPINT     80
CD                            (CYCLES)                                  RCPINT     81
CD                                                                      RCPINT     82
CD       ADATA(N+16)=T1R1     TIMER FOR LOCAL RELAY                     RCPINT     83
CD                                                                      RCPINT     84
CD       ADATA(N+17)=T2R1     TIMER FOR LOCAL RELAY                     RCPINT     85
CD                                                                      RCPINT     86
CD       IADATA(N+18)         REMOTE RELAY TRIP STATUS                  RCPINT     87
CD                                                                      RCPINT     88
CD       ADATA(N+19)=PIODR1   PAST VALUE OF TIE LINE POWER              RCPINT     89
CD                                                                      RCPINT     90
CD       ADATA(N+20)=PIIR1    PAST VALUE OF BLOCK 'A' OUTPUT            RCPINT     91
CD                                                                      RCPINT     92
CD       ADATA(N+21)=PIIIR1   PAST VALUE OF BLOCK 'B' OUTPUT            RCPINT     93
CD                                                                      RCPINT     94
CD       ADATA(N+22)=RIR1     OUTPUT OF THE RS BLOCK                    RCPINT     95
CD                                                                      RCPINT     96
CD       ADATA(N+23)=RIIR1    OUTPUT OF THE TC BLOCK FOR R1 & R2 MODELS RCPINT     97
CD                  =QOLDR1   OUTPUT OF THE TC BLOCK FOR R3 MODEL       RCPINT     98
CD                                                                      RCPINT     99
CD       ADATA(N+24)=TRCLSE   TIME DELAY FOR RECLOSING                  RCPINT    100
CD                                                                      RCPINT    101
CD       ADATA(N+25)=RTIMER   TIMER FOR RECLOSING                       RCPINT    102
CD                                                                      RCPINT    103
CD                                                                      RCPINT    104
CD                                                                      RCPINT    105
CD    LINE PARAMETER IN PI-CIRCUIT FORM                                 RCPINT    106
CD                                                                      RCPINT    107
CD       ADATA(N+26)=GIJR1    GKM                                       RCPINT    108
CD       ADATA(N+27)=BIJR1    BKM                                       RCPINT    109
CD       ADATA(N+28)=GIOR1    GK1                                       RCPINT    110
CD       ADATA(N+29)=BIOR1    BK1                                       RCPINT    111
CD       ADATA(N+30)=GJOR1    GK2                                       RCPINT    112
CD       ADATA(N+31)=BJOR1    BK2                                       RCPINT    113
CD       IADATA(N+32)=NJSELI  FLAG FOR THE LINE TYPE                    RCPINT    114
CD                                                                      RCPINT    115
CD                                                                      RCPINT    116
CD       ADATA(N+33)=TAR1     TIME CONSTANT FOR 'A' BLOCK               RCPINT    117
CD       ADATA(N+34)=TBR1     TIME CONSTANT FOR 'B' BLOCK               RCPINT    118
CD                                                                      RCPINT    119
C                                                                       RCPINT    120
      INCLUDE 'PARX.INS'                                                RCPINT    121
      INCLUDE 'CNPT.INS'                                                RCPINT    122
      INCLUDE 'CNAUTO.INS'                                              RCPINT    123
      INCLUDE 'CNNNEW.INS'                                              RCPINT    124
      INCLUDE 'CNSTN.INS'                                               RCPINT    125
      INCLUDE 'CNB19.INS'                                               RCPINT    126
      INCLUDE 'CNUNIT.INS'                                              RCPINT    127
      INCLUDE 'CNLFDA.INS'                                              RCPINT    128
      INCLUDE 'CNVOLT.INS'                                              RCPINT    129
      INCLUDE 'CNSELI.INS'                                              RCPINT    130
      INCLUDE 'CNMSG.INS'                                               RCPINT    131
C                                                                       RCPINT    132
      CHARACTER*2 CID,CKK                                               RCPINT    133
      INTEGER*4 ICID                                                    RCPINT    134
      EQUIVALENCE (ICID,CID)                                            RCPINT    135
C                                                                       RCPINT    136
      COMPLEX VOLTK                                                     RCPINT    137
      DIMENSION VOLTX(2)                                                RCPINT    138
      EQUIVALENCE (VOLTK,VOLTX(1)),(VOLTX(1),VREAL),(VOLTX(2),VIMAG)    RCPINT    139
CD                                                                      RCPINT    140
CD 1. REORDER BUS NUMBERS IN SERIES CAPACITOR TABLE                     RCPINT    141
CD                                                                      RCPINT    142
      IEBK=0                                                            RCPINT    143
      DO 1000 I=LRCPRA,NRCPRA                                           RCPINT    144
C                                                                       RCPINT    145
      K=IDATPT(I)                                                       RCPINT    146
      IF(IADATA(K+1).GT.9)GOTO 1000                                     RCPINT    147
C                                                                       RCPINT    148
      NLFI=IADATA(K+2)                                                  RCPINT    149
      NLFJ=IADATA(K+3)                                                  RCPINT    150
      NPROGI=NNEW(NLFI)                                                 RCPINT    151
      NPROGJ=NNEW(NLFJ)                                                 RCPINT    152
      IADATA(K+1)=1                                                     RCPINT    153
      IADATA(K+2)=NPROGI                                                RCPINT    154
      IADATA(K+3)=NPROGJ                                                RCPINT    155
      NI3=NPROGI*3                                                      RCPINT    156
      NJ3=NPROGJ*3                                                      RCPINT    157
      ICID=IADATA(K+4)                                                  RCPINT    158
      CALL UNPACK(CID,JJJ,ICID)                                         RCPINT    159
      IDRRR=IADATA(K+7)                                                 RCPINT    160
C                                                                       RCPINT    161
      CALL LOLINE(NPROGI,NPROGJ,CID,JNL)                                RCPINT    162
      IF(JNL.EQ.0)THEN                                                  RCPINT    163
       IEBK=1                                                           RCPINT    164
       WRITE(MSG(1),3220) NLFI,INAME(NI3-2),INAME(NI3-1),INAME(NI3)     RCPINT    165
     &,NLFJ,INAME(NJ3-2),INAME(NJ3-1),INAME(NJ3),CID                    RCPINT    166
       CALL PRTMSG(1)                                                   RCPINT    167
       GOTO 1000                                                        RCPINT    168
      ELSE                                                              RCPINT    169
CD                                                                      RCPINT    170
CD 2. LOAD THE LINE PARAMETER INTO ADDAT ARRAY                          RCPINT    171
CD                                                                      RCPINT    172
       JNL5=IABS(JNL)                                                   RCPINT    173
       JNL5=JNL5*5                                                      RCPINT    174
       ITFK=LFTB(JNL5-4)                                                RCPINT    175
       CALL UNPACK(CKK,NJSELI,ITFK)                                     RCPINT    176
       IADATA(K+32)=NJSELI                                              RCPINT    177
       IF(NJSELI.NE.0)THEN                                              RCPINT    178
        ADATA(K+26)=EQPI(1,NJSELI)                                      RCPINT    179
        ADATA(K+27)=-EQPI(2,NJSELI)                                     RCPINT    180
        ADATA(K+28)=EQPI(3,NJSELI)                                      RCPINT    181
        ADATA(K+29)=EQPI(4,NJSELI)                                      RCPINT    182
        ADATA(K+30)=EQPI(5,NJSELI)                                      RCPINT    183
        ADATA(K+31)=EQPI(6,NJSELI)                                      RCPINT    184
       ELSE                                                             RCPINT    185
        ADATA(K+26)=GA(JNL5-2)                                          RCPINT    186
        ADATA(K+27)=-BA(JNL5-1)                                         RCPINT    187
        ADATA(K+28)=0.                                                  RCPINT    188
        ADATA(K+29)=BCHG(JNL5)/2.                                       RCPINT    189
        ADATA(K+30)=0.                                                  RCPINT    190
        ADATA(K+31)=BCHG(JNL5)/2.                                       RCPINT    191
       ENDIF                                                            RCPINT    192
      ENDIF                                                             RCPINT    193
CD                                                                      RCPINT    194
CD 3. CONVERT CYCLE INTO SECOND ACCORDING TO FREQUENCY BASE.            RCPINT    195
CD                                                                      RCPINT    196
      ADATA(K+14)=ADATA(K+14)/FQBASE                                    RCPINT    197
      ADATA(K+15)=ADATA(K+15)/FQBASE                                    RCPINT    198
      ADATA(K+24)=ADATA(K+24)/FQBASE                                    RCPINT    199
CD                                                                      RCPINT    200
CD 4. CONVERT THE RATE AND POWER SETTING TO PU                          RCPINT    201
CD                                                                      RCPINT    202
      ADATA(K+8)=ADATA(K+8)/BASPC                                       RCPINT    203
      ADATA(K+9)=ADATA(K+9)/BASPC                                       RCPINT    204
      ADATA(K+10)=ADATA(K+10)/BASPC                                     RCPINT    205
      ADATA(K+11)=ADATA(K+11)/BASPC                                     RCPINT    206
      ADATA(K+12)=ADATA(K+12)/BASPC                                     RCPINT    207
CD                                                                      RCPINT    208
CD 5. CALCULATE THE POWER FLOW IN THE RELAYED LINE                      RCPINT    209
CD                                                                      RCPINT    210
      GIJ = ADATA(K+26)                                                 RCPINT    211
      BIJ = ADATA(K+27)                                                 RCPINT    212
      GIO = ADATA(K+28)                                                 RCPINT    213
      BIO = ADATA(K+29)                                                 RCPINT    214
C                                                                       RCPINT    215
      GT = GIO + GIJ                                                    RCPINT    216
      BT = BIO + BIJ                                                    RCPINT    217
C                                                                       RCPINT    218
      VOLTK=VOLT(NPROGI)                                                RCPINT    219
      EI = VREAL                                                        RCPINT    220
      FI = VIMAG                                                        RCPINT    221
C                                                                       RCPINT    222
      VOLTK=VOLT(NPROGJ)                                                RCPINT    223
      EJ = VREAL                                                        RCPINT    224
      FJ = VIMAG                                                        RCPINT    225
C                                                                       RCPINT    226
      C1R = EI*GT - FI*BT                                               RCPINT    227
      C1I = EI*BT + FI*GT                                               RCPINT    228
      C2R = EJ*GIJ - FJ*BIJ                                             RCPINT    229
      C2I = EJ*BIJ + FJ*GIJ                                             RCPINT    230
      CTR = C1R - C2R                                                   RCPINT    231
      CTI = C1I -C2I                                                    RCPINT    232
      P3IOLD = EI*CTR + FI*CTI                                          RCPINT    233
      PIIOLD = P3IOLD                                                   RCPINT    234
      PIOLD = P3IOLD                                                    RCPINT    235
CD                                                                      RCPINT    236
CD 6. INITIALIZE THE POWER AND THE OUTPUT OF THE BLOCK OF THE RELAY     RCPINT    237
CD                                                                      RCPINT    238
      ADATA(K+19) = PIOLD                                               RCPINT    239
      ADATA(K+20) = PIIOLD                                              RCPINT    240
      ADATA(K+21) = P3IOLD                                              RCPINT    241
      ADATA(K+22) = 0.0                                                 RCPINT    242
      ADATA(K+23) = 0.0                                                 RCPINT    243
CD                                                                      RCPINT    244
CD 7. SET UP REMOTE TRIPPING IF REMOTE TRIPPING SCHEME IS SEPCIFIED     RCPINT    245
CD                                                                      RCPINT    246
      IF(IDRRR.NE.0)THEN                                                RCPINT    247
       KSHIFT=K+32                                                      RCPINT    248
       CALL REMINT(KSHIFT,IDRRR)                                        RCPINT    249
      ENDIF                                                             RCPINT    250
C                                                                       RCPINT    251
 1000 CONTINUE                                                          RCPINT    252
C                                                                       RCPINT    253
 3220  FORMAT(' *** ERROR LINE BETWEEN BUS#',2(I6,1X,3A4),1X,A2         RCPINT    254
     &,' CANNOT BE FOUND ')                                             RCPINT    255
C                                                                       RCPINT    256
      RETURN                                                            RCPINT    257
C                                                                       RCPINT    258
      END                                                               RCPINT    259
