CFPRIME DE9                                                             DE9         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 DE9                                                    DE9         3
CD                                                                      DE9         4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPE 9 EXCITER,     DE9         5
CD    USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.                  DE9         6
CD                                                                      DE9         7
CD    THE DATA STRUCTURE FOR THIS TYPE OF EXCITER IS GIVEN BELOW.       DE9         8
CD                                                                      DE9         9
CD   3.8 Exciter type 9                                                 DE9        10
CD                                                                      DE9        11
CD     Exciter data                                                     DE9        12
CD                                                                      DE9        13
CD     IDDAT(JE+ 1)   = IVTN         : sensing bus number               DE9        14
CD     DDAT(JE+ 2)    = (reserved for future use)                       DE9        15
CD     DDAT(JE+ 3)    = (reserved for future use)                       DE9        16
CD     DDAT(JE+ 4)    = KE                                              DE9        17
CD     DDAT(JE+ 5)    = TE                                              DE9        18
CD     DDAT(JE+ 6)    = SE(VSAT) or AEX                                 DE9        19
CD     DDAT(JE+ 7)    = SE(0.75VSAT) or BEX                             DE9        20
CD     DDAT(JE+ 8)    = VSAT                                            DE9        21
CD     DDAT(JE+ 9)    = (reserved for future use)                       DE9        22
CD     DDAT(JE+10)    = KV                                              DE9        23
CD     DDAT(JE+11)    = TRH                                             DE9        24
CD     DDAT(JE+12)    = (reserved for future use)                       DE9        25
CD     DDAT(JE+13)    = (reserved for future use)                       DE9        26
CD     DDAT(JE+14)    = VRMAX                                           DE9        27
CD     DDAT(JE+15)    = VRMIN                                           DE9        28
CD     DDAT(JE+16)    = (reserved for future use)                       DE9        29
CD     DDAT(JE+17)    = (reserved for future use)                       DE9        30
CD     DDAT(JE+18)    = TR                                              DE9        31
CD     DDAT(JE+19)    = RC                                              DE9        32
CD     DDAT(JE+20)    = XC                                              DE9        33
CD                                                                      DE9        34
CD     Exciter states                                                   DE9        35
CD                                                                      DE9        36
CD     XSTATE(JES+1)  = TR block     : compulsory                       DE9        37
CD     XSTATE(JES+2)  = TRH block    : compulsory                       DE9        38
CD     XSTATE(JES+3)  = TE block     : compulsory                       DE9        39
CD                                                                      DE9        40
CD     Exciter Y-variables                                              DE9        41
CD                                                                      DE9        42
CD     VREG(JYE+1)    = VC (input to the TR block)                      DE9        43
CD     VREF(JYE+2)    = reference value                                 DE9        44
CD                                                                      DE9        45
      INCLUDE 'PARX.INS'                                                DE9        46
      INCLUDE 'CNPT.INS'                                                DE9        47
      INCLUDE 'CNVOLT.INS'                                              DE9        48
      INCLUDE 'CNIPTR.INS'                                              DE9        49
      INCLUDE 'CNMDAT.INS'                                              DE9        50
      INCLUDE 'CNB3.INS'                                                DE9        51
      INCLUDE 'CNB5.INS'                                                DE9        52
      INCLUDE 'CNB8.INS'                                                DE9        53
      INCLUDE 'CNB9.INS'                                                DE9        54
      INCLUDE 'CNB10.INS'                                               DE9        55
      INCLUDE 'CNB19.INS'                                               DE9        56
      INCLUDE 'CNEXC.INS'                                               DE9        57
      INCLUDE 'CNXSTA.INS'                                              DE9        58
      INCLUDE 'CNQSTA.INS'                                              DE9        59
      INCLUDE 'CNMYVA.INS'                                              DE9        60
      INCLUDE 'CNYVAR.INS'                                              DE9        61
