CFPRIME AUDB46                                                          AUDB46      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 AUDB46(LORD)                                           AUDB46      3
CD                                                                      AUDB46      4
CD    TO FORMULATE THE ELEMENTARY LINEARIZED EQUATIONS OF USER DEFINED  AUDB46      5
CD    BLOCK TYPES 46 (TYPE T20 GOVERNOR END BLOCK) IN A USER DEFINED    AUDB46      6
CD    GOVERNOR MODEL FOR USE IN CONSTRUCTING THE JACOBIAN MATRICES.     AUDB46      7
CD                                                                      AUDB46      8
      INCLUDE 'PARX.INS'                                                AUDB46      9
      INCLUDE 'CNB19.INS'                                               AUDB46     10
      INCLUDE 'CNUNIT.INS'                                              AUDB46     11
      INCLUDE 'CNFLAG.INS'                                              AUDB46     12
      INCLUDE 'CNUDM.INS'                                               AUDB46     13
      INCLUDE 'CNUDMA.INS'                                              AUDB46     14
C                                                                       AUDB46     15
      DIMENSION AX1(0:4),BX1(0:5)                                       AUDB46     16
C                                                                       AUDB46     17
      LDEB=(JDEB(264).NE.0)                                             AUDB46     18
C                                                                       AUDB46     19
      IUB=IUB+1                                                         AUDB46     20
      IORD=IUDAT(JE4+LORD)                                              AUDB46     21
      JEI=JEB+2                                                         AUDB46     22
      KINT=KINPU                                                        AUDB46     23
      KINPU=KINPU+IUDAT(JEI+13)                                         AUDB46     24
      IF(KINT.LT.KINPU) THEN                                            AUDB46     25
         J=KINT+1                                                       AUDB46     26
         XDAT=GAINS(J)                                                  AUDB46     27
         IOUT=INPUTS(J)                                                 AUDB46     28
         CYB(IUB,IOUT)=XDAT                                             AUDB46     29
         XUY(1,IOUT)=XDAT                                               AUDB46     30
         GO TO 100                                                      AUDB46     31
      ENDIF                                                             AUDB46     32
      KINP=KINPU                                                        AUDB46     33
      KINPU=KINPU+IUDAT(JEI+14)                                         AUDB46     34
      IF(KINP.LT.KINPU) THEN                                            AUDB46     35
         J=KINP+1                                                       AUDB46     36
         XDAT=GAINS(J)                                                  AUDB46     37
         IIN=INPUTS(J)                                                  AUDB46     38
         DU0(IUB,IIN)=XDAT                                              AUDB46     39
         XUREF(1)=XDAT                                                  AUDB46     40
      ENDIF                                                             AUDB46     41
  100 CONTINUE                                                          AUDB46     42
C                                                                       AUDB46     43
      AT0=UDAT(JEI+7)                                                   AUDB46     44
      H0=UDAT(JEI+3)                                                    AUDB46     45
      G0=VALIN(1)*AT0                                                   AUDB46     46
      U0=G0*SQRT(H0)                                                    AUDB46     47
      TW=UDAT(JEI+1)                                                    AUDB46     48
      TIN=VALOUT(IORD)                                                  AUDB46     49
C                                                                       AUDB46     50
      NSTURB=1                                                          AUDB46     51
      JLS=IUDAT(JEI+12)                                                 AUDB46     52
      TE=SSMAT(JLS+1)                                                   AUDB46     53
      TC=SSMAT(JLS+2)                                                   AUDB46     54
      TT=SSMAT(JLS+3)                                                   AUDB46     55
      IF(TE.GT.0.0)NSTURB=NSTURB+2                                      AUDB46     56
      IF(TC.GT.0.0)NSTURB=NSTURB+1                                      AUDB46     57
      IF(TT.GT.0.0)NSTURB=NSTURB+1                                      AUDB46     58
      PHIP=SSMAT(JLS+4)*2.0*ABS(U0)                                     AUDB46     59
      PHIC=SSMAT(JLS+5)*2.0*ABS(U0)                                     AUDB46     60
      PIX=4.0*ATAN(1.0)                                                 AUDB46     61
