CFPRIME ASVC2                                                           ASVC2       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 ASVC2(EPD,EPQ)                                         ASVC2       3
CD                                                                      ASVC2       4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 2 SVC.                 ASVC2       5
CD                                                                      ASVC2       6
      INCLUDE 'PARX.INS'                                                ASVC2       7
      INCLUDE 'CNB8.INS'                                                ASVC2       8
      INCLUDE 'CNEXC.INS'                                               ASVC2       9
      INCLUDE 'CNSVS.INS'                                               ASVC2      10
      INCLUDE 'CNYVAR.INS'                                              ASVC2      11
      INCLUDE 'CNPARX.INS'                                              ASVC2      12
      INCLUDE 'CNMDAT.INS'                                              ASVC2      13
      INCLUDE 'CNXSTA.INS'                                              ASVC2      14
      INCLUDE 'CNMSTA.INS'                                              ASVC2      15
C                                                                       ASVC2      16
      INCLUDE 'CNABAK.INS'                                              ASVC2      17
C                                                                       ASVC2      18
      ICOLBV=1                                                          ASVC2      19
      NBR(1)=IDDAT(JS+10)                                               ASVC2      20
      NXS=0                                                             ASVC2      21
      VSR1=VSR/VSM                                                      ASVC2      22
      VSI1=VSI/VSM                                                      ASVC2      23
C                                                                       ASVC2      24
C     TS1 BLOCK                                                         ASVC2      25
C                                                                       ASVC2      26
      IF (IDDAT(JS+1).NE.0) THEN                                        ASVC2      27
C                                                                       ASVC2      28
         NXS=NXS+1                                                      ASVC2      29
         TS1I=DDAT(JS+1)                                                ASVC2      30
         A(NXS,NXS)=-TS1I                                               ASVC2      31
C                                                                       ASVC2      32
         B(NXS,1)=TS1I*VSR1                                             ASVC2      33
         B(NXS,2)=TS1I*VSI1                                             ASVC2      34
C                                                                       ASVC2      35
      END IF                                                            ASVC2      36
C                                                                       ASVC2      37
C     TS2, TS3 BLOCK                                                    ASVC2      38
C                                                                       ASVC2      39
      IF (IDDAT(JS+4).EQ.0) THEN                                        ASVC2      40
C                                                                       ASVC2      41
         T2T3=1.0                                                       ASVC2      42
C                                                                       ASVC2      43
      ELSE                                                              ASVC2      44
C                                                                       ASVC2      45
         NXS=NXS+1                                                      ASVC2      46
         TS3I=DDAT(JS+4)                                                ASVC2      47
         T2T3=DDAT(JS+3)*TS3I                                           ASVC2      48
         A(NXS,NXS)=-TS3I                                               ASVC2      49
         IF (IDDAT(JS+1).EQ.0) THEN                                     ASVC2      50
            B(NXS,1)=TS3I*VSR1                                          ASVC2      51
            B(NXS,2)=TS3I*VSI1                                          ASVC2      52
         ELSE                                                           ASVC2      53
            A(NXS,NXS-1)=TS3I                                           ASVC2      54
         END IF                                                         ASVC2      55
C                                                                       ASVC2      56
      END IF                                                            ASVC2      57
C                                                                       ASVC2      58
C     TS4, TS5 BLOCK                                                    ASVC2      59
C                                                                       ASVC2      60
      IF (IDDAT(JS+6).EQ.0) THEN                                        ASVC2      61
C                                                                       ASVC2      62
         T4T5=1.0                                                       ASVC2      63
C                                                                       ASVC2      64
      ELSE                                                              ASVC2      65
C                                                                       ASVC2      66
         NXS=NXS+1                                                      ASVC2      67
         TS5I=DDAT(JS+6)                                                ASVC2      68
         T4T5=DDAT(JS+5)*TS5I                                           ASVC2      69
         A(NXS,NXS)=-TS5I                                               ASVC2      70
         NXS1=NXS                                                       ASVC2      71
         IF (IDDAT(JS+4).NE.0) THEN                                     ASVC2      72
            NXS1=NXS1-1                                                 ASVC2      73
            A(NXS,NXS1)=TS5I*(1.0-T2T3)                                 ASVC2      74
         END IF                                                         ASVC2      75
         IF (IDDAT(JS+1).EQ.0) THEN                                     ASVC2      76
            B(NXS,1)=TS5I*T2T3*VSR1                                     ASVC2      77
            B(NXS,2)=TS5I*T2T3*VSI1                                     ASVC2      78
         ELSE                                                           ASVC2      79
            A(NXS,NXS1-1)=TS5I*T2T3                                     ASVC2      80
         END IF                                                         ASVC2      81
C                                                                       ASVC2      82
      END IF                                                            ASVC2      83
C                                                                       ASVC2      84
C     TS6 BLOCK                                                         ASVC2      85
C                                                                       ASVC2      86
      IF (IDDAT(JS+18).NE.0) THEN                                       ASVC2      87
C                                                                       ASVC2      88
         NXS=NXS+1                                                      ASVC2      89
         TS6I=DDAT(JS+18)                                               ASVC2      90
         CSVCT6=DDAT(JS+7)*TS6I                                         ASVC2      91
         A(NXS,NXS)=-TS6I                                               ASVC2      92
         NXS1=NXS                                                       ASVC2      93
         IF (IDDAT(JS+6).NE.0) THEN                                     ASVC2      94
            NXS1=NXS1-1                                                 ASVC2      95
            A(NXS,NXS1)=CSVCT6*(1.0-T4T5)                               ASVC2      96
         END IF                                                         ASVC2      97
         IF (IDDAT(JS+4).NE.0) THEN                                     ASVC2      98
            NXS1=NXS1-1                                                 ASVC2      99
            A(NXS,NXS1)=CSVCT6*T4T5*(1.0-T2T3)                          ASVC2     100
         END IF                                                         ASVC2     101
         IF (IDDAT(JS+1).EQ.0) THEN                                     ASVC2     102
            B(NXS,1)=CSVCT6*T2T3*T4T5*VSR1                              ASVC2     103
            B(NXS,2)=CSVCT6*T2T3*T4T5*VSI1                              ASVC2     104
         ELSE                                                           ASVC2     105
            A(NXS,NXS1-1)=CSVCT6*T4T5*T2T3                              ASVC2     106
         END IF                                                         ASVC2     107
C                                                                       ASVC2     108
      END IF                                                            ASVC2     109
C                                                                       ASVC2     110
C     AK MATRIX                                                         ASVC2     111
C                                                                       ASVC2     112
      AK(1,NXS)=-EPQ*BSRAT                                              ASVC2     113
      AK(2,NXS)=EPD*BSRAT                                               ASVC2     114
C                                                                       ASVC2     115
C     YD MATRIX                                                         ASVC2     116
C                                                                       ASVC2     117
      YD(1,2)=YD(1,2)+BSVCS                                             ASVC2     118
      YD(2,1)=YD(2,1)-BSVCS                                             ASVC2     119
C                                                                       ASVC2     120
      RETURN                                                            ASVC2     121
      END                                                               ASVC2     122
