solinit.F [SRC] [CPP] [JOB] [SCAN]
TOOLS / SOLINIT / SRC



   1 | include(dom.inc)
   2 | 
   3 |       PROGRAM solinit
   4 | 
   5 | !       ================================================================!
   6 | !                                                                       !
   7 | !       solinit.F : Creates an initial solution for PRISSMA             !
   8 | !                                                                       !
   9 | !       author    : J. AMAYA (october 2007)                             !
  10 | !                                                                       !
  11 | !       ================================================================!
  12 | 
  13 |         IMPLICIT NONE
  14 | 
  15 |         include 'dom_constants.h'
  16 | 
  17 |         DOM_INT      :: ntcells, ntnodes, ntfaces, inode, i_cnodes
  18 |         DOM_INT      :: i, j, k, icell, cnnode(8)
  19 |         DOM_REAL     :: r, d, x_ref, y_ref, z_ref, R_ref, L_ref, T_ref
  20 | 
  21 |         CHARACTER*80 :: nodesfile, clnodefile, propfile
  22 |         CHARACTER*80 :: gdatafile, path, kextfile
  23 | 
  24 |         DOM_REAL     :: T, P, XH2O, XCO2, XCO
  25 |         DOM_REAL     :: XO2, XN2, XSOOT, XFUEL
  26 |         DOM_REAL     :: YH2O, YCO2, YCO
  27 |         DOM_REAL     :: YO2, YN2, YFUEL
  28 |         DOM_REAL     :: W_FUEL, W_TOT
  29 |         DOM_REAL     :: kscat, kabs
  30 | 
  31 |         DOM_REAL, ALLOCATABLE, DIMENSION(:) :: T_n, P_n, XH2O_n, XCO2_n
  32 |         DOM_REAL, ALLOCATABLE, DIMENSION(:) :: XCO_n, XO2_n, XN2_n
  33 |         DOM_REAL, ALLOCATABLE, DIMENSION(:) :: XSOOT_n
  34 |         DOM_REAL, ALLOCATABLE, DIMENSION(:) :: kscattering_n
  35 |         DOM_REAL, ALLOCATABLE, DIMENSION(:) :: kabsorption_n
  36 |         DOM_REAL, ALLOCATABLE, DIMENSION(:) :: x, y, z
  37 | 
  38 | !       ------------------!
  39 | !       Read choices file !
  40 | !       ------------------!
  41 | 
  42 |         OPEN (FILE_CHCS , FILE='solinit.choices', FORM='FORMATTED')
  43 |         READ (FILE_CHCS,*) path
  44 |         CLOSE(FILE_CHCS)
  45 | 
  46 | !       -----------!
  47 | !       Open files !
  48 | !       -----------!
  49 | 
  50 |         nodesfile  = path(1:len_trim(path))//'/Nodelist.in'
  51 |         clnodefile = path(1:len_trim(path))//'/Cellnodes.in'
  52 |         propfile   = path(1:len_trim(path))//'/Properties.in'
  53 |         gdatafile  = path(1:len_trim(path))//'/Global.in'
  54 |         kextfile   = path(1:len_trim(path))//'/K_Extinction.in'
  55 | 
  56 |         OPEN(FILE_NODES, FILE=nodesfile , FORM='UNFORMATTED')
  57 |         OPEN(FILE_CLNOD, FILE=clnodefile, FORM='UNFORMATTED')
  58 |         OPEN(FILE_GDATA, FILE=gdatafile , FORM='UNFORMATTED')
  59 |         OPEN(FILE_PROP , FILE=propfile  , FORM='UNFORMATTED')
  60 |         OPEN(FILE_KEXT , FILE=kextfile  , FORM='UNFORMATTED')
  61 | 
  62 | !       ----------------------!
  63 | !       Read Global mesh data !
  64 | !       ----------------------!
  65 | 
  66 |         READ(FILE_GDATA) ntcells, ntnodes, ntfaces
  67 |         CLOSE(FILE_GDATA)
  68 | 
  69 | !       -----------------!
  70 | !       Allocate vectors !
  71 | !       -----------------!
  72 | 
  73 |         ALLOCATE(T_n    (ntnodes))
  74 |         ALLOCATE(P_n    (ntnodes))
  75 |         ALLOCATE(XH2O_n (ntnodes))
  76 |         ALLOCATE(XCO2_n (ntnodes))
  77 |         ALLOCATE(XCO_n  (ntnodes))
  78 |         ALLOCATE(XO2_n  (ntnodes))
  79 |         ALLOCATE(XN2_n  (ntnodes))
  80 |         ALLOCATE(XSOOT_n(ntnodes))
  81 |         ALLOCATE(x      (ntnodes))
  82 |         ALLOCATE(y      (ntnodes))
  83 |         ALLOCATE(z      (ntnodes))
  84 | 
  85 |         ALLOCATE(kscattering_n(ntnodes))
  86 |         ALLOCATE(kabsorption_n(ntnodes))
  87 | 
  88 | !       --------------------!
  89 | !       Read node positions !
  90 | !       --------------------!
  91 | 
  92 |         DO i=1, ntnodes
  93 |           READ(FILE_NODES) inode, x(i), y(i), z(i)
  94 |         ENDDO
  95 | 
  96 |         CLOSE(FILE_NODES)
  97 | 
  98 | !       -------------------------!
  99 | !       Fill the nodes with data !
 100 | !       -------------------------!
 101 | 
 102 |         kscattering_n = 0.
 103 |         kabsorption_n = 0.
 104 | 
 105 |         DO i=1, ntnodes
 106 |           include 'perso.inc'
 107 |         ENDDO
 108 | 
 109 | !       ---------------------!
 110 | !       Gather data to cells !
 111 | !       ---------------------!
 112 | 
 113 |         DO i=1, ntcells
 114 | 
 115 |           cnnode = 0
 116 |           READ(FILE_CLNOD) icell, i_cnodes,(cnnode(j),j=1,i_cnodes)
 117 | 
 118 |           T     = 0.
 119 |           P     = 0.
 120 |           XH2O  = 0.
 121 |           XCO2  = 0.
 122 |           XCO   = 0.
 123 |           XO2   = 0.
 124 |           XN2   = 0.
 125 |           XSOOT = 0.
 126 |           kscat = 0.
 127 |           kabs  = 0.
 128 | 
 129 |           DO j=1, i_cnodes
 130 |             k = cnnode(j)
 131 |             T     = T     + T_n(k)
 132 |             P     = P     + P_n(k)
 133 |             XH2O  = XH2O  + XH2O_n(k)
 134 |             XCO2  = XCO2  + XCO2_n(k)
 135 |             XCO   = XCO   + XCO_n(k)
 136 |             XO2   = XO2   + XO2_n(k)
 137 |             XN2   = XN2   + XN2_n(k)
 138 |             XSOOT = XSOOT + XSOOT_n(k)
 139 |             kscat = kscat + kscattering_n(k)
 140 |             kabs  = kabs  + kabsorption_n(k)
 141 |           ENDDO
 142 | 
 143 |           T     = T     / real(i_cnodes)
 144 |           P     = P     / real(i_cnodes)
 145 |           XH2O  = XH2O  / real(i_cnodes)
 146 |           XCO2  = XCO2  / real(i_cnodes)
 147 |           XCO   = XCO   / real(i_cnodes)
 148 |           XO2   = XO2   / real(i_cnodes)
 149 |           XN2   = XN2   / real(i_cnodes)
 150 |           XSOOT = XSOOT / real(i_cnodes)
 151 |           kabs  = kabs  / real(i_cnodes)
 152 |           kscat = kscat / real(i_cnodes)
 153 | 
 154 |           XFUEL = ABS(1 - (XH2O+XCO2+XCO+XO2+XN2) )
 155 |           W_TOT = XFUEL*W_FUEL + XCO2*W_CO2 + XO2*W_O2 + XH2O*W_H2O +   &
 156 |      &            XCO*W_CO + XN2*W_N2
 157 | 
 158 | !         ------------------------------!
 159 | !         Convert Molar->Mass fractions !
 160 | !         ------------------------------!
 161 | 
 162 |           YH2O  = XH2O  * (W_H2O /W_TOT)
 163 |           YCO2  = XCO2  * (W_CO2 /W_TOT)
 164 |           YCO   = XCO   * (W_CO  /W_TOT)
 165 |           YO2   = XO2   * (W_O2  /W_TOT)
 166 |           YN2   = XN2   * (W_N2  /W_TOT)
 167 |           YFUEL = XFUEL * (W_FUEL/W_TOT)
 168 | 
 169 | !         ---------------------------!
 170 | !         Write 'Properties.in' file !
 171 | !         ---------------------------!
 172 |           WRITE(FILE_PROP ) i, T, P, XH2O, XCO2, XCO, XO2, XN2, XSOOT
 173 |           WRITE(FILE_KEXT ) i, kabs, kscat
 174 | 
 175 |         ENDDO
 176 | 
 177 |         CLOSE(FILE_CLNOD)
 178 |         CLOSE(FILE_PROP )
 179 |         CLOSE(FILE_KEXT )
 180 | 
 181 |         WRITE(*,*) " Initial solution file successfully written"
 182 | 
 183 |       END PROGRAM solinit