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