CFPRIME DCWRIT                                                          DCWRIT      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  DCWRIT                                                DCWRIT      3
CD -------------------------------------------------------------------  DCWRIT      4
CD                                                                      DCWRIT      5
CD              *****     DCWRIT  ROUTINE   *****                       DCWRIT      6
CD                                                                      DCWRIT      7
CD -------------------------------------------------------------------  DCWRIT      8
CD                                                                      DCWRIT      9
CD       PURPOSE:  Write the dc solution data to the output file.       DCWRIT     10
CD                                                                      DCWRIT     11
CD                                                                      DCWRIT     12
CD       DEFINITION OF LOCAL VARIABLES:                                 DCWRIT     13
CD                 ALP    -  alpha in degrees.                          DCWRIT     14
CD                 GAM    -  gamma in degrees.                          DCWRIT     15
CD                 I      - 'do' loop index.                            DCWRIT     16
CD                 JPOSN   -  storage position for dc information.      DCWRIT     17
CD                                                                      DCWRIT     18
CD -------------------------------------------------------------------  DCWRIT     19
      INCLUDE 'CNUNIT.INS'                                              DCWRIT     20
      INCLUDE 'PARX.INS'                                                DCWRIT     21
      INCLUDE 'GRDC01.INS'                                              DCWRIT     22
      INCLUDE 'GRDC02.INS'                                              DCWRIT     23
      INCLUDE 'GRDC03.INS'                                              DCWRIT     24
      INCLUDE 'CNPARX.INS'                                              DCWRIT     25
      INCLUDE 'CNFLAG.INS'                                              DCWRIT     26
      INCLUDE 'UDCF.INS'                                                DCWRIT     27
      INCLUDE 'UDCG.INS'                                                DCWRIT     28
C                                                                       DCWRIT     29
C---------------------------------------------------------------------  DCWRIT     30
C                                                                       DCWRIT     31
      LDEB=.FALSE.                                                      DCWRIT     32
      WRITE (IUD6,9002) TIME                                            DCWRIT     33
      DO 20 I = 1, ICDC                                                 DCWRIT     34
         JPOSN = IDC(I)                                                 DCWRIT     35
         NUM = IDCBNU(JPOSN)                                            DCWRIT     36
         NU2 = IDCBN2(JPOSN)                                            DCWRIT     37
         ICT = ICTYPE(JPOSN)                                            DCWRIT     38
         ICTA = IABS(ICT)                                               DCWRIT     39
         IF(ICTA.EQ.1) THEN                                             DCWRIT     40
C                                                                       DCWRIT     41
C           line commutation                                            DCWRIT     42
C                                                                       DCWRIT     43
            ALP = ACOS(CALPHA(JPOSN))*180.0/PII                         DCWRIT     44
            GAM = ACOS(CGAMMA(JPOSN))*180.0/PII                         DCWRIT     45
            QA = QAHVDC(JPOSN)                                          DCWRIT     46
         ELSE                                                           DCWRIT     47
C                                                                       DCWRIT     48
C           self commutation                                            DCWRIT     49
C                                                                       DCWRIT     50
            ALP = CALPHA(JPOSN)*180.0/PII                               DCWRIT     51
            GAM = CGAMMA(JPOSN)                                         DCWRIT     52
            QA = QAHVDC(JPOSN) + Q2HVDC(JPOSN)                          DCWRIT     53
         ENDIF                                                          DCWRIT     54
         IF(NUM .EQ. 0) THEN                                            DCWRIT     55
C                                                                       DCWRIT     56
C           1.0 per unit ac infinite bus                                DCWRIT     57
C                                                                       DCWRIT     58
            TEMP = 1.0                                                  DCWRIT     59
         ELSE                                                           DCWRIT     60
C                                                                       DCWRIT     61
            IF(NU2 .EQ. 0) THEN                                         DCWRIT     62
C                                                                       DCWRIT     63
C              shunt converter                                          DCWRIT     64
C                                                                       DCWRIT     65
               TEMP = SQRT( DCEA(NUM) * DCEA(NUM) +                     DCWRIT     66
     1                DCEB(NUM) * DCEB(NUM) )                           DCWRIT     67
            ELSE                                                        DCWRIT     68
C                                                                       DCWRIT     69
C              series converter                                         DCWRIT     70
C                                                                       DCWRIT     71
               TEMP = SQRT((DCEA(NUM) - DCEA(NU2))**2 +                 DCWRIT     72
     1               (DCEB(NUM) - DCEB(NU2))**2 )                       DCWRIT     73
            ENDIF                                                       DCWRIT     74
         ENDIF                                                          DCWRIT     75
         WRITE (IUD6,9004) DCCNAM(JPOSN), TEMP, VDCONV(JPOSN),          DCWRIT     76
     1                    XDCONV(JPOSN)*1000.0, ALP, GAM,               DCWRIT     77
     2                    PAHVDC(JPOSN), QA                             DCWRIT     78
20    CONTINUE                                                          DCWRIT     79
C                                                                       DCWRIT     80
C                                                                       DCWRIT     81
C---------------------------------------------------------------------  DCWRIT     82
C                                                                       DCWRIT     83
      RETURN                                                            DCWRIT     84
C                                                                       DCWRIT     85
C---------------------------------------------------------------------  DCWRIT     86
C                                                                       DCWRIT     87
9002  FORMAT (/,' DC SOLUTION AT TIME = ', F10.6, /,                    DCWRIT     88
     1       8X,'CONVERTER NAME',10X,' AC PU    DC KV   DC AMPS',       DCWRIT     89
     2       '   ALPHA    GAMMA    P (MW)   Q (MVAR)  ')                DCWRIT     90
9004  FORMAT (1X, A, 1X, F7.4, F9.3, F10.3, 2F9.3, 2F10.3)              DCWRIT     91
C                                                                       DCWRIT     92
C---------------------------------------------------------------------  DCWRIT     93
C                                                                       DCWRIT     94
      END                                                               DCWRIT     95
