Skip to content

Commit a25acd2

Browse files
arciyer123Krishnan Iyer
authored andcommitted
implement fixes and expand to cover more cases of double precision
1 parent ad50852 commit a25acd2

29 files changed

+285
-285
lines changed

src/common/m_constants.fpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ module m_constants
88

99
character, parameter :: dflt_char = ' ' !< Default string value
1010

11-
real(wp), parameter :: dflt_real = -1d6 !< Default real value
12-
real(wp), parameter :: sgm_eps = 1e-16 !< Segmentation tolerance
13-
real(wp), parameter :: small_alf = 1e-11 !< Small alf tolerance
11+
real(wp), parameter :: dflt_real = -1e6_wp !< Default real value
12+
real(wp), parameter :: sgm_eps = 1e-16_wp !< Segmentation tolerance
13+
real(wp), parameter :: small_alf = 1e-11_wp !< Small alf tolerance
1414
real(wp), parameter :: pi = 3.141592653589793_wp !< Pi
15-
real(wp), parameter :: verysmall = 1.e-12 !< Very small number
15+
real(wp), parameter :: verysmall = 1.e-12_wp !< Very small number
1616

1717
integer, parameter :: num_stcls_min = 5 !< Minimum # of stencils
1818
integer, parameter :: path_len = 400 !< Maximum path length
@@ -24,7 +24,7 @@ module m_constants
2424
integer, parameter :: num_patches_max = 10
2525
integer, parameter :: pathlen_max = 400
2626
integer, parameter :: nnode = 4 !< Number of QBMM nodes
27-
real(wp), parameter :: capillary_cutoff = 1e-6 !< color function gradient magnitude at which to apply the surface tension fluxes
27+
real(wp), parameter :: capillary_cutoff = 1e-6_wp !< color function gradient magnitude at which to apply the surface tension fluxes
2828
real(wp), parameter :: acoustic_spatial_support_width = 2.5_wp !< Spatial support width of acoustic source, used in s_source_spatial
2929
real(wp), parameter :: dflt_vcfl_dt = 100._wp !< value of vcfl_dt when viscosity is off for computing adaptive timestep size
3030

src/common/m_helper.fpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ contains
153153
if (thermal == 2) gamma_m = 1._wp
154154

155155
temp = 293.15_wp
156-
D_m = 0.242e-4
156+
D_m = 0.242e-4_wp
157157
uu = sqrt(pl0/rhol0)
158158

159159
omega_ref = 3._wp*k_poly*Ca + 2._wp*(3._wp*k_poly - 1._wp)/Web
@@ -260,17 +260,17 @@ contains
260260
real(wp), dimension(nb) :: phi
261261

262262
! nondiml. min. & max. initial radii for numerical quadrature
263-
!sd = 0.05D0
264-
!R0mn = 0.75D0
265-
!R0mx = 1.3D0
263+
!sd = 0.05e0_wp
264+
!R0mn = 0.75e0_wp
265+
!R0mx = 1.3e0_wp
266266

267-
!sd = 0.3D0
268-
!R0mn = 0.3D0
269-
!R0mx = 6.D0
267+
!sd = 0.3e0_wp
268+
!R0mn = 0.3e0_wp
269+
!R0mx = 6.e0_wp
270270

271-
!sd = 0.7D0
272-
!R0mn = 0.12D0
273-
!R0mx = 150.D0
271+
!sd = 0.7e0_wp
272+
!R0mn = 0.12e0_wp
273+
!R0mx = 150.e0_wp
274274

275275
sd = poly_sigma
276276
R0mn = 0.8_wp*exp(-2.8_wp*sd)

src/common/m_helper_basic.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module m_helper_basic
2222
!> This procedure checks if two floating point numbers of wp are within tolerance.
2323
!! @param a First number.
2424
!! @param b Second number.
25-
!! @param tol_input Relative error (default = 1e-6).
25+
!! @param tol_input Relative error (default = 1e-6_wp).
2626
!! @return Result of the comparison.
2727
logical function f_approx_equal(a, b, tol_input) result(res)
2828
!$acc routine seq
@@ -35,7 +35,7 @@ logical function f_approx_equal(a, b, tol_input) result(res)
3535
if (present(tol_input)) then
3636
tol = tol_input
3737
else
38-
tol = 1e-6
38+
tol = 1e-6_wp
3939
end if
4040

4141
if (a == b) then

src/common/m_phase_change.fpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ module m_phase_change
5151

