CFPRIME DSTAB9                                                          DSTAB9      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 DSTAB9(KBUSNO,NXS)                                     DSTAB9      3
CD                                                                      DSTAB9      4
CD    TO CALCULATE THE DERIVATIVES OF THE STATES OF TYPE 9 STABILIZER,  DSTAB9      5
CD    USED BY BOTH RUNGE-KUTTA AND TRAPEZOIDAL METHOD.                  DSTAB9      6
CD                                                                      DSTAB9      7
CD    THE DATA STRUCTURE OF THEI TYPE OF STABILIZER IS GIVEN BELOW.     DSTAB9      8
CD                                                                      DSTAB9      9
CD   4.8 Stabilizer type 9                                              DSTAB9     10
CD                                                                      DSTAB9     11
CD     Stabilizer data                                                  DSTAB9     12
CD                                                                      DSTAB9     13
CD     IDDAT(JS+ 1)   = BUSR         : sensing bus number               DSTAB9     14
CD     IDDAT(JS +2)   = TYPE         : type of input signal:            DSTAB9     15
CD                                     = 1 rotor speed                  DSTAB9     16
CD                                     = 2 acceleration power           DSTAB9     17
CD                                     = 3 bus frequency                DSTAB9     18
CD                                     = 4 electrical power             DSTAB9     19
CD                                     = 5 bus voltage magnitude        DSTAB9     20
CD                                     = 6 voltage deviation from steadyDSTAB9     21
CD                                        state value                   DSTAB9     22
CD     IDDAT(JS+ 3)   = 0                                               DSTAB9     23
CD     IDDAT(JS+ 4)   = 4                                               DSTAB9     24
CD     IDDAT(JS+ 5)   = N                                               DSTAB9     25
CD     IDDAT(JS+ 6)   = M                                               DSTAB9     26
CD     DDAT(JS+ 7)    = T11                                             DSTAB9     27
CD     DDAT(JS+ 8)    = T12                                             DSTAB9     28
CD     DDAT(JS+ 9)    = T1                                              DSTAB9     29
CD     DDAT(JS+10)    = T2                                              DSTAB9     30
CD     DDAT(JS+11)    = T3                                              DSTAB9     31
CD     DDAT(JS+12)    = T4                                              DSTAB9     32
CD     DDAT(JS+13)    = VSMAX                                           DSTAB9     33
CD     DDAT(JS+14)    = VSMIN                                           DSTAB9     34
CD     DDAT(JS+15)    = KS1                                             DSTAB9     35
CD     DDAT(JS+16)    = T5                                              DSTAB9     36
CD     DDAT(JS+17)    = T6                                              DSTAB9     37
CD     DDAT(JS+18)    = T7                                              DSTAB9     38
CD     DDAT(JS+19)    = KS2                                             DSTAB9     39
CD     DDAT(JS+20)    = T8                                              DSTAB9     40
CD     DDAT(JS+21)    = T9                                              DSTAB9     41
CD     DDAT(JS+22)    = T10                                             DSTAB9     42
CD     DDAT(JS+23)    = KS3                                             DSTAB9     43
CD     DDAT(JS+24)    = TFD                                             DSTAB9     44
CD     DDAT(JS+25)    = TFG                                             DSTAB9     45
CD     DDAT(JS+26)    = TF                                              DSTAB9     46
CD     DDAT(JS+27)    = RC                                              DSTAB9     47
CD     DDAT(JS+28)    = XC                                              DSTAB9     48
CD     DDAT(JS+29)    = PTHR                                            DSTAB9     49
CD                                                                      DSTAB9     50
CD     Stabilizer states                                                DSTAB9     51
CD                                                                      DSTAB9     52
CD     XSTATE(JSS+1)  = TF block if input is bus frequency              DSTAB9     53
CD                                                  : optional          DSTAB9     54
CD     XSTATE(JSS+2)  = T5 block                    : optional          DSTAB9     55
CD     XSTATE(JSS+3)  = T6 block                    : optional          DSTAB9     56
CD     XSTATE(JSS+4)  = T7 block                    : optional          DSTAB9     57
CD     XSTATE(JSS+5)  = T8 block                    : optional          DSTAB9     58
CD     XSTATE(JSS+6)  = T9 block                    : optional          DSTAB9     59
CD     XSTATE(JSS+7)  = T10 block                   : optional          DSTAB9     60
CD     XSTATE(JSS+8)  = state no. 1 In TFG block         : optional     DSTAB9     61
CD                                                  : all optional      DSTAB9     62
CD     XSTATE(JSS+N+7)         = state no. N in TFG block          : optDSTAB9     63
CD     XSTATE(JSS+N+8)         = T11 block                         : optDSTAB9     64
CD     XSTATE(JSS+N+9)         = T2 block                          : optDSTAB9     65
CD     XSTATE(JSS+N+10) = T4 block                       : optional     DSTAB9     66
CD                                                                      DSTAB9     67
CD     Where N = IDDAT(JS+5)                                            DSTAB9     68
CD                                                                      DSTAB9     69
CD     Stabilizer Y-variables                                           DSTAB9     70
CD                                                                      DSTAB9     71
CD     VSS(JYS+1)     = stabilizer output                               DSTAB9     72
CD                                                                      DSTAB9     73
      INCLUDE 'PARX.INS'                                                DSTAB9     74
      INCLUDE 'CNVOLT.INS'                                              DSTAB9     75
      INCLUDE 'CNMDAT.INS'                                              DSTAB9     76
      INCLUDE 'CNEXC.INS'                                               DSTAB9     77
      INCLUDE 'CNXSTA.INS'                                              DSTAB9     78
      INCLUDE 'CNYVAR.INS'                                              DSTAB9     79
      INCLUDE 'CNFLAG.INS'                                              DSTAB9     80
      INCLUDE 'CNPARX.INS'                                              DSTAB9     81
      INCLUDE 'CNUNIT.INS'                                              DSTAB9     82
      INCLUDE 'CNB19.INS'                                               DSTAB9     83