C                                                                       AUDB46     62
      AX1(4)=-TC*TT*(2.0*TE/PIX)**2-TC*TE*TE/TW*(TE/PIX)**2             AUDB46     63
      AX1(3)=-PHIC*TT*(2.0*TE/PIX)**2-PHIC*TE*TE/TW*(TE/PIX)**2         AUDB46     64
      AX1(2)=-TC*TT-(2.0*TE/PIX)**2-TC*TE*TE/TW                         AUDB46     65
      AX1(1)=-PHIC*TT-PHIC*TE*TE/TW                                     AUDB46     66
      AX1(0)=-1.0                                                       AUDB46     67
      BX1(5)=TW*TC*TT*(TE/PIX)**2                                       AUDB46     68
      BX1(4)=PHIP*TC*TT*(2.0*TE/PIX)**2+PHIC*TT*TW*(TE/PIX)**2          AUDB46     69
      BX1(3)=TC*(2.0*TE/PIX)**2+TW*(TE/PIX)**2+TW*TC*TT                 AUDB46     70
     &+PHIP*PHIC*TT*(2.0*TE/PIX)**2                                     AUDB46     71
      BX1(2)=PHIP*(2.0*TE/PIX)**2+PHIP*TC*TT+PHIC*(2.0*TE/PIX)**2       AUDB46     72
     &+PHIC*TT*TW                                                       AUDB46     73
      BX1(1)=TC+TW+PHIP*PHIC*TT                                         AUDB46     74
      BX1(0)=PHIP+PHIC                                                  AUDB46     75
C                                                                       AUDB46     76
      KORD=KORD+1                                                       AUDB46     77
      IF (IUDAT(JEI+2).NE.0) THEN                                       AUDB46     78
         AXB(KORD,KORD)=-1.0/UDAT(JEI+2)                                AUDB46     79
         BUB(KORD,IUB)=AT0/UDAT(JEI+2)                                  AUDB46     80
         CXB(IORD,KORD)=-TIN*2.0/G0                                     AUDB46     81
         AXB(KORD+1,KORD)=-2.0*H0/G0/BX1(NSTURB)                        AUDB46     82
      ELSE                                                              AUDB46     83
         DUB(IORD,IUB)=-AT0*TIN*2.0/G0                                  AUDB46     84
         BUB(KORD+1,IUB)=-2.0*AT0*H0/G0/BX1(NSTURB)                     AUDB46     85
      END IF                                                            AUDB46     86
C                                                                       AUDB46     87
      DO 110 I=1,NSTURB                                                 AUDB46     88
  110 AXB(KORD+1,I+KORD)=2.0*H0/U0/BX1(NSTURB)*AX1(NSTURB-I)            AUDB46     89
     &-BX1(NSTURB-I)/BX1(NSTURB)                                        AUDB46     90
C                                                                       AUDB46     91
      DO 120 I=1,NSTURB-1                                               AUDB46     92
  120 AXB(I+KORD+1,I+KORD)=1.0                                          AUDB46     93
C                                                                       AUDB46     94
      Y0=2.0*TIN/U0+UDAT(JEI+6)*H0                                      AUDB46     95
      DO 130 I=1,NSTURB                                                 AUDB46     96
  130 CXB(IORD,I+KORD)=Y0*AX1(NSTURB-I)                                 AUDB46     97
C                                                                       AUDB46     98
      KORD=KORD+NSTURB                                                  AUDB46     99
C                                                                       AUDB46    100
      IUB=IUB+1                                                         AUDB46    101
      DUB(IORD,IUB)=-TIN                                                AUDB46    102
      DU0(IUB,12)=1.0/WXBASE                                            AUDB46    103
      IF(LDEB) WRITE(IUD6,1000) KORD,LORD,IORD                          AUDB46    104
C                                                                       AUDB46    105
      RETURN                                                            AUDB46    106
 1000 FORMAT(1X,'KORD,LORD,IORD: ',3I5)                                 AUDB46    107
      END                                                               AUDB46    108
