32 USE mixture_module, ONLY : gas_mass_fraction , rho_mix, mass_flow_rate
36 USE plume_module, ONLY: s , w , z , vent_height , r , mag_u
40 USE variables, ONLY : dakota_flag , hysplit_flag
42 USE variables, ONLY : height_weight , height_obj , mu_weight , &
43 mu_obj , sigma_weight , sigma_obj , skew_weight , skew_obj
56 CHARACTER(LEN=20) :: description
58 CHARACTER(len=8) :: x1
66 REAL*8 :: mu_phi , sigma_phi , skew_phi
70 REAL*8 :: solid_mass_flux , solid_mass_flux0
72 REAL*8 :: solid_mass_flux_change
74 REAL*8 :: obj_function
76 REAL*8 :: w_old , w_oldold
77 REAL*8 :: w_minrel , w_maxrel
83 REAL*8 :: z_array(10000000)
84 REAL*8 :: w_array(10000000)
86 REAL*8,
ALLOCATABLE :: z_norm(:) , w_norm(:)
87 REAL*8,
ALLOCATABLE :: first_der_right(:) , first_der_left(:)
88 REAL*8,
ALLOCATABLE :: sec_der(:) , k(:)
89 REAL*8,
ALLOCATABLE :: first_der_central(:)
93 REAL*8 :: column_regime
95 INTEGER :: idx , max_idx
99 REAL*8 :: plume_height
101 REAL*8 :: deltarho_min
104 REAL*8 :: deltarho , deltarho_old
122 description =
'Initial MFR'
139 delta_rho = rho_mix - rho_atm
143 WRITE(x1,
'(I2.2)') i_part
145 description =
'Mean Diameter '//trim(x1)
147 CALL
write_dakota(description,mom0(i_part,1)/mom0(i_part,0))
149 description =
'Sau. Mean Diam. '//trim(x1)
151 CALL
write_dakota(description,mom0(i_part,3)/mom0(i_part,2))
156 mu(1) = mom0(i_part,1)/mom0(i_part,0)
158 mu(2) = -(mom0(i_part,1)/mom0(i_part,0))**2 + (mom0(i_part,2) / &
161 mu(3) = 2.d0 * (mom0(i_part,1)/mom0(i_part,0))**3 &
162 - 3.d0 * (mom0(i_part,1)/mom0(i_part,0)) * (mom0(i_part,2) / &
164 + (mom0(i_part,3)/mom0(i_part,0))
166 mu(4) = -3.d0 * (mom0(i_part,1)/mom0(i_part,0))**4 &
167 + 6.d0 * (mom0(i_part,1)/mom0(i_part,0))**2 * (mom0(i_part,2) / &
168 mom0(i_part,0)) - 4.d0 * (mom0(i_part,1)/mom0(i_part,0)) * &
169 (mom0(i_part,3)/mom0(i_part,0)) + (mom0(i_part,4)/mom0(i_part,0))
190 WRITE(x1,
'(I2.2)') i_part
192 IF ( distribution_variable .EQ.
'particles_number' )
THEN
194 k1 = log( 1.d3 * mom0(i_part,1) / mom0(i_part,0) )
195 k2 = log( 1.d3 * mom0(i_part,3) / mom0(i_part,2) )
197 mu_phi = - 0.25d0 * ( 5*k2 - k1 ) / log(2.d0)
199 sigma_phi = sqrt( 0.5d0 * (k2-k1) ) / log(2.d0)
201 ELSEIF ( distribution_variable .EQ.
'mass_fraction' )
THEN
203 mu_phi = mom0(i_part,1)/mom0(i_part,0)
205 sigma_phi = sqrt( -(mom0(i_part,1)/mom0(i_part,0))**2 + &
206 (mom0(i_part,2)/mom0(i_part,0)) )
208 skew_phi = ( 2.d0 * (mom0(i_part,1)/mom0(i_part,0))**3 &
209 - 3.d0 * mu_phi * ( mom0(i_part,2) / mom0(i_part,0) ) &
210 + mom0(i_part,3) / mom0(i_part,0) ) / sigma_phi**3
214 description =
'Init Avg Diam '//trim(x1)
218 description =
'Init Var Diam '//trim(x1)
222 description =
'Init Skw Diam '//trim(x1)
226 mass_fract = solid_partial_mass_fraction(i_part) * ( 1.d0 - &
229 description =
'Init Mass Fract '//trim(x1)
233 solid_mass_flux0 = solid_partial_mass_fraction(i_part) * ( 1.d0 - &
234 gas_mass_fraction) * rho_mix * pi_g * r**2 * mag_u
236 description =
'Init Solid Flux '//trim(x1)
258 deltarho_min = 1000.d0
272 IF ( verbose_level .GE. 2 )
THEN
275 WRITE(*,*)
'**************** BEFORE PREDICTOR STEP *****************'
290 IF ( verbose_level .GE. 2 )
THEN
293 WRITE(*,*)
'**************** BEFORE CORRECTOR STEP *****************'
302 rhs = 0.5d0 * ( rhstemp - rhs )
305 IF ( verbose_level .GE. 2 )
THEN
308 WRITE(*,*)
'**************** AFTER CORRECTOR STEP *****************'
319 IF ( w .LE. 0.d0)
THEN
331 IF ( ( w_old .LT. w ) .AND. ( w_old .LT. w_oldold ) )
THEN
339 IF ( w .GT. w_maxabs ) w_maxabs = w
341 IF ( ( w_old .GT. w ) .AND. ( w_old .GT. w_oldold ) )
THEN
349 delta_rho = min( delta_rho , rho_mix - rho_atm )
352 deltarho = rho_mix - rho_atm
355 IF ( deltarho * deltarho_old .LT. 0.d0 )
THEN
358 height_nbl = z - vent_height
364 deltarho_old = deltarho
366 IF ( verbose_level .GE. 2 )
THEN
370 WRITE(*,*)
'**',mom(i_part,1)/mom(i_part,0)
384 IF ( w .LE. 1.d-5 )
THEN
399 ALLOCATE( z_norm(max_idx) , w_norm(idx) )
400 ALLOCATE( first_der_right(max_idx-1) , first_der_left(max_idx-1) )
401 ALLOCATE( sec_der(max_idx-2) , k(max_idx-2) )
402 ALLOCATE( first_der_central(max_idx-2) )
404 z_norm = ( z_array(1:max_idx) - minval( z_array(1:max_idx) ) ) &
405 / ( maxval( z_array(1:max_idx) ) - minval( z_array(1:max_idx) ) )
407 w_norm = w_array(1:max_idx) / maxval( w_array(1:max_idx) )
409 first_der_right(1:max_idx-2) = ( z_norm(3:max_idx) - z_norm(2:max_idx-1) ) &
410 / ( w_norm(3:max_idx) - w_norm(2:max_idx-1) )
412 first_der_left(1:max_idx-2) = ( z_norm(2:max_idx-1) - z_norm(1:max_idx-2) ) &
413 / ( w_norm(2:max_idx-1) - w_norm(1:max_idx-2) )
415 sec_der(1:max_idx-2) = ( first_der_right(1:max_idx-2) - first_der_left(1:max_idx-2) ) &
416 / ( 0.5 * ( w_norm(3:max_idx) - w_norm(1:max_idx-2 ) ) )
418 first_der_central = ( z_norm(3:max_idx) - z_norm(1:max_idx-2) ) &
419 / ( w_norm(3:max_idx) - w_norm(1:max_idx-2) )
421 k(1:max_idx-2) = sec_der(1:max_idx-2) / ( ( 1.0 + first_der_central(1:max_idx-2)**2 )**(1.5d0) )
423 k_max = maxval( k(1:max_idx-2) )
425 check_sb = ( w_maxrel - w_minrel ) / w_maxabs
458 IF ( delta_rho .GT. 0.d0 )
THEN
460 WRITE(*,*)
'collapsing'
466 IF ( check_sb .GT. eps_sb )
THEN
470 WRITE(*,*)
'superbuoyant'
485 description =
'Column regime'
489 description =
'NBL height (atv)'
493 description =
'Plume height (atv)'
494 plume_height = z - vent_height
500 WRITE(x1,
'(I2.2)') i_part
502 IF ( distribution_variable .EQ.
'particles_number' )
THEN
504 k1 = log( 1.d3 * mom(i_part,1) / mom(i_part,0) )
505 k2 = log( 1.d3 * mom(i_part,3) / mom(i_part,2) )
507 mu_phi = - 0.25d0 * ( 5*k2 - k1 ) / log(2.d0)
509 sigma_phi = sqrt( 0.5d0 * (k2-k1) ) / log(2.d0)
511 ELSEIF ( distribution_variable .EQ.
'mass_fraction' )
THEN
513 mu_phi = mom(i_part,1)/mom(i_part,0)
515 sigma_phi = sqrt( -(mom(i_part,1)/mom(i_part,0))**2 + &
516 (mom(i_part,2)/mom(i_part,0)) )
518 skew_phi = ( 2.d0 * (mom0(i_part,1)/mom0(i_part,0))**3 &
519 - 3.d0 * mu_phi * ( mom0(i_part,2) / mom0(i_part,0) ) &
520 + mom0(i_part,3) / mom0(i_part,0) ) / sigma_phi**3
524 description =
'Final Avg Diam '//trim(x1)
528 description =
'Final Var Diam '//trim(x1)
532 description =
'Final Skw Diam '//trim(x1)
536 mass_fract = solid_partial_mass_fraction(i_part) * ( 1.d0 - &
539 description =
'Final Mass Fract '//trim(x1)
543 solid_mass_flux = solid_partial_mass_fraction(i_part) * ( 1.d0 - &
544 gas_mass_fraction) * rho_mix * pi_g * r**2 * mag_u
546 description =
'Final Mass Flux '//trim(x1)
550 solid_mass_flux_change = 1.d0 - solid_mass_flux / solid_mass_flux0
552 description =
'Solid Flux Lost '//trim(x1)
559 description =
'Objective_function'
561 obj_function = mu_weight * ( ( mu_phi-mu_obj ) / &
562 max( abs(mu_phi),abs(mu_obj) ) )**2 &
563 + sigma_weight * ( ( sigma_phi-sigma_obj ) / &
564 max( abs(sigma_phi),abs(sigma_obj) ) )**2 &
565 + skew_weight * ( ( skew_phi-skew_obj ) / &
566 max( abs(skew_phi),abs(skew_obj) ) )**2 &
567 + height_weight * ( ( plume_height-height_obj ) / &
568 max( abs(plume_height),abs(height_obj) ) )**2
572 WRITE(*,*)
'plume_height,obj_function' , plume_height , obj_function
573 WRITE(*,*)
'height_nbl',height_nbl
subroutine rate(rhs_)
Compute the right-hand side of the equations.
subroutine write_hysplit(last)
Write outputs.
subroutine zmet
Meteo parameters.
subroutine initialize_particles
Particles variables inizialization.
subroutine write_column
Write outputs.
subroutine initialize_mixture
Mixture properties initialization.
subroutine write_dakota(description, value)
Dakota outputs.
Gas/particles mixture module.
subroutine plumerise
Main subroutine for the integration.
subroutine initialize_plume
Plume variables initialization.
subroutine unlump(f_)
Calculate physical variables from lumped variables.
subroutine lump(f_)
Calculate the lumped variables.
subroutine initialize_meteo
Meteo parameters initialization.
Predictor-corrector module.
subroutine marching(fold, fnew, rate)
Marching s one step.