CFPRIME UVARB                                                           UVARB       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 UVARB (N,JG,MD,MQ,JXST)                                UVARB       3
CD                                                                      UVARB       4
CD    TO CALCULATE THE GENERATOR AND NETWORK INTERFACE VARIABLES.       UVARB       5
CD                                                                      UVARB       6
C                                                                       UVARB       7
      INCLUDE 'PARX.INS'                                                UVARB       8
      INCLUDE 'CNMDAT.INS'                                              UVARB       9
      INCLUDE 'CNB4.INS'                                                UVARB      10
      INCLUDE 'CNXSTA.INS'                                              UVARB      11
      INCLUDE 'CNB19.INS'                                               UVARB      12
      INCLUDE 'CNUVAR.INS'                                              UVARB      13
C                                                                       UVARB      14
C                                                                       UVARB      15
      SINUS=SIN(XSTATE(JXST+2))                                         UVARB      16
      COSIN=COS(XSTATE(JXST+2))                                         UVARB      17
      UX=SINUS*SINUS                                                    UVARB      18
      UY=COSIN*COSIN                                                    UVARB      19
      UXY=SINUS*COSIN                                                   UVARB      20
      XAL=DDAT(JG+8)                                                    UVARB      21
       RA=DDAT(JG+9)                                                    UVARB      22
      AXD=DDAT(JG+22)                                                   UVARB      23
      XADS=DDAT(JG+32)*DDAT(JG+6)                                       UVARB      24
C                                                                       UVARB      25
      C3=1./(AXD+1./XADS)                                               UVARB      26
C                                                                       UVARB      27
      A=XSTATE(JXST+3)*DDAT(JG+36)                                      UVARB      28
C                                                                       UVARB      29
      IF(MD.EQ.2)THEN                                                   UVARB      30
      A=A+XSTATE(JXST+4)*DDAT(JG+37)                                    UVARB      31
      ELSEIF(MD.EQ.3)THEN                                               UVARB      32
      A=A+XSTATE(JXST+4)*DDAT(JG+37)+XSTATE(JXST+5)*DDAT(JG+38)         UVARB      33
      ENDIF                                                             UVARB      34
C                                                                       UVARB      35
      B=0.0                                                             UVARB      36
      C4=1./(DDAT(JG+23)+(1./(DDAT(JG+33)*DDAT(JG+7))))                 UVARB      37
      IF(MQ.GT.1)THEN                                                   UVARB      38
      JXSTMD=JXST+MD+2                                                  UVARB      39
         IF(MQ.EQ.2)THEN                                                UVARB      40
         B=XSTATE(JXSTMD+1)/DDAT(JG+12)                                 UVARB      41
         ELSEIF(MQ.EQ.3)THEN                                            UVARB      42
         B=XSTATE(JXSTMD+1)/DDAT(JG+12)+XSTATE(JXSTMD+2)/DDAT(JG+16)    UVARB      43
         ELSEIF(MQ.EQ.4)THEN                                            UVARB      44
         B=XSTATE(JXSTMD+1)/DDAT(JG+12)+XSTATE(JXSTMD+2)/DDAT(JG+16)    UVARB      45
     &     +XSTATE(JXSTMD+3)/DDAT(JG+20)                                UVARB      46
      ENDIF                                                             UVARB      47
      ENDIF                                                             UVARB      48
C                                                                       UVARB      49
      U3N=-(C3*A*SINUS+B*COSIN*C4)                                      UVARB      50
      U6N=(C3*A*COSIN-C4*B*SINUS)                                       UVARB      51
      U1N=UXY*(C3-C4)-RA                                                UVARB      52
      U2N=(C3*UX+C4*UY+XAL)                                             UVARB      53
      U4N=-(C3*UY+C4*UX+XAL)                                            UVARB      54
C                                                                       UVARB      55
      IF(ISPEED.NE.0)THEN                                               UVARB      56
      OMEGA=1.0+XSTATE(JXST+1)/WXBASE                                   UVARB      57
      U1N=U1N*OMEGA                                                     UVARB      58
      U2N=U2N*OMEGA                                                     UVARB      59
      U3N=U3N*OMEGA                                                     UVARB      60
      U4N=U4N*OMEGA                                                     UVARB      61
      ENDIF                                                             UVARB      62
C                                                                       UVARB      63
      U5N=-U1N-2.0*RA                                                   UVARB      64
      DET=U1N*U5N-U2N*U4N                                               UVARB      65
      UVAR(1,N)=U5N/DET                                                 UVARB      66
      UVAR(2,N)=-U2N/DET                                                UVARB      67
      UVAR(3,N)=-U4N/DET                                                UVARB      68
      UVAR(4,N)=U1N/DET                                                 UVARB      69
      UVAR(5,N)=UVAR(1,N)*U3N+UVAR(2,N)*U6N                             UVARB      70
      UVAR(6,N)=UVAR(3,N)*U3N+UVAR(4,N)*U6N                             UVARB      71
C                                                                       UVARB      72
      RETURN                                                            UVARB      73
C                                                                       UVARB      74
      END                                                               UVARB      75
