CFPRIME DCEFCT                                                          DCEFCT      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  DCEFCT                                                DCEFCT      3
CD -------------------------------------------------------------------  DCEFCT      4
CD                                                                      DCEFCT      5
CD              *****     DCEFCT  ROUTINE   *****                       DCEFCT      6
CD                                                                      DCEFCT      7
CD -------------------------------------------------------------------  DCEFCT      8
CD                                                                      DCEFCT      9
CD       PURPOSE:  Calculate the current injection to interface         DCEFCT     10
CD                 to AC solution.                                      DCEFCT     11
CD                                                                      DCEFCT     12
CD                                                                      DCEFCT     13
CD       DEFINITION OF LOCAL VARIABLES:                                 DCEFCT     14
CD                 ETA    -  original real voltage value.               DCEFCT     15
CD                 ETAT   -  updated real voltage value.                DCEFCT     16
CD                 ETB    -  original imaginary voltage value.          DCEFCT     17
CD                 ETBT   -  updated imaginary voltage value.           DCEFCT     18
CD                 I      - 'do' loop index.                            DCEFCT     19
CD                 VALUE  -  voltage magnitude squared.                 DCEFCT     20
CD                                                                      DCEFCT     21
CD -------------------------------------------------------------------  DCEFCT     22
      INCLUDE 'PARX.INS'                                                DCEFCT     23
      INCLUDE 'CNPT.INS'                                                DCEFCT     24
C                                                                       DCEFCT     25
      INCLUDE 'UDCA.INS'                                                DCEFCT     26
      INCLUDE 'GRPDCS.INS'                                              DCEFCT     27
      INCLUDE 'UDCF.INS'                                                DCEFCT     28
      INCLUDE 'UDCG.INS'                                                DCEFCT     29
      INCLUDE 'UDCJ.INS'                                                DCEFCT     30
C                                                                       DCEFCT     31
      DOUBLE PRECISION    ETA,ETAT,ETB,ETBT,VALUE                       DCEFCT     32
C                                                                       DCEFCT     33
C---------------------------------------------------------------------  DCEFCT     34
C                                                                       DCEFCT     35
      DO 20 I = 1, NACBUS                                               DCEFCT     36
         ETA = DCEA(I)                                                  DCEFCT     37
         ETB = DCEB(I)                                                  DCEFCT     38
         ETAT = DCEAT(I)                                                DCEFCT     39
         ETBT = DCEBT(I)                                                DCEFCT     40
         VALUE = ETAT * ETAT + ETBT * ETBT                              DCEFCT     41
         IF (VALUE.LE.0.0.AND.VALUE.GE.0.0) VALUE = 0.01                DCEFCT     42
         IF(THEVIN) THEN                                                DCEFCT     43
            VTWR(I) = (ETA * ETAT + ETB * ETBT) / VALUE                 DCEFCT     44
            VTWI(I) = (ETAT * ETB - ETBT * ETA) / VALUE                 DCEFCT     45
         ELSE                                                           DCEFCT     46
            VTWR(I) = 1.0                                               DCEFCT     47
            VTWI(I) = 0.0                                               DCEFCT     48
         ENDIF                                                          DCEFCT     49
         PTHVDC(I) = PTHVDC(I) / REAL (NDSTEP)                          DCEFCT     50
20    CONTINUE                                                          DCEFCT     51
C                                                                       DCEFCT     52
C                                                                       DCEFCT     53
C---------------------------------------------------------------------  DCEFCT     54
C                                                                       DCEFCT     55
      RETURN                                                            DCEFCT     56
C                                                                       DCEFCT     57
C---------------------------------------------------------------------  DCEFCT     58
C                                                                       DCEFCT     59
      END                                                               DCEFCT     60
