CFPRIME ASTA12                                                          ASTA12      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 ASTA12(ISTATE)                                         ASTA12      3
CD                                                                      ASTA12      4
CD    TO FORMULATE THE JACOBIAN MATRICES OF TYPE 12 STABILIZER.         ASTA12      5
CD                                                                      ASTA12      6
      INCLUDE 'PARX.INS'                                                ASTA12      7
      INCLUDE 'CNB8.INS'                                                ASTA12      8
      INCLUDE 'CNEXC.INS'                                               ASTA12      9
      INCLUDE 'CNSTAB.INS'                                              ASTA12     10
      INCLUDE 'CNPARX.INS'                                              ASTA12     11
      INCLUDE 'CNMDAT.INS'                                              ASTA12     12
      INCLUDE 'CNXSTA.INS'                                              ASTA12     13
      INCLUDE 'CNMSTA.INS'                                              ASTA12     14
      INCLUDE 'CNUDMB.INS'                                              ASTA12     15
      INCLUDE 'CNABAK.INS'                                              ASTA12     16
C                                                                       ASTA12     17
C     SUBSCRIPTS                                                        ASTA12     18
C                                                                       ASTA12     19
      ISUB1=IDDAT(JS+25)                                                ASTA12     20
      ISUB2=IDDAT(JS+26)                                                ASTA12     21
      ISUB3=IDDAT(JS+27)                                                ASTA12     22
      ISUB4=IDDAT(JS+28)                                                ASTA12     23
      ISUB5=IDDAT(JS+29)                                                ASTA12     24
      ISUB6=IDDAT(JS+30)                                                ASTA12     25
C                                                                       ASTA12     26
      IE=0                                                              ASTA12     27
      ICASE=IDDAT(JS+31)                                                ASTA12     28
C                                                                       ASTA12     29
      IF (ICASE.EQ.0) THEN                                              ASTA12     30
C                                                                       ASTA12     31
C     OUTPUT SWITCH AT "OFF" POSITION, EXIT                             ASTA12     32
C                                                                       ASTA12     33
         IF (ISUB1.NE.0) IE=IE+1                                        ASTA12     34
         IF (ISUB2.NE.0) IE=IE+1                                        ASTA12     35
         IF (ISUB3.NE.0) IE=IE+1                                        ASTA12     36
         IF (ISUB4.NE.0) IE=IE+1                                        ASTA12     37
         IF (ISUB5.NE.0) IE=IE+1                                        ASTA12     38
         IF (ISUB6.NE.0) IE=IE+1                                        ASTA12     39
         IF (IFLTRN.NE.0) CALL ASTF1(ISTATE)                            ASTA12     40
         INSTA(1,1)=0                                                   ASTA12     41
C                                                                       ASTA12     42
         GOTO 110                                                       ASTA12     43
C                                                                       ASTA12     44
      END IF                                                            ASTA12     45
C                                                                       ASTA12     46
      INTYP1=IDDAT(JS+2)                                                ASTA12     47
      INTYP2=IDDAT(JS+4)                                                ASTA12     48
C                                                                       ASTA12     49
C     K1, T1 BLOCK (OPTIONAL)                                           ASTA12     50
C                                                                       ASTA12     51
      CC1=DDAT(JS+5)                                                    ASTA12     52
      IF (ISUB1.EQ.0) THEN                                              ASTA12     53
         INPUT1=0                                                       ASTA12     54
      ELSE                                                              ASTA12     55
         IE=IE+1                                                        ASTA12     56
         INPUT1=1                                                       ASTA12     57
         T1I=1.0/DDAT(JS+6)                                             ASTA12     58
         A(ISUB1,ISUB1)=-T1I                                            ASTA12     59
         INSTA(IE,1)=ISUB1                                              ASTA12     60
         RINSTA(IE,1)=CC1*T1I                                           ASTA12     61
         RINSTA(IE,2)=0.0                                               ASTA12     62
      END IF                                                            ASTA12     63
C                                                                       ASTA12     64
C     K2, T2 BLOCK (OPTIONAL)                                           ASTA12     65
C                                                                       ASTA12     66
      CC2=DDAT(JS+7)                                                    ASTA12     67
      IF (ISUB2.EQ.0) THEN                                              ASTA12     68
         INPUT2=0                                                       ASTA12     69
      ELSE                                                              ASTA12     70
         IE=IE+1                                                        ASTA12     71
         INPUT2=1                                                       ASTA12     72
         T2I=1.0/DDAT(JS+8)                                             ASTA12     73
         A(ISUB2,ISUB2)=-T2I                                            ASTA12     74
         INSTA(IE,2)=ISUB2                                              ASTA12     75
         RINSTA(IE,1)=0.0                                               ASTA12     76
         RINSTA(IE,2)=CC2*T2I                                           ASTA12     77
      END IF                                                            ASTA12     78
