CFPRIME UFLMON                                                          UFLMON      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 UFLMON(IDISW,H)                                        UFLMON      3
CD                                                                      UFLMON      4
CD    THIS ROUTINE CHECKS THE CF-1 UNDERFREQUENCY LOAD SHEDDING         UFLMON      5
CD    RELAY CONDITIONS DURING THE SIMULATION.                           UFLMON      6
CD                                                                      UFLMON      7
CD                                                                      UFLMON      8
CD     LUFREQ           Starting position of IDATPT array  of CF-1      UFLMON      9
CD                      relay scheme. LUFREQ is in the common labelled  UFLMON     10
CD                      PT of include file CNPT.                        UFLMON     11
CD                                                                      UFLMON     12
CD     NUFREQ           Finishing position of IDATPT array of CF-1      UFLMON     13
CD                      relay scheme. NUFREQ is in common labelled AUTO UFLMON     14
CD                      of include file CNAUTO.                         UFLMON     15
CD                                                                      UFLMON     16
CD     let k = k-th UFLS RELAY                                          UFLMON     17
CD                                                                      UFLMON     18
CD     N = IDATPT(k)    IDATPT is the array that stores the start       UFLMON     19
CD                      position of the K-TH UFLS relay scheme data     UFLMON     20
CD                                                                      UFLMON     21
CD IADATA(N+1)=IRSBNO   BUS NUMBER                                      UFLMON     22
CD                                                                      UFLMON     23
CD IADATA(N+2)=IFLAG    = 0 : SIGNAL CONTROLS BOTH LOCAL AND REMOTE     UFLMON     24
CD                      = 1 : CONTROLS REMOTE ONLY                      UFLMON     25
CD                                                                      UFLMON     26
CD IADATA(N+3)=IRSTCD   TRIP CODE 1= NOT TRIPPED, 2= TRIPPED            UFLMON     27
CD                                                                      UFLMON     28
CD IADATA(N+4)=IDRRR    NO OF REMOTE RELAYS                             UFLMON     29
CD                                                                      UFLMON     30
CD IADATA(N+5)          REMOTE RELAY TRIP FLAG                          UFLMON     31
CD                                                                      UFLMON     32
CD ADATA(N+6)=RSVINT    MAGNITUDE OF INITIAL BUS VOLTAGE                UFLMON     33
CD                                                                      UFLMON     34
CD ADATA(N+7)=RSBTMR    BREAKER TIMER                                   UFLMON     35
CD                                                                      UFLMON     36
CD ADATA(N+8)=RSEYRO    REAL COMPONENT OF PRESENT BUS VOLTAGE           UFLMON     37
CD                                                                      UFLMON     38
CD ADATA(N+9)=RSEYIO    IMAGINARY COMPONENT OF PRESENT BUS VOLTAGE      UFLMON     39
CD                                                                      UFLMON     40
CD ADATA(N+10)=RSFEQO   PRESENT BUS FREQUENCY                           UFLMON     41
CD                                                                      UFLMON     42
CD ADATA(N+11)=RSCKR    INTEGRATOR GAIN--K                              UFLMON     43
CD                                                                      UFLMON     44
CD ADATA(N+12)=RSX1O    PAST VALUE OF STATE VARIABLE X1 INTEGRATOR      UFLMON     45
CD                      INPUT                                           UFLMON     46
CD                                                                      UFLMON     47
CD ADATA(N+13)=RSX2O    PAST VALUE OF STATE VARIABLE X2 INTEGRATOR      UFLMON     48
CD                      OUTPUT                                          UFLMON     49
CD                                                                      UFLMON     50
CD ADATA(N+14)=RSX1N    PRESENT VALUE OF X1                             UFLMON     51
CD                                                                      UFLMON     52
CD ADATA(N+15)=RSX2N    PRESENT VALUE OF X2                             UFLMON     53
CD                                                                      UFLMON     54
CD ADATA(N+16)=RSFEQ1   TRIPPING FREQUENCY (SPECIFIED IN CYCLES, STORED UFLMON     55
CD                      IN RADIANS/SEC INTERNALLY)                      UFLMON     56
CD                                                                      UFLMON     57
CD ADATA(N+17)=RSTLEV   TIME LEVER                                      UFLMON     58
CD                                                                      UFLMON     59
CD ADATA(N+18)=RSBDLY   BREAKER TIME DELAY (SPECIFIED IN CYCLES, STORED UFLMON     60
CD                      IN RADIANS/SEC INTERNALLY)                      UFLMON     61
CD                                                                      UFLMON     62
CD ADATA(N+19)=RSLDRP   PER CENT REAL POWER DROP FOR CONSTANT IMPEDANCE UFLMON     63
CD                      LOAD                                            UFLMON     64
CD                                                                      UFLMON     65
CD ADATA(N+20)=RSLDRP   PER CENT REACTIVE POWER DROP FOR CONSTANT       UFLMON     66
CD                      IMPEDANCE LOAD                                  UFLMON     67
CD                                                                      UFLMON     68
CD ADATA(N+21)=RSLDRP   PER CENT REAL POWER DROP FOR CONSTANT CURRENT   UFLMON     69
CD                      LOAD                                            UFLMON     70
CD                                                                      UFLMON     71
CD ADATA(N+22)=RSLDRP   PER CENT REACTIVE POWER DROP FOR CONSTANT       UFLMON     72
CD                      CURRENT LOAD                                    UFLMON     73
CD                                                                      UFLMON     74
CD ADATA(N+23)=RSLDRP   PER CENT REAL POWER DROP FOR CONSTANT MVA LOAD  UFLMON     75
CD                                                                      UFLMON     76
CD ADATA(N+24)=RSLDRP   PER CENT REACTIVE POWER DROP FOR CONSTANT MVA   UFLMON     77
CD                      LOAD                                            UFLMON     78
CD                                                                      UFLMON     79
CD ADATA(N+25)=RSLDRP   PER CENT REAL POWER DROP FOR CONSTANT MVA WITH  UFLMON     80
CD                      FREQUENCY DEPENDENCE                            UFLMON     81
CD                                                                      UFLMON     82
CD ADATA(N+26)=RSLDRP   PER CENT REACTIVE POWER DROP FOR CONSTANT MVA   UFLMON     83
CD                      WITH FREQUENCY DEPPENDCE                        UFLMON     84
CD                                                                      UFLMON     85
      INCLUDE 'PARX.INS'                                                UFLMON     86
      INCLUDE 'CNPT.INS'                                                UFLMON     87
      INCLUDE 'CNB4.INS'                                                UFLMON     88
      INCLUDE 'CNB19.INS'                                               UFLMON     89
      INCLUDE 'CNVOLT.INS'                                              UFLMON     90
      INCLUDE 'CNAUTO.INS'                                              UFLMON     91