C                                                                       DSTAB9     84
*IF DEBUG                                                               DSTAB9     85
      LDEB=(JDEB(87).NE.0)                                              DSTAB9     86
*ENDIF                                                                  DSTAB9     87
C                                                                       DSTAB9     88
C     TYPE 9 STABILIZER -- PSS2A                                        DSTAB9     89
C                                                                       DSTAB9     90
      VSI1=VSI1*DDAT(JS+15)                                             DSTAB9     91
      IF (IDDAT(JS+16).NE.0) THEN                                       DSTAB9     92
         KSTATE=KSTATE+1                                                DSTAB9     93
         DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))/DDAT(JS+16) DSTAB9     94
         VSI1=DDAT(JS+16)*DSTATE(LSTATE+KSTATE)                         DSTAB9     95
      END IF                                                            DSTAB9     96
      IF (IDDAT(JS+17).NE.0) THEN                                       DSTAB9     97
         KSTATE=KSTATE+1                                                DSTAB9     98
         DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))/DDAT(JS+17) DSTAB9     99
         VSI1=DDAT(JS+17)*DSTATE(LSTATE+KSTATE)                         DSTAB9    100
      END IF                                                            DSTAB9    101
      IF (IDDAT(JS+18).NE.0) THEN                                       DSTAB9    102
         KSTATE=KSTATE+1                                                DSTAB9    103
         DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))/DDAT(JS+18) DSTAB9    104
         VSI1=XSTATE(JSTATE+KSTATE)                                     DSTAB9    105
      END IF                                                            DSTAB9    106
C                                                                       DSTAB9    107
      IF (IDDAT(JS+20).NE.0) THEN                                       DSTAB9    108
         KSTATE=KSTATE+1                                                DSTAB9    109
         DSTATE(LSTATE+KSTATE)=(VSI2-XSTATE(JSTATE+KSTATE))/DDAT(JS+20) DSTAB9    110
         VSI2=DDAT(JS+20)*DSTATE(LSTATE+KSTATE)                         DSTAB9    111
      END IF                                                            DSTAB9    112
      IF (IDDAT(JS+21).NE.0) THEN                                       DSTAB9    113
         KSTATE=KSTATE+1                                                DSTAB9    114
         DSTATE(LSTATE+KSTATE)=(VSI2-XSTATE(JSTATE+KSTATE))/DDAT(JS+21) DSTAB9    115
         VSI2=DDAT(JS+21)*DSTATE(LSTATE+KSTATE)                         DSTAB9    116
      END IF                                                            DSTAB9    117
      VSI2=VSI2*DDAT(JS+19)                                             DSTAB9    118
      IF (IDDAT(JS+22).NE.0) THEN                                       DSTAB9    119
         KSTATE=KSTATE+1                                                DSTAB9    120
         DSTATE(LSTATE+KSTATE)=(VSI2-XSTATE(JSTATE+KSTATE))/DDAT(JS+22) DSTAB9    121
         VSI2=XSTATE(JSTATE+KSTATE)                                     DSTAB9    122
      END IF                                                            DSTAB9    123
