CFPRIME DE14                                                            DE14        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 DE14                                                   DE14        3
CD                                                                      DE14        4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPE 14 EXCITER,    DE14        5
CD    USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.                  DE14        6
CD                                                                      DE14        7
CD    THE DATA STRUCTURE FOR THIS TYPE OF EXCITER IS GIVEN BELOW.       DE14        8
CD                                                                      DE14        9
CD   3.10 Exciter type 14                                               DE14       10
CD                                                                      DE14       11
CD     Exciter data                                                     DE14       12
CD                                                                      DE14       13
CD     IDDAT(JE+ 1)   = IVTN         : sensing bus number               DE14       14
CD     DDAT(JE+ 2)    = KA                                              DE14       15
CD     DDAT(JE+ 3)    = TA                                              DE14       16
CD     DDAT(JE+ 4)    = KE                                              DE14       17
CD     DDAT(JE+ 5)    = TE                                              DE14       18
CD     DDAT(JE+ 6)    = SE(VSAT) or AEX                                 DE14       19
CD     DDAT(JE+ 7)    = SE(0.75VSAT) or BEX                             DE14       20
CD     DDAT(JE+ 8)    = VSAT                                            DE14       21
CD     DDAT(JE+ 9)    = KC                                              DE14       22
CD     DDAT(JE+10)    = TJ                                              DE14       23
CD     DDAT(JE+11)    = TH                                              DE14       24
CD     DDAT(JE+12)    = TC                                              DE14       25
CD     DDAT(JE+13)    = TB                                              DE14       26
CD     DDAT(JE+14)    = VRMAX                                           DE14       27
CD     DDAT(JE+15)    = VRMIN                                           DE14       28
CD     DDAT(JE+16)    = VEMIN                                           DE14       29
CD     DDAT(JE+17)    = TD                                              DE14       30
CD     DDAT(JE+18)    = TR                                              DE14       31
CD     DDAT(JE+19)    = RC                                              DE14       32
CD     DDAT(JE+20)    = XC                                              DE14       33
CD     DDAT(JE+21)    = XDE                                             DE14       34
CD     DDAT(JE+22)    = X'DE                                            DE14       35
CD     DDAT(JE+23)    = KRB                                             DE14       36
CD     DDAT(JE+24)    = TRB                                             DE14       37
CD     DDAT(JE+25)    = VFELIM                                          DE14       38
CD     DDAT(JE+26)    = VAMAX                                           DE14       39
CD     DDAT(JE+27)    = VAMIN                                           DE14       40
CD     DDAT(JE+28)    = KH                                              DE14       41
CD     DDAT(JE+29)    = VHMAX                                           DE14       42
CD     DDAT(JE+30)    = VJMAX                                           DE14       43
CD     DDAT(JE+31)    = RAMP                                            DE14       44
CD     DDAT(JE+32)    = RMAX                                            DE14       45
CD     DDAT(JE+33)    = RMIN                                            DE14       46
CD                                                                      DE14       47
CD     Exciter states                                                   DE14       48
CD                                                                      DE14       49
CD     XSTATE(JES+1)  = TR block     : compulsory                       DE14       50
CD     XSTATE(JES+2)  = TH block     : compulsory                       DE14       51
CD     XSTATE(JES+3)  = TB block     : compulsory                       DE14       52
CD     XSTATE(JES+4)  = TA block     : compulsory                       DE14       53
CD     XSTATE(JES+5)  = TE block     : compulsory                       DE14       54
CD     XSTATE(JES+6)  = TRB block    : compulsory                       DE14       55
CD                                                                      DE14       56
CD     Exciter Y-variables                                              DE14       57
CD                                                                      DE14       58
CD     VREG(JYE+1)    = VC (input to the TR block)                      DE14       59
CD     VREF(JYE+2)    = reference value                                 DE14       60
CD                                                                      DE14       61
      INCLUDE 'PARX.INS'                                                DE14       62
      INCLUDE 'CNPT.INS'                                                DE14       63
      INCLUDE 'CNVOLT.INS'                                              DE14       64
      INCLUDE 'CNIPTR.INS'                                              DE14       65
      INCLUDE 'CNMDAT.INS'                                              DE14       66
      INCLUDE 'CNB3.INS'                                                DE14       67
      INCLUDE 'CNB5.INS'                                                DE14       68
      INCLUDE 'CNB8.INS'                                                DE14       69
      INCLUDE 'CNB9.INS'                                                DE14       70
      INCLUDE 'CNB10.INS'                                               DE14       71
      INCLUDE 'CNB19.INS'                                               DE14       72
      INCLUDE 'CNEXC.INS'                                               DE14       73
      INCLUDE 'CNXSTA.INS'                                              DE14       74
      INCLUDE 'CNQSTA.INS'                                              DE14       75
      INCLUDE 'CNMYVA.INS'                                              DE14       76
      INCLUDE 'CNYVAR.INS'                                              DE14       77