C                                                                       UFLMON     92
      LOGICAL IDISW                                                     UFLMON     93
      CHARACTER*132 CARD                                                UFLMON     94
C                                                                       UFLMON     95
      COMPLEX VOLTK                                                     UFLMON     96
      DIMENSION VOLTX(2)                                                UFLMON     97
      EQUIVALENCE (VOLTK,VOLTX(1)),(VREAL,VOLTX(1)),(VIMAG,VOLTX(2))    UFLMON     98
C                                                                       UFLMON     99
      DO 200 KK=LUFREQ,NUFREQ                                           UFLMON    100
C                                                                       UFLMON    101
      K=IDATPT(KK)                                                      UFLMON    102
C                                                                       UFLMON    103
      IF(IADATA(K+3).GT.9)GOTO 200                                      UFLMON    104
C                                                                       UFLMON    105
      IFLAG=IADATA(K+2)                                                 UFLMON    106
      IDRRR=IADATA(K+4)                                                 UFLMON    107
CD                                                                      UFLMON    108
CD    CHECK IF RELAY TRIPPED                                            UFLMON    109
CD                                                                      UFLMON    110
      IF(IADATA(K+3).NE.0)GOTO 150                                      UFLMON    111
      NPROG=IADATA(K+1)                                                 UFLMON    112
      VOLTK=VOLT(NPROG)                                                 UFLMON    113
CD                                                                      UFLMON    114
CD    CHECK IF BKR TIMER ACTIVATED TO TRIP                              UFLMON    115
CD                                                                      UFLMON    116
      IF(ADATA(K+7).EQ.0.0)GOTO 110                                     UFLMON    117
      IF(ADATA(K+7)-.0001.GT.TS)GOTO 150                                UFLMON    118
CD                                                                      UFLMON    119
CD    INITIATE TO TRIP                                                  UFLMON    120
CD                                                                      UFLMON    121
CD    SELECT POWER UNIT CODING AND INITIAL  BREAKER TIMER               UFLMON    122
CD                                                                      UFLMON    123
  100 LDMDE=1                                                           UFLMON    124
      ADATA(K+7)=0.0                                                    UFLMON    125
      IADATA(K+3)=2                                                     UFLMON    126
CD                                                                      UFLMON    127
CD    IF TRIP WRITE LOAD SHEDDING DATA TO ISWFA FILE                    UFLMON    128
CD                                                                      UFLMON    129
       IF(IFLAG.EQ.0)THEN                                               UFLMON    130
        IF(IASWX.EQ.0)THEN                                              UFLMON    131
         WRITE(CARD,2040)                                               UFLMON    132
         WRITE(CARD,2010) TS                                            UFLMON    133
         WRITE(ISWFA,2030) CARD                                         UFLMON    134
         NAWR=NAWR+1                                                    UFLMON    135
         IASWX=1                                                        UFLMON    136
        ENDIF                                                           UFLMON    137
        WRITE(CARD,2040)                                                UFLMON    138
        WRITE(CARD,2020) NPROG,(ADATA(K+LL),LL=19,26)                   UFLMON    139
        WRITE(ISWFA,2030) CARD                                          UFLMON    140
        NAWR=NAWR+1                                                     UFLMON    141
       ENDIF                                                            UFLMON    142