C                                                                       DSTAB9    124
      VSI1=VSI1+DDAT(JS+23)*VSI2                                        DSTAB9    125
      IF (IDDAT(JS+25).NE.0) THEN                                       DSTAB9    126
         MSTF=IDDAT(JS+6)                                               DSTAB9    127
         NSTF=IDDAT(JS+5)-MSTF                                          DSTAB9    128
         DO 210 NST=1,NSTF                                              DSTAB9    129
            KSTATE=KSTATE+1                                             DSTAB9    130
            DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))          DSTAB9    131
     1                            /DDAT(JS+25)                          DSTAB9    132
            VSI1=XSTATE(JSTATE+KSTATE)                                  DSTAB9    133
  210    CONTINUE                                                       DSTAB9    134
         IF (MSTF.NE.0) THEN                                            DSTAB9    135
            DO 220 NST=1,MSTF                                           DSTAB9    136
               KSTATE=KSTATE+1                                          DSTAB9    137
               DSTATE(LSTATE+KSTATE)=(VSI1-XSTATE(JSTATE+KSTATE))       DSTAB9    138
     1                               /DDAT(JS+25)                       DSTAB9    139
               VSI1=XSTATE(JSTATE+KSTATE)+DDAT(JS+24)                   DSTAB9    140
     1              *DSTATE(LSTATE+KSTATE)                              DSTAB9    141
  220       CONTINUE                                                    DSTAB9    142
         END IF                                                         DSTAB9    143
      END IF                                                            DSTAB9    144
C                                                                       DSTAB9    145
      VSX=VSI1-VSI2                                                     DSTAB9    146
C                                                                       DSTAB9    147
      IF (IDDAT(JS+7).NE.0.AND.IDDAT(JS+8).NE.0) THEN                   DSTAB9    148
         KSTATE=KSTATE+1                                                DSTAB9    149
         DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+8)   DSTAB9    150
         VSX=DDAT(JS+7)*DSTATE(LSTATE+KSTATE)                           DSTAB9    151
      END IF                                                            DSTAB9    152
      IF (IDDAT(JS+10).NE.0) THEN                                       DSTAB9    153
         KSTATE=KSTATE+1                                                DSTAB9    154
         DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+10)  DSTAB9    155
         VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+9)*DSTATE(LSTATE+KSTATE)     DSTAB9    156
      END IF                                                            DSTAB9    157
      IF (IDDAT(JS+12).NE.0) THEN                                       DSTAB9    158
         KSTATE=KSTATE+1                                                DSTAB9    159
         DSTATE(LSTATE+KSTATE)=(VSX-XSTATE(JSTATE+KSTATE))/DDAT(JS+12)  DSTAB9    160
         VSX=XSTATE(JSTATE+KSTATE)+DDAT(JS+11)*DSTATE(LSTATE+KSTATE)    DSTAB9    161
      END IF                                                            DSTAB9    162
C                                                                       DSTAB9    163
      IF (VSX.GT.DDAT(JS+13)) VSX=DDAT(JS+13)                           DSTAB9    164
      IF (VSX.LT.DDAT(JS+14)) VSX=DDAT(JS+14)                           DSTAB9    165
      VSS(JYS+1)=VSX                                                    DSTAB9    166
C                                                                       DSTAB9    167
      LSTATE=LSTATE+KSTATE                                              DSTAB9    168
      JSTATE=JSTATE+KSTATE                                              DSTAB9    169
C                                                                       DSTAB9    170
      RETURN                                                            DSTAB9    171
C                                                                       DSTAB9    172
      END                                                               DSTAB9    173