5252
!> @name Parameters for the first order transition phase change
5353
!> @{
54-
integer, parameter :: max_iter = 1e8 !< max # of iterations
55-
real(wp), parameter :: pCr = 4.94d7 !< Critical water pressure
54+
integer, parameter :: max_iter = 1e8_wp !< max # of iterations
55+
real(wp), parameter :: pCr = 4.94e7_wp !< Critical water pressure
5656
real(wp), parameter :: TCr = 385.05 + 273.15 !< Critical water temperature
57-
real(wp), parameter :: mixM = 1.0e-8 !< threshold for 'mixture cell'. If Y < mixM, phase change does not happen
57+
real(wp), parameter :: mixM = 1.0e-8_wp !< threshold for 'mixture cell'. If Y < mixM, phase change does not happen
5858
integer, parameter :: lp = 1 !< index for the liquid phase of the reacting fluid
5959
integer, parameter :: vp = 2 !< index for the vapor phase of the reacting fluid
6060
!> @}
@@ -148,7 +148,7 @@ contains
148148
!$acc loop seq
149149
do i = momxb, momxe
150150

151-
dynE = dynE + 5.0e-1*q_cons_vf(i)%sf(j, k, l)**2/rho
151+
dynE = dynE + 5.0e-1_wp*q_cons_vf(i)%sf(j, k, l)**2/rho
152152

153153
end do
154154

@@ -352,12 +352,12 @@ contains
352352
353353
! Maybe improve this condition afterwards. As long as the initial guess is in between -min(ps_inf)
354354
! and infinity, a solution should be able to be found.
355-
pS = 1.0d4
355+
pS = 1.0e4_wp
356356
357357
! Newton Solver for the pT-equilibrium
358358
ns = 0
359-
! change this relative error metric. 1E4 is just arbitrary
360-
do while ((abs(pS - pO) > palpha_eps) .and. (abs((pS - pO)/pO) > palpha_eps/1e4) .or. (ns == 0))
359+
! change this relative error metric. 1e4_wp is just arbitrary
360+
do while ((abs(pS - pO) > palpha_eps) .and. (abs((pS - pO)/pO) > palpha_eps/1e4_wp) .or. (ns == 0))
361361
362362
! increasing counter
363363
ns = ns + 1
@@ -425,17 +425,17 @@ contains
425425
ns = 0
426426

427427
! Relaxation factor
428-
Om = 1.0e-3
428+
Om = 1.0e-3_wp
429429

430430
p_infpTg = p_infpT
431431

432432
if (((pS < 0.0_wp) .and. ((q_cons_vf(lp + contxb - 1)%sf(j, k, l) &
433433
+ q_cons_vf(vp + contxb - 1)%sf(j, k, l)) > ((rhoe &
434434
- gs_min(lp)*ps_inf(lp)/(gs_min(lp) - 1))/qvs(lp)))) .or. &
435-
((pS >= 0.0_wp) .and. (pS < 1.0e-1))) then
435+
((pS >= 0.0_wp) .and. (pS < 1.0e-1_wp))) then
436436

437437
! improve this initial condition
438-
pS = 1.0d4
438+
pS = 1.0e4_wp
439439

440440
end if
441441

@@ -447,7 +447,7 @@ contains
447447
R2D(1) = 0.0_wp; R2D(2) = 0.0_wp
448448
DeltamP(1) = 0.0_wp; DeltamP(2) = 0.0_wp
449449
do while (((sqrt(R2D(1)**2 + R2D(2)**2) > ptgalpha_eps) &
450-
.and. ((sqrt(R2D(1)**2 + R2D(2)**2)/rhoe) > (ptgalpha_eps/1d6))) &
450+
.and. ((sqrt(R2D(1)**2 + R2D(2)**2)/rhoe) > (ptgalpha_eps/1e6_wp))) &
451451
.or. (ns == 0))
452452

453453
! Updating counter for the iterative procedure
@@ -754,7 +754,7 @@ contains
754754
ns = 0
755755

756756
! underrelaxation factor
757-
Om = 1.0e-3
757+
Om = 1.0e-3_wp
758758
do while ((abs(FT) > ptgalpha_eps) .or. (ns == 0))
759759
! increasing counter
760760
ns = ns + 1

src/common/m_precision_select.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module m_precision_select
1414
integer, parameter :: double_precision = selected_real_kind(15, 307)
1515

1616
! Set the working precision (wp) to single or double precision
17-
integer, parameter :: wp = single_precision ! Change this to single_precision if needed
17+
integer, parameter :: wp = double_precision ! Change this to single_precision if needed
1818