CD                                                                      UFLMON    143
CD    CHECK REMOTE TRIPPING                                             UFLMON    144
CD                                                                      UFLMON    145
 150   IF(IADATA(K+3).EQ.2)THEN                                         UFLMON    146
        IF(IDRRR.NE.0)THEN                                              UFLMON    147
         KADD=K+26                                                      UFLMON    148
         KBUS=K                                                         UFLMON    149
         IPOINT=5                                                       UFLMON    150
         CALL RETRIP(KADD,KBUS,IDRRR,IPOINT)                            UFLMON    151
         IF(IADATA(KBUS+IPOINT).EQ.-1)IADATA(K+3)=3                     UFLMON    152
        ENDIF                                                           UFLMON    153
       ENDIF                                                            UFLMON    154
C                                                                       UFLMON    155
C                                                                       UFLMON    156
       GOTO 200                                                         UFLMON    157
C                                                                       UFLMON    158
C   BYPASS DISCONTINUNITY POINT                                         UFLMON    159
C                                                                       UFLMON    160
 110  IF(IDISW)THEN                                                     UFLMON    161
C                                                                       UFLMON    162
C     STORE VOLTAGE AND BYPASS                                          UFLMON    163
C                                                                       UFLMON    164
      ADATA(K+8)=VREAL                                                  UFLMON    165
      ADATA(K+9)=VIMAG                                                  UFLMON    166
      GOTO 200                                                          UFLMON    167
      ENDIF                                                             UFLMON    168
C                                                                       UFLMON    169
C     SOLVE FOR BUS FREQ                                                UFLMON    170
C                                                                       UFLMON    171
      ENEW=VREAL                                                        UFLMON    172
      FNEW=VIMAG                                                        UFLMON    173
      EFSQ=ENEW*ENEW+FNEW*FNEW                                          UFLMON    174
      IF(EFSQ.NE.0.0)GOTO 130                                           UFLMON    175
      WNEW=ADATA(K+10)                                                  UFLMON    176
      GOTO 140                                                          UFLMON    177
  130 VM=SQRT(EFSQ)                                                     UFLMON    178
C                                                                       UFLMON    179
C     PRECESS VARIABLE FIRST BEFORE PROCESSING                          UFLMON    180
C                                                                       UFLMON    181
      ADATA(K+12)=ADATA(K+14)                                           UFLMON    182
      ADATA(K+13)=ADATA(K+15)                                           UFLMON    183
      EDT=H*FQBASE                                                      UFLMON    184
      WNEW=(FNEW*ADATA(K+8)-ENEW*ADATA(K+9))/(EFSQ*EDT)                 UFLMON    185
  140 X1N=(ADATA(K+16)-WNEW)*VM/ADATA(K+6)                              UFLMON    186
      X2N=ADATA(K+11)*EDT*0.5*(X1N+ADATA(K+12))+ADATA(K+13)             UFLMON    187
      IF(X2N.LT.0.0)X2N=0.0                                             UFLMON    188
C                                                                       UFLMON    189
C     PRECESS VARIABLE                                                  UFLMON    190
C                                                                       UFLMON    191
      ADATA(K+14)=X1N                                                   UFLMON    192
      ADATA(K+15)=X2N                                                   UFLMON    193
      ADATA(K+10)=WNEW                                                  UFLMON    194
      ADATA(K+8)=VREAL                                                  UFLMON    195
      ADATA(K+9)=VIMAG                                                  UFLMON    196
      IF(X2N.LT.ADATA(K+17))GOTO 200                                    UFLMON    197
C                                                                       UFLMON    198
C     SET BKR TIMER IF BKR TIME NON ZERO OTHERWISE TRIP INSTANTANEOUSLY UFLMON    199
C                                                                       UFLMON    200
      IF(IADATA(K+18).EQ.0)GOTO 100                                     UFLMON    201
      ADATA(K+7)=TS+ADATA(K+18)                                         UFLMON    202
C                                                                       UFLMON    203
C            REMOTE RELAY ACTIVIATED                                    UFLMON    204
C                                                                       UFLMON    205
      IF(IDRRR.NE.0)THEN                                                UFLMON    206
        KADD=K+26                                                       UFLMON    207
        CALL RTIMER(KADD,IDRRR)                                         UFLMON    208
      ENDIF                                                             UFLMON    209
C                                                                       UFLMON    210
  200 CONTINUE                                                          UFLMON    211
 2010 FORMAT(F10.5)                                                     UFLMON    212
 2020 FORMAT('SLDU',I5,5X,8F10.5)                                       UFLMON    213
 2030 FORMAT(A132)                                                      UFLMON    214
 2040 FORMAT(132(' '))                                                  UFLMON    215
      RETURN                                                            UFLMON    216
      END                                                               UFLMON    217
                                                                        UFLMON    218
