MAMMA  1.0
Conduitsolver
equations.f90
Go to the documentation of this file.
1 !********************************************************************************
8 !********************************************************************************
9 MODULE equations
10 
11  USE constitutive
12 
13  USE geometry, ONLY : pi
14  USE parameters, ONLY : verbose_level
15  USE parameters, ONLY : n_eqns , n_vars
16  USE parameters, ONLY : n_cry , n_gas , n_mom
17 
18  USE parameters, ONLY : idx_p1 , idx_p2 , idx_u1 , idx_u2 , idx_t , &
21 
26 
27  IMPLICIT none
28 
33  LOGICAL :: isothermal
34 
36  REAL*8 :: fixed_temp
37 
43 
48  LOGICAL :: lateral_degassing
49 
50 
52  REAL*8 :: alfa2_lat_thr
53 
57  LOGICAL :: ext_water
58 
62  LOGICAL :: inst_vaporization
63 
68  CHARACTER*30 :: aquifer_type
69 
72 
74  REAL*8 :: min_z_influx
75 
76  REAL*8 :: delta_z_influx
77 
79  REAL*8 :: max_z_influx
80 
82  REAL*8 :: t_w
83 
85  COMPLEX*16 :: t_boiling
86 
88  REAL*8 :: lambda_w
89 
91  REAL*8 :: cv_w
92 
94  REAL*8 :: visc_w
95 
96 CONTAINS
97 
98 
99  !******************************************************************************
103  !
114  !******************************************************************************
115 
116  SUBROUTINE phys_var_qp(r_qp,c_qp)
118  USE complexify
119  IMPLICIT none
120 
121  REAL*8, INTENT(IN), OPTIONAL :: r_qp(n_eqns)
122  COMPLEX*16, INTENT(IN), OPTIONAL :: c_qp(n_eqns)
123 
124  COMPLEX*16 :: qp(n_eqns)
125 
126  INTEGER :: i , j
127 
128  IF ( present(c_qp) ) THEN
129 
130  qp = c_qp
131 
132  ELSE
133 
134  qp = dcmplx( r_qp , 0.d0 )
135 
136  END IF
137 
138  p_1 = qp(idx_p1)
139  p_2 = qp(idx_p2)
140  u_1 = qp(idx_u1)
141  u_2 = qp(idx_u2)
142  t = qp(idx_t)
143 
144  ! dissolved and axsolved gas variables
145  x_d_md(1:n_gas) = qp(idx_xd_first:idx_xd_last)
146 
147  alfa_g(1:n_gas) = qp(idx_alfa_first:idx_alfa_last)
148 
149  alfa_2 = sum( alfa_g(1:n_gas) )
150 
151  alfa_g_2(1:n_gas) = alfa_g(1:n_gas) / alfa_2
152 
153  alfa_1 = 1.d0 - alfa_2
154 
155  ! crystal variables
156  IF ( n_mom .LE. 1 ) THEN
157 
158  beta(1:n_cry) = qp(idx_beta_first:idx_beta_last)
159 
160  ELSE
161 
162  DO i = 1,n_cry
163 
164  DO j = 0,n_mom-1
165 
166  mom_cry(i,j) = qp(idx_cry_eqn_first+n_mom*(i-1)+j)
167 
168  END DO
169 
170  beta(i) = pi / 6.d0 * mom_cry(i,3)
171 
172  END DO
173 
174  END IF
175 
176  ! eval_densities requires: beta, x_d_md , p_1 , p_2 , T
177  CALL eval_densities
178 
180 
181  x_c_1(1:n_cry) = rho_c(1:n_cry) * beta(1:n_cry) / rho_1
182  x_md_1 = dcmplx(1.d0,0.d0) - sum(x_c_1)
183 
184  x_d_1(1:n_gas) = x_d_md(1:n_gas) * x_md_1
185  x_m_1 = dcmplx(1.d0,0.d0) - sum(x_d_1) - sum(x_c_1)
186 
187  alfa_d_1(1:n_gas) = rho_1 * x_d_1(1:n_gas) / rho_d(1:n_gas)
188  alfa_m_1 = rho_1 * x_m_1 / rho_m
189 
191 
192  x_1 = alfa_1 * rho_1 / rho_mix
193  x_2 = alfa_2 * rho_2 / rho_mix
194 
195  x_g(1:n_gas) = alfa_g(1:n_gas) * rho_g(1:n_gas) / rho_mix
196 
197  x_g_2(1:n_gas) = x_g(1:n_gas) / x_2
198 
199  x_d(1:n_gas) = x_d_1(1:n_gas) * x_1
200  x_m = x_m_1 * x_1
201  x_c(1:n_cry) = x_c_1(1:n_cry) * x_1
202 
203  u_mix = x_1 * u_1 + x_2 * u_2
204 
205  rhob_m = rho_mix * x_m
206  rhob_c(1:n_cry) = rho_mix * x_c(1:n_cry)
207 
208  cv_mix = x_m * cv_m + sum( x_c(1:n_cry) * cv_c(1:n_cry) ) &
209  + sum( x_d(1:n_gas) * cv_d(1:n_gas) ) &
210  + sum( x_g(1:n_gas) * cv_g(1:n_gas) )
211 
212  END SUBROUTINE phys_var_qp
213 
214  !******************************************************************************
218  !
229  !******************************************************************************
230 
231  SUBROUTINE eval_qp2( r_qp , qp2 )
233  IMPLICIT none
234 
235  REAL*8, INTENT(IN) :: r_qp(n_vars)
236  REAL*8, INTENT(OUT) :: qp2(1+n_cry+n_gas+n_gas+4)
237 
238  COMPLEX*16 :: qp(n_vars)
239 
240  INTEGER :: i
241 
242  DO i = 1,n_vars
243 
244  qp(i) = dcmplx( r_qp(i), 0.d0 )
245 
246  END DO
247 
248  CALL phys_var_qp( c_qp = qp )
249  CALL eos
250 
251  CALL f_beta_eq
252 
253  CALL f_xdis_eq
254 
255  qp2(1) = REAL(rho_1)
256  qp2(1+1:1+n_gas) = REAL(rho_g(1:n_gas))
257  qp2(1+n_gas+1:1+n_gas+n_cry) = REAL(beta_eq(1:n_cry))
258  qp2(1+n_gas+n_cry+1:1+n_gas+n_cry+n_gas) = REAL( x_d_md_eq(1:n_gas) )
259 
260  CALL mixture_viscosity
261 
262  qp2(1+n_gas+n_cry+n_gas+1) = REAL( visc_mix )
263 
264  CALL f_viscmelt
265 
266  qp2(1+n_gas+n_cry+n_gas+2) = REAL( visc_melt )
267 
268  CALL f_theta
269 
270  qp2(1+n_gas+n_cry+n_gas+3) = REAL( theta )
271 
272  CALL f_bubbles
273 
274  qp2(1+n_gas+n_cry+n_gas+4) = REAL( visc_rel_bubbles )
275 
276  END SUBROUTINE eval_qp2
277 
278  !******************************************************************************
282  !
290  !******************************************************************************
291 
292  SUBROUTINE eval_fluxes_qp(c_qp,r_qp,c_flux,r_flux)
294  USE complexify
295  USE geometry, ONLY : radius
296 
297  IMPLICIT none
298 
299  COMPLEX*16, INTENT(IN), OPTIONAL :: c_qp(n_vars)
300  COMPLEX*16, INTENT(OUT), OPTIONAL :: c_flux(n_eqns)
301  REAL*8, INTENT(IN), OPTIONAL :: r_qp(n_vars)
302  REAL*8, INTENT(OUT), OPTIONAL :: r_flux(n_eqns)
303 
304  COMPLEX*16 :: qp(n_eqns)
305  COMPLEX*16 :: flux(n_eqns)
306 
307  INTEGER :: i , j
308 
309 
310  IF ( present(c_qp) .AND. present(c_flux) ) THEN
311 
312  qp = c_qp
313 
314  ELSEIF ( present(r_qp) .AND. present(r_flux) ) THEN
315 
316  qp = dcmplx( r_qp , 0.d0 )
317 
318  ELSE
319 
320  WRITE(*,*) 'Constitutive, eval_fluxes: problem with arguments'
321  stop
322 
323  END IF
324 
325  CALL phys_var_qp( c_qp = qp )
326  CALL eos
327 
328  flux(1:n_eqns) = dcmplx(0.d0,0.d0)
329 
330  !---- Mixture Density -------------------------------------------------------
331  flux(idx_mix_mass_eqn) = rho_mix * u_mix * radius**2
332 
333  IF ( verbose_level .GE. 3 ) THEN
334 
335  WRITE(*,*) 'Mixture mass flux'
336  WRITE(*,*) flux(idx_mix_mass_eqn)
337 
338  END IF
339 
340  !---- Volumetric Fraction First Phase ---------------------------------------
341  IF ( p_relax_model .EQ. 'single' ) THEN
342 
343  flux(idx_vol1_eqn) = dcmplx( 0.d0 , 0.d0 )
344 
345  ELSE
346 
347  flux(idx_vol1_eqn) = rho_mix * u_mix * alfa_1 * radius**2
348 
349  END IF
350 
351  IF ( verbose_level .GE. 3 ) THEN
352 
353  WRITE(*,*) 'Volume Fraction1 flux'
354  WRITE(*,*) flux(idx_vol1_eqn)
355 
356  END IF
357 
358  !---- Mixture Momentum ------------------------------------------------------
359  flux(idx_mix_mom_eqn) = ( alfa_1 * rho_1 * u_1**2 + alfa_2 * rho_2 * u_2**2 &
360  + alfa_1 * p_1 + alfa_2 * p_2 ) * radius**2
361 
362  IF ( verbose_level .GE. 3 ) THEN
363 
364  WRITE(*,*) 'Mixture momentum flux'
365  WRITE(*,*) flux(idx_mix_mom_eqn)
366 
367  END IF
368 
369  !---- Relative Velocity -----------------------------------------------------
370  IF ( drag_funct_model .EQ. 'single_velocity' ) THEN
371 
372  flux(idx_rel_vel_eqn) = dcmplx( 0.d0 , 0.d0 )
373 
374  ELSE
375 
376  flux(idx_rel_vel_eqn) = ( 0.5d0 * ( u_1 * u_1 - u_2 * u_2 ) &
377  + ( mu_1 - mu_2 ) ) * radius**2
378 
379  END IF
380 
381  IF ( verbose_level .GE. 3 ) THEN
382 
383  WRITE(*,*) 'Relative velocity flux'
384  WRITE(*,*) flux(idx_rel_vel_eqn)
385 
386  END IF
387 
388  !---- Total Energy ----------------------------------------------------------
389  IF ( isothermal ) THEN
390 
391  flux(idx_mix_engy_eqn) = dcmplx( 0.d0 , 0.d0 )
392 
393  ELSE
394 
395  flux(idx_mix_engy_eqn) = ( alfa_1 * rho_1 * u_1 * ( e_1 + p_1/rho_1 &
396  + 0.5d0 * u_1 * u_1 ) + alfa_2 * rho_2 * u_2 * ( e_2 + p_2/rho_2 &
397  + 0.5d0 * u_2* u_2 ) - rho_mix * x_1 * x_2 * ( u_1 - u_2 ) &
398  * ( s_1 - s_2 ) * t ) * radius**2
399  END IF
400 
401  IF ( verbose_level .GE. 3 ) THEN
402 
403  WRITE(*,*) 'Mixture energy flux'
404  WRITE(*,*) flux(idx_mix_engy_eqn)
405 
406  END IF
407 
408  !----- Dissolved Gas Phases -------------------------------------------------
410  ( x_d_md(1:n_gas)*alfa_1 * &
411  ( rho_1 - sum( beta(1:n_cry) * rho_c(1:n_cry) ) ) * u_1 ) * radius**2
412 
413  IF ( verbose_level .GE. 3 ) THEN
414 
415  WRITE(*,*) 'Dissolved gas mass fraction fluxes'
417 
418  END IF
419 
420  !---- Mass Fraction Exsolved Gas Phases -------------------------------------
421  flux(idx_ex_gas_eqn_first:idx_ex_gas_eqn_last) = alfa_g(1:n_gas) * &
422  rho_g(1:n_gas) * u_2 * radius**2
423 
424  IF ( verbose_level .GE. 3 ) THEN
425 
426  WRITE(*,*) 'Mass fraction exsolved gas'
428 
429  END IF
430 
431  !----- Crystal Phases -------------------------------------------------------
432 
433  IF ( n_mom .LE. 1 ) THEN
434 
435  flux(idx_cry_eqn_first:idx_cry_eqn_last) = alfa_1 * rho_c(1:n_cry) * &
436  beta(1:n_cry) * u_1 * radius**2
437 
438  IF ( verbose_level .GE. 3 ) THEN
439 
440  WRITE(*,*) 'Crystal volume fraction'
441  WRITE(*,*) flux(idx_cry_eqn_first:idx_cry_eqn_last)
442 
443  END IF
444 
445  ELSE
446 
447  DO i=1,n_cry
448 
449  DO j=0,n_mom-1
450 
451  flux(idx_cry_eqn_first+n_mom*(i-1)+j) = alfa_1 * mom_cry(i,j) * &
452  u_1 * radius**2
453 
454  END DO
455 
456  END DO
457 
458  END IF
459 
460  IF ( present(c_qp) .AND. present(c_flux) ) THEN
461 
462  c_flux = flux
463 
464  ELSEIF ( present(r_qp) .AND. present(r_flux) ) THEN
465 
466  r_flux = REAL( flux )
467 
468  END IF
469 
470 
471  END SUBROUTINE eval_fluxes_qp
472 
473  !******************************************************************************
477  !
487  !******************************************************************************
488 
489  SUBROUTINE eval_nonhyperbolic_terms_qp( c_qp , c_nh_term_impl , r_qp , &
490  r_nh_term_impl )
492  USE complexify
493  USE geometry, ONLY : radius
494  IMPLICIT NONE
495 
496  COMPLEX*16, INTENT(IN), OPTIONAL :: c_qp(n_vars)
497  COMPLEX*16, INTENT(OUT), OPTIONAL :: c_nh_term_impl(n_eqns)
498  REAL*8, INTENT(IN), OPTIONAL :: r_qp(n_vars)
499  REAL*8, INTENT(OUT), OPTIONAL :: r_nh_term_impl(n_eqns)
500 
501  COMPLEX*16 :: qp(n_eqns)
502 
503  COMPLEX*16 :: nh_term_impl(n_eqns)
504 
505  COMPLEX*16 :: relaxation_term(n_eqns)
506  COMPLEX*16 :: forces_term(n_eqns)
507  COMPLEX*16 :: source_term(n_eqns)
508 
509  INTEGER :: i
510 
511 
512  IF ( present(c_qp) .AND. present(c_nh_term_impl) ) THEN
513 
514  qp = c_qp
515 
516  ELSEIF ( present(r_qp) .AND. present(r_nh_term_impl) ) THEN
517 
518  DO i = 1,n_eqns
519 
520  qp(i) = dcmplx( r_qp(i) , 0.d0 )
521 
522  END DO
523 
524  ELSE
525 
526  WRITE(*,*) 'Constitutive, eval_fluxes: problem with arguments'
527  stop
528 
529  END IF
530 
531  CALL phys_var_qp( c_qp = qp )
532  CALL eos
533 
534  !--------------- Evaluate the relaxation terms -----------------------------
535  CALL eval_relaxation_terms( relaxation_term )
536 
537  !--------------- Evaluate the forces terms ---------------------------------
538  CALL eval_forces_terms( forces_term )
539 
540  !--------------- Evaluate the forces terms ---------------------------------
541  CALL eval_source_terms( source_term )
542 
543  IF ( verbose_level .GE. 3 ) THEN
544 
545  WRITE(*,*) 'relaxation_term'
546  WRITE(*,*) relaxation_term / ( radius**2 )
547 
548  WRITE(*,*) 'forces_term'
549  WRITE(*,*) forces_term / ( radius **2 )
550 
551  WRITE(*,*) 'source_term'
552  WRITE(*,*) source_term / ( radius **2 )
553 
554  END IF
555 
556  nh_term_impl = relaxation_term + forces_term + source_term
557 
558  IF ( present(c_qp) .AND. present(c_nh_term_impl) ) THEN
559 
560  c_nh_term_impl = nh_term_impl
561 
562  ELSEIF ( present(r_qp) .AND. present(r_nh_term_impl) ) THEN
563 
564  r_nh_term_impl = REAL( nh_term_impl )
565 
566  END IF
567 
568  END SUBROUTINE eval_nonhyperbolic_terms_qp
569 
570  !******************************************************************************
574  !
579  !******************************************************************************
580 
581  SUBROUTINE eval_relaxation_terms( relaxation_term )
583  USE complexify
584  USE geometry, ONLY : radius
585  IMPLICIT none
586 
587  COMPLEX*16, INTENT(OUT) :: relaxation_term(n_eqns)
588 
589  COMPLEX*16 :: pressure_relaxation
590  COMPLEX*16 :: velocity_relaxation
591  !COMPLEX*16 :: frag_relaxation
592 
593  INTEGER :: i , j
594  INTEGER :: idx
595 
596  idx = 0
597 
598  relaxation_term(1:n_eqns) = dcmplx(0.d0,0.d0)
599 
600  ! relaxation term for the mixture density -----------------------------------
601  relaxation_term(idx_mix_mass_eqn) = dcmplx(0.d0,0.d0)
602 
603 
604  ! relaxation term for the volume fraction equation --------------------------
605  CALL press_relax_term( pressure_relaxation )
606  relaxation_term(idx_vol1_eqn) = pressure_relaxation * radius**2
607 
608 
609  ! relaxation term for the mixture momentum ----------------------------------
610  relaxation_term(idx_mix_mom_eqn) = dcmplx(0.d0,0.d0)
611 
612 
613  ! relaxation term for relative velocity -------------------------------------
614  CALL vel_relax_term( velocity_relaxation )
615  relaxation_term(idx_rel_vel_eqn) = velocity_relaxation * radius**2
616 
617  ! relaxation term for the mixture energy ------------------------------------
618  relaxation_term(idx_mix_engy_eqn) = dcmplx(0.d0,0.d0)
619 
620  ! relaxation term for dissolved gas -----------------------------------------
621  CALL f_xdis_eq
622  relaxation_term(idx_dis_gas_eqn_first:idx_dis_gas_eqn_last) = &
623  - ( x_d_md(1:n_gas) - x_d_md_eq(1:n_gas) ) * ( 1.d0 - alfa_2 ) &
624  * ( rho_1 - sum( beta(1:n_cry) * rho_c(1:n_cry) ) ) / tau_d(1:n_gas) &
625  * radius ** 2
626 
627  DO i=1,n_gas
628 
629  IF ( REAL( x_d_md(i) ) .LT. REAL( x_d_md_eq(i) ) ) then
630 
631  relaxation_term(idx_dis_gas_eqn_first+i-1) = dcmplx(0.d0,0.d0)
632 
633  END IF
634 
635  END DO
636 
637  ! relaxation term for exsolved gas ------------------------------------------
638  CALL f_xdis_eq
639 
640  relaxation_term(idx_ex_gas_eqn_first:idx_ex_gas_eqn_last) = &
641  ( x_d_md(1:n_gas) - x_d_md_eq(1:n_gas) ) * ( 1.d0 - alfa_2) &
642  * ( rho_1 - sum( beta(1:n_cry) * rho_c(1:n_cry) ) ) / tau_d(1:n_gas) &
643  * radius **2
644 
645  DO i=1,n_gas
646 
647  IF ( REAL( x_d_md(i) ) .LT. REAL( x_d_md_eq(i) ) ) then
648 
649  relaxation_term(idx_ex_gas_eqn_first+i-1) = dcmplx(0.d0,0.d0)
650 
651  END IF
652 
653  END DO
654 
655  ! relaxation term for crystallization ---------------------------------------
656 
657  IF ( n_mom .LE. 1 ) THEN
658 
659  CALL f_beta_eq
660 
661  relaxation_term(idx_cry_eqn_first:idx_cry_eqn_last) = &
662  - ( 1.d0 - alfa_2 ) * rho_c(1:n_cry) &
663  * ( beta(1:n_cry) - beta_eq(1:n_cry) ) / tau_c(1:n_cry) * radius ** 2
664 
665  ELSE
666 
667  CALL f_growth_rate
668  CALL f_nucleation_rate
669 
670  DO i = 1,n_cry
671 
672  DO j = 0,n_mom-1
673 
674  !relaxation_term(idx_cry_eqn_first+n_mom*(i-1)+j) = &
675  ! function of growth_rate(i) and nucleation_rate(i)
676 
677  END DO
678 
679  END DO
680 
681 
682 
683  END IF
684 
685  END SUBROUTINE eval_relaxation_terms
686 
687  !******************************************************************************
691  !
695  !******************************************************************************
696 
697  SUBROUTINE eval_forces_terms( force_term )
699  USE geometry, ONLY : radius
700  USE complexify
701  IMPLICIT none
702 
703  COMPLEX*16, INTENT(OUT) :: force_term(n_eqns)
704 
705  COMPLEX*16 :: visc_force_1 , visc_force_2
706  COMPLEX*16 :: visc_force_1_rel , visc_force_2_rel
707 
708  REAL*8 :: gas_wall_drag
709 
710  INTEGER :: i
711 
712  INTEGER :: idx
713 
714  idx = 0
715 
716  force_term(1:n_eqns) = dcmplx(0.d0,0.d0)
717 
718  ! Term for the mixture density ----------------------------------------------
719  force_term(idx_mix_mass_eqn) = dcmplx(0.d0,0.d0)
720 
721  ! Term for the first phase volume fraction ----------------------------------
722  force_term(idx_vol1_eqn) = dcmplx(0.d0,0.d0)
723 
724  ! Term for the mixture momentum equation ------------------------------------
725  force_term(idx_mix_mom_eqn) = - rho_mix * grav * radius**2.d0
726 
727  CALL mixture_viscosity
728 
729  visc_force_1 = - 8.d0 * visc_mix * u_1
730 
731  ! Turbulent gas-wall friction (Degruyter et al. 2012)
732 
733  gas_wall_drag = 0.03d0
734 
735  visc_force_2 = - gas_wall_drag / 4.d0 * radius * rho_2 * cdabs( u_2 ) * u_2
736 
737  visc_force_1 = visc_force_1 * ( 1.d0 - frag_eff )
738  visc_force_2 = visc_force_2 * frag_eff
739 
740  !visc_force_1 = visc_force_1 * t
741  !visc_force_2 = visc_force_2 * ( 1.0 - t )
742 
743 
744  force_term(idx_mix_mom_eqn) = force_term(idx_mix_mom_eqn) + visc_force_2 &
745  + visc_force_1
746 
747  ! Term for the relative velocity equation -----------------------------------
748  force_term(idx_rel_vel_eqn) = dcmplx(0.0,0.0)
749 
750  IF ( drag_funct_model .EQ. 'single_velocity' ) THEN
751 
752  force_term(idx_rel_vel_eqn) = dcmplx( 0.d0 , 0.d0 )
753 
754  ELSE
755 
756  visc_force_1_rel = visc_force_1 / ( ( 1.d0 - alfa_2 ) * rho_1 )
757 
758  visc_force_2_rel = - visc_force_2 / ( alfa_2 * rho_2 )
759 
760  force_term(idx_rel_vel_eqn) = force_term(idx_rel_vel_eqn) &
761  + visc_force_2_rel + visc_force_1_rel
762 
763  END IF
764 
765  ! Term for the mixture energy -----------------------------------------------
766  IF ( isothermal ) THEN
767 
768  force_term(idx_mix_engy_eqn) = dcmplx(0.d0,0.d0)
769 
770  ELSE
771 
772  force_term(idx_mix_engy_eqn) = - rho_mix * u_mix * grav * radius**2
773 
774  force_term(idx_mix_engy_eqn) = force_term(idx_mix_engy_eqn) &
775  + 2.d0 * visc_force_2 * u_2 + 2.d0 * visc_force_1 * u_1
776 
777  END IF
778 
779  ! Terms for the exsolved gas phases -----------------------------------------
781 
782  force_term(i) = dcmplx(0.d0,0.d0)
783 
784  END DO
785 
786  ! Terms for the dissolved gas phases ----------------------------------------
788 
789  force_term(i) = dcmplx(0.d0,0.d0)
790 
791  END DO
792 
793  ! Terms for the crystal phases ----------------------------------------------
795 
796  force_term(i) = dcmplx(0.d0,0.d0)
797 
798  END DO
799 
800 
801  END SUBROUTINE eval_forces_terms
802 
803 
804  !******************************************************************************
808  !
815  !******************************************************************************
816 
817  SUBROUTINE eval_source_terms( source_term )
819  USE geometry, ONLY : radius
820  USE complexify
821  IMPLICIT none
822 
823  COMPLEX*16, INTENT(OUT) :: source_term(n_eqns)
824 
825  COMPLEX*16 :: q_lat
826 
827  COMPLEX*16 :: water_mass_flux
828 
829  COMPLEX*16 :: heat_flux
830 
831  INTEGER :: i
832 
833  INTEGER :: idx
834 
835  idx = 0
836 
837  q_lat = dcmplx(0.d0,0.d0)
838 
839  IF ( lateral_degassing ) THEN
840 
842 
843  IF ( p_2 .GE. p_lith ) THEN
844 
845  q_lat = ( rho_2 * alfa_2 * k_cr * ( p_2 - p_lith ) ) / &
846  ( visc_2 * radius )
847 
848  ELSE
849 
850  q_lat = dcmplx(0.d0,0.d0)
851 
852  END IF
853 
854  END IF
855 
856 
857  water_mass_flux = dcmplx(0.d0,0.d0)
858 
859  source_term(1:n_eqns) = dcmplx(0.d0,0.d0)
860 
861  ! --- TOTAL MASS SOURCE TERM ------------------------------------------------
862  IF ( lateral_degassing ) THEN
863 
864  source_term(idx_mix_mass_eqn) = - 2.d0 * q_lat * radius
865 
866  ELSE
867 
868  source_term(idx_mix_mass_eqn) = dcmplx(0.d0,0.d0)
869 
870  END IF
871 
872  IF ( ext_water ) THEN
873 
874  rho_w = 971.80 ! 80C. For shallow aquifers, the effect of P is expected
875  ! to be less important
876 
877  IF ( ( zeta_lith .GT. min_z_influx ) .AND. &
878  ( zeta_lith .LT. min_z_influx + delta_z_influx ) ) THEN
879 
880  IF ( total_water_influx .GT. 0.d0 ) THEN
881 
882  water_mass_flux = dcmplx( total_water_influx/delta_z_influx , 0.d0)
883 
884  ELSE
885 
886  IF ( aquifer_type .EQ. 'unconfined' ) THEN
887 
889 
890  IF ( p_hydro .GE. REAL(p_1) ) then
891 
892  visc_w = 2.414d-5 * 10.d0 ** ( 247.8d0 / ( t_w - 140.d0 ) )
893 
894  water_mass_flux = ( 2.d0 * radius * 3.14d0) * rho_w * k_cr / &
895  visc_w * ( p_hydro - p_1 ) / radius
896 
897  ELSE
898 
899  water_mass_flux = dcmplx( 0.d0 , 0.d0 )
900 
901  END IF
902 
903  ELSEIF ( aquifer_type .EQ. 'confined') THEN
904 
906 
907  IF ( p_lith .GE. REAL(p_1) ) then
908 
909  visc_w = 2.414d-5 * 10.d0 ** ( 247.8d0 / ( t_w - 140.d0 ) )
910 
911  water_mass_flux = ( 2.d0 * radius * 3.14d0) * rho_w * k_cr / &
912  visc_w * ( p_lith - p_1 ) / radius
913 
914  ELSE
915 
916  water_mass_flux = dcmplx( 0.d0 , 0.d0 )
917 
918  END IF
919 
920  END IF
921 
922  END IF
923 
924  ELSE
925 
926  water_mass_flux = dcmplx(0.d0,0.d0)
927 
928  END IF
929 
930  source_term(idx_mix_mass_eqn) = source_term(idx_mix_mass_eqn) &
931  + water_mass_flux
932 
933  END IF
934 
935  ! --- FIRST PHASE VOLUME FRACTION -------------------------------------------
936  source_term(idx_vol1_eqn) = dcmplx(0.d0,0.d0)
937 
938  ! --- Mixture Momentum ------------------------------------------------------
939  IF ( lateral_degassing ) THEN
940 
941  source_term(idx_mix_mom_eqn) = - 2.d0 * q_lat * radius * u_2
942 
943  ELSE
944 
945  source_term(idx_mix_mom_eqn) = dcmplx(0.d0,0.d0)
946 
947  END IF
948 
949  ! --- Relative Velocity -----------------------------------------------------
950  source_term(idx_rel_vel_eqn) = dcmplx(0.d0,0.d0)
951 
952  ! --- MIXTURE ENERGY --------------------------------------------------------
953  IF ( isothermal ) THEN
954 
955  source_term(idx_mix_engy_eqn) = dcmplx(0.d0,0.d0)
956 
957  ELSE
958 
959  IF ( lateral_degassing ) THEN
960 
961  source_term(idx_mix_engy_eqn) = - 2.d0 * q_lat * radius * alfa_2 * &
962  ( t * cv_2 + 0.5d0 * u_2*u_2 )
963 
964  ELSE
965 
966  source_term(idx_mix_engy_eqn) = dcmplx(0.d0,0.d0)
967 
968  END IF
969 
970  IF ( ext_water ) THEN
971 
972  IF ( ( zeta_lith .GT. min_z_influx ) .AND. &
973  ( zeta_lith .LT. min_z_influx + delta_z_influx ) ) THEN
974 
975  IF ( inst_vaporization ) THEN
976 
977  heat_flux = - water_mass_flux * ( cv_d(1) * ( t_boiling-t_w ) &
978  + cv_2 * ( - t_boiling ) + lambda_w )
979 
980  ELSE
981 
982  heat_flux = water_mass_flux * cv_d(1) * t_w
983 
984  END IF
985 
986  source_term(idx_mix_engy_eqn) = source_term(idx_mix_engy_eqn) &
987  + heat_flux
988 
989  END IF
990 
991  END IF
992 
993  END IF
994 
995  ! --- DISSOLVED GAS BULK DENSITY --------------------------------------------
996 
997  ! H2O source due to inlet
998  IF ( ext_water .AND. .NOT.inst_vaporization ) THEN
999 
1000  source_term(idx_dis_gas_eqn_first) = water_mass_flux
1001 
1002  ELSE
1003 
1004  source_term(idx_dis_gas_eqn_first) = dcmplx(0.d0,0.d0)
1005 
1006  END IF
1007 
1008  ! Other gas phases (from 2 to n_gas)
1010 
1011  source_term(i) = dcmplx(0.d0,0.d0)
1012 
1013  END DO
1014 
1015  ! --- EXSOLVED GAS MASS FRACTIONS -------------------------------------------
1016 
1018 
1019  IF ( lateral_degassing ) THEN
1020 
1021  source_term(i) = - 2.d0 * q_lat * radius
1022 
1023  ELSE
1024 
1025  source_term(i) = dcmplx(0.d0,0.d0)
1026 
1027  END IF
1028 
1029  END DO
1030 
1031  ! --- CRYSTALS BULK DENSITY -------------------------------------------------
1032 
1034 
1035  source_term(i) = dcmplx(0.d0,0.d0)
1036 
1037  END DO
1038 
1039  END SUBROUTINE eval_source_terms
1040 
1041 
1042  !******************************************************************************
1046  !
1050  !******************************************************************************
1051 
1052  SUBROUTINE eval_explicit_forces( expl_forces_term )
1054  USE geometry, ONLY : radius
1055 
1056  IMPLICIT NONE
1057 
1058  REAL*8, INTENT(OUT) :: expl_forces_term(n_eqns)
1059 
1060  INTEGER :: i
1061 
1062  INTEGER :: idx
1063 
1064  idx = 0
1065 
1066  expl_forces_term(1:n_eqns) = 0.d0
1067 
1068 
1069  ! --- TOTAL MASS TERM -------------------------------------------------------
1070  expl_forces_term(idx_mix_mass_eqn) = 0.d0
1071 
1072  ! --- FIRST PHASE VOLUME FRACTION -------------------------------------------
1073  expl_forces_term(idx_vol1_eqn) = 0.d0
1074 
1075  ! --- Mixture Momentum ------------------------------------------------------
1076  expl_forces_term(idx_mix_mom_eqn) = dreal( rho_mix * grav * radius ** 2 )
1077 
1078  ! --- Relative Velocity -----------------------------------------------------
1079  expl_forces_term(idx_rel_vel_eqn) = 0.d0
1080 
1081  ! --- MIXTURE ENERGY --------------------------------------------------------
1082  IF ( isothermal ) THEN
1083 
1084  expl_forces_term(idx_mix_engy_eqn) = 0.d0
1085 
1086  ELSE
1087 
1088  expl_forces_term(idx_mix_engy_eqn) = dreal( rho_mix * u_mix * grav * &
1089  radius **2 )
1090 
1091  END IF
1092 
1093  ! --- DISSOLVED GAS BULK DENSITY --------------------------------------------
1095 
1096  expl_forces_term(i) = 0.d0
1097 
1098  END DO
1099 
1100  ! --- EXSOLVED GAS MASS FRACTIONS -------------------------------------------
1102 
1103  expl_forces_term(i) = 0.d0
1104 
1105  END DO
1106 
1107  ! --- CRYSTALS BULK DENSITY ------------------------------------------------
1109 
1110  expl_forces_term(i) = 0.d0
1111 
1112  END DO
1113 
1114  END SUBROUTINE eval_explicit_forces
1115 
1116 
1117 END MODULE equations
1118 
complex *16 u_1
melt-crystals phase local velocity
complex *16 x_md_1
melt+dis.gas mass fraction in phase 1
complex *16 rhob_m
melt bulk density
real *8 visc_w
Water viscosity.
Definition: equations.f90:94
subroutine eval_explicit_forces(expl_forces_term)
Explicit Forces terms.
Definition: equations.f90:1053
logical isothermal
Flag for isothermal runs: .
Definition: equations.f90:33
integer idx_p2
Index of p2 in the qp array.
Definition: parameters.f90:38
Parameters.
Definition: parameters.f90:10
real *8 total_water_influx
Total water influx.
Definition: equations.f90:71
integer idx_cry_eqn_last
Definition: parameters.f90:59
complex *16 s_1
local specific entropy of the melt-crystals phase
real *8 grav
gravitational acceleration
integer idx_ex_gas_eqn_last
Definition: parameters.f90:57
integer idx_mix_mom_eqn
Definition: parameters.f90:51
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
logical ext_water
Flag to activate the injection of external water: .
Definition: equations.f90:57
complex *16, dimension(:), allocatable rho_c
crystals local density
complex *16 theta
Relative viscosity of the crystals.
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
complex *16 rho_m
melt local density
integer n_gas
Numbeer of crystal phases.
Definition: parameters.f90:30
real *8 fixed_temp
Temperature for isothermal runs.
Definition: equations.f90:36
complex *16, dimension(:), allocatable x_c_1
cristal mass fractions in phase 1
real *8 visc_2
gas viscosity
complex *16 alfa_2
total exsolved gas local volume fraction
complex *16 u_2
exsolved gas local velocity
integer idx_ex_gas_eqn_first
Definition: parameters.f90:56
subroutine eval_forces_terms(force_term)
Force terms.
Definition: equations.f90:698
complex *16 rho_mix
mixture local density
complex *16, dimension(:), allocatable beta_eq
equil. cry. volume fraction in the melt-crystals phase
subroutine eval_fluxes_qp(c_qp, r_qp, c_flux, r_flux)
Fluxes.
Definition: equations.f90:293
character *30 aquifer_type
Aquifer type: .
Definition: equations.f90:68
real *8 cv_2
exsolved gas specific heat capacity at constant volume
logical lateral_degassing
Flag for lateral degassing: .
Definition: equations.f90:48
subroutine f_bubbles
Exsolved gas relative viscosity.
subroutine eval_nonhyperbolic_terms_qp(c_qp, c_nh_term_impl, r_qp, r_nh_term_impl)
Non-Hyperbolic terms.
Definition: equations.f90:491
complex *16 p_2
local pressure of the exsolved gas
subroutine eval_qp2(r_qp, qp2)
Conservative to physical variables.
Definition: equations.f90:232
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
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.
complex *16, dimension(:), allocatable x_c
crystals mass fraction (with respect to the mixture)
logical lateral_degassing_flag
Input flag for lateral degassing: .
Definition: equations.f90:42
integer n_cry
Numbeer of crystal phases.
Definition: parameters.f90:29
integer idx_mix_engy_eqn
Definition: parameters.f90:53
real *8 pi
Definition: geometry.f90:25
complex *16 rho_2
exsolved gas local density
complex *16 alfarho_2
bulk density of the exsolved gas
character *20 p_relax_model
pressure relaxation model
real *8, dimension(:), allocatable tau_d
exsolution parameter:
complex *16 t_boiling
Boiling temperature.
Definition: equations.f90:85
complex *16 u_mix
mixture velocity
complex *16 s_2
local specific entropy of the exsolved gas
integer idx_mix_mass_eqn
Definition: parameters.f90:49
complex *16 x_1
melt-crystals phase local mass fraction
real *8 k_cr
country rock permeability
complex *16 alfa_1
dis_gas+melt+crystals phase local volume fraction
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 max_z_influx
Maximum depth of influx.
Definition: equations.f90:79
real *8 radius
Effective radius.
Definition: geometry.f90:27
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.
integer idx_rel_vel_eqn
Definition: parameters.f90:52
Governing equations.
Definition: equations.f90:9
real *8 cv_m
melt specific heat capacity at constant volume
real *8 lambda_w
Latent heat of vaporization.
Definition: equations.f90:88
real *8 zeta_lith
Elevation above the bottom for the evaluation of the lithostatic pressure.
integer idx_beta_first
First index of beta in the qp array.
Definition: parameters.f90:46
subroutine f_nucleation_rate
Lithostatic pressure.
logical inst_vaporization
Flag for instantaneous vaporization: .
Definition: equations.f90:62
complex *16, dimension(:), allocatable rhob_c
crystals bulk density
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
integer idx_dis_gas_eqn_first
Definition: parameters.f90:54
subroutine f_beta_eq
Equilibrium Crystal content.
subroutine eval_relaxation_terms(relaxation_term)
Relaxation terms.
Definition: equations.f90:582
real *8, dimension(:), allocatable cv_g
exsolved gas heat capacity at constant volume
integer idx_xd_first
First index of xd in the qp array.
Definition: parameters.f90:42
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
integer idx_cry_eqn_first
Definition: parameters.f90:58
real *8, dimension(:), allocatable cv_d
dissolved gas heat capacity at constant volume
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
real *8 delta_z_influx
Definition: equations.f90:76
complex *16 e_1
local specific internal energy of the melt-crystals phase
complex *16 cv_mix
mixture specific heat capacity at constant volume
integer idx_vol1_eqn
Definition: parameters.f90:50
real *8, dimension(:), allocatable cv_c
crystals specific heat capacity at constant volume
real *8 p_hydro
Hydrostatic pressure.
real *8 min_z_influx
Minimum depth of influx.
Definition: equations.f90:74
integer idx_dis_gas_eqn_last
Definition: parameters.f90:55
complex *16 x_m
melt mass fraction (with respect to the mixture)
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
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 cv_w
Heat capacity of water.
Definition: equations.f90:91
real *8 t_w
Water temperature in the aquifer.
Definition: equations.f90:82
integer n_vars
Number of conservative variables.
Definition: parameters.f90:32
real *8 rho_w
Water density.
complex *16, dimension(:), allocatable beta
crystal volume fraction in the melt-crystals phase
real *8 alfa2_lat_thr
Exsolved gas volume fraction threshold for lateral degassing.
Definition: equations.f90:52
subroutine eval_source_terms(source_term)
Source terms.
Definition: equations.f90:818
integer verbose_level
Definition: parameters.f90:101
complex *16 x_m_1
melt mass fraction in phase 1
complex *16 x_2
exsolved gas local mass fraction
real *8 p_lith
Lithostatic pressure.
complex *16 mu_1
free Gibbs energy of the melt-crystals phase
complex *16 p_1
local pressure of the melt-crystals phase
subroutine lithostatic_pressure
Lithostatic pressure.
subroutine eval_densities
Phases densities.
subroutine f_xdis_eq
Equilibrium Dissolved gas.
complex *16 visc_rel_bubbles
relative viscosity due to bubbles
complex *16 t
mixture local temperature
subroutine phys_var_qp(r_qp, c_qp)
Physical variables.
Definition: equations.f90:117
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.
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 visc_mix
mixture viscosity
integer n_eqns
Number of equations.
Definition: parameters.f90:33