1919
#ifdef MFC_MPI
2020
! Declare mpi_p as a module variable

src/common/m_variables_conversion.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ contains
189189
Y_rs(i) = rhoYks(i)/rho
190190
end do
191191

192-
if (sum(Y_rs) > 1e-16) then
192+
if (sum(Y_rs) > 1e-16_wp) then
193193
call get_temperature(.true., energy - dyn_p, 1200._wp, Y_rs, T)
194194
call get_pressure(rho, T, Y_rs, pres)
195195
else
@@ -295,7 +295,7 @@ contains
295295
alpha_K(i) = min(max(0._wp, alpha_K(i)), 1._wp)
296296
end do
297297

298-
alpha_K = alpha_K/max(sum(alpha_K), 1e-16)
298+
alpha_K = alpha_K/max(sum(alpha_K), 1e-16_wp)
299299

300300
end if
301301

@@ -420,7 +420,7 @@ contains
420420
alpha_K(i) = min(max(0._wp, alpha_K(i)), 1._wp)
421421
end do
422422

423-
alpha_K = alpha_K/max(sum(alpha_K), 1e-16)
423+
alpha_K = alpha_K/max(sum(alpha_K), 1e-16_wp)
424424

425425
end if
426426

@@ -987,7 +987,7 @@ contains
987987
if (model_eqns /= 4) then
988988
qK_prim_vf(i)%sf(j, k, l) = qK_cons_vf(i)%sf(j, k, l) &
989989
/rho_K
990-
dyn_pres_K = dyn_pres_K + 5e-1*qK_cons_vf(i)%sf(j, k, l) &
990+
dyn_pres_K = dyn_pres_K + 5e-1_wp*qK_cons_vf(i)%sf(j, k, l) &
991991
*qK_prim_vf(i)%sf(j, k, l)
992992
else
993993
qK_prim_vf(i)%sf(j, k, l) = qK_cons_vf(i)%sf(j, k, l) &
@@ -1349,7 +1349,7 @@ contains
13491349

13501350
! Computing the energy from the pressure
13511351
E_K = gamma_K*pres_K + pi_inf_K &
1352-
+ 5e-1*rho_K*vel_K_sum + qv_K
1352+
+ 5e-1_wp*rho_K*vel_K_sum + qv_K
13531353

13541354
! mass flux, this should be \alpha_i \rho_i u_i
13551355
!$acc loop seq
@@ -1468,7 +1468,7 @@ contains
14681468
(rho*(1._wp - adv(num_fluids)))
14691469
end if
14701470
else
1471-
c = ((H - 5e-1*vel_sum)/gamma)
1471+
c = ((H - 5e-1_wp*vel_sum)/gamma)
14721472
end if
14731473

14741474
if (mixture_err .and. c < 0._wp) then

src/post_process/m_derived_variables.fpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ contains
212212
end if
213213

214214
if (mixture_err .and. q_sf(i, j, k) < 0._wp) then
215-
q_sf(i, j, k) = 1e-16
215+
q_sf(i, j, k) = 1e-16_wp
216216
else
217217
q_sf(i, j, k) = sqrt(q_sf(i, j, k))
218218
end if
@@ -285,8 +285,8 @@ contains
285285
end if
286286
end if
287287

288-
if (abs(top) < 1e-8) top = 0._wp
289-
if (abs(bottom) < 1e-8) bottom = 0._wp
288+
if (abs(top) < 1e-8_wp) top = 0._wp
289+
if (abs(bottom) < 1e-8_wp) bottom = 0._wp
290290

291291
if (top == bottom) then
292292
slope = 1._wp
@@ -295,20 +295,20 @@ contains
295295
! (bottom == 0._wp .AND. top /= 0._wp)) THEN
296296
! slope = 0._wp
297297
else
298-
slope = (top*bottom)/(bottom**2._wp + 1e-16)
298+
slope = (top*bottom)/(bottom**2._wp + 1e-16_wp)
299299
end if
300300