C                                                                       DE9        62
      NXS=3                                                             DE9        63
      VRMAX=DDAT(JE+14)                                                 DE9        64
      VRMIN=DDAT(JE+15)                                                 DE9        65
      SEKX=DDAT(JE+4)*XSTATE(JSTATE+3)                                  DE9        66
      SEKX=SEKX+DDAT(JE+6)*EXP(DDAT(JE+7)*XSTATE(JSTATE+3))             DE9        67
C                                                                       DE9        68
C     ADD A DEAD BAND FOR KV IF NECESSARY                               DE9        69
C                                                                       DE9        70
      IF (IDDAT(JE+21).EQ.1) THEN                                       DE9        71
         CVLMT=DDAT(JE+10)                                              DE9        72
      ELSE                                                              DE9        73
         CVLMT=(1.0-DEADBD)*DDAT(JE+10)                                 DE9        74
      END IF                                                            DE9        75
C                                                                       DE9        76
      IDDAT(JE+21)=1                                                    DE9        77
C                                                                       DE9        78
      VSUM=VREF(JYE+2)-V1                                               DE9        79
      IF (ISTABN.GT.0) VSUM=VSUM+VSS(JYS+1)                             DE9        80
      IF (IUALN.NE.0) VSUM=VSUM+VUAL(JYU+1)                             DE9        81
      IF (ITEBN.NE.0) VSUM=VSUM+TEB(JYTB+1)                             DE9        82
      IF (IMXLN.NE.0) VSUM=VSUM-VMXL(JYMX+1)                            DE9        83
C                                                                       DE9        84
      VSUM1=VSUM                                                        DE9        85
      IF (VSUM.GT.CVLMT)THEN                                            DE9        86
      VSUM=DDAT(JE+10)                                                  DE9        87
      ELSEIF(VSUM.LT.-CVLMT)THEN                                        DE9        88
      VSUM=-DDAT(JE+10)                                                 DE9        89
      ENDIF                                                             DE9        90
C                                                                       DE9        91
      DSTATE(LSTATE+2)=VSUM*(VRMAX-VRMIN)/DDAT(JE+10)/DDAT(JE+11)       DE9        92
C                                                                       DE9        93
      VR=XSTATE(JSTATE+2)                                               DE9        94
      IF (VR.GE.VRMAX) THEN                                             DE9        95
         VR=VRMAX                                                       DE9        96
         IF (DSTATE(LSTATE+2).GT.0.0) THEN                              DE9        97
            DSTATE(LSTATE+2)=0.0                                        DE9        98
            QSTATE(JSTATE+2)=0.0                                        DE9        99
         END IF                                                         DE9       100
      ELSE IF (VR.LE.VRMIN) THEN                                        DE9       101
         VR=VRMIN                                                       DE9       102
         IF (DSTATE(LSTATE+2).LT.0.0) THEN                              DE9       103
            DSTATE(LSTATE+2)=0.0                                        DE9       104
            QSTATE(JSTATE+2)=0.0                                        DE9       105
         END IF                                                         DE9       106
      END IF                                                            DE9       107
      XSTATE(JSTATE+2)=VR                                               DE9       108
C                                                                       DE9       109
      IF(VSUM1.GT.CVLMT)THEN                                            DE9       110
      VR=VRMAX                                                          DE9       111
      IDDAT(JE+21)=2                                                    DE9       112
      ELSEIF(VSUM1.LT.-CVLMT)THEN                                       DE9       113
      VR=VRMIN                                                          DE9       114
      IDDAT(JE+21)=2                                                    DE9       115
      ENDIF                                                             DE9       116
C                                                                       DE9       117
      VEIN=VR-SEKX                                                      DE9       118
      DSTATE(LSTATE+3)=VEIN/DDAT(JE+5)                                  DE9       119
C                                                                       DE9       120
      EFD(JYG+4)=XSTATE(JSTATE+3)                                       DE9       121
C                                                                       DE9       122
      LSTATE=LSTATE+NXS                                                 DE9       123
C                                                                       DE9       124
      RETURN                                                            DE9       125
C                                                                       DE9       126
      END                                                               DE9       127