C                                                                       DE14       78
      NXS=6                                                             DE14       79
      VRMAX=DDAT(JE+14)                                                 DE14       80
      VRMIN=DDAT(JE+15)                                                 DE14       81
      RAMP=DDAT(JE+31)                                                  DE14       82
      SEKX=DDAT(JE+4)*XSTATE(JSTATE+5)                                  DE14       83
      SEKX=SEKX+DDAT(JE+6)*EXP(DDAT(JE+7)*XSTATE(JSTATE+5))             DE14       84
      SEKX=SEKX+CFDN*(DDAT(JE+21)-DDAT(JE+22))                          DE14       85
C                                                                       DE14       86
         XRATE=(SEKX-DDAT(JE+25)-XSTATE(JSTATE+6))*DDAT(JE+28)          DE14       87
         IF(XRATE.LT.0.0)THEN                                           DE14       88
         XRATE=0.0                                                      DE14       89
         ELSEIF(XRATE.GT.DDAT(JE+29))THEN                               DE14       90
         XRATE=DDAT(JE+29)                                              DE14       91
         ENDIF                                                          DE14       92
C                                                                       DE14       93
C   RATE FEEDBACK BLOCK                                                 DE14       94
C                                                                       DE14       95
         IF (IDDAT(JE+11).NE.0)THEN                                     DE14       96
         DSTATE(LSTATE+2)=(XRATE-XSTATE(JSTATE+2))/DDAT(JE+11)          DE14       97
         V2=XSTATE(JSTATE+2)+DSTATE(LSTATE+2)*DDAT(JE+10)               DE14       98
         ELSE                                                           DE14       99
         V2=0.                                                          DE14      100
         DSTATE(LSTATE+2)=0.0                                           DE14      101
         XSTATE(JSTATE+2)=XRATE                                         DE14      102
         ENDIF                                                          DE14      103
         V20=V2                                                         DE14      104
         IF(V2.LT.0.0)THEN                                              DE14      105
         V2=0.0                                                         DE14      106
         ELSEIF(V2.GT.DDAT(JE+30))THEN                                  DE14      107
         V2=DDAT(JE+30)                                                 DE14      108
         ENDIF                                                          DE14      109
C                                                                       DE14      110
         VSUM=VREF(JYE+2)-V1                                            DE14      111
C                                                                       DE14      112
      IF (ISTABN.GT.0) VSUM=VSUM+VSS(JYS+1)                             DE14      113
      IF (IUALN.NE.0) VSUM=VSUM+VUAL(JYU+1)                             DE14      114
      IF (ITEBN.NE.0) VSUM=VSUM+TEB(JYTB+1)                             DE14      115
      IF (IMXLN.NE.0) VSUM=VSUM-VMXL(JYMX+1)                            DE14      116
C                                                                       DE14      117
C     LEAD/LAG BLOCK                                                    DE14      118
C                                                                       DE14      119
      IF (IDDAT(JE+13).NE.0)THEN                                        DE14      120
C                                                                       DE14      121
C   TB NE 0.0                                                           DE14      122
C                                                                       DE14      123
      DSTATE(LSTATE+3)=(VSUM-XSTATE(JSTATE+3))/DDAT(JE+13)              DE14      124
      V3=XSTATE(JSTATE+3)+DDAT(JE+12)*DSTATE(LSTATE+3)                  DE14      125
