AshFlow  0.1
ashflowmodel
 All Classes Files Functions Variables Pages
inpout.f90
Go to the documentation of this file.
1 !********************************************************************
3 !
6 !********************************************************************
7 
8 MODULE inpout
9 
10  IMPLICIT NONE
11 
12  CHARACTER(LEN=15) :: finp
13  CHARACTER*150 :: fout5
14 
15  CHARACTER(LEN=80) :: run_name, input_name
16 
17  CHARACTER(LEN=80) :: out_file
18  CHARACTER(LEN=80) :: out_file2
19  CHARACTER(LEN=80) :: out_file3
20  CHARACTER(LEN=80) :: out_file4
21 
22 
23  CHARACTER(LEN=3) :: outtime
24  REAL*8 :: factime
25  CHARACTER(LEN=3) :: outpres_b = 'Pa '
26  REAL*8 :: facpres
27  CHARACTER(LEN=3) :: outflux = 'd00'
28  REAL*8 :: facflux
29  CHARACTER(LEN=3) :: outmass = 'Kg '
30  REAL*8 :: facmass
31  CHARACTER(LEN=3) :: outvelo = 'ms '
32  REAL*8 :: facvelo
33  CHARACTER(LEN=3) :: outdist = ' m '
34  REAL*8 :: facdist
35 
36  CHARACTER(LEN=5) :: outdens = 'Kgm-3'
37  CHARACTER(LEN=3) :: outpres_t = 'Pa'
38 
39  INTEGER*4 :: iprint
40 
41  REAL*8 :: pi
42  !
43  !** Input files unit numbers
44  !
45  INTEGER, PARAMETER :: ninp = 7
46  !
47  !** Output files unit numbers
48  !
49  INTEGER, PARAMETER :: nout5=14
50 
51  SAVE
52 
53 CONTAINS
54 
55 
56  !*****************************************************************************
58  !
63  !******************************************************************************
64 
65  SUBROUTINE initialize
66 
67  USE current_module, ONLY: r
68 
69  USE mixture_module, ONLY: epsilon
70 
71  USE envi_module, ONLY: gi
72 
73  USE solver_module, ONLY: dh_dr
74 
75  IMPLICIT NONE
76 
77  outtime = 'sec' ! Output units for time
78  factime = 1.0d0
79  outpres_b = 'Pa ' ! Output units for pressure
80  facpres = 1.0d0
81  outflux = 'd00' ! Output units for mass flux
82  facflux = 1.0d0
83  outmass = 'Kg ' ! Output units for remaining chamber mass
84  facmass = 1.0d0
85  outvelo = 'ms ' ! Output units for velocity
86  facvelo = 1.0d0
87  outdist = ' m ' ! Output units for distance
88  facdist = 1.0d0
89  outpres_t = 'Pa ' ! Output units for pressure
90  outdens = 'Kgm-3 ' ! Output units for density
91 
92  END SUBROUTINE initialize
93 
94  !*****************************************************************************
100  !******************************************************************************
101 
102  SUBROUTINE reainp
103 
104  USE current_module, ONLY: oned_model , h0, r0, tvent_flag, t0
105 
106  USE envi_module, ONLY: fric, theta, gi, t_a, p, gas_constair, c_vair
107 
108  USE solver_module, ONLY: vel_equation , dr0 , eps_rel , eps_abs
109 
110  USE mixture_module, ONLY: nmag, n, ri, cpwvapour, rwvapour
111 
112  USE particles_module, ONLY: iclass, diam, rhosol, fracsolid, c_d , mean_phi,&
113  sigma_phi , min_phi , max_phi , c_d_input , phi_dist
114 
115  USE particles_module, ONLY: diam1 , diam2 , min_rho , max_rho
116 
117  USE tools, ONLY : runend
118 
120 
121  IMPLICIT NONE
122 
123  LOGICAL :: tend1
124  CHARACTER(LEN=80) :: card
125 
126  INTEGER :: i
127 
128  LOGICAL :: eval_gsd_flag
129 
130  namelist / control_parameters / run_name
131 
132  namelist / flow_parameters / oned_model , vel_equation , dr0 , eps_rel , eps_abs
133 
134  namelist / env_parameters / fric, theta, gi, t_a, p, gas_constair, c_vair, rwvapour, cpwvapour
135 
136  namelist / initial_values / r0, h0, ri, tvent_flag, t0, n, nmag , eval_gsd_flag
137 
138  namelist / density_parameters / diam1 , diam2 , min_rho , max_rho
139 
140  finp = 'flow_model.inp'
141 
142  OPEN(ninp,file=finp,status='old')
143 
144  READ(ninp, control_parameters)
145 
146  READ(ninp, flow_parameters)
147 
148  READ(ninp, env_parameters)
149 
150  pi = 4.d0 * atan(1.d0)
151  theta = theta*180/pi
152 
153  READ(ninp, initial_values)
154 
155  READ(ninp, density_parameters)
156 
157  tend1 = .false.
158 
159  granulometry_search: DO
160 
161  READ( ninp , *, END = 300 ) card
162 
163  IF( trim(card) == 'GRANULOMETRY' ) THEN
164 
165  EXIT granulometry_search
166 
167  END IF
168 
169  END DO granulometry_search
170 
171  READ(ninp,*) iclass
172 
173  IF (iclass .LT. 1) THEN
174 
175  WRITE(*,*) 'INPUT_ASH_FLOW_MODEL: no particle classes'
176 
177  ELSE
178 
179  CALL allocate_particles
180 
181  ENDIF
182 
183  IF ( eval_gsd_flag ) THEN
184 
185  READ(ninp,*) mean_phi, sigma_phi , min_phi , max_phi , c_d_input
186 
188 
189  ELSE
190 
191  DO i = 1, iclass
192 
193  READ(ninp,*) diam(i), rhosol(i), fracsolid(i), c_d(i)
194 
195  ENDDO
196 
197  END IF
198 
199  goto 310
200 300 tend1 = .true.
201 310 CONTINUE
202 
203  !
204  !*** Close input file
205  !
206 
207  CLOSE(ninp)
208 
209  fout5 = trim(run_name)//'.bak'
210 
211  OPEN(nout5,file=fout5,status='unknown')
212 
213  WRITE(nout5, control_parameters)
214 
215  WRITE(nout5, flow_parameters)
216 
217  WRITE(nout5, env_parameters)
218 
219  WRITE(nout5, initial_values)
220 
221  WRITE(nout5, density_parameters)
222 
223  IF (( tend1) .OR. (iclass .EQ. 0)) THEN
224 
225  WRITE(*,*) 'WARNING: input', 'SAMPLING POINTS not found'
226 
227  ELSE
228 
229  WRITE(nout5,*) '''GRANULOMETRY'''
230  WRITE(nout5,*) iclass
231 
232  IF ( eval_gsd_flag ) THEN
233 
234  WRITE(nout5,*) mean_phi, sigma_phi , min_phi , max_phi , c_d_input
235 
236  ELSE
237 
238  DO i = 1, iclass
239 
240  WRITE(nout5,*) diam(i), rhosol(i), fracsolid(i), c_d(i)
241 
242  END DO
243 
244  END IF
245 
246  END IF
247 
248  CLOSE(nout5)
249 
250  out_file = trim(run_name)//'.flow'
251  out_file2 = trim(run_name)//'.part'
252  out_file3 = trim(run_name)//'.dep'
253  out_file4 = trim(run_name)//'.ep'
254 
255  !
256  OPEN(51,file=out_file)
257  OPEN(52,file=out_file2)
258  OPEN(53,file='dakota_run.dak')
259  OPEN(54,file=out_file3)
260  OPEN(56, file=out_file4)
261 
262  IF ( eval_gsd_flag ) THEN
263 
264  WRITE(52,177) iclass,phi_dist(1:iclass)
265 
266  END IF
267 
268 177 FORMAT(i5,1x,50(e12.5, 1x))
269 
270  RETURN
271 
272 1007 CALL runend(-1, 'Error: cannot OPEN file: '//fout5)
273 
274  END SUBROUTINE reainp
275 
276  SUBROUTINE write_output
277 
278  USE current_module, ONLY : r , h , t , solid_mass_flux , u , oned_model, mass_flux, plume_velocity, initial_mf, solidmf_ratio
279  USE particles_module, ONLY : sumsed, fracsolid, v_s, iclass, final, acc_rate, diam, norm_flux, ipf, fpf, rhosol, diam
280  USE particles_module, ONLY : wavelengthfreen, wavelengthshearn, wavelengthfreex, wavelengthshearx, wavelength_height
281  USE particles_module, ONLY : pn, k, ustar, h_bl, ks, eta0, eta, ss0, bv, init_fracsolid, rhosol, diam, phi_dist, no_bins
282  USE mixture_module, ONLY : ri , epsilon , n , beta, pdyn, final_solid_mass_flux
283  USE mixture_module, ONLY : init_n, initial_smf, entrainment_rate
284  USE envi_module, ONLY : gi
285 
286  IMPLICIT NONE
287 
288  REAL*8 :: volume_flux
289  REAL*8 :: mean_grainsize
290  REAL*8 :: std_dev
291 
292  INTEGER :: i
293  INTEGER :: j
294 
295  IF ( oned_model ) THEN
296 
297  volume_flux = h * u
298 
299  ELSE
300 
301  volume_flux = h*u*r
302 
303  mass_flux = (beta * u * h * r) * 2 * pi
304  final_solid_mass_flux = (beta * u * h * r) * ( 1.d0 - n )
305  plume_velocity = mass_flux/(3.14d0 * r**2 * beta)
306  solidmf_ratio = final_solid_mass_flux/ initial_smf
307 
308  mean_grainsize = sum( phi_dist(1:no_bins)*fracsolid(1:no_bins))
309  std_dev = sqrt(sum( fracsolid(1:no_bins)*(phi_dist(1:no_bins)- mean_grainsize)**2 ) )
310 
311  !WRITE(*,*) 'mean_grainsize', mean_grainsize
312  !WRITE(*,*) 'std_dev', std_dev
313 
314  ! Particle Mass Flux
315  !DO i=1,iclass
316 
317  ! initial particle flux
318 
319  !ipf = Initial_MF * (1-init_N) * init_fracsolid
320  !fpf = mass_flux * (1-n) * fracsolid
321  !norm_flux = (ipf - fpf) / ipf
322 
323  !WRITE (*,*) 'ipf, fpf, norm_flux', ipf, fpf, norm_flux
324 
325  !ENDDO
326 
327 
328  END IF
329 
330  !
331  ! *** equations for postprocessing: flow dynamic pressure and deposit wavelength
332  !
333 
334  ! Dynamic Pressure (kPa)
335 
336  pdyn = (0.5 * beta * u **2)* 0.001
337 
338  ! Boundary Layer Thickness -- taken from Amanda's code from Allen 1970 book
339 
340  h_bl = 0.376d0*r*(0.0001d0/(beta*u*r))**(0.2)
341 
342  ! Eq. 14 Valentine 1987
343  ! ustar = (u * k) / LOG(30 * H_bl /ks)
344 
345  DO i=1,iclass
346 
347  ustar = (u * k) / log(50 * h_bl /diam(i))
348 
349  ! Accumulation rate
350 
351  acc_rate = (v_s(i) * solid_mass_flux)/( h * u) !Accumulation rate kg/s
352 
353  ! Rouse Number -- eq 2 from Valentine (1987)
354 
355  pn = v_s(i) / (0.4d0 * ustar)
356 
357  ! Non dimension reference height
358 
359  eta0 = h_bl/h
360 
361  ! Brunt-Vaisala Frequency
362 
363  DO j = 1,final
364 
365  eta(j) = 0.1d0 * (j) ! Non-dimensionless height in the flow, between 0 and 1
366 
367  ss0(j) = (eta0 / (1 - eta0)) * ((1 - eta(j)) / eta(j)) ** pn ! Non-dimensionalised concentration profile: Equation 4 from Valentine 1987
368 
369  bv(j) = (1/(2 * pi)) * (( gi / h ) * ( pn / (eta(j) *(1-eta(j))))) ** 0.5 !Brunt-Vaisala Frequency as a function on non-dimensional height in the flow, equation 8 in Valentine 1987
370 
371 
372  ENDDO
373 
374 
375  wavelengthfreen = u / maxval(bv) ! minimum wavelength using freestream velocity
376  wavelengthshearn = ustar / maxval(bv) ! minimum wavelength using shear velocity
377 
378  wavelengthfreex = u / minval(bv) ! maximum wavelength using freestream velocity
379  wavelengthshearx = ustar / minval(bv) ! maximum wavelength using shear velocity
380 
381  wavelength_height = 2 * pi * h * 0.4 ! Using Yalin, 1972 wavelength = 2*pi*h
382 
383  !WRITE(*,*) 'wavelengthfreen', wavelengthfreen
384  !WRITE(*,*) 'wavelengthshearn', wavelengthshearn
385  !WRITE(*,*) 'wavelengthfreex', wavelengthfreex
386  !WRITE(*,*) 'wavelengthshearx', wavelengthshearx
387  !WRITE(*,*) 'wavelength_height', wavelength_height
388  !READ(*,*)
389 
390  ENDDO
391 
392  ! Boundary Layer Thickness
393 
394  WRITE(51,100) r , h , u , t , beta , solid_mass_flux , sumsed , ri , &
395  epsilon , volume_flux , n, pdyn
396 
397  !WRITE(54,155) r , mean_grainsize, std_dev
398 
399  WRITE(56,156) r , entrainment_rate
400 
401  WRITE(54,155) r , h , u , v_s , beta, pn, wavelengthfreen, &
402  wavelength_height, acc_rate
403 
404  WRITE(52,177) r , fracsolid
405 
406 
407 100 FORMAT(f12.5,1x,e12.5,1x,e12.5,1x,e12.5,1x,e12.5,1x,e12.5,1x,e12.5, &
408  1x,e12.5,1x,e12.5, 1x,e12.5, 1x,e12.5, 1x,e12.5)
409 
410 !155 FORMAT(f12.5,1x,e12.5,1x,e12.5,1x)
411 
412 155 FORMAT(f12.5,1x,e12.5,1x,e12.5,1x,e12.5,1x,e12.5,1x,e12.5,1x,e12.5, &
413  1x,e12.5,1x,e12.5)
414 
415 156 FORMAT(f12.5,1x,e12.5)
416 
417 177 FORMAT(f12.5,1x,50(e12.5, 1x))
418 
419 
420  END SUBROUTINE write_output
421 
422  SUBROUTINE write_dakota
423 
424  USE current_module, ONLY : r , h , t , solid_mass_flux , u , oned_model, mass_flux, plume_velocity, initial_mf, solidmf_ratio
425  USE particles_module, ONLY : sumsed, fracsolid, phi_dist, no_bins, iclass, diam, rhosol, v_s, norm_flux
426  USE mixture_module, ONLY : ri , epsilon , n , beta, flow_regime, gas_constmix, c_vmix, initial_velocity
427  USE mixture_module, ONLY : initial_velocity, initial_density, solidvolumefraction, final_solid_mass_flux, initial_smf
428  USE envi_module, ONLY : alpha, gi
429 
430  IMPLICIT NONE
431 
432  INTEGER :: i
433  CHARACTER(len=8) :: x1
434 
435  WRITE(53,*) 'initial mass flux', log10(initial_mf)
436  WRITE(53,*) 'initial_velocity', initial_velocity
437  WRITE(53,*) 'initial_density', initial_density
438  WRITE(53,*) 'solidvolumefraction', solidvolumefraction
439  WRITE(53,*) 'radius', r
440  WRITE(53,*) 'temperature', t
441  WRITE(53,*) 'Gas Mass Fraction', n
442  WRITE(53,*) 'Sedimentation', sumsed
443  WRITE(53,*) 'Flow Velocity', u
444  WRITE(53,*) 'Flow Density', beta
445  WRITE(53,*) 'Ri', ri
446  WRITE(53,*) 'Flow Height', h
447  WRITE(53,*) 'Flow Regime', flow_regime
448  WRITE(53,*) 'Solid Mass Fraction', 1-n
449  WRITE(53,*) 'Final Mass Flux', mass_flux
450  WRITE(53,*) 'Initial Plume Velocity', plume_velocity
451  WRITE(53,*) 'Gas Mass Constant', gas_constmix
452  WRITE(53,*) 'C_vmix', c_vmix
453  WRITE(53,*) 'deltabeta1', beta - alpha
454  WRITE(53,*) 'deltabeta_g', (beta - alpha) * gi
455  WRITE(53,*) 'settling velocity', v_s
456  WRITE(53,*) 'final_smflux', final_solid_mass_flux
457  WRITE(53,*) 'initial_smflux', initial_smf
458  WRITE(53,*) 'solidMF_ratio', solidmf_ratio
459  WRITE(53,*) 'alpha', alpha
460 
461 
462  DO i = 1, iclass
463 
464 
465  WRITE(x1,'(I2.2)')i
466 ! WRITE(53,*) 'Diam'//x1,diam(i)*10e6
467  WRITE(53,*) 'Diam'//x1,diam(i)
468  WRITE(53,*) 'Frac'//x1,fracsolid(i)
469  !WRITE(53,*) 'norm_flux'//x1,norm_flux(i)
470  !WRITE(53,*) 'Rhosol'//x1,rhosol(i)
471  !WRITE(nout5,*) diam(i), rhosol(i), fracsolid(i), C_d(i)
472 
473 
474  END DO
475 
476 
477 
478  END SUBROUTINE write_dakota
479 
480 
481  SUBROUTINE close_units
482 
483  CLOSE(51)
484  CLOSE(52)
485  CLOSE(53)
486  CLOSE(54)
487  CLOSE(56)
488 
489 
490  END SUBROUTINE close_units
491 
492 
493 
494 END MODULE inpout
subroutine initialize_particles
Allocating particles variables This subroutine allocates the variables defining the particle sediment...
Definition: particles.f90:147
subroutine initialize
Initialize variables.
Definition: inpout.f90:65
subroutine write_output
Definition: inpout.f90:276
Tools.
Definition: tools.f90:5
subroutine write_dakota
Definition: inpout.f90:422
Current module This module contains descriptors for the initial conditions of the flow...
Definition: current.f90:7
Mixture module This module contains all the variables required for describing and calculating the cha...
Definition: mixture.f90:10
subroutine allocate_particles
Particle inizialization This subroutine allocates the variables defining the particle physical charac...
Definition: particles.f90:234
Solver Module This module contains the differential equations that are solved at each iteration...
Definition: solver_flow.f90:10
Input/Output module.
Definition: inpout.f90:8
subroutine reainp
Read Input data This subroutine reads input data from the file flow_model.inp.
Definition: inpout.f90:102
Particles module This module contains the procedures and the variables related to the solid particles...
Definition: particles.f90:6
environment module This module contains all the variables related to the background environmental con...
Definition: environment.f90:8
subroutine close_units
Definition: inpout.f90:481
subroutine runend(iflag, message)
Program end.
Definition: tools.f90:23