C                                                                       ASTA12     79
      GAIN1=1.0                                                         ASTA12     80
      GAIN2=0.0                                                         ASTA12     81
      GAIN3=0.0                                                         ASTA12     82
      GAIN4=0.0                                                         ASTA12     83
C                                                                       ASTA12     84
C     T'Q0, TQ0 BLOCK (OPTIONAL)                                        ASTA12     85
C                                                                       ASTA12     86
      IF (ISUB3.NE.0) THEN                                              ASTA12     87
         IE=IE+1                                                        ASTA12     88
         TQ0I=1.0/DDAT(JS+10)                                           ASTA12     89
         A(ISUB3,ISUB3)=-TQ0I                                           ASTA12     90
         INSTA(IE,1)=ISUB3                                              ASTA12     91
         RINSTA(IE,1)=0.0                                               ASTA12     92
         RINSTA(IE,2)=0.0                                               ASTA12     93
         IF (INPUT1.EQ.0) THEN                                          ASTA12     94
            RINSTA(IE,1)=CC1*TQ0I                                       ASTA12     95
         ELSE                                                           ASTA12     96
            A(ISUB3,ISUB1)=TQ0I                                         ASTA12     97
         END IF                                                         ASTA12     98
         IF (INPUT2.EQ.0) THEN                                          ASTA12     99
            RINSTA(IE,2)=CC2*TQ0I                                       ASTA12    100
         ELSE                                                           ASTA12    101
            A(ISUB3,ISUB2)=TQ0I                                         ASTA12    102
         END IF                                                         ASTA12    103
         GAIN1=DDAT(JS+9)*TQ0I                                          ASTA12    104
      END IF                                                            ASTA12    105
C                                                                       ASTA12    106
C     T'Q1, TQ1 BLOCK (OPTIONAL)                                        ASTA12    107
C                                                                       ASTA12    108
      IF (ISUB4.NE.0) THEN                                              ASTA12    109
         IE=IE+1                                                        ASTA12    110
         TQ1I=1.0/DDAT(JS+12)                                           ASTA12    111
         TPQ1=DDAT(JS+11)                                               ASTA12    112
         GAIN1=GAIN1*TQ1I                                               ASTA12    113
         A(ISUB4,ISUB4)=-TQ1I                                           ASTA12    114
         IF (ISUB3.NE.0) A(ISUB4,ISUB3)=-GAIN1                          ASTA12    115
         INSTA(IE,1)=ISUB4                                              ASTA12    116
         RINSTA(IE,1)=0.0                                               ASTA12    117
         RINSTA(IE,2)=0.0                                               ASTA12    118
         IF (INPUT1.EQ.0) THEN                                          ASTA12    119
            RINSTA(IE,1)=CC1*GAIN1                                      ASTA12    120
         ELSE                                                           ASTA12    121
            A(ISUB4,ISUB1)=GAIN1                                        ASTA12    122
         END IF                                                         ASTA12    123
         IF (INPUT2.EQ.0) THEN                                          ASTA12    124
            RINSTA(IE,2)=CC2*GAIN1                                      ASTA12    125
         ELSE                                                           ASTA12    126
            A(ISUB4,ISUB2)=GAIN1                                        ASTA12    127
         END IF                                                         ASTA12    128
         GAIN2=1.0-TPQ1*TQ1I                                            ASTA12    129
         GAIN1=GAIN1*TPQ1                                               ASTA12    130
      END IF                                                            ASTA12    131
