MAMMA  1.0
Conduitsolver
constitutive.f90
Go to the documentation of this file.
1 !********************************************************************************
8 !********************************************************************************
10 
11  USE geometry, ONLY : pi
12  USE parameters, ONLY : verbose_level
13  USE parameters, ONLY : n_eqns , n_vars
14  USE parameters, ONLY : n_cry , n_gas , n_mom
15 
16  USE parameters, ONLY : idx_p1 , idx_p2 , idx_u1 , idx_u2 , idx_t , &
19 
20  IMPLICIT none
21 
22  !--------- Constants for the equations of state -------------------------------
23  REAL*8 :: cv_2
24  REAL*8 :: cv_m
25  REAL*8, ALLOCATABLE :: cv_c(:)
26  REAL*8, ALLOCATABLE :: cv_d(:)
27  REAL*8, ALLOCATABLE :: cv_g(:)
28 
29  !~ REAL*8 :: C0_2 !< exsolved gas sound speed at atmospheric conditions
30  REAL*8 :: c0_m
31  REAL*8, ALLOCATABLE :: c0_c(:)
32  REAL*8, ALLOCATABLE :: c0_d(:)
33  REAL*8, ALLOCATABLE :: c0_g(:)
34 
35  REAL*8 :: gamma_2
36  REAL*8 :: gamma_m
37  REAL*8, ALLOCATABLE :: gamma_c(:)
38  REAL*8, ALLOCATABLE :: gamma_d(:)
39  REAL*8, ALLOCATABLE :: gamma_g(:)
40 
41  REAL*8 :: rho0_2
42  REAL*8 :: rho0_m
43  REAL*8, ALLOCATABLE :: rho0_c(:)
44  REAL*8, ALLOCATABLE :: rho0_d(:)
45  REAL*8, ALLOCATABLE :: rho0_g(:)
46 
47  REAL*8 :: t0_2
48  REAL*8 :: t0_m
49  REAL*8, ALLOCATABLE :: t0_c(:)
50  REAL*8, ALLOCATABLE :: t0_d(:)
51  REAL*8, ALLOCATABLE :: t0_g(:)
52 
53  !~ REAL*8 :: p0_2 !< exsolved gas reference pressure
54  REAL*8 :: p0_m
55  REAL*8, ALLOCATABLE :: p0_c(:)
56  REAL*8, ALLOCATABLE :: p0_d(:)
57  REAL*8, ALLOCATABLE :: p0_g(:)
58 
59  REAL*8 :: bar_e_2
60  REAL*8 :: bar_e_m
61  REAL*8, ALLOCATABLE :: bar_e_c(:)
62  REAL*8, ALLOCATABLE :: bar_e_d(:)
63  REAL*8, ALLOCATABLE :: bar_e_g(:)
64 
65  REAL*8 :: bar_p_m
66  REAL*8, ALLOCATABLE :: bar_p_c(:)
67  REAL*8, ALLOCATABLE :: bar_p_d(:)
68  REAL*8, ALLOCATABLE :: bar_p_g(:)
69 
70  !~ REAL*8 :: s0_2 !< exsolved gas reference entropy
71  REAL*8 :: s0_m
72  REAL*8, ALLOCATABLE :: s0_c(:)
73  REAL*8, ALLOCATABLE :: s0_d(:)
74  REAL*8, ALLOCATABLE :: s0_g(:)
75 
76  !-----------------------------------------------------------------------------------------!
77  REAL*8, ALLOCATABLE :: pc_g(:)
78  REAL*8, ALLOCATABLE :: tc_g(:)
79  REAL*8, ALLOCATABLE :: a_g(:)
80  REAL*8, ALLOCATABLE :: b_g(:)
81 
86  CHARACTER*20 :: gas_law
87  !----------------------------------------------------------------------------------------!
88 
89 
90  COMPLEX*16 :: cv_1
91 
92  COMPLEX*16 :: e_mix
93 
94  COMPLEX*16 :: e_1
95  COMPLEX*16 :: e_2
96  COMPLEX*16 :: e_m
97  COMPLEX*16, ALLOCATABLE :: e_c(:)
98  COMPLEX*16, ALLOCATABLE :: e_d(:)
99  COMPLEX*16, ALLOCATABLE :: e_g(:)
100 
101  COMPLEX*16 :: p_1
102  COMPLEX*16 :: p_2
103 
104  COMPLEX*16 :: s_1
105  COMPLEX*16 :: s_2
106  COMPLEX*16 :: s_m
107  COMPLEX*16, ALLOCATABLE :: s_c(:)
108  COMPLEX*16, ALLOCATABLE :: s_d(:)
109  COMPLEX*16, ALLOCATABLE :: s_g(:)
110 
111  COMPLEX*16 :: mu_1
112  COMPLEX*16 :: mu_2
113  COMPLEX*16 :: mu_m
114  COMPLEX*16, ALLOCATABLE :: mu_c(:)
115  COMPLEX*16, ALLOCATABLE :: mu_d(:)
116  COMPLEX*16, ALLOCATABLE :: mu_g(:)
117 
118  COMPLEX*16 :: rho_1
119  COMPLEX*16 :: rho_2
120  COMPLEX*16 :: rho_m
121  COMPLEX*16, ALLOCATABLE :: rho_c(:)
122  COMPLEX*16, ALLOCATABLE :: rho_d(:)
123  COMPLEX*16, ALLOCATABLE :: rho_g(:)
124  COMPLEX*16 :: rho_md
125 
126  COMPLEX*16, ALLOCATABLE :: rhob_c(:)
127  COMPLEX*16 :: rhob_m
128 
129  COMPLEX*16 :: alfa_1
130  COMPLEX*16 :: alfa_2
131  COMPLEX*16, ALLOCATABLE :: alfa_g(:)
132 
133  COMPLEX*16 :: alfarho_2
134 
135  COMPLEX*16 :: alfa_m_1
136  COMPLEX*16, ALLOCATABLE :: alfa_d_1(:)
137  COMPLEX*16, ALLOCATABLE :: alfa_g_2(:)
138 
139 
140  COMPLEX*16, ALLOCATABLE :: beta(:)
141  COMPLEX*16, ALLOCATABLE :: beta_eq(:)
142 
143  COMPLEX*16, ALLOCATABLE :: mom_cry(:,:)
144 
145  COMPLEX*16, ALLOCATABLE :: growth_rate(:)
146  COMPLEX*16, ALLOCATABLE :: nucleation_rate(:)
147 
148  COMPLEX*16 :: u_1
149  COMPLEX*16 :: u_2
150 
151  COMPLEX*16 :: x_1
152  COMPLEX*16 :: x_2
153  COMPLEX*16, ALLOCATABLE :: x_c(:)
154  COMPLEX*16 :: x_m
155  COMPLEX*16, ALLOCATABLE :: x_d(:)
156  COMPlEX*16, ALLOCATABLE :: x_g(:)
157 
158  COMPLEX*16, ALLOCATABLE :: x_d_md(:)
159  COMPLEX*16, ALLOCATABLE :: x_d_md_eq(:)
160 
161 
162  COMPLEX*16, ALLOCATABLE :: x_c_1(:)
163  COMPLEX*16 :: x_m_1
164  COMPLEX*16 :: x_md_1
165  COMPLEX*16, ALLOCATABLE :: x_d_1(:)
166  COMPLEX*16, ALLOCATABLE :: x_g_2(:)
167 
168  COMPLEX*16 :: t
169  COMPLEX*16 :: rho_mix
170  COMPLEX*16 :: u_mix
171  COMPLEX*16 :: cv_mix
172  COMPLEX*16 :: visc_mix
173 
174  COMPLEX*16 :: s
175 
176  COMPLEX*16 :: c_1
177  COMPLEX*16 :: c_2
178 
179  INTEGER :: n_drag_models
180 
181  CHARACTER (LEN=30), DIMENSION(20) :: available_drag_models
182 
191  CHARACTER*30 :: drag_funct_model
192 
194  COMPLEX*16 :: drag_funct
195 
202 
203  ! parameters of the Forchheimer model
204 
208 
211 
214 
215  ! friction coefficient
217 
218  ! drag coefficient
219  REAL*8 :: c_d
220 
221  ! ash particl size
222  REAL*8 :: r_a
223 
228  CHARACTER*20 :: p_relax_model
229 
231  COMPLEX*16 :: tau_p
232 
237  REAL*8 :: tau_p_coeff
238 
244  REAL*8, ALLOCATABLE :: tau_c(:)
245 
247  REAL*8, ALLOCATABLE :: beta0(:)
248 
250  REAL*8, ALLOCATABLE :: beta_max(:)
251 
255  CHARACTER*20 :: crystallization_model
256 
258  REAL*8 :: frag_eff
259 
266 
268  REAL*8 :: frag_thr
269 
271  REAL*8 :: tau_frag_exp
272 
274  COMPLEX*16 :: tau_frag
275 
280  REAL*8 :: tau_frag_coeff
281 
287  REAL*8, ALLOCATABLE :: tau_d(:)
288 
293  CHARACTER*20 :: exsol_model
294 
296  REAL*8, ALLOCATABLE :: solub(:)
297 
298  REAL*8, ALLOCATABLE :: solub_exp(:)
299 
300  REAL*8, ALLOCATABLE :: x_ex_dis_in(:)
301 
303  REAL*8 :: grav
304 
306  REAL*8 :: k_cr
307 
309  REAL*8 :: rho_cr
310 
312  REAL*8 :: visc_2
313 
315  COMPLEX*16 :: visc_melt
316 
318  COMPLEX*16 :: visc_1
319 
321  COMPLEX*16 :: visc_rel_bubbles
322 
323  INTEGER :: n_theta_models
324 
325  CHARACTER (LEN=30), DIMENSION(20) :: available_theta_models
326 
340  CHARACTER*30 :: theta_model
341 
343  COMPLEX*16 :: theta
344 
346  REAL*8 :: theta_fixed
347 
349  REAL*8 :: c1 , c2 , c3
350 
352  REAL*8 :: p_lith
353 
355  REAL*8 :: p_hydro
356 
358  REAL*8 :: zeta_lith
359 
360  INTEGER :: n_bubble_models
361 
362  CHARACTER (LEN=30), DIMENSION(20) :: available_bubble_models
363 
375  CHARACTER*20 :: bubbles_model
376 
380  LOGICAL :: explosive
381 
383  COMPLEX*16 :: permkc
384  COMPLEX*16 :: inv_permkc
385 
386  REAL*8 :: alfa_switch
387  REAL*8 :: a_2nd , b_2nd , perm0
388 
390 
391  CHARACTER (LEN=30), DIMENSION(20) :: available_visc_melt_models
392 
401  CHARACTER*30 :: visc_melt_model
402 
403 
404  REAL*8, DIMENSION(12) :: wt_init
405 
407  REAL*8 :: rho_w
408 
409  REAL*8 :: xa,xb,xc
410 
411 
412 CONTAINS
413 
414  SUBROUTINE initialize_models
416  IMPLICIT NONE
417 
418  n_drag_models = 6
419 
420  available_drag_models(1) = 'constant'
421  available_drag_models(2) = 'eval'
422  available_drag_models(3) = 'darcy'
423  available_drag_models(4) = 'forchheimer'
424  available_drag_models(5) = 'drag'
425  available_drag_models(6) = 'single_velocity'
426 
427 
428  n_theta_models = 11
429 
430  available_theta_models(1) = 'Lejeune_and_Richet1995'
431  available_theta_models(2) = 'Dingwell1993'
432  available_theta_models(3) = 'Melnik_and_Sparks1999'
433  available_theta_models(4) = 'Costa2005'
434  available_theta_models(5) = 'Melnik_and_Sparks2005'
435  available_theta_models(6) = 'Vona_et_al2011'
436  available_theta_models(7) = 'Vona_et_al2011_mod'
437  available_theta_models(8) = 'Vona_et_al2013_eq19'
438  available_theta_models(9) = 'Vona_et_al2013_eq20'
439  available_theta_models(10) = 'Vona_et_al2013_eq21'
440  available_theta_models(11) = 'Fixed_value'
441 
442  n_bubble_models = 11
443 
444  available_bubble_models(1) = 'none'
445  available_bubble_models(2) = 'Costa2007'
446  available_bubble_models(3) = 'Einstein'
447  available_bubble_models(4) = 'Quane-Russel'
448  available_bubble_models(5) = 'Eilers'
449  available_bubble_models(6) = 'Sibree'
450  available_bubble_models(7) = 'Taylor'
451  available_bubble_models(8) = 'Mackenzie'
452  available_bubble_models(9) = 'DucampRaj'
453  available_bubble_models(10) = 'BagdassarovDingwell'
454  available_bubble_models(11) = 'Rahaman'
455 
456 
458 
459  available_visc_melt_models(1) = 'Hess_and_Dingwell1996'
460  available_visc_melt_models(2) = 'Romano_et_al2003'
461  available_visc_melt_models(3) = 'Giordano_et_al2008'
462  available_visc_melt_models(4) = 'Giordano_et_al2009'
463  available_visc_melt_models(5) = 'Di_Genova_et_al2013_eqn_3,5'
464  available_visc_melt_models(6) = 'Di_Genova_et_al2013_eqn_4,5'
465 
466  END SUBROUTINE initialize_models
467 
468  !******************************************************************************
472  !
476  !******************************************************************************
477 
478  SUBROUTINE allocate_phases_parameters
480  ALLOCATE( cv_c(n_cry) )
481  ALLOCATE( c0_c(n_cry) )
482  ALLOCATE( gamma_c(n_cry) )
483  ALLOCATE( rho0_c(n_cry) )
484  ALLOCATE( t0_c(n_cry) )
485  ALLOCATE( p0_c(n_cry) )
486  ALLOCATE( bar_e_c(n_cry) )
487  ALLOCATE( bar_p_c(n_cry) )
488  ALLOCATE( s0_c(n_cry) )
489  ALLOCATE( e_c(n_cry) )
490  ALLOCATE( s_c(n_cry) )
491  ALLOCATE( mu_c(n_cry) )
492  ALLOCATE( rho_c(n_cry) )
493  ALLOCATE( rhob_c(n_cry) )
494  ALLOCATE( beta(n_cry) )
495  ALLOCATE( beta_eq(n_cry) )
496  ALLOCATE( x_c(n_cry) )
497  ALLOCATE( x_c_1(n_cry) )
498  ALLOCATE( tau_c(n_cry) )
499  ALLOCATE( beta0(n_cry) )
500  ALLOCATE( beta_max(n_cry) )
501 
502  IF ( n_mom .GT. 1 ) THEN
503 
504  ALLOCATE( mom_cry(1:n_cry,0:n_mom-1) )
505  ALLOCATE( growth_rate(n_cry) )
506  ALLOCATE( nucleation_rate(n_cry) )
507 
508  END IF
509 
510  ALLOCATE( cv_d(n_gas) )
511  ALLOCATE( c0_d(n_gas) )
512  ALLOCATE( gamma_d(n_gas) )
513  ALLOCATE( rho0_d(n_gas) )
514  ALLOCATE( t0_d(n_gas) )
515  ALLOCATE( p0_d(n_gas) )
516  ALLOCATE( bar_e_d(n_gas) )
517  ALLOCATE( bar_p_d(n_gas) )
518  ALLOCATE( s0_d(n_gas) )
519  ALLOCATE( e_d(n_gas) )
520  ALLOCATE( s_d(n_gas) )
521  ALLOCATE( mu_d(n_gas) )
522  ALLOCATE( rho_d(n_gas) )
523  ALLOCATE( alfa_d_1(n_gas) )
524 
525  ALLOCATE( x_d(n_gas) )
526  ALLOCATE( x_d_md(n_gas) )
527  ALLOCATE( x_d_md_eq(n_gas) )
528  ALLOCATE( x_d_1(n_gas) )
529  ALLOCATE( tau_d(n_gas) )
530  ALLOCATE( solub(n_gas) )
531  ALLOCATE( solub_exp(n_gas) )
532 
533  ALLOCATE( x_ex_dis_in(n_gas) )
534 
535  ALLOCATE( cv_g(n_gas) )
536  ALLOCATE( c0_g(n_gas) )
537  ALLOCATE( gamma_g(n_gas) )
538  ALLOCATE( rho0_g(n_gas) )
539  ALLOCATE( t0_g(n_gas) )
540  ALLOCATE( p0_g(n_gas) )
541  ALLOCATE( bar_e_g(n_gas) )
542  ALLOCATE( bar_p_g(n_gas) )
543  ALLOCATE( s0_g(n_gas) )
544  ALLOCATE( e_g(n_gas) )
545  ALLOCATE( s_g(n_gas) )
546  ALLOCATE( mu_g(n_gas) )
547  ALLOCATE( rho_g(n_gas) )
548  ALLOCATE( x_g(n_gas) )
549  ALLOCATE( x_g_2(n_gas) )
550  ALLOCATE( alfa_g(n_gas) )
551  ALLOCATE( alfa_g_2(n_gas) )
552 
553  ALLOCATE( pc_g(n_gas) )
554  ALLOCATE( tc_g(n_gas) )
555  ALLOCATE( a_g(n_gas) )
556  ALLOCATE( b_g(n_gas) )
557 
558  END SUBROUTINE allocate_phases_parameters
559 
560 
561  !******************************************************************************
565  !
570  !******************************************************************************
571 
572  SUBROUTINE eos
574  USE complexify
575  IMPLICIT none
576 
577  e_c(1:n_cry) = dcmplx(bar_e_c(1:n_cry),0.d0) + dcmplx(cv_c(1:n_cry),0.d0) &
578  * t + dcmplx(bar_p_c(1:n_cry),0.d0) / rho_c(1:n_cry)
579 
580  e_m = dcmplx(bar_e_m,0.d0) + dcmplx(cv_m,0.d0) * t + &
581  dcmplx(bar_p_m,0.d0) / rho_m
582 
583  e_d(1:n_gas) = dcmplx(bar_e_d(1:n_gas),0.d0) + dcmplx(cv_d(1:n_gas),0.d0) &
584  * t + dcmplx(bar_p_d(1:n_gas),0.d0) / rho_d(1:n_gas)
585 
586  e_1 = sum( x_c_1(1:n_cry) * e_c(1:n_cry) ) + x_m_1 * e_m + &
587  sum( x_d_1(1:n_gas) * e_d(1:n_gas) )
588 
589  e_g(1:n_gas) = dcmplx(bar_e_g(1:n_gas),0.d0) + dcmplx(cv_g(1:n_gas),0.d0) &
590  * t - dcmplx(a_g(1:n_gas),0.0) * rho_g(1:n_gas)
591 
592  e_2 = sum( x_g_2(1:n_gas) * e_g(1:n_gas) )
593 
594  s_c(1:n_cry) = s0_c(1:n_cry) + cv_c(1:n_cry) * log( t / t0_c(1:n_cry) * &
595  ( rho0_c(1:n_cry) / rho_c(1:n_cry) )**( gamma_c(1:n_cry) - 1.d0 ) )
596 
597  s_m = s0_m + cv_m * log( t / t0_m * ( rho0_m / rho_m )**( gamma_m - 1.d0 ) )
598 
599  s_d(1:n_gas) = s0_d(1:n_gas) + cv_d(1:n_gas) * log( t / t0_d(1:n_gas) * &
600  ( rho0_d(1:n_gas) / rho_d(1:n_gas) )**( gamma_d(1:n_gas) - 1.d0 ) )
601 
602  s_1 = sum( x_c_1(1:n_cry) * s_c(1:n_cry) ) + x_m_1 * s_m + &
603  sum( x_d_1(1:n_gas) * s_d(1:n_gas) )
604 
605  s_g(1:n_gas) = s0_g(1:n_gas) + cv_g(1:n_gas) * log( t / t0_g(1:n_gas) * &
606  ( ( rho0_g(1:n_gas) / rho_g(1:n_gas) ) * ( dcmplx(1.d0,0.d0) - &
607  b_g(1:n_gas) * rho_g(1:n_gas) ) ) ** ( gamma_g(1:n_gas) - 1.d0 ) )
608 
609  s_2 = sum( x_g_2(1:n_gas) * s_g(1:n_gas) )
610 
611  mu_m = e_m + p_1/rho_m - t * s_m
612 
613  mu_c(1:n_cry) = e_c(1:n_cry) + p_1/rho_c(1:n_cry) - t * s_c(1:n_cry)
614 
615  mu_d(1:n_gas) = e_d(1:n_gas) + p_1/rho_d(1:n_gas) - t * s_d(1:n_gas)
616 
617  mu_1 = sum( x_c_1(1:n_cry) * mu_c(1:n_cry) ) + x_m_1 * mu_m + &
618  sum( x_d_1(1:n_gas) * mu_d(1:n_gas) )
619 
620  mu_g(1:n_gas) = e_g(1:n_gas) + p_2/rho_g(1:n_gas) - t * s_g(1:n_gas)
621 
622  mu_2 = sum( x_g_2(1:n_gas) * mu_g(1:n_gas) )
623 
624  !mu_1 = e_1 + p_1/rho_1 - T * s_1
625  !mu_2 = e_2 + p_2/rho_2 - T * s_2
626 
627  s = x_1 * s_1 + x_2 * s_2
628 
629  END SUBROUTINE eos
630 
631  !******************************************************************************
635  !
644  !******************************************************************************
645 
646  SUBROUTINE sound_speeds(C_mix,mach)
648  USE complexify
649  IMPLICIT none
650 
651  REAL*8, INTENT(OUT) :: C_mix , mach
652 
654  COMPLEX*16 :: C2_c(1:n_cry) , C2_m , C2_d(1:n_gas) , C2_1 , C2_2
655  COMPLEX*16 :: C2_g(1:n_gas)
656 
658  COMPLEX*16 :: K_1 , K_2 , K_mix
659  COMPLEX*16 :: K_c(1:n_cry) , K_m , K_d(1:n_gas) , K_g(1:n_gas)
660 
661  !REAL*8 :: C_mix_Wallis
662 
663  c2_c(1:n_cry) = c0_c(1:n_cry)**2.d0 * ( rho_c(1:n_cry) / rho0_c(1:n_cry) ) &
664  ** ( gamma_c(1:n_cry) - dcmplx(1.0,0.d0) ) * cdexp( ( s_c(1:n_cry) - &
665  s0_c(1:n_cry) ) / cv_c(1:n_cry) )
666 
667  c2_m = c0_m**2.d0 * ( rho_m / rho0_m ) ** &
668  ( gamma_m - dcmplx(1.0,0.d0) ) * cdexp( ( s_m - s0_m ) / cv_m )
669 
670  c2_d(1:n_gas) = c0_d(1:n_gas)**2.d0 * ( rho_d(1:n_gas) / rho0_d(1:n_gas) ) &
671  ** ( gamma_d(1:n_gas) - dcmplx(1.0,0.d0) ) * cdexp( ( s_d(1:n_gas) - &
672  s0_d(1:n_gas) ) / cv_d(1:n_gas) )
673 
674  k_c(1:n_cry) = 1.d0 / ( rho_c(1:n_cry) * c2_c(1:n_cry) )
675  k_m = 1.d0 / ( rho_m * c2_m )
676  k_d(1:n_gas) = 1.d0 / ( rho_d(1:n_gas) * c2_d(1:n_gas) )
677 
678  k_1 = alfa_m_1*k_m + sum( beta(1:n_cry)*k_c(1:n_cry) ) &
679  + sum( alfa_d_1(1:n_gas) * k_d(1:n_gas) )
680 
681  c2_1 = 1.d0 / ( k_1 * rho_1 )
682 
683  c_1 = cdsqrt( c2_1 )
684 
685  c2_g(1:n_gas) = cv_g(1:n_gas) * ( gamma_g(1:n_gas) - dcmplx(1.0,0.d0) ) &
686  * gamma_g(1:n_gas) * t / ( dcmplx(1.0,0.d0) - b_g(1:n_gas) * &
687  rho_g(1:n_gas) )**2.0 - dcmplx(2.0,0.d0) * a_g(1:n_gas) * rho_g(1:n_gas)
688 
689  k_g(1:n_gas) = 1.d0 / ( rho_g(1:n_gas) * c2_g(1:n_gas) )
690 
691  k_2 = sum( alfa_g_2(1:n_gas) * k_g(1:n_gas) )
692 
693  c2_2 = 1.d0 / ( k_2 * rho_2 )
694 
695  c_2 = cdsqrt( c2_2 )
696 
697  k_mix = alfa_1*k_1 + alfa_2*k_2
698 
699  c_mix = dreal( 1.d0 / cdsqrt( k_mix * rho_mix ) )
700 
701  ! Sound speed of the mixture (Wallis, 1969)
702  ! C_mix = REAL( C_2 / SQRT(x_2) * ( x_2 + (1.d0 - x_2 ) * rho_2 / rho_1 ) )
703 
704  mach = dreal( u_mix / c_mix )
705 
706  IF ( verbose_level .GE. 2 ) THEN
707 
708  WRITE(*,*) 'K_1,k_2',k_1,k_2
709  WRITE(*,*) 'K_mix,rho_mix',k_mix,rho_mix
710  WRITE(*,*) 'u_mix,C_mix',u_mix,c_mix
711 
712  END IF
713 
714 
715  END SUBROUTINE sound_speeds
716 
717  !******************************************************************************
721  !
726  !******************************************************************************
727 
728  SUBROUTINE eval_densities
730  IMPLICIT none
731 
732  COMPLEX*16 :: a,b,c
733  COMPLEX*16 :: y1,y2,y3
734 
735  COMPLEX*16 :: coeff1 , coeff2 , coeff3
736 
737  INTEGER :: i
738 
739  rho_c(1:n_cry) = ( p_1 + bar_p_c(1:n_cry) ) / ( t * cv_c(1:n_cry) * &
740  ( gamma_c(1:n_cry) - dcmplx(1.d0,0.d0) ) )
741 
742  rho_m = ( p_1 + bar_p_m ) / ( t * cv_m * ( gamma_m - dcmplx(1.d0,0.d0) ) )
743  rho_d(1:n_gas) = ( p_1 + bar_p_d(1:n_gas) ) / ( t * cv_d(1:n_gas) * &
744  ( gamma_d(1:n_gas) - dcmplx(1.d0,0.d0) ) )
745 
746  rho_md = dcmplx(1.d0,0.d0) / ( sum( x_d_md(1:n_gas) / rho_d(1:n_gas) ) &
747  + ( dcmplx(1.d0,0.d0) - sum( x_d_md(1:n_gas) ) ) / rho_m )
748 
749  rho_1 = sum( beta(1:n_cry) * rho_c(1:n_cry) ) + ( dcmplx(1.d0,0.d0) - &
750  sum( beta(1:n_cry) ) ) * rho_md
751 
752  IF ( gas_law .EQ. 'IDEAL' ) THEN
753 
754  rho_g(1:n_gas) = ( p_2 ) / ( t * cv_g(1:n_gas) * &
755  ( gamma_g(1:n_gas) - dcmplx(1.d0,0.d0) ) )
756 
757  ELSEIF ( gas_law .EQ. 'VDW' ) THEN
758 
759  DO i=1,n_gas
760 
761  a = a_g(i) * dcmplx(-1.d0,0.d0)
762  b = cv_g(i) * ( gamma_g(i) - dcmplx(1.d0,0.d0) ) * t + p_2 * b_g(i)
763  c = - p_2
764 
765  coeff1 = a / ( a_g(i) * b_g(i) )
766  coeff2 = b / ( a_g(i) * b_g(i) )
767  coeff3 = c / ( a_g(i) * b_g(i) )
768 
769  CALL solve_cubic( coeff1 , coeff2 , coeff3 , y1 , y2 , y3 )
770 
771  rho_g(i) = y1
772 
773  END DO
774 
775  END IF
776 
777  rho_2 = sum( alfa_g_2(1:n_gas) * rho_g(1:n_gas) )
778 
779  END SUBROUTINE eval_densities
780 
781  !******************************************************************************
783  !
793  !******************************************************************************
794 
795  SUBROUTINE solve_cubic(a,b,c,y1,y2,y3)
797  USE complexify
798  IMPLICIT NONE
799 
800  COMPLEX*16, INTENT(IN) :: a,b,c
801  COMPLEX*16, INTENT(OUT) :: y1,y2,y3
802 
803  COMPLEX*16 :: Q,R,D_temp
804  COMPLEX*16 :: phi , arg , u , v
805 
806  q = ( 3.d0*b - a**2) / dcmplx(9.d0,0.d0)
807  r = ( 9.d0*a*b - 27.d0*c - 2.d0*a**3 ) / dcmplx(54.d0,0.d0)
808 
809  d_temp = q**3 + r**2
810 
811  IF ( d_temp .GE. 0 ) THEN
812 
813  arg = r + cdsqrt(d_temp)
814 
815  u = sign(1.d0,REAL(arg))*(abs(arg))**(1.D0/3.D0)
816 
817  arg = r - cdsqrt(d_temp)
818  v = sign(1.d0,REAL(arg))*(abs(arg))**(1.D0/3.D0)
819 
820  y1 = u + v - a / dcmplx(3.d0,0.d0)
821 
822  ELSE
823 
824  phi = acos(r/cdsqrt(-(q**3)))
825 
826  y1 = 2.d0 * cdsqrt(-q) * cos(phi/ dcmplx(3.d0,0.d0) ) &
827  - a / dcmplx(3.d0,0.d0)
828 
829  y2 = 2.d0 * cdsqrt(-q) * cos((phi+2.d0*pi)/ dcmplx(3.d0,0.d0) ) &
830  - a / dcmplx(3.d0,0.d0)
831 
832  y3 = 2.d0 * cdsqrt(-q) * cos((phi-2.d0*pi)/ dcmplx(3.d0,0.d0) ) &
833  - a/ dcmplx(3.d0,0.d0)
834 
835  END IF
836 
837  END SUBROUTINE solve_cubic
838 
839 
840  !******************************************************************************
844  !
859  !******************************************************************************
860 
861  SUBROUTINE f_xdis_eq
863  USE complexify
864 
865  IMPLICIT NONE
866 
867 
868  COMPLEX*16 :: aa , bb , cc , pp
869  COMPLEX*16 :: P_bar, log10Ds, Ds, Dcl
870  REAL*8 :: beta_S(4)
871  REAL*8 :: melt_volume
872 
873  COMPLEX*16 :: melt_mass
874  COMPLEX*16 :: co2_exs_mass,h2o_exs_mass,S_exs_mass,Cl_exs_mass
875  COMPLEX*16 :: S_dis_mass,Cl_dis_mass
876  COMPLEX*16 :: gas_mass, Ratio_exs_dis
877  COMPLEX*16 :: S_mass,Cl_mass
878 
879 
880  IF ( REAL(p_2) .LE. 0.D0 ) then
881 
882  x_d_md_eq = dcmplx(0.d0, 0.d0)
883 
884  ELSE
885 
886  SELECT CASE ( exsol_model )
887 
888  CASE DEFAULT
889 
890 
891  CASE ( 'Henry' )
892 
893  ! Henry's law
894 
895  x_d_md_eq(1:n_gas) = solub(1:n_gas) * (alfa_g_2(1:n_gas) * p_2 ) &
896  ** solub_exp(1:n_gas)
897 
898  CASE ( 'Zhang' )
899 
900  ! Zhang
901 
902  aa = 0.4874d0 - 608.0d0 / t + 489530.d0 / ( t * t )
903 
904  bb = -0.06062d0 + 135.6d0 / t - 69200.d0 / ( t * t )
905 
906  cc = 0.00253d0 - 4.154d0 / t + 1509.0d0 / ( t * t )
907 
908  pp = p_2 * 1.0d-6
909 
910  x_d_md_eq(1:n_gas) = 1.0d-2 * ( aa * cdsqrt(pp) + bb * pp + cc &
911  * pp ** 1.5d0 )
912 
913  CASE ( 'H20-CO2-S-CL' )
914 
915  ! Henry's law (s is global variable and is a constant for rhyolite)
916 
917  melt_volume=1.0 !%m3
918 
919  melt_mass=melt_volume*rho_md
920 
921  !water exsolved mass
922  h2o_exs_mass=melt_mass*x_g(1)
923 
924  !co2 exsolved mass
925  co2_exs_mass=melt_mass*x_g(2)
926 
927  !S exsolved mass
928  s_exs_mass=melt_mass*x_g(3)
929 
930  !Cl exsolved mass
931  cl_exs_mass=melt_mass*x_g(4)
932 
933  !Total volatile mass
934  gas_mass=co2_exs_mass+h2o_exs_mass+s_exs_mass+cl_exs_mass
935 
936  !Ratio_exs_dis is ratio of all gas mass to melt mass
937  ratio_exs_dis=gas_mass/melt_mass
938 
939  !Pressure in bar
940  p_bar = p_2 / 1e5;
941 
942  !fitting coefficient
943  beta_s = [4.8095e+02, -4.5850e+02, 3.0240e-03, -2.7519e-07]
944 
945  !Solubility for S and Cl
946  log10ds = beta(1) * p_bar**(-0.0075) + beta(2) + beta(3) * p_bar &
947  + beta(4) * p_bar**(2.0)
948  ds = 10**(log10ds)
949  dcl = dcmplx(2.d0, 0.d0)
950 
951  !Equilibrium dissolved water
952  x_d_md_eq(1) = solub(1) * (alfa_g_2(1) * p_2) ** solub_exp(1)
953  !Equilibrium dissolved co2
954  x_d_md_eq(2) = solub(2) * (alfa_g_2(2) * p_2) ** solub_exp(2)
955 
956  !Total mass of S
957  s_mass=melt_mass*x_ex_dis_in(3)
958 
959  !Dissolved mass of S
960  s_dis_mass=s_mass - (ds*ratio_exs_dis/(ds*ratio_exs_dis + 1.0))*s_mass
961 
962  !Equilibrium dissolved S
963  x_d_md_eq(3)=s_dis_mass/melt_mass
964 
965  !Total mass of S
966  cl_mass=melt_mass*x_ex_dis_in(4)
967 
968  !Dissolved mass of Cl
969  cl_dis_mass=cl_mass- (dcl*ratio_exs_dis/(dcl* ratio_exs_dis + 1.0)) &
970  *cl_mass
971 
972  !Equilibrium dissolved Cl
973  x_d_md_eq(4)=cl_dis_mass/melt_mass
974 
975  END SELECT
976 
977  END IF
978 
979  END SUBROUTINE f_xdis_eq
980 
981  !*****************************************************************************
985  !
997  !*****************************************************************************
998 
999  SUBROUTINE f_beta_eq
1001  USE complexify
1002  IMPLICIT NONE
1003 
1004  COMPLEX*16 :: x_d_md_tot ,x_d_md_wt_tot
1005  COMPLEX*16 :: p_1_bar, T_celsius
1006  COMPLEX*16 :: crystal_mass_fraction(1:n_cry)
1007 
1008  INTEGER :: j
1009 
1010  p_1_bar = p_1 / 1.0e5
1011  t_celsius = t - 273.d0
1012 
1013  x_d_md_tot = sum( x_d_md(1:n_gas) )
1014  x_d_md_wt_tot = x_d_md_tot * 100.d0
1015 
1016  SELECT CASE ( crystallization_model )
1017 
1018  CASE DEFAULT
1019 
1020  CASE ( 'Vitturi2010' )
1021 
1022  DO j=1,n_cry
1023 
1024  !----------------------------------------------------------------------
1025  beta_eq(j)=beta0(j) + 0.55d0*( 0.58815d0*( p_1/1.d6 )**( -0.5226d0 ) )
1026  !----------------------------------------------------------------------
1027 
1028  beta_eq(j) = max( beta0(j) + 1d-15, beta_eq(j) )
1029  beta_eq(j) = min( beta_max(j) , beta_eq(j) )
1030 
1031  END DO
1032 
1033  END SELECT
1034 
1035  END SUBROUTINE f_beta_eq
1036 
1037  !******************************************************************************
1041  !
1044  !******************************************************************************
1045 
1046  SUBROUTINE f_growth_rate
1048  USE complexify
1049  IMPLICIT NONE
1050 
1051  integer :: i
1052 
1053  DO i = 1,n_cry
1054 
1055  growth_rate(i) = 0.d0
1056 
1057  END DO
1058 
1059  END SUBROUTINE f_growth_rate
1060 
1061 
1062  !******************************************************************************
1066  !
1069  !******************************************************************************
1070 
1071  SUBROUTINE f_nucleation_rate
1073  USE complexify
1074  IMPLICIT NONE
1075 
1076  integer :: i
1077 
1078  DO i = 1,n_cry
1079 
1080  nucleation_rate(i) = 0.d0
1081 
1082  END DO
1083 
1084 
1085  END SUBROUTINE f_nucleation_rate
1086 
1087  !******************************************************************************
1091  !
1094  !******************************************************************************
1095 
1096  SUBROUTINE lithostatic_pressure
1098  USE geometry, ONLY : zn
1099 
1100  USE complexify
1101  IMPLICIT NONE
1102 
1103  p_lith = ( zn - zeta_lith ) * rho_cr * grav
1104 
1105  END SUBROUTINE lithostatic_pressure
1106 
1107 
1108  !******************************************************************************
1112  !
1115  !******************************************************************************
1116 
1117  SUBROUTINE hydrostatic_pressure
1119  USE geometry
1120 
1121  USE complexify
1122  IMPLICIT NONE
1123 
1124  p_hydro = ( zn - zeta_lith ) * rho_w * grav
1125 
1126  END SUBROUTINE hydrostatic_pressure
1127 
1128 
1129  !******************************************************************************
1133  !
1137  !******************************************************************************
1138 
1139  SUBROUTINE press_relax_term( pressure_relaxation )
1141  USE complexify
1142  IMPLICIT NONE
1143 
1144  COMPLEX*16, INTENT(OUT) :: pressure_relaxation
1145 
1146  CALL mixture_viscosity
1147 
1148  SELECT CASE ( p_relax_model )
1149 
1150  CASE DEFAULT
1151 
1152  tau_p = dcmplx( 1.d0 , 0.d0 )
1153 
1154  CASE ( 'eval' )
1155 
1156  IF ( ( explosive ) .AND. ( frag_eff .GT. 0.d0 ) ) THEN
1157 
1158  tau_p = ( visc_mix ** ( 1.d0 - frag_eff ) * visc_2 ** frag_eff ) &
1159  / ( alfa_1 * alfa_2 * rho_mix )
1160 
1161  ELSE
1162 
1163  tau_p = visc_mix / ( alfa_1 * alfa_2 * rho_mix )
1164 
1165  END IF
1166 
1167 
1168  CASE ( 'eval2' )
1169 
1170 
1171  tau_p = ( 1.d0 - frag_eff ) * visc_mix / &
1172  ( (alfa_1 ** alfa_1) * rho_mix ) + 0.001 * frag_eff
1173 
1174 
1175  CASE ( 'constant' )
1176 
1177  tau_p = dcmplx( 1.d0 , 0.d0 )
1178 
1179  CASE ( 'single_pressure' )
1180 
1181  tau_p = dcmplx( 1.d0 , 0.d0 )
1182 
1183  END SELECT
1184 
1185  tau_p = tau_p_coeff * tau_p
1186 
1187  pressure_relaxation = - ( p_2 - p_1 ) / tau_p
1188 
1189  END SUBROUTINE press_relax_term
1190 
1191  !******************************************************************************
1195  !
1200  !******************************************************************************
1201 
1202  SUBROUTINE vel_relax_term( velocity_relaxation )
1204  USE complexify
1205  IMPLICIT NONE
1206 
1207  COMPLEX*16, INTENT(OUT) :: velocity_relaxation
1208 
1209  COMPLEX*16 :: Rey
1210  COMPLEX*16 :: diam
1211  COMPLEX*16 :: radius_bubble
1212  COMPLEX*16 :: effusive_drag , explosive_drag
1213 
1214  COMPLEX*16 :: k_1 , k_2
1215 
1216  COMPLEX*16 :: throat_radius
1217 
1218  REAL*8 :: frag_transition, t
1219 
1220  frag_transition = frag_thr + 0.05d0
1221 
1222  t = min(1.0d0,max(0.0d0, ( REAL(alfa_2) - frag_thr ) / &
1223  (frag_transition - frag_thr )))
1224 
1225  SELECT CASE ( drag_funct_model )
1226 
1227  CASE DEFAULT
1228 
1229  effusive_drag = dcmplx(1.d0,0.d0)
1230 
1231  explosive_drag = effusive_drag
1232 
1233  CASE ( 'eval' )
1234 
1235  ! permeability model
1236 
1237  CALL f_permkc
1238 
1239  diam = ( alfa_2 / ( 4.0 / 3.0 * pi * bubble_number_density &
1240  * ( alfa_1 ) ) ) ** ( 1.d0 / 3.d0 )
1241 
1242  rey = alfa_2 * rho_2 * diam * cdabs( u_2 - u_1 ) / visc_2
1243 
1244  effusive_drag = visc_2 * inv_permkc * ( 1.d0 + 1.d-2 * rey / alfa_1 )
1245 
1246  explosive_drag = effusive_drag
1247 
1248  IF ( verbose_level .GE. 3 ) THEN
1249 
1250  WRITE(*,*) 'Rey',rey
1251  WRITE(*,*) 'visc_2',visc_2
1252  WRITE(*,*) 'rho_2',rho_2
1253  WRITE(*,*) 'inv_permkc',inv_permkc
1254 
1255  END IF
1256 
1257  CASE ( 'Klug_and_Cashman' )
1258 
1259  ! permeability model
1260 
1261  CALL f_permkc
1262 
1263  diam = ( alfa_2 / ( 4.0 / 3.0 * pi * bubble_number_density &
1264  * ( alfa_1 ) ) ) ** ( 1.d0 / 3.d0 )
1265 
1266  rey = alfa_2 * rho_2 * diam * cdabs( u_2 - u_1 ) / visc_2
1267 
1268  effusive_drag = visc_2 * inv_permkc * ( 1.d0 + 1.d-2 * rey / alfa_1 )
1269 
1270  explosive_drag = 3.d0 * c_d / ( 8.d0 * r_a ) * rho_2 * cdabs( u_2 - u_1 )
1271 
1272  CASE ( 'darcy' )
1273 
1274  ! Darcy formulation from Eq. 16 Degruyter et al. 2012
1275 
1276  radius_bubble = ( alfa_2 / ( 4.0 / 3.0 * pi * bubble_number_density &
1277  * ( alfa_1 ) ) ) ** ( 1.d0 / 3.d0 )
1278 
1279  throat_radius = radius_bubble * throat_bubble_ratio
1280 
1281  k_1 = 0.125d0 * throat_radius ** 2.d0 * alfa_2 ** tortuosity_factor
1282 
1283  effusive_drag = visc_2 / k_1
1284 
1285  explosive_drag = 3.d0 * c_d / ( 8.d0 * r_a ) * rho_2 * cdabs( u_2 - u_1 )
1286 
1287  CASE ( 'forchheimer' )
1288 
1289  ! Forchheimer (Eq. 16 Degruyter et al. 2012)
1290 
1291  IF ( REAL(alfa_2) .GT. 0.0001 ) then
1292 
1293  radius_bubble = ( alfa_2 / ( 4.0 / 3.0 * pi * bubble_number_density &
1294  * ( alfa_1 ) ) ) ** ( 1.d0 / 3.d0 )
1295 
1296  throat_radius = radius_bubble * throat_bubble_ratio
1297 
1298  k_1 = 0.125d0 * throat_radius ** 2.d0 * alfa_2 ** tortuosity_factor
1299 
1300  k_2 = throat_radius / friction_coefficient * alfa_2 ** ( ( 1.d0 + &
1301  3.d0 * tortuosity_factor ) / 2.d0 )
1302 
1303  effusive_drag = visc_2 / k_1 + rho_2 / k_2 * cdabs( u_2 - u_1 )
1304 
1305  explosive_drag = 3.d0 * c_d / ( 8.d0 * r_a ) * rho_2 &
1306  * cdabs( u_2 - u_1 )
1307 
1308  ELSE
1309 
1310  effusive_drag = dcmplx(1.0e20,0.0)
1311 
1312  explosive_drag = dcmplx(0.0,0.0)
1313 
1314  END IF
1315 
1316 
1317  CASE ( 'forchheimer_wt' )
1318 
1319  ! Forchheimer (Eq. 16 Degruyter et al. 2012) without transit. zone (phi_t)
1320 
1321  IF ( REAL(alfa_2) .GT. 0.0001 ) then
1322 
1323  radius_bubble = ( alfa_2 / ( 4.0 / 3.0 * pi * bubble_number_density &
1324  * ( alfa_1 ) ) ) ** ( 1.d0 / 3.d0 )
1325 
1326  throat_radius = radius_bubble * throat_bubble_ratio
1327 
1328  k_1 = 0.125d0 * throat_radius ** 2.d0 * alfa_2 ** tortuosity_factor
1329 
1330  k_2 = throat_radius / friction_coefficient * alfa_2 ** ( ( 1.d0 + &
1331  3.d0 * tortuosity_factor ) / 2.d0 )
1332 
1333  effusive_drag = visc_2 / k_1 + rho_2 / k_2 * cdabs( u_2 - u_1 )
1334 
1335  explosive_drag = 3.d0 * c_d / ( 8.d0 * r_a ) * rho_2 &
1336  * cdabs( u_2 - u_1 )
1337 
1338  ELSE
1339 
1340  effusive_drag = dcmplx(1.0e20,0.0)
1341 
1342  explosive_drag = dcmplx(0.0,0.0)
1343 
1344  END IF
1345 
1346  CASE ('drag')
1347 
1348  radius_bubble = ( alfa_2 / ( 4.0 / 3.0 * pi * ( alfa_1 ) ) ) &
1349  ** ( 1.d0 / 3.d0 )
1350 
1351  rey = 2.d0 * radius_bubble * cdabs( u_2 - u_1 ) / visc_1
1352 
1353  c_d = dreal( 24.0d0 / rey * ( 1.0d0 + 1.0d0 / 8.0d0 * rey**0.72) )
1354 
1355  effusive_drag = 3.d0 * c_d / ( 8.d0 * radius_bubble ) * rho_1 &
1356  * cdabs( u_2 - u_1 )
1357 
1358  explosive_drag = effusive_drag
1359 
1360  CASE ( 'constant' )
1361 
1362  effusive_drag = dcmplx(1.d0,0.d0)
1363 
1364  explosive_drag = effusive_drag
1365 
1366  CASE ( 'single_velocity' )
1367 
1368  effusive_drag = dcmplx(1.d0,0.d0)
1369 
1370  explosive_drag = effusive_drag
1371 
1372  END SELECT
1373 
1374  IF ( drag_funct_model .EQ. 'forchheimer' ) THEN
1375 
1376  drag_funct = effusive_drag ** ( 1.d0 - t ) * &
1377  ( explosive_drag + 1.d-10 ) ** t
1378 
1379  ELSE
1380 
1381  drag_funct = effusive_drag ** ( 1.d0 - frag_eff ) * &
1382  ( explosive_drag + 1.d-10 ) ** frag_eff
1383 
1384  END IF
1385 
1387 
1388  velocity_relaxation = - drag_funct * ( u_1 - u_2 ) * ( rho_mix &
1389  / ( rho_1 * rho_2 ) )
1390 
1391  IF ( drag_funct_model .EQ. 'eval' ) THEN
1392 
1393  velocity_relaxation = - drag_funct * ( u_1-u_2 ) / ( x_1 * x_2 * rho_mix )
1394 
1395  ELSE
1396 
1397  velocity_relaxation = - drag_funct * ( u_1 - u_2 ) * ( rho_mix &
1398  / ( rho_1 * rho_2 ) )
1399 
1400  END IF
1401 
1402  IF ( verbose_level .GE. 3 ) THEN
1403 
1404  WRITE(*,*) drag_funct , ( u_1 - u_2 ) , x_1 , x_2 , rho_mix
1405  WRITE(*,*) - drag_funct * ( u_1 - u_2 ) / ( x_1 * x_2 * rho_mix )
1406  WRITE(*,*) 'velocity_relaxation',velocity_relaxation
1407 
1408  END IF
1409 
1410  END SUBROUTINE vel_relax_term
1411 
1412  !******************************************************************************
1416  !
1423  !******************************************************************************
1424 
1425  SUBROUTINE f_permkc
1427  IMPLICIT NONE
1428 
1429  REAL*8 :: permkc_alfa_switch
1430  REAL*8 :: d_permkc_alfa_switch
1431  REAL*8 :: log_base
1432 
1433  alfa_switch = 0.03
1434 
1435  log_base = 1.d0 / dlog10(dexp(1.d0))
1436 
1437  permkc_alfa_switch = (perm0*10.d0**(-10.2d0*(100.d0*alfa_switch) &
1438  **(0.014d0/alfa_switch)) )
1439 
1440  d_permkc_alfa_switch = log_base * permkc_alfa_switch * &
1441  dlog10(permkc_alfa_switch / perm0) * ( 0.014d0/alfa_switch**2) * &
1442  ( 1 - dlog(100*alfa_switch) )
1443 
1444  a_2nd = ( permkc_alfa_switch - d_permkc_alfa_switch * alfa_switch) &
1445  / ( alfa_switch**2 - 2.d0 * alfa_switch**2.d0 )
1446 
1447  b_2nd = d_permkc_alfa_switch - 2.d0 * a_2nd*alfa_switch
1448 
1449  IF ( REAL(alfa_2) .LT. alfa_switch ) then
1450 
1452 
1453  ELSE
1454 
1455  permkc = perm0*10.d0**(-10.2d0*(100.d0*alfa_2) ** ( 0.014d0 / alfa_2 ) )
1456 
1457  ENDIF
1458 
1459  inv_permkc = 1.d0 / permkc
1460 
1461  END SUBROUTINE f_permkc
1462 
1463 
1464  !******************************************************************************
1466  !
1470  !******************************************************************************
1471 
1472  SUBROUTINE mixture_viscosity
1474  USE complexify
1475  IMPLICIT NONE
1476 
1477  CALL f_viscliq
1478 
1479  CALL f_bubbles
1480 
1482 
1483  END SUBROUTINE mixture_viscosity
1484 
1485  !******************************************************************************
1489  !
1494  !******************************************************************************
1495 
1496  SUBROUTINE f_viscliq
1498  USE complexify
1499  IMPLICIT NONE
1500 
1501  ! Calculate viscosity of the melt (bubbles and crystal-free)
1502  CALL f_viscmelt
1503 
1504  ! Calculate relative visocisty due to crystals
1505  CALL f_theta
1506 
1507  ! Calculate viscosity of the melt+crystal
1508  visc_1 = visc_melt * theta
1509 
1510  END SUBROUTINE f_viscliq
1511 
1512  !******************************************************************************
1516  !
1523  !******************************************************************************
1524 
1525  SUBROUTINE f_viscmelt
1527  USE complexify
1528  IMPLICIT NONE
1529 
1530  COMPLEX*16 :: w
1531  COMPLEX*16 :: visc1exp , visc2exp , visc3exp
1532 
1533  COMPLEX*16, DIMENSION(12) :: wt
1534 
1535  COMPLEX*16, DIMENSION(12) :: norm_wt, xmf
1536  REAL*8, DIMENSION(12) :: mw
1537  REAL*8 :: A
1538  COMPLEX*16 :: gfw , B , C
1539  REAL*8, DIMENSION(10) :: bb
1540  COMPLEX*16, DIMENSION(10) :: bcf
1541  COMPLEX*16, DIMENSION(7) :: cc , ccf
1542  COMPLEX*16 :: siti , tial , fmm , nak
1543  COMPLEX*16 :: b1 , b2 , b3 , b4 , b5 , b6 , b7 , b11 , b12 , b13 , c1 , c2 ,&
1544  c3 , c4 , c5 , c6 , c11
1545 
1546  COMPLEX*16 :: x_d_md_tot
1547 
1548  INTEGER :: i
1549 
1550  x_d_md_tot = sum( x_d_md(1:n_gas) )
1551 
1552  w = x_d_md_tot * 100.d0
1553 
1554  SELECT CASE ( visc_melt_model )
1555 
1556  CASE DEFAULT
1557 
1558  CASE ( 'Hess_and_Dingwell1996')
1559 
1560  ! melt viscosity of rhyolite reaches a maximum at 1.e12
1561 
1562  IF ( REAL(w) .LT. 0.03 ) then
1563 
1564  visc_melt = dcmplx( 1.0d12 , 0.d0 )
1565 
1566  ELSE
1567 
1568  visc1exp = (-3.545d0 + 0.833d0 * cdlog(w))
1569 
1570  visc2exp = (9601.0d0 - 2368.0d0 * cdlog(w))
1571 
1572  visc3exp = visc2exp / ( t - ( 195.70d0 + 32.250d0 * cdlog(w) ) )
1573 
1574  visc_melt = 10.0**(visc1exp+visc3exp)
1575 
1576  END IF
1577 
1578  CASE ( 'Romano_et_al2003')
1579 
1580  ! Campi-Flegrei - Romano et al. (2003)
1581 
1582  IF ( REAL(w) .LT. 0.03 ) then
1583 
1584  visc_melt = dcmplx( 1.0d12 , 0.d0 )
1585 
1586  ELSE
1587 
1588  visc1exp = ( -5.8996d0 -0.2857d0 * cdlog(w))
1589 
1590  visc2exp = ( 10775.0d0 - 394.83d0 * cdlog(w))
1591 
1592  visc3exp = visc2exp / ( t - ( 148.71d0 -21.65d0 * cdlog(w) ) )
1593 
1594  visc_melt = 10.0**(visc1exp+visc3exp)
1595 
1596  END IF
1597 
1598  CASE ( 'Giordano_et_al2008' )
1599 
1600  ! -------------------------- Giordano et al. (2008) ----------------------
1601  ! Call for dissolved water in te melt from the model and add it to the
1602  ! composition of glass in wt
1603 
1604  DO i = 1,12
1605 
1606  wt(i) = dcmplx( wt_init(i) , 0.d0 )
1607 
1608  END DO
1609 
1610 
1611  wt(11) = w
1612 
1613  ! Create the normalized wt. % distribution
1614 
1615  norm_wt = 100.d0 * ( wt / sum(wt) )
1616 
1617  ! Change to molar fractions
1618 
1619  mw = [ 60.0843 , 79.8658 , 101.961276 , 71.8444 , 70.937449 , 40.3044 , &
1620  56.0774 , 61.97894 , 94.1960 , 141.9446 , 18.01528 , 18.9984 ]
1621  gfw = 100.d0 / sum( norm_wt / mw )
1622  xmf = ( norm_wt / mw ) * gfw
1623 
1624 
1625  ! Model coefficients
1626 
1627  bb = [159.56, -173.34, 72.13, 75.69, -38.98, -84.08, 141.54, -2.43, &
1628  -0.91, 17.62]
1629  cc = [2.75, 15.72, 8.32, 10.2, -12.29, -99.54, 0.3]
1630 
1631  ! Load composition-based matrix for multiplication against
1632  ! model-coefficients
1633 
1634  siti = xmf(1) + xmf(2)
1635  tial = xmf(2) + xmf(3)
1636  fmm = xmf(4) + xmf(5) + xmf(6)
1637  nak = xmf(8) + xmf(9)
1638  b1 = siti
1639  b2 = xmf(3)
1640  b3 = xmf(4) + xmf(5) + xmf(10)
1641  b4 = xmf(6)
1642  b5 = xmf(7)
1643  b6 = xmf(8) + xmf(11) + xmf(12)
1644  b7 = xmf(11) + xmf(12) + cdlog( 1.d0 + xmf(11) )
1645  b11 = siti * fmm
1646  b12 = ( siti + xmf(3) + xmf(10) ) * ( nak + xmf(11) )
1647  b13 = xmf(3) * nak
1648 
1649  c1 = xmf(1)
1650  c2 = tial
1651  c3 = fmm
1652  c4 = xmf(7)
1653  c5 = nak
1654  c6 = cdlog( 1.d0 + xmf(11) + xmf(12) )
1655  c11 = xmf(3) + fmm + xmf(7) - xmf(10)
1656  c11 = c11 * ( nak + xmf(11) + xmf(12) )
1657 
1658  bcf = [b1, b2, b3, b4, b5, b6, b7, b11, b12, b13]
1659  ccf = [c1, c2, c3, c4, c5, c6, c11]
1660 
1661  ! Model main parameters
1662 
1663  a = -4.55d0
1664  b = sum( bb * bcf )
1665  c = sum( cc * ccf )
1666 
1667  ! Calculates viscosity
1668 
1669  visc_melt = a + b / ( t - c )
1670  visc_melt = 10.d0 ** visc_melt
1671 
1672  CASE ('Di_Genova_et_al2013_eqn_3,5')
1673 
1674  ! Viscosity for peralkaline rhyolites from Pantelleria Island
1675  ! Di Genova et al. 2013 (Eqs. 3,5)
1676 
1677  a = -4.55d0
1678 
1679  ! -------- Giordano et al. 2009 ------------------------------------------
1680  b1 = 4278.17d0
1681  b2 = 8.6d0
1682  b = b1 + b2 * w
1683 
1684  c1 = 513.d0
1685  c2 = -245.3d0
1686  c = c1 + c2 * cdlog( 1.d0 + w )
1687 
1688  visc_melt = a + b / ( t - c )
1689  visc_melt = 10.d0 ** visc_melt
1690 
1691  CASE ('Di_Genova_et_al2013_eqn_4,5')
1692 
1693  ! Viscosity for peralkaline rhyolites from Pantelleria Island
1694  ! Di Genova et al. 2013 (Eqs. 4,5)
1695 
1696  a = -4.55d0
1697 
1698  ! -------- New parametrization -------------------------------------------
1699  b3 = 10528.64d0
1700  b4 = -4672.21d0
1701  b = b3 + b4 * cdlog( 1.d0 + w )
1702 
1703  c3 = 172.27d0
1704  c4 = 89.75d0
1705  c = c3 + c4 * cdlog( 1.d0 + w )
1706 
1707 
1708  visc_melt = a + b / ( t - c )
1709  visc_melt = 10.d0 ** visc_melt
1710 
1711 
1712  CASE ( 'Giordano_et_al2009' )
1713 
1714  a = -4.55d0
1715 
1716  b1 = 6101.0d0
1717  b2 = -63.66d0
1718 
1719  b = b1 + b2 * 3.5d0 * w
1720  !B = b1 + b2 * w
1721 
1722 
1723  c1 = 567.0d0
1724  c2 = -160.3d0
1725  c = c1 + c2 * cdlog( 1.d0 + 3.5d0 * w )
1726  !C = c1 + c2 * CDLOG( 1.D0 + w )
1727 
1728  visc_melt = a + b / ( t - c )
1729  visc_melt = 10.d0 ** visc_melt
1730 
1731  END SELECT
1732 
1733 
1734  END SUBROUTINE f_viscmelt
1735 
1736  !******************************************************************************
1740  !
1755  !******************************************************************************
1756 
1757  SUBROUTINE f_theta
1759  USE complexify
1760  IMPLICIT NONE
1761 
1762  COMPLEX*16 :: arg_erf , t , errorf, var_phi
1763 
1764  REAL*8 :: omega , betas , theta0
1765 
1766  REAL*8 :: p , a1 , a2 , a3 , a4 , a5
1767  REAL*8 :: phi_star, csi, delta, Einstein_coeff
1768 
1769  SELECT CASE (theta_model)
1770 
1771  CASE DEFAULT
1772 
1773  CASE ( 'Lejeune_and_Richet1995')
1774 
1775  !---------- Einstein-Roscoe ( with constants from Lejeune & Richet '95)
1776  theta = ( 1.0d0 - ( sum( beta(1:n_cry) ) / 0.7d0 ) ) ** ( -3.4d0 )
1777 
1778  CASE ('Dingwell1993')
1779 
1780  !---------- Dingwell & al '93
1781  theta = ( 1.0d0 + 0.75d0 * ( ( sum(beta(1:n_cry) ) / 0.84d0 ) / ( 1.d0 - &
1782  ( sum( beta(1:n_cry) ) / .84d0 ) ) ) ) **2.d0
1783 
1784  CASE ('Fixed_value')
1785 
1786  !-----------Constant theta
1787  theta = theta_fixed ! Melnik & Sparks '99
1788 
1789  CASE ('Costa2005')
1790 
1791  !-----------Costa
1792  c1 = 0.9995d0
1793  c2 = 0.4d0
1794  c3 = 1.d0
1795 
1796 
1797  p = 0.3275911d0
1798  a1 = 0.254829592d0
1799  a2 = -0.284496736d0
1800  a3 = 1.421413741d0
1801  a4 = -1.453152027d0
1802  a5 = 1.061405429d0
1803 
1804  arg_erf = 0.5d0 * dsqrt(pi) * sum( beta(1:n_cry) ) * ( 1.d0 + c2 / &
1805  ( 1.d0 - sum( beta(1:n_cry) ) ) ** c3 )
1806 
1807  t = 1.d0 / ( 1.d0 + p * arg_erf )
1808 
1809  errorf = 1.d0 - ( a1 * t + a2 * t**2 + a3 * t**3 + a4 * t**4 + a5 * t**5)&
1810  * cdexp( - arg_erf ** 2 )
1811 
1812  theta = ( 1.d0 - c1 * errorf ) ** ( - 2.5d0 / c1 )
1813 
1814  CASE ('Melnik_and_Sparks2005')
1815 
1816  !-----------Melnik & Sparks 2005 Eq.16
1817  c1 = 1.4d0
1818  c2 = 8.6d0
1819  c3 = 0.69d0
1820 
1821  theta = c1 * 10.d0 ** ( atan( c2 * ( sum( beta(1:n_cry) ) - c3 ) ) + pi )
1822 
1823  CASE ('Melnik_and_Sparks1999')
1824 
1825  omega = 20.6d0
1826  betas = 0.62d0
1827  theta0 = 3.5d0
1828 
1829  theta = theta0 * 10.d0 ** ( 0.5d0 * pi + atan( omega * ( sum( &
1830  beta(1:n_cry) ) - betas )))
1831 
1832  CASE ('Vona_et_al2011')
1833 
1834  !-----------Costa et al. 2009, Vona et al. 2011
1835 
1836  p = 0.3275911d0
1837  a1 = 0.254829592d0
1838  a2 = -0.284496736d0
1839  a3 = 1.421413741d0
1840  a4 = -1.453152027d0
1841  a5 = 1.061405429d0
1842 
1843  ! This is the value reported in Vona et al 2011, but according to Fig 9
1844  ! of that article, a best fitting is obtained with 0.29
1845 
1846  phi_star = 0.274d0
1847  csi = 0.0327d0
1848  delta = 13.d0 - 0.84d0
1849  einstein_coeff = 2.8d0
1850 
1851 
1852  var_phi = sum( beta(1:n_cry) * rho_c(1:n_cry) / rho_1 ) / phi_star
1853 
1854  arg_erf = 0.5d0 * dsqrt(pi) / (1.0d0 - csi) * var_phi * ( 1.d0 + &
1855  var_phi ** 0.84d0 )
1856 
1857  t = 1.d0 / ( 1.d0 + p * arg_erf )
1858 
1859  errorf = 1.d0 - ( a1 * t + a2 * t**2.0d0 + a3 * t**3.0d0 &
1860  + a4 * t**4.0d0 + a5 * t**5.0d0) * cdexp( - arg_erf ** 2.0d0 )
1861 
1862  theta = theta_fixed * (1.d0 + var_phi ** delta ) / &
1863  ( ( 1.d0 - (1.d0 - csi) * errorf ) ** (einstein_coeff * phi_star) )
1864 
1865 
1866  CASE ('Vona_et_al2011_mod')
1867 
1868  !-----------Costa et al. 2009, Vona et al. 2011
1869 
1870  p = 0.3275911d0
1871  a1 = 0.254829592d0
1872  a2 = -0.284496736d0
1873  a3 = 1.421413741d0
1874  a4 = -1.453152027d0
1875  a5 = 1.061405429d0
1876 
1877  ! Modification of Vona et al. 2011 in order to better reproduce
1878  ! the viscosity at Stromboli.
1879 
1880  phi_star = 0.39d0
1881  csi = 0.03d0
1882  delta = 2.0d0 - 0.84d0
1883  einstein_coeff = 2.8d0
1884 
1885 
1886  var_phi = sum( beta(1:n_cry) * rho_c(1:n_cry) / rho_1 ) / phi_star
1887 
1888  arg_erf = 0.5d0 * dsqrt(pi) / (1.0d0 - csi) * var_phi * ( 1.d0 + &
1889  var_phi ** 0.84d0 )
1890 
1891  t = 1.d0 / ( 1.d0 + p * arg_erf )
1892 
1893  errorf = 1.d0 - ( a1 * t + a2 * t**2.0d0 + a3 * t**3.0d0 + a4 * t**4.0d0 &
1894  + a5 * t**5.0d0) * cdexp( - arg_erf ** 2.0d0 )
1895 
1896  theta = theta_fixed * (1.d0 + var_phi ** delta )/( ( 1.d0 - (1.d0 - csi)&
1897  * errorf ) ** (einstein_coeff * phi_star) )
1898 
1899  CASE ('Vona_et_al2013_eq19')
1900 
1901  theta = ( 1.d0 - sum(beta(1:n_cry)) / (1.d0 - alfa_2 ) ) ** ( - 5.d0 &
1902  / 2.d0) * ( 1 - alfa_2 ) ** (- 1.d0)
1903 
1904  CASE ('Vona_et_al2013_eq20')
1905 
1906  theta = ( 1.d0 - sum(beta(1:n_cry)) - alfa_2 ) ** ( - ( 5.d0 * &
1907  sum(beta(1:n_cry)) + 2.d0 * alfa_2 ) / ( 2.d0 * ( sum(beta(1:n_cry))&
1908  + alfa_2 ) ) )
1909 
1910  CASE ('Vona_et_al2013_eq21')
1911 
1912  theta = ( 1.d0 - alfa_2 / (1.d0 - sum(beta(1:n_cry)) ) ) ** ( -1.0 ) &
1913  * ( 1 - sum(beta(1:n_cry)) ) ** (- 5.d0/2.d0)
1914 
1915  END SELECT
1916 
1917  END SUBROUTINE f_theta
1918 
1919  !******************************************************************************
1923  !
1934  !******************************************************************************
1935 
1936  SUBROUTINE f_bubbles
1938  USE complexify
1939  USE geometry, ONLY : radius
1940  IMPLICIT NONE
1941 
1942  REAL*8 :: Ca, gamma_Ca
1943 
1944  IF( (.NOT. (theta_model .EQ. 'Vona_et_al2013_eq19' ) ) .AND. &
1945  (.NOT. (theta_model .EQ. 'Vona_et_al2013_eq20' ) ) .AND. &
1946  (.NOT. (theta_model .EQ. 'Vona_et_al2013_eq21' ) ) ) THEN
1947 
1948  SELECT CASE ( bubbles_model )
1949 
1950  CASE DEFAULT
1951 
1952  visc_rel_bubbles = dcmplx(1.0d0,0.0d0)
1953 
1954  CASE ( 'none' )
1955 
1956  visc_rel_bubbles = dcmplx(1.0d0,0.0d0)
1957 
1958  CASE ( 'Costa2007' )
1959 
1960  gamma_ca = 0.25d0
1961 
1962  ca = r_a * visc_melt * (8.00d0 * (u_mix * pi * radius**2) &
1963  / (3.0d0 * pi * radius**3.0d0)) / gamma_ca
1964 
1965  visc_rel_bubbles = (1.0d0/(1.0d0 + 25.0d0*ca*ca)) &
1966  * ( 1.0d0 / (1.0d0-alfa_2) &
1967  + 25.0d0*ca*ca*((1.0d0-alfa_2)**(5.0d0/3.0d0)))
1968 
1969 
1970  CASE ( 'Einstein' )
1971 
1972  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) / ( 1.d0 - alfa_2 )
1973 
1974  CASE ( 'Quane-Russel' )
1975 
1976  ! For Campi-Flegrei we use 0.63 as reported in 2004 Report (Task2.2)
1977 
1978  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * cdexp( ( - 0.63 * alfa_2 ) &
1979  / ( 1.d0 - alfa_2 ) )
1980 
1981  CASE ( 'Eilers' )
1982 
1983  ! Eq. (17) Mader et al. 2013
1984 
1985  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * (1.0d0 + (1.25d0 * alfa_2) &
1986  / (1.0d0 - 1.29 * alfa_2) ) ** 2.0d0
1987 
1988  CASE ( 'Sibree' )
1989 
1990  ! Eq. (18) Mader et al. 2013
1991 
1992  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * ( 1.0d0 / ( 1.0d0 &
1993  - (1.2 * alfa_2)** 0.33333d0 ) )
1994 
1995  CASE ( 'Taylor' )
1996 
1997  ! Eq. (16) Mader et al. 2013
1998 
1999  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * (1.0d0 + alfa_2)
2000 
2001  CASE ( 'Mackenzie' )
2002 
2003  ! Eq. (19) Mader et al. 2013
2004 
2005  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * (1.0d0 - (5.d0 / 3.d0) &
2006  * alfa_2)
2007 
2008  CASE ( 'DucampRaj' )
2009 
2010  ! Eq. (21) Mader et al. 2013, using b = 3
2011 
2012  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * cdexp( -3.d0 * ( alfa_2 &
2013  / ( 1.d0 - alfa_2 ) ) )
2014 
2015  CASE ( 'BagdassarovDingwell' )
2016 
2017  ! Eq. (22) Mader et al. 2013
2018 
2019  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * ( 1.d0 / (1.d0 + 22.4d0 &
2020  * alfa_2 ) )
2021 
2022  CASE ( 'Rahaman' )
2023 
2024  ! Eq. (20) Mader et al. 2013
2025 
2026  visc_rel_bubbles = dcmplx(1.0d0,0.0d0) * cdexp( - 11.2d0 * alfa_2 )
2027 
2028  END SELECT
2029 
2030  ELSE
2031 
2032  visc_rel_bubbles = dcmplx(1.0d0,0.0d0)
2033 
2034  END IF
2035 
2036  END SUBROUTINE f_bubbles
2037 
2038  !*****************************************************************************
2042  !
2057  !******************************************************************************
2058 
2059  SUBROUTINE f_alfa(xtot,xmax,r_beta,r_rho_md,r_rho_2,r_alfa_2)
2061  IMPLICIT NONE
2062 
2063  REAL*8, INTENT(IN) :: xtot(n_gas) , xmax(n_gas)
2064  REAL*8, INTENT(IN) :: r_beta(n_cry)
2065  REAL*8, INTENT(IN) :: r_rho_md
2066  REAL*8, INTENT(IN) :: r_rho_2
2067  REAL*8, INTENT(OUT) :: r_alfa_2(n_gas)
2068 
2069 
2070  REAL*8 :: r_x_g(n_gas)
2071 
2072  ! Mass fraction of the exsolved gas with respect to the crystal-free magma
2073  r_x_g(1:n_gas) = xtot(1:n_gas) - xmax(1:n_gas)
2074 
2075  r_alfa_2 = ( r_x_g * ( 1.d0 - sum( r_beta(1:n_cry) ) ) * r_rho_md ) / &
2076  ( ( 1.d0 - xtot) * r_rho_2 + r_x_g * ( 1.d0 - sum( r_beta(1:n_cry) ) ) &
2077  * r_rho_md )
2078 
2079  END SUBROUTINE f_alfa
2080 
2081  !*****************************************************************************
2085  !
2100  !******************************************************************************
2101 
2102  SUBROUTINE f_alfa3(r_p_2,xtot,r_beta,r_rho_md,r_rho_g,r_alfa_g)
2104  IMPLICIT NONE
2105 
2106  REAL*8, INTENT(IN) :: xtot(n_gas)
2107  REAL*8, INTENT(IN) :: r_beta(n_cry)
2108  REAL*8, INTENT(IN) :: r_p_2
2109  REAL*8, INTENT(IN) :: r_rho_md
2110  REAL*8, INTENT(IN) :: r_rho_g(n_gas)
2111  REAL*8, INTENT(OUT) :: r_alfa_g(n_gas)
2112 
2113 
2114  !REAL*8 :: r_x_g(n_gas) !< exsolved gas mass fraction
2115  REAL*8 :: r_x_d(n_gas)
2116  REAL*8 :: r_alfa_g_2_max(n_gas),best_alfa_g_2(n_gas)
2117  REAL*8 :: r_alfa_g_2(n_gas), r_alfa_g_2_new(n_gas)
2118  REAL*8 :: h,error,best_error
2119  REAL*8 :: A(n_gas,n_gas),num(n_gas), den(n_gas)
2120  REAL*8 :: r_rho_md_beta
2121  INTEGER :: iter,i,j
2122  INTEGER :: pivot(n_gas)
2123  INTEGER :: ok
2124 
2125  r_alfa_g = 1.0e-5;
2126 
2127  r_alfa_g_2_max = (xtot / solub)**(1.0 / solub_exp) / r_p_2;
2128 
2129 
2130  r_rho_md_beta = ( 1.d0 - sum( r_beta(1:n_cry) ) ) * r_rho_md
2131 
2132  h = 1e-5;
2133 
2134  iter = 1
2135  error = 1.0
2136  r_alfa_g_2 = [0.0 , 1.0]
2137 
2138  best_error = 1.0
2139  best_alfa_g_2 = r_alfa_g_2
2140 
2141  DO WHILE ( r_alfa_g_2(1) .LT. r_alfa_g_2_max(1) - h)
2142 
2143  r_alfa_g_2 = [r_alfa_g_2(1) + h, 1.0 - (r_alfa_g_2(1) + h)]
2144 
2145  DO i = 1,n_gas
2146 
2147  r_x_d(i) = dreal( solub(i) * (r_alfa_g_2(i) * p_2)**(solub_exp(i)) )
2148 
2149  DO j = 1,n_gas
2150  a(i,j) = - xtot(i) * r_rho_g(j) + r_rho_md_beta * &
2151  ( xtot(i) - r_x_d(i) )
2152  END DO
2153 
2154  a(i,i) = a(i,i) + r_rho_g(i)
2155 
2156  r_alfa_g(i) = r_rho_md_beta * ( xtot(i) - r_x_d(i) )
2157 
2158  END DO
2159 
2160  call dgesv(n_gas, 1, a , n_gas, pivot, r_alfa_g , n_gas, ok)
2161 
2162  r_alfa_g_2_new = r_alfa_g / sum( r_alfa_g )
2163 
2164  error = maxval(abs(r_alfa_g_2_new - r_alfa_g_2))
2165 
2166  DO i = 1,n_gas
2167  IF (r_alfa_g(i) .LT. 0.0) THEN
2168  error = 1.0
2169  END IF
2170  END DO
2171 
2172  DO i = 1,n_gas
2173  IF (r_x_d(i) .GT. xtot(i)) THEN
2174  error = 1.0
2175  END IF
2176  END DO
2177 
2178  IF ( error .LT. best_error) THEN
2179  best_error = error
2180  best_alfa_g_2 = r_alfa_g_2
2181  END IF
2182 
2183  END DO
2184 
2185  r_alfa_g_2 = best_alfa_g_2
2186 
2187  DO i = 1,n_gas
2188 
2189  r_x_d(i) = dreal(solub(i) * (r_alfa_g_2(i) * p_2)**(solub_exp(i)) )
2190 
2191  DO j = 1,n_gas
2192  a(i,j) = - xtot(i) * r_rho_g(j) + r_rho_md_beta * &
2193  ( xtot(i) - r_x_d(i) )
2194  END DO
2195 
2196  a(i,i) = a(i,i) + r_rho_g(i)
2197 
2198  r_alfa_g(i) = r_rho_md_beta * ( xtot(i) - r_x_d(i) )
2199 
2200  END DO
2201 
2202  call dgesv(n_gas, 1, a , n_gas, pivot, r_alfa_g , n_gas, ok)
2203 
2204  num = r_alfa_g * r_rho_g + ( 1.0 - sum( r_alfa_g ))* r_rho_md_beta * r_x_d
2205  den = sum(r_alfa_g * r_rho_g) + ( 1.0 - sum( r_alfa_g )) * r_rho_md_beta
2206  error = maxval(abs(xtot - num/den));
2207 
2208  IF( error .GT. 1e-010 ) THEN
2209  WRITE(*,*) 'Initial exsolved volatile content error!'
2210  WRITE(*,*) 'error='
2211  WRITE(*,*) error
2212  stop
2213  END IF
2214 
2215 
2216  END SUBROUTINE f_alfa3
2217 
2218 END MODULE constitutive
2219 
real *8, dimension(:), allocatable bar_p_c
crystals cohesion pressure
real *8, dimension(:), allocatable x_ex_dis_in
complex *16 u_1
melt-crystals phase local velocity
complex *16 s
mixture entropy
complex *16 x_md_1
melt+dis.gas mass fraction in phase 1
subroutine f_viscliq
Magma viscosity.
complex *16 rhob_m
melt bulk density
complex *16, dimension(:), allocatable growth_rate
growth rate for the crystals
integer idx_p2
Index of p2 in the qp array.
Definition: parameters.f90:38
Parameters.
Definition: parameters.f90:10
character(len=30), dimension(20) available_visc_melt_models
real *8, dimension(:), allocatable bar_e_c
crystals formation energy
real *8, dimension(:), allocatable gamma_d
dissolved gas adiabatic exponent
real *8, dimension(:), allocatable b_g
parameter for the VDW EOS
real *8, dimension(:), allocatable bar_e_d
dissolved gas formation energy
complex *16 s_1
local specific entropy of the melt-crystals phase
real *8, dimension(:), allocatable t0_c
crystals gas reference temperature
real *8, dimension(:), allocatable p0_g
exsolved gas reference pressure
real *8 drag_funct_coeff
coefficient for the drag function for the relative velocity:
real *8 grav
gravitational acceleration
complex *16, dimension(:,:), allocatable mom_cry
moments of the crystal referred to the melt-crystals phase
complex *16, dimension(:), allocatable rho_g
exsolved gas local density
subroutine allocate_phases_parameters
Initialization of relaxation flags.
real *8 bar_p_m
melt cohesion pressure
real *8 alfa_switch
real *8 theta_fixed
Fixed value for the relative viscosity of the crystals.
complex *16, dimension(:), allocatable rho_c
crystals local density
real *8, dimension(:), allocatable s0_d
dissolved gas reference entropy
complex *16 theta
Relative viscosity of the crystals.
real *8 c1
Coefficients for the relative viscosity models.
complex *16 mu_2
free Gibbs energy of the exsolved gas
integer idx_u2
Index of u2 in the qp array.
Definition: parameters.f90:40
real *8 t0_m
melt reference temperature
real *8 p0_m
melt reference pressure
complex *16 rho_m
melt local density
integer n_gas
Numbeer of crystal phases.
Definition: parameters.f90:30
complex *16, dimension(:), allocatable x_c_1
cristal mass fractions in phase 1
real *8, dimension(:), allocatable p0_d
dissolved gas reference pressure
logical explosive
Flag to choose the eruptive style: .
complex *16 e_m
local specific internal energy of the melt
complex *16 cv_1
dis.gas+melt+crystals specific heat capacity at constant volume
real *8 gamma_m
melt adiabatic exponent
real *8 visc_2
gas viscosity
character *30 theta_model
Parameter to choose the model for the influence of crystal on the mixture: &#39;Lejeune_and_Richet1995&#39; &#39;...
real *8 gamma_2
exsolved gas adiabatic exponent
complex *16 alfa_2
total exsolved gas local volume fraction
complex *16 u_2
exsolved gas local velocity
subroutine f_alfa3(r_p_2, xtot, r_beta, r_rho_md, r_rho_g, r_alfa_g)
Bottom exsolved gas.
real *8, dimension(:), allocatable gamma_c
crystals adiabatic exponent
real *8, dimension(:), allocatable rho0_d
dissolved gas reference density
complex *16 rho_mix
mixture local density
complex *16, dimension(:), allocatable beta_eq
equil. cry. volume fraction in the melt-crystals phase
real *8, dimension(:), allocatable bar_e_g
exsolved gas formation energy
complex *16, dimension(:), allocatable e_g
local specific internal energy of the exsolved gas
real *8 tau_frag_exp
Fragmentation exponent.
real *8, dimension(:), allocatable tc_g
critical gas temperature
real *8 cv_2
exsolved gas specific heat capacity at constant volume
integer n_theta_models
real *8 frag_thr
Threshold for the fragmentation.
complex *16 inv_permkc
subroutine initialize_models
character *20 bubbles_model
Parameter to choose the model for the influence of the bubbles on the mixture: .
character *20 crystallization_model
Model for the equilibrium crystal volume fraction: .
real *8 c0_m
melt sound speed at atmospheric conditions
subroutine f_bubbles
Exsolved gas relative viscosity.
subroutine solve_cubic(a, b, c, y1, y2, y3)
Solution of a cubic.
complex *16, dimension(:), allocatable e_d
local specific internal energy of the dissolved gas
real *8, dimension(12) wt_init
real *8, dimension(:), allocatable c0_c
crystals sound speed at atm conditions
complex *16 tau_frag
fragmentation rate
complex *16 p_2
local pressure of the exsolved gas
integer fragmentation_model
Parameter to choose the fragmentation model: .
real *8 tau_frag_coeff
fragmentation coefficient:
complex *16 rho_md
dis_gas+melt local density
complex *16 e_2
local specific internal energy of the exsolved gas
real *8, dimension(:), allocatable tau_c
crystallization parameter:
complex *16, dimension(:), allocatable x_d_md_eq
equil. dis. gas mass fraction in the melt+dis.gas phase
complex *16 tau_p
pressure relaxation rate
integer idx_alfa_first
First index of alfa in the qp array.
Definition: parameters.f90:44
subroutine vel_relax_term(velocity_relaxation)
Velocity relaxation term.
subroutine f_viscmelt
Melt viscosity.
real *8 bubble_number_density
bubble number density
complex *16, dimension(:), allocatable x_c
crystals mass fraction (with respect to the mixture)
real *8 bar_e_2
exsolved gas formation energy
integer n_cry
Numbeer of crystal phases.
Definition: parameters.f90:29
real *8, dimension(:), allocatable rho0_c
crystals reference density
complex *16, dimension(:), allocatable s_g
local specific entropy of the exsolved gas
integer n_drag_models
real *8 pi
Definition: geometry.f90:25
complex *16 rho_2
exsolved gas local density
integer n_visc_melt_models
character *20 gas_law
equation of state for gas
real *8 s0_m
melt reference entropy
complex *16 alfarho_2
bulk density of the exsolved gas
subroutine f_permkc
Magma permeability.
character(len=30), dimension(20) available_drag_models
real *8, dimension(:), allocatable bar_p_d
dissolved gas cohesion pressure
subroutine f_alfa(xtot, xmax, r_beta, r_rho_md, r_rho_2, r_alfa_2)
Bottom exsolved gas.
character *20 p_relax_model
pressure relaxation model
real *8 friction_coefficient
real *8, dimension(:), allocatable tau_d
exsolution parameter:
complex *16 c_2
second phase local sound speed
subroutine sound_speeds(C_mix, mach)
Local sound speeds.
complex *16 mu_m
free Gibbs energy of the melt
complex *16 u_mix
mixture velocity
real *8 rho0_2
exsolved gas reference density
complex *16 s_2
local specific entropy of the exsolved gas
real *8, dimension(:), allocatable s0_c
crystals reference entropy
real *8, dimension(:), allocatable c0_d
dissolved gas sound speed at atm conditions
complex *16 x_1
melt-crystals phase local mass fraction
real *8 tortuosity_factor
tortuosity factor
complex *16 drag_funct
drag function for the relative velocity:
real *8 k_cr
country rock permeability
complex *16 alfa_1
dis_gas+melt+crystals phase local volume fraction
complex *16, dimension(:), allocatable s_d
local specific entropy of the dissolved gas
complex *16, dimension(:), allocatable alfa_g
exsolved gas phases local volume fraction
integer idx_alfa_last
Last index of alfa in the qp array.
Definition: parameters.f90:45
complex *16 alfa_m_1
melt volume fraction in phase 1
real *8 radius
Effective radius.
Definition: geometry.f90:27
real *8, dimension(:), allocatable beta_max
maximum crystal volume fraction
complex *16, dimension(:), allocatable alfa_g_2
exsolved gas volume fractions in phase 2
subroutine f_growth_rate
This subroutine compute the growth rates for the different crystal phases.
complex *16 visc_1
melt+crystal viscosity
complex *16 s_m
local specific entropy of the melt
character *20 exsol_model
String for exsolution model: .
real *8 cv_m
melt specific heat capacity at constant volume
real *8 bar_e_m
melt formation energy
real *8 zeta_lith
Elevation above the bottom for the evaluation of the lithostatic pressure.
real *8, dimension(:), allocatable rho0_g
exsolved gas reference density
integer idx_beta_first
First index of beta in the qp array.
Definition: parameters.f90:46
complex *16, dimension(:), allocatable s_c
local specific entropy of the crystals
subroutine f_nucleation_rate
Lithostatic pressure.
complex *16, dimension(:), allocatable rhob_c
crystals bulk density
real *8 tau_p_coeff
pressure relaxation coefficient:
real *8 frag_eff
index of fragmentation in the interval [0;1]
integer n_mom
Number of moments for each crystal phase.
Definition: parameters.f90:35
subroutine f_beta_eq
Equilibrium Crystal content.
integer n_bubble_models
real *8, dimension(:), allocatable cv_g
exsolved gas heat capacity at constant volume
real *8, dimension(:), allocatable p0_c
crystals reference pressure
integer idx_xd_first
First index of xd in the qp array.
Definition: parameters.f90:42
real *8 rho0_m
melt reference density
real *8 zn
Right (top) of the physical domain.
Definition: geometry.f90:21
integer idx_p1
Index of p1 in the qp array.
Definition: parameters.f90:37
integer idx_u1
Index of u1 in the qp array.
Definition: parameters.f90:39
complex *16, dimension(:), allocatable x_g
exsolved gas mass fraction (with respect to the mixture)
character *30 drag_funct_model
drag function model
Constitutive equations.
Definition: constitutive.f90:9
real *8, dimension(:), allocatable cv_d
dissolved gas heat capacity at constant volume
character *30 visc_melt_model
Parameter to select the melt viscosity (bubbles and crystal-free) model: .
integer idx_beta_last
Last index of beta in the qp array.
Definition: parameters.f90:47
complex *16, dimension(:), allocatable rho_d
dissolved gas local density
complex *16, dimension(:), allocatable e_c
local specific internal energy of the crystals
complex *16 e_1
local specific internal energy of the melt-crystals phase
complex *16 cv_mix
mixture specific heat capacity at constant volume
real *8, dimension(:), allocatable c0_g
exsolved gas sound speed at atm conditions
real *8, dimension(:), allocatable cv_c
crystals specific heat capacity at constant volume
real *8 p_hydro
Hydrostatic pressure.
character(len=30), dimension(20) available_bubble_models
real *8, dimension(:), allocatable a_g
parameter for the VDW EOS
complex *16 x_m
melt mass fraction (with respect to the mixture)
real *8 log10_bubble_number_density
complex *16, dimension(:), allocatable alfa_d_1
dissolved gas volume fractions in phase 1
subroutine press_relax_term(pressure_relaxation)
Pressure relaxation term.
complex *16, dimension(:), allocatable x_d_1
dissolved gas mass fractions in phase 1
real *8, dimension(:), allocatable solub
Solubility parameter for the Henry&#39;s law.
complex *16 rho_1
dis_gas+melt+crystals phase local density
subroutine hydrostatic_pressure
Hydrostatic pressure.
complex *16, dimension(:), allocatable x_d
dissolved gas mass fraction (with respect to the mixture)
real *8 rho_cr
contry rock density
real *8, dimension(:), allocatable t0_g
exsolved gas reference temperature
real *8, dimension(:), allocatable pc_g
critical gas pressure
integer n_vars
Number of conservative variables.
Definition: parameters.f90:32
real *8 rho_w
Water density.
real *8 throat_bubble_ratio
throat bubble ratio
complex *16, dimension(:), allocatable beta
crystal volume fraction in the melt-crystals phase
complex *16 e_mix
total internal energy
integer verbose_level
Definition: parameters.f90:101
real *8, dimension(:), allocatable gamma_g
exsolved gas adiabatic exponent
complex *16 x_m_1
melt mass fraction in phase 1
complex *16 x_2
exsolved gas local mass fraction
complex *16 c_1
first phase local sound speed
real *8 p_lith
Lithostatic pressure.
complex *16, dimension(:), allocatable mu_d
free Gibbs energy of the dissolved gas
complex *16 mu_1
free Gibbs energy of the melt-crystals phase
complex *16 p_1
local pressure of the melt-crystals phase
real *8, dimension(:), allocatable s0_g
exsolved gas reference entropy
subroutine lithostatic_pressure
Lithostatic pressure.
subroutine eval_densities
Phases densities.
subroutine f_xdis_eq
Equilibrium Dissolved gas.
real *8, dimension(:), allocatable t0_d
dissolved gas reference temperature
complex *16, dimension(:), allocatable nucleation_rate
nulceation rate for the crystals
complex *16 visc_rel_bubbles
relative viscosity due to bubbles
complex *16 permkc
Magma permeability.
complex *16 t
mixture local temperature
real *8, dimension(:), allocatable bar_p_g
exsolved gas cohesion pressure
complex *16, dimension(:), allocatable x_d_md
dissolved gas mass fraction in the melt+dis.gas phase
Grid module.
Definition: geometry.f90:7
complex *16 visc_melt
melt viscosity
complex *16, dimension(:), allocatable x_g_2
exsolved gas mass fractions in phase 2
subroutine eos
Equation of state.
character(len=30), dimension(20) available_theta_models
complex *16, dimension(:), allocatable mu_g
free Gibbs energy of the exsolved gas
real *8, dimension(:), allocatable solub_exp
real *8 t0_2
exsolved gas reference temperature
integer idx_t
Index of T in the qp array.
Definition: parameters.f90:41
subroutine f_theta
Crystal relative viscosity.
subroutine mixture_viscosity
Mixture viscosity.
integer idx_xd_last
Last index of xd in the qp array.
Definition: parameters.f90:43
complex *16, dimension(:), allocatable mu_c
free Gibbs energy of the crystals
complex *16 visc_mix
mixture viscosity
integer n_eqns
Number of equations.
Definition: parameters.f90:33
real *8, dimension(:), allocatable beta0
chamber (equilibrium) crystal volume fraction