C                                                                       DE14      126
C  TB = 0                                                               DE14      127
C                                                                       DE14      128
      ELSE                                                              DE14      129
      V3=VSUM                                                           DE14      130
      DSTATE(LSTATE+3)=0.0                                              DE14      131
      XSTATE(JSTATE+3)=V3                                               DE14      132
      ENDIF                                                             DE14      133
C                                                                       DE14      134
C   AMPILIFIER BLOCK                                                    DE14      135
C                                                                       DE14      136
      IF(IDDAT(JE+3).NE.0)THEN                                          DE14      137
C                                                                       DE14      138
C   TA.NE.0                                                             DE14      139
C                                                                       DE14      140
         IF(IDDAT(JE+17).NE.0)THEN                                      DE14      141
C                                                                       DE14      142
C   *** NEW NON-WIND-UP LIMIT TYPES 14 ONLY ***                         DE14      143
C                                                                       DE14      144
         RATIO=DDAT(JE+17)/DDAT(JE+3)                                   DE14      145
         VR=RATIO*DDAT(JE+2)*V3+(1-RATIO)*XSTATE(JSTATE+4)              DE14      146
         IF(VR.GT.DDAT(JE+14))THEN                                      DE14      147
         VR=DDAT(JE+14)                                                 DE14      148
         ELSEIF(VR.LT.DDAT(JE+15))THEN                                  DE14      149
         VR=DDAT(JE+15)                                                 DE14      150
         ENDIF                                                          DE14      151
         DSTATE(LSTATE+4)=(VR-XSTATE(JSTATE+4))/DDAT(JE+17)             DE14      152
         ELSE                                                           DE14      153
         DSTATE(LSTATE+4)=(DDAT(JE+2)*V3-XSTATE(JSTATE+4))/             DE14      154
     +    DDAT(JE+3)                                                    DE14      155
         VR=XSTATE(JSTATE+4)                                            DE14      156
         ENDIF                                                          DE14      157
C                                                                       DE14      158
C   TA=0                                                                DE14      159
C                                                                       DE14      160
      ELSE                                                              DE14      161
C                                                                       DE14      162
      VR=DDAT(JE+2)*V3                                                  DE14      163
      DSTATE(LSTATE+4)=0.                                               DE14      164
      XSTATE(JSTATE+4)=VR                                               DE14      165
C                                                                       DE14      166
      ENDIF                                                             DE14      167
C                                                                       DE14      168
C=                                                                      DE14      169
      IF (IDDAT(JE+17).EQ.0) THEN                                       DE14      170
         IF (VR.GE.VRMAX) THEN                                          DE14      171
            VR=VRMAX                                                    DE14      172
            IF (DSTATE(LSTATE+4).GT.0.0) THEN                           DE14      173
               DSTATE(LSTATE+4)=0.0                                     DE14      174
               QSTATE(JSTATE+4)=0.0                                     DE14      175
            END IF                                                      DE14      176
         ELSE IF (VR.LE.VRMIN) THEN                                     DE14      177
            VR=VRMIN                                                    DE14      178
            IF (DSTATE(LSTATE+4).LT.0.0) THEN                           DE14      179
               DSTATE(LSTATE+4)=0.0                                     DE14      180
               QSTATE(JSTATE+4)=0.0                                     DE14      181
            END IF                                                      DE14      182
         END IF                                                         DE14      183
      END IF                                                            DE14      184
C=                                                                      DE14      185
        SVH=V20*DDAT(JE+23)                                             DE14      186
        IF(SVH.GT.DDAT(JE+32))THEN                                      DE14      187
        SVH=DDAT(JE+32)                                                 DE14      188
        ELSEIF(SVH.LT.DDAT(JE+33))THEN                                  DE14      189
        SVH=DDAT(JE+33)                                                 DE14      190
        ENDIF                                                           DE14      191
        DSTATE(LSTATE+6)=SVH/DDAT(JE+24)                                DE14      192
        IF (XSTATE(JSTATE+6).GE.RAMP) THEN                              DE14      193
           IF (DSTATE(LSTATE+6).GT.0.0) THEN                            DE14      194
              DSTATE(LSTATE+6)=0.0                                      DE14      195
              QSTATE(JSTATE+6)=0.0                                      DE14      196
           END IF                                                       DE14      197
        ELSE IF (XSTATE(JSTATE+6).LE.0.0) THEN                          DE14      198
           IF (DSTATE(LSTATE+6).LT.0.0) THEN                            DE14      199
              DSTATE(LSTATE+6)=0.0                                      DE14      200
              QSTATE(JSTATE+6)=0.0                                      DE14      201
           END IF                                                       DE14      202
        END IF                                                          DE14      203
