AshFlow  0.1
ashflowmodel
 All Classes Files Functions Variables Pages
solver_flow.f90
Go to the documentation of this file.
1 !********************************************************************************
8 !********************************************************************************
9 
11  USE particles_module, ONLY: iclass
12  USE current_module
13  USE mixture_module
14  USE envi_module, ONLY: p, t_a, gi, gas_constair, c_vair
15 
16  !
17  IMPLICIT NONE
18  !
19  ! ... Right-Hand Side (rhs) and Known Term (f) of the equation system
20  !
21  REAL*8, ALLOCATABLE, DIMENSION(:) :: rhstemp
22  REAL*8, ALLOCATABLE, DIMENSION(:) :: rhs
23  REAL*8, ALLOCATABLE, DIMENSION(:) :: ftemp
24  REAL*8, ALLOCATABLE, DIMENSION(:) :: f
25  REAL*8, ALLOCATABLE, DIMENSION(:) :: f_stepold
26  REAL*8, ALLOCATABLE, DIMENSION(:) :: f_oldold
27 
28  REAL*8, ALLOCATABLE, DIMENSION(:) :: f_new
29  REAL*8, ALLOCATABLE, DIMENSION(:) :: f_RK
30  REAL*8, ALLOCATABLE, DIMENSION(:,:) :: rhs_RK
31  REAL*8, ALLOCATABLE, DIMENSION(:) :: rhs4
32  REAL*8, ALLOCATABLE, DIMENSION(:) :: f_err
33 
34  REAL*8 :: eps_rel , eps_abs
35 
36  INTEGER :: itotal
37 
38  INTEGER :: n_RK
39 
40  REAL*8 :: dh_dr
41  REAL*8 :: dbeta_dr
42  REAL*8 :: dr
43  REAL*8 :: dr0
44  REAL*8 :: dr_old
45  !
46  LOGICAL :: vel_equation
47 
48  SAVE
49 
50 CONTAINS
51 
52  !******************************************************************************
59  !******************************************************************************
60 
61  SUBROUTINE allocate_matrix
62 
63  IMPLICIT NONE
64 
65  itotal = iclass + 5
66 
67  n_rk = 6
68 
69  ALLOCATE(rhstemp(itotal))
70  ALLOCATE(rhs(itotal))
71  ALLOCATE(ftemp(itotal))
72  ALLOCATE(f(itotal))
73  ALLOCATE(f_stepold(itotal))
74 
75  ALLOCATE(f_new(itotal))
76  ALLOCATE(f_rk(itotal))
77  ALLOCATE(rhs_rk(n_rk,itotal))
78  ALLOCATE(rhs4(itotal))
79  ALLOCATE(f_err(itotal))
80 
81  f = 0.d0
82  ftemp = 0.d0
83  rhs = 0.d0
84  rhstemp = 0.d0
85 
86  RETURN
87  END SUBROUTINE allocate_matrix
88 
89  !*****************************************************************************
97  !*****************************************************************************
98 
99  SUBROUTINE rate(rhs_)
100 
101  ! External variables
102  USE envi_module, ONLY: alpha, theta, fric
103  USE particles_module, ONLY: rhosol , diam, solidmassflux_fract, v_s, s, &
104  sumsed, fracsolid, c_d
105 
106  IMPLICIT NONE
107 
108  REAL*8, DIMENSION(:), INTENT(OUT) :: rhs_
109 
110  REAL*8 :: var , coeff_radial
111 
112  REAL*8 :: term1 , term2
113 
114  REAL*8 :: rhs_2a , rhs_2b
115 
116 
117  LOGICAL :: no_entr , const_volume_flux
118 
119  INTEGER :: i
120 
121  IF ( oned_model ) THEN
122 
123  var = 1.d0
124 
125  ELSE
126 
127  var = r
128 
129  END IF
130 
131  solid_mass_flux = (beta * u * h * var) * ( 1.d0 - n )
132  ! provides the mass_flux of a particle of a given size
133  solidmassflux_fract(1:iclass) = solid_mass_flux*fracsolid(1:iclass)
134 
135  ! SEDIMENTATION for the particle fraction
136  v_s(1:iclass) = dsqrt( (rhosol(1:iclass) * gi * diam(1:iclass)) / &
137  (c_d(1:iclass) * beta) )
138 
139  s(1:iclass) = 1.d0 / (h * u) * solidmassflux_fract(1:iclass) * v_s(1:iclass)
140 
141  sumsed = sum(s(1:iclass)) ! sum of sedimentation across all particles sizes
142 
143  !---- Mass conservation of the mixture (Eq.1 Bursik & Woods 1996)
144 
145  entrainment_rate = epsilon * alpha * u * var
146  rhs_(1) = entrainment_rate - sumsed
147 
148  !---- Momentum Conservation (Eq.4 Bursik & Woods 1996)
149 
150  IF ( r_new .NE. r_old ) THEN
151 
152  dbeta_dr = (beta_new - beta_old) / (r_new - r_old)
153  dh_dr = (h_new - h_old) / (r_new - r_old)
154 
155  ELSE
156 
157  dbeta_dr = 0.d0
158  dh_dr = 0.d0
159 
160  END IF
161 
162  coeff_radial = ( var - 1.d0 ) / ( r - 1.d0 )
163 
164  no_entr = .false.
165 
166  const_volume_flux = .false.
167 
168  IF ( no_entr ) THEN
169 
170  term1 = 0.d0
171 
172  ELSE
173 
174  term1 = - u * epsilon * alpha / ( h * beta )
175 
176  END IF
177 
178  IF ( const_volume_flux ) THEN
179 
180  term2 = 0.d0
181 
182  ELSE
183 
184  term2 = - ( epsilon * alpha * u * var - sumsed ) / ( beta * h * var ) * &
185  dcos(theta) + u / beta * dcos(theta) * dbeta_dr
186 
187  END IF
188 
189  ! RHS term for the modified momentum equation
190  rhs_2a = ( term1 + ri * ( term2 + coeff_radial * u / var * dcos(theta) + &
191  u / h * dsin(theta) - u / ( 2.d0 * ( beta - alpha ) ) * dcos(theta) * &
192  dbeta_dr ) - fric * u / h ) / ( 1.d0 - ri * cos(theta) )
193 
194  ! RHS term for the original equation
195  rhs_2b = - epsilon * alpha * u / ( beta * h ) + ri * u / h * ( - dh_dr &
196  * dcos(theta) + dsin(theta) ) - ri * u / ( 2.d0 * ( beta - alpha )) &
197  * dcos(theta) * dbeta_dr - fric * u / h
198 
199  IF ( vel_equation ) THEN
200 
201  rhs_(2) = rhs_2a
202 
203  ELSE
204 
205  rhs_(2) = rhs_2b
206 
207  END IF
208 
209  !---- Thermal Energy Conservation (Eq.5 Bursik & Woods 1996)
210 
211  rhs_(3) = epsilon * alpha * u * var * (c_vair * t_a + p/alpha) - sumsed * &
212  c_s * t
213 
214  !---- Mass average specific heat
215  rhs_(4) = ((c_vair - c_vmix) / beta * epsilon * alpha * u * var + (c_s - &
216  c_vmix) / beta * (-sumsed))/ (u * h * var)
217 
218  !---- Gas constant of mixture
219  rhs_(5) = (gas_constair - gas_constmix) / (beta * n * u * h * var ) * &
220  epsilon * alpha * u * var
221 
222  DO i=1, iclass
223 
224  rhs_(5+i) = -s(i)
225 
226  ENDDO
227 
228  RETURN
229  END SUBROUTINE rate
230 
231 
232  !*****************************************************************************
239  !*****************************************************************************
240 
241  SUBROUTINE lump(f_)
242 
243  ! External variables
244  USE envi_module, ONLY: p
245  USE mixture_module, ONLY: c_vmix, cpwvapour
246  USE particles_module, ONLY: fracsolid, iclass
247 
248  IMPLICIT NONE
249  REAL*8, DIMENSION(:), INTENT(OUT) :: f_
250  INTEGER :: i
251  REAL*8 :: var
252 
253  CALL compute_mixture
254  !
255 
256  IF ( oned_model ) THEN
257 
258  var = 1.d0
259 
260  ELSE
261 
262  var = r
263 
264  END IF
265 
266 
267  f_(1) = beta * u * h * var
268 
269  f_(2) = u
270  f_(3) = beta * u * h * var * (c_vmix * t + p/beta + 0.5 * u**2)
271  f_(4) = c_vmix
272  f_(5) = gas_constmix
273 
274  DO i=1, iclass
275 
276  f_(5+i) = (beta * u * h * var) * (1-n) * fracsolid(i)
277 
278  ENDDO
279 
280  RETURN
281  END SUBROUTINE lump
282 
283  !******************************************************************************
285  !
294  !*****************************************************************************
295 
296  SUBROUTINE marching(fold,fnew,rat,delta_r)
297 
298  IMPLICIT NONE
299  REAL*8, DIMENSION(:), INTENT(IN) :: fold, rat
300  REAL*8, INTENT(IN) :: delta_r
301  REAL*8, DIMENSION(:), INTENT(OUT) :: fnew
302  INTEGER :: i
303 
304  DO i=1,itotal
305 
306  fnew(i) = fold(i) + rat(i) * delta_r
307 
308  END DO
309 
310  RETURN
311 
312  END SUBROUTINE marching
313 
314  !*****************************************************************************
322  !*****************************************************************************
323 
324  SUBROUTINE unlump(f_)
325 
326  ! External varuables
327  USE envi_module, ONLY: alpha , p
328  USE mixture_module, ONLY: rhosol_ave
329  USE particles_module, ONLY: iclass, fracsolid, rhosol
330 
331  IMPLICIT NONE
332 
333  REAL*8, DIMENSION(:), INTENT(IN) :: f_
334 
335  REAL*8 :: c1 , c2 , c3 , c4
336 
337  REAL*8 :: var
338 
339  IF ( oned_model ) THEN
340 
341  var = 1.d0
342 
343  ELSE
344 
345  var = r
346 
347  END IF
348 
349  u = f_(2)
350  n = 1.d0 - sum(f_(5+1:5+iclass))/f_(1)
351  c_vmix = f_(4)
352  gas_constmix = f_(5)
353  fracsolid(1:iclass) = (f_(5+1:5+iclass))/sum(f_(5+1:5+iclass))
354 
355  rhosol_ave = 1.d0 / (sum(fracsolid/rhosol))
356 
357  c1 = ( 1.d0 - n ) / rhosol_ave
358  c2 = n * gas_constmix / p
359  c3 = ( f_(3)/f_(1) - 0.5d0 * u**2 ) / c_vmix
360  c4 = - p / c_vmix
361 
362  beta = ( 1.d0 - c2*c4 ) / ( c2*c3 + c1 )
363  t = c4 / beta + c3
364 
365  h = f_(1) / (beta * u * var)
366 
367  ri = ((beta - alpha) * gi * h) / (beta * u**2.d0)
368  epsilon = 0.075d0 / dsqrt(1.d0 + (718.d0 * ri**2.4d0))
369 
370  RETURN
371 
372  END SUBROUTINE unlump
373 
374 END MODULE solver_module
375 
subroutine rate(rhs_)
Right hand side equations This subroutine contains the right-hand side of the equations that are comp...
Definition: solver_flow.f90:99
subroutine marching(fold, fnew, rat, delta_r)
Marching r one step.
Current module This module contains descriptors for the initial conditions of the flow...
Definition: current.f90:7
Mixture module This module contains all the variables required for describing and calculating the cha...
Definition: mixture.f90:10
subroutine compute_mixture
Computing conditions within mixture This subroutine calculates the characteristics of the mixture by ...
Definition: mixture.f90:102
Solver Module This module contains the differential equations that are solved at each iteration...
Definition: solver_flow.f90:10
subroutine unlump(f_)
Unlumping variable Lumped variables defined in subroutine 'lump' are unlumped to calculate physical v...
subroutine allocate_matrix
Allocate matrix This subroutine defines the matrix over which each of the conditions are solved...
Definition: solver_flow.f90:61
subroutine lump(f_)
Lump variables Variables are grouped together to calculate the lumped variables.
Particles module This module contains the procedures and the variables related to the solid particles...
Definition: particles.f90:6
environment module This module contains all the variables related to the background environmental con...
Definition: environment.f90:8