C                                                                       ASTA12    132
C     T'Q2, TQ2 BLOCK (OPTIONAL)                                        ASTA12    133
C                                                                       ASTA12    134
      IF (ISUB5.NE.0) THEN                                              ASTA12    135
         IE=IE+1                                                        ASTA12    136
         TQ2I=1.0/DDAT(JS+14)                                           ASTA12    137
         TPQ2=DDAT(JS+13)                                               ASTA12    138
         GAIN2=GAIN2*TQ2I                                               ASTA12    139
         GAIN1=GAIN1*TQ2I                                               ASTA12    140
         A(ISUB5,ISUB5)=-TQ2I                                           ASTA12    141
         IF (ISUB3.NE.0) A(ISUB5,ISUB3)=-GAIN1                          ASTA12    142
         IF (ISUB4.NE.0) A(ISUB5,ISUB4)=GAIN2                           ASTA12    143
         INSTA(IE,1)=ISUB5                                              ASTA12    144
         RINSTA(IE,1)=0.0                                               ASTA12    145
         RINSTA(IE,2)=0.0                                               ASTA12    146
         IF (INPUT1.EQ.0) THEN                                          ASTA12    147
            RINSTA(IE,1)=CC1*GAIN1                                      ASTA12    148
         ELSE                                                           ASTA12    149
            A(ISUB5,ISUB1)=GAIN1                                        ASTA12    150
         END IF                                                         ASTA12    151
         IF (INPUT2.EQ.0) THEN                                          ASTA12    152
            RINSTA(IE,2)=CC2*GAIN1                                      ASTA12    153
         ELSE                                                           ASTA12    154
            A(ISUB5,ISUB2)=GAIN1                                        ASTA12    155
         END IF                                                         ASTA12    156
         GAIN3=1.0-TPQ2*TQ2I                                            ASTA12    157
         GAIN2=GAIN2*TPQ2                                               ASTA12    158
         GAIN1=GAIN1*TPQ2                                               ASTA12    159
      END IF                                                            ASTA12    160
C                                                                       ASTA12    161
C     T'Q3, TQ3 BLOCK (OPTIONAL)                                        ASTA12    162
C                                                                       ASTA12    163
      IF (ISUB6.NE.0) THEN                                              ASTA12    164
         IE=IE+1                                                        ASTA12    165
         TQ3I=1.0/DDAT(JS+16)                                           ASTA12    166
         TPQ3=DDAT(JS+15)                                               ASTA12    167
         GAIN3=GAIN3*TQ3I                                               ASTA12    168
         GAIN2=GAIN2*TQ3I                                               ASTA12    169
         GAIN1=GAIN1*TQ3I                                               ASTA12    170
         A(ISUB6,ISUB6)=-TQ3I                                           ASTA12    171
         IF (ISUB3.NE.0) A(ISUB6,ISUB3)=-GAIN1                          ASTA12    172
         IF (ISUB4.NE.0) A(ISUB6,ISUB4)=GAIN2                           ASTA12    173
         IF (ISUB5.NE.0) A(ISUB6,ISUB5)=GAIN3                           ASTA12    174
         INSTA(IE,1)=ISUB6                                              ASTA12    175
         RINSTA(IE,1)=0.0                                               ASTA12    176
         RINSTA(IE,2)=0.0                                               ASTA12    177
         IF (INPUT1.EQ.0) THEN                                          ASTA12    178
            RINSTA(IE,1)=CC1*GAIN1                                      ASTA12    179
         ELSE                                                           ASTA12    180
            A(ISUB6,ISUB1)=GAIN1                                        ASTA12    181
         END IF                                                         ASTA12    182
         IF (INPUT2.EQ.0) THEN                                          ASTA12    183
            RINSTA(IE,2)=CC2*GAIN1                                      ASTA12    184
         ELSE                                                           ASTA12    185
            A(ISUB6,ISUB2)=GAIN1                                        ASTA12    186
         END IF                                                         ASTA12    187
         GAIN4=1.0-TPQ3*TQ3I                                            ASTA12    188
         GAIN3=GAIN3*TPQ3                                               ASTA12    189
         GAIN2=GAIN2*TPQ3                                               ASTA12    190
         GAIN1=GAIN1*TPQ3                                               ASTA12    191
      END IF                                                            ASTA12    192
C                                                                       ASTA12    193
C     OUTPUT EQUATION                                                   ASTA12    194
C                                                                       ASTA12    195
      IE1=0                                                             ASTA12    196
      DSTB1=0.0                                                         ASTA12    197
      DSTB2=0.0                                                         ASTA12    198
      IF (INPUT1.EQ.0) THEN                                             ASTA12    199
         DSTB1=CC1*GAIN1                                                ASTA12    200
      ELSE                                                              ASTA12    201
         IE1=IE1+1                                                      ASTA12    202
         IOUTS(IE1)=ISUB1                                               ASTA12    203
         ROUTS(IE1)=GAIN1                                               ASTA12    204
      END IF                                                            ASTA12    205
      IF (INPUT2.EQ.0) THEN                                             ASTA12    206
         DSTB2=CC2*GAIN1                                                ASTA12    207
      ELSE                                                              ASTA12    208
         IE1=IE1+1                                                      ASTA12    209
         IOUTS(IE1)=ISUB2                                               ASTA12    210
         ROUTS(IE1)=GAIN1                                               ASTA12    211
      END IF                                                            ASTA12    212
      IF (ISUB3.NE.0) THEN                                              ASTA12    213
         IE1=IE1+1                                                      ASTA12    214
         IOUTS(IE1)=ISUB3                                               ASTA12    215
         ROUTS(IE1)=-GAIN1                                              ASTA12    216
      END IF                                                            ASTA12    217
      IF (ISUB4.NE.0) THEN                                              ASTA12    218
         IE1=IE1+1                                                      ASTA12    219
         IOUTS(IE1)=ISUB4                                               ASTA12    220
         ROUTS(IE1)=GAIN2                                               ASTA12    221
      END IF                                                            ASTA12    222
      IF (ISUB5.NE.0) THEN                                              ASTA12    223
         IE1=IE1+1                                                      ASTA12    224
         IOUTS(IE1)=ISUB5                                               ASTA12    225
         ROUTS(IE1)=GAIN3                                               ASTA12    226
      END IF                                                            ASTA12    227
      IF (ISUB6.NE.0) THEN                                              ASTA12    228
         IE1=IE1+1                                                      ASTA12    229
         IOUTS(IE1)=ISUB6                                               ASTA12    230
         ROUTS(IE1)=GAIN4                                               ASTA12    231
      END IF                                                            ASTA12    232
C                                                                       ASTA12    233
C     TORSIONAL FILTER                                                  ASTA12    234
C                                                                       ASTA12    235
      IF (IFLTRN.NE.0) CALL ASTF1(ISTATE)                               ASTA12    236
C                                                                       ASTA12    237
C     INTERCONNECTION WITH EXCITER                                      ASTA12    238
C                                                                       ASTA12    239
      IE1=IE                                                            ASTA12    240
      IF (IEXN.NE.50) THEN                                              ASTA12    241
C                                                                       ASTA12    242
      DO 10 I=1,4                                                       ASTA12    243
         IF (IUST(I).EQ.0) GOTO 100                                     ASTA12    244
         IWS1=IUST(I)                                                   ASTA12    245
         WS1=GUST(I)                                                    ASTA12    246
         DO 20 J=1,IE                                                   ASTA12    247
            IWS2=IOUTS(J)                                               ASTA12    248
            A(IWS1,IWS2)=ROUTS(J)*WS1                                   ASTA12    249
  20     CONTINUE                                                       ASTA12    250
         IE1=IE1+1                                                      ASTA12    251
         INSTA(IE1,1)=IWS1                                              ASTA12    252
         RINSTA(IE1,1)=DSTB1*WS1                                        ASTA12    253
         RINSTA(IE1,2)=DSTB2*WS1                                        ASTA12    254
  10  CONTINUE                                                          ASTA12    255
C                                                                       ASTA12    256
      ELSE                                                              ASTA12    257
C                                                                       ASTA12    258
C     CONNECTION WITH A USER DEFIEND EXCITER                            ASTA12    259
C                                                                       ASTA12    260
      MSEXC=MSUDM(1,1)                                                  ASTA12    261
      IWS1=ISTATE-MSEXC                                                 ASTA12    262
      DO 30 I=1,MSEXC+1                                                 ASTA12    263
         IWS2=IWS1+I                                                    ASTA12    264
         IF (I.GT.MSEXC) IWS2=3                                         ASTA12    265
         DO 40 J=1,IE                                                   ASTA12    266
            IWS3=IOUTS(J)                                               ASTA12    267
            A(IWS2,IWS3)=ROUTS(J)*BXVS(I)                               ASTA12    268
  40     CONTINUE                                                       ASTA12    269
         IE1=IE1+1                                                      ASTA12    270
         INSTA(IE1,1)=IWS2                                              ASTA12    271
         RINSTA(IE1,1)=DSTB1*BXVS(I)                                    ASTA12    272
         RINSTA(IE1,2)=DSTB2*BXVS(I)                                    ASTA12    273
  30  CONTINUE                                                          ASTA12    274
C                                                                       ASTA12    275
      END IF                                                            ASTA12    276
C                                                                       ASTA12    277
 100  CONTINUE                                                          ASTA12    278
      INSTA(IE1+1,1)=0                                                  ASTA12    279
C                                                                       ASTA12    280
C     INCOPORATE WITH INPUT SIGNALS                                     ASTA12    281
C                                                                       ASTA12    282
      CALL ASGNAL(ISTATE,INTYP1,INTYP2)                                 ASTA12    283
C                                                                       ASTA12    284
 110  CONTINUE                                                          ASTA12    285
C                                                                       ASTA12    286
      ISTATE=ISTATE+IE                                                  ASTA12    287
C                                                                       ASTA12    288
      RETURN                                                            ASTA12    289
      END                                                               ASTA12    290