C                                                                       DE14      204
C   EXCITER, JUNCTION AND WINDUP LIMITER                                DE14      205
C                                                                       DE14      206
         VINPT=VR-V2                                                    DE14      207
         VINMAX=DDAT(JE+26)*ET                                          DE14      208
         VINMIN=DDAT(JE+27)*ET                                          DE14      209
         IF(VINPT.GT.VINMAX)THEN                                        DE14      210
         VINPT=VINMAX                                                   DE14      211
         ELSEIF(VINPT.LT.VINMIN)THEN                                    DE14      212
         VINPT=VINMIN                                                   DE14      213
         ENDIF                                                          DE14      214
C                                                                       DE14      215
C   EXTR VARIABLE FOR TSEC                                              DE14      216
C                                                                       DE14      217
      XVARB=XSTATE(JSTATE+4)                                            DE14      218
      REFMX=0.99*DDAT(JE+14)                                            DE14      219
C                                                                       DE14      220
      VEIN=VINPT-SEKX                                                   DE14      221
C                                                                       DE14      222
      DSTATE(LSTATE+5)=VEIN/DDAT(JE+5)                                  DE14      223
      VEMIN=DDAT(JE+16)                                                 DE14      224
C                                                                       DE14      225
C  NEGATIVE LIMIT ON  VE  FOR IEX=3 & 5                                 DE14      226
C                                                                       DE14      227
      IF (XSTATE(JSTATE+5).LE.VEMIN) THEN                               DE14      228
         IF (DSTATE(LSTATE+5).LT.0.0) THEN                              DE14      229
            DSTATE(LSTATE+5)=0.0                                        DE14      230
            QSTATE(JSTATE+5)=0.0                                        DE14      231
         END IF                                                         DE14      232
         VE=VEMIN                                                       DE14      233
      ELSE                                                              DE14      234
         VE=XSTATE(JSTATE+5)                                            DE14      235
      END IF                                                            DE14      236
      VTH=VE-CFDN*DDAT(JE+22)                                           DE14      237
C                                                                       DE14      238
C        RECTIFIER LOADING EFFECTS                                      DE14      239
C                                                                       DE14      240
      IF (IDDAT(JE+9).NE.0)THEN                                         DE14      241
         IF(VTH.GT.0.0)THEN                                             DE14      242
           FACT=DDAT(JE+9)*CFDN/VTH                                     DE14      243
           IF (FACT.GE.0.75)THEN                                        DE14      244
           EFD(JYG+4)=VTH*1.732*(1.-FACT)                               DE14      245
           ELSE IF (FACT.GE.0.433)THEN                                  DE14      246
           EFD(JYG+4)=VTH*SQRT(0.75-FACT*FACT)                          DE14      247
           ELSE                                                         DE14      248
           EFD(JYG+4)=VTH*(1.-0.577*FACT)                               DE14      249
           ENDIF                                                        DE14      250
         ENDIF                                                          DE14      251
C                                                                       DE14      252
      ELSE                                                              DE14      253
C                                                                       DE14      254
      EFD(JYG+4)=VTH                                                    DE14      255
C                                                                       DE14      256
      ENDIF                                                             DE14      257
C                                                                       DE14      258
      IF(EFD(JYG+4).LT.0.0)EFD(JYG+4)=0.0                               DE14      259
C                                                                       DE14      260
      LSTATE=LSTATE+NXS                                                 DE14      261
C                                                                       DE14      262
      RETURN                                                            DE14      263
      END                                                               DE14      264