301301
! Flux limiter function
302302
if (flux_lim == 1) then ! MINMOD (MM)
303303
q_sf(j, k, l) = max(0._wp, min(1._wp, slope))
304304
elseif (flux_lim == 2) then ! MUSCL (MC)
305-
q_sf(j, k, l) = max(0._wp, min(2._wp*slope, 5e-1*(1._wp + slope), 2._wp))
305+
q_sf(j, k, l) = max(0._wp, min(2._wp*slope, 5e-1_wp*(1._wp + slope), 2._wp))
306306
elseif (flux_lim == 3) then ! OSPRE (OP)
307-
q_sf(j, k, l) = (15e-1*(slope**2._wp + slope))/(slope**2._wp + slope + 1._wp)
307+
q_sf(j, k, l) = (15e-1_wp*(slope**2._wp + slope))/(slope**2._wp + slope + 1._wp)
308308
elseif (flux_lim == 4) then ! SUPERBEE (SB)
309309
q_sf(j, k, l) = max(0._wp, min(1._wp, 2._wp*slope), min(slope, 2._wp))
310310
elseif (flux_lim == 5) then ! SWEBY (SW) (beta = 1.5)
311-
q_sf(j, k, l) = max(0._wp, min(15e-1*slope, 1._wp), min(slope, 15e-1))
311+
q_sf(j, k, l) = max(0._wp, min(15e-1_wp*slope, 1._wp), min(slope, 15e-1_wp))
312312
elseif (flux_lim == 6) then ! VAN ALBADA (VA)
313313
q_sf(j, k, l) = (slope**2._wp + slope)/(slope**2._wp + 1._wp)
314314
elseif (flux_lim == 7) then ! VAN LEER (VL)

src/pre_process/include/2dHardcodedIC.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
real(wp) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, alph
77

8-
eps = 1e-9
8+
eps = 1e-9_wp
99

1010
#:enddef
1111

@@ -71,7 +71,7 @@
7171
case (204) ! Rayleigh-Taylor instability
7272
rhoH = 3
7373
rhoL = 1
74-
pRef = 1e5
74+
pRef = 1e5_wp
7575
pInt = pRef
7676
h = 0.7
7777
lam = 0.2
@@ -80,7 +80,7 @@
8080

8181
intH = amp*sin(2*pi*x_cc(i)/lam - pi/2) + h
8282

83-
alph = 5e-1*(1 + tanh((y_cc(j) - intH)/2.5e-3))
83+
alph = 5e-1_wp*(1 + tanh((y_cc(j) - intH)/2.5e-3_wp))
8484

8585
if (alph < eps) alph = eps
8686
if (alph > 1 - eps) alph = 1 - eps

src/pre_process/include/3dHardcodedIC.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
real(wp) :: eps
77

8-
eps = 1e-9
8+
eps = 1e-9_wp
99
#:enddef
1010

1111
#:def Hardcoded3D()
@@ -14,7 +14,7 @@
1414
case (300) ! Rayleigh-Taylor instability
1515
rhoH = 3
1616
rhoL = 1
17-
pRef = 1e5
17+
pRef = 1e5_wp
1818
pInt = pRef
1919
h = 0.7
2020
lam = 0.2
@@ -23,7 +23,7 @@
2323

2424
intH = amp*(sin(2*pi*x_cc(i)/lam - pi/2) + sin(2*pi*z_cc(k)/lam - pi/2)) + h
2525

26-
alph = 5e-1*(1 + tanh((y_cc(j) - intH)/2.5e-3))
26+
alph = 5e-1_wp*(1 + tanh((y_cc(j) - intH)/2.5e-3_wp))
2727

2828
if (alph < eps) alph = eps
2929
if (alph > 1 - eps) alph = 1 - eps

src/pre_process/m_assign_variables.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ contains
197197
#:endif
198198
199199
! Updating the patch identities bookkeeping variable
200-
if (1._wp - eta < 1e-16) patch_id_fp(j, k, l) = patch_id
200+
if (1._wp - eta < 1e-16_wp) patch_id_fp(j, k, l) = patch_id
201201
202202
end subroutine s_assign_patch_mixture_primitive_variables
203203
@@ -216,7 +216,7 @@ contains
216216
real(wp) :: R3bar, n0, ratio, nH, vfH, velH, rhoH, deno
217217
218218
p0 = 101325
219-
pres_mag = 1e-1
219+
pres_mag = 1e-1_wp
220220
loc = x_cc(177)
221221
n_tait = fluid_pp(1)%gamma
222222
B_tait = fluid_pp(1)%pi_inf
@@ -669,7 +669,7 @@ contains
669669
end if
670670
671671
! Updating the patch identities bookkeeping variable
672-
if (1._wp - eta < 1e-16) patch_id_fp(j, k, l) = patch_id
672+
if (1._wp - eta < 1e-16_wp) patch_id_fp(j, k, l) = patch_id
673673
674674
end subroutine s_assign_patch_species_primitive_variables
675675

0 commit comments

Comments
 (0)