CFPRIME ABCD                                                            ABCD        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 ABCD(NSECT,ZCX,Y1CX,Y2CX,REQ,XEQ,G1EQ,B1EQ,G2EQ,B2EQ) ABCD        3
CD                                                                      ABCD        4
CD    TO CALCULATE THE ABCD CONSTANTS OF A TWO PORT NETWORK.            ABCD        5
CD                                                                      ABCD        6
      INCLUDE 'PARX.INS'                                                ABCD        7
      INCLUDE 'CNFLAG.INS'                                              ABCD        8
      INCLUDE 'CNUNIT.INS'                                              ABCD        9
C                                                                       ABCD       10
       COMPLEX ACX(NDCL),BCX(NDCL),CCX(NDCL),DCX(NDCL)                  ABCD       11
       COMPLEX Y1CX(20),Y2CX(20),ZCX(20)                                ABCD       12
       COMPLEX ACXF,BCXF,CCXF,DCXF,Y1CXF,Y2CXF,ZCXF                     ABCD       13
       COMPLEX ACXFT,BCXFT,CCXFT,DCXFT                                  ABCD       14
C                                                                       ABCD       15
      LDEB=(JDEB(3).NE.0)                                               ABCD       16
C                                                                       ABCD       17
      IF(LDEB)THEN                                                      ABCD       18
      WRITE(IUD6,1030)                                                  ABCD       19
      WRITE(IUD6,1020) (J,ZCX(J),Y1CX(J),Y2CX(J),J=1,NSECT)             ABCD       20
      ENDIF                                                             ABCD       21
C                                                                       ABCD       22
C     CALC ABCD'S FOR EACH LINE SECTION                                 ABCD       23
C                                                                       ABCD       24
      DO 110 J=1,NSECT                                                  ABCD       25
      ACX(J)=1.+Y2CX(J)*ZCX(J)                                          ABCD       26
      BCX(J)=ZCX(J)                                                     ABCD       27
      CCX(J)=Y1CX(J)+Y2CX(J)+ZCX(J)*Y1CX(J)*Y2CX(J)                     ABCD       28
      DCX(J)=1.+Y1CX(J)*ZCX(J)                                          ABCD       29
      IF(LDEB)WRITE(IUD6,1209) J,ACX(J),BCX(J),CCX(J),DCX(J)            ABCD       30
  110 CONTINUE                                                          ABCD       31
C                                                                       ABCD       32
      ACXF=ACX(1)                                                       ABCD       33
      BCXF=BCX(1)                                                       ABCD       34
      CCXF=CCX(1)                                                       ABCD       35
      DCXF=DCX(1)                                                       ABCD       36
C                                                                       ABCD       37
C     CALCULATE FINAL ABCD'S.                                           ABCD       38
C                                                                       ABCD       39
      DO 120 J=2,NSECT                                                  ABCD       40
      ACXFT=ACXF*ACX(J)+BCXF*CCX(J)                                     ABCD       41
      BCXFT=ACXF*BCX(J)+BCXF*DCX(J)                                     ABCD       42
      CCXFT=CCXF*ACX(J)+DCXF*CCX(J)                                     ABCD       43
      DCXFT=CCXF*BCX(J)+DCXF*DCX(J)                                     ABCD       44
      ACXF=ACXFT                                                        ABCD       45
      BCXF=BCXFT                                                        ABCD       46
      CCXF=CCXFT                                                        ABCD       47
      DCXF=DCXFT                                                        ABCD       48
 120  CONTINUE                                                          ABCD       49
C                                                                       ABCD       50
      IF(LDEB)WRITE(IUD6,1210) ACXF,BCXF,CCXF,DCXF                      ABCD       51
C                                                                       ABCD       52
C     CALCULATE THE FINAL Z,Y1,Y2                                       ABCD       53
C                                                                       ABCD       54
      ZCXF=BCXF                                                         ABCD       55
      Y2CXF=(ACXF-1.)/ZCXF                                              ABCD       56
      Y1CXF=(DCXF-1.)/ZCXF                                              ABCD       57
C                                                                       ABCD       58
      REQ=REAL(ZCXF)                                                    ABCD       59
      XEQ=AIMAG(ZCXF)                                                   ABCD       60
      G1EQ=REAL(Y1CXF)                                                  ABCD       61
      B1EQ=AIMAG(Y1CXF)                                                 ABCD       62
      G2EQ=REAL(Y2CXF)                                                  ABCD       63
      B2EQ=AIMAG(Y2CXF)                                                 ABCD       64
C                                                                       ABCD       65
      IF(LDEB)WRITE(IUD6,1222) REQ,XEQ,G1EQ,B1EQ,G2EQ,B2EQ              ABCD       66
C                                                                       ABCD       67
      RETURN                                                            ABCD       68
C                                                                       ABCD       69
 1222 FORMAT(1X,'DEBUG(ABCD) R,X,G1,B1,G2,B2 : ',6F10.4)                ABCD       70
 1030 FORMAT(1X,'SECTION',T15,'R',T25,'X',T35,'G1',T45,'B1',T55,'G2',   ABCD       71
     1       T65,'B2')                                                  ABCD       72
 1209 FORMAT(1X,'%DEBUG(ABCD) SECT,A,B,C,D : ',I5,8F10.4)               ABCD       73
 1210 FORMAT(1X,'%DEBUG(ABCD) FINAL A,B,C,D CONSTANTS : ',8F10.4)       ABCD       74
 1020     FORMAT(I10,6F10.4)                                            ABCD       75
      END                                                               ABCD       76
