Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ebfm/core/LOOP_SNOW.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from .compute_backend import get_backend, ComputeBackend
from .constants import SECONDS_PER_HOUR
from .LOOP_SNOW_common import _DT_SAFETY_FACTOR
from .LOOP_SNOW_kernels import (
_compaction_kernel,
_heat_conduction_kernel,
Expand Down Expand Up @@ -546,7 +547,7 @@ def heat_conduction(gpu=None):
# Stability time step (CFL condition)
# Layer 0: surface ghost layer, excluded from CFL condition
dt_stab: NDArray[np.float64] = (
0.5
_DT_SAFETY_FACTOR
* np.min(c_eff[:, 1:], axis=1)
* np.min(OUT["subZ"][:, 1:], axis=1) ** 2
/ np.max(kk[:, 1:], axis=1)
Expand Down
5 changes: 5 additions & 0 deletions src/ebfm/core/LOOP_SNOW_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2026 EBFM Authors
#
# SPDX-License-Identifier: BSD-3-Clause

_DT_SAFETY_FACTOR = 0.5
6 changes: 4 additions & 2 deletions src/ebfm/core/LOOP_SNOW_gpu_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

from .compute_backend import cuda

from .LOOP_SNOW_common import _DT_SAFETY_FACTOR

# Threads per block used for all 1-D column-parallel launches.
_TPB = 128

Expand Down Expand Up @@ -509,7 +511,7 @@ def _heat_conduction_prep_kernel_gpu(
# denom_bottom = c_eff[-1] * (0.25*subZ[-2] + 0.75*subZ[-1])
denom_bottom[i] = c_eff[i, nl - 1] * (0.25 * subZ[i, nl - 2] + 0.75 * subZ[i, nl - 1])

# dt_stab = 0.5 * min(c_eff[1:]) * min(subZ[1:])**2 / max(kk[1:]) / dayseconds
# dt_stab = _DT_SAFETY_FACTOR * min(c_eff[1:]) * min(subZ[1:])**2 / max(kk[1:]) / dayseconds
min_ceff = math.inf
min_sz = math.inf
max_kk = 0.0
Expand All @@ -520,7 +522,7 @@ def _heat_conduction_prep_kernel_gpu(
min_sz = subZ[i, k]
if kk[i, k] > max_kk:
max_kk = kk[i, k]
dt_stab[i] = 0.5 * min_ceff * (min_sz * min_sz) / max_kk / dayseconds
dt_stab[i] = _DT_SAFETY_FACTOR * min_ceff * (min_sz * min_sz) / max_kk / dayseconds


@cuda.jit
Expand Down
6 changes: 4 additions & 2 deletions src/ebfm/core/LOOP_SNOW_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from .compute_backend import njit, prange

from .LOOP_SNOW_common import _DT_SAFETY_FACTOR


@njit(parallel=True, cache=True)
def _compaction_kernel(
Expand Down Expand Up @@ -224,7 +226,7 @@ def _heat_conduction_prep_kernel(
# denom_bottom = c_eff[-1] * (0.25*subZ[-2] + 0.75*subZ[-1])
denom_bottom[i] = c_eff[i, nl - 1] * (0.25 * subZ[i, nl - 2] + 0.75 * subZ[i, nl - 1])

# dt_stab = 0.5 * min(c_eff[1:]) * min(subZ[1:])**2 / max(kk[1:]) / dayseconds
# dt_stab = _DT_SAFETY_FACTOR * min(c_eff[1:]) * min(subZ[1:])**2 / max(kk[1:]) / dayseconds
min_ceff = math.inf
min_sz = math.inf
max_kk = 0.0
Expand All @@ -235,7 +237,7 @@ def _heat_conduction_prep_kernel(
min_sz = subZ[i, k]
if kk[i, k] > max_kk:
max_kk = kk[i, k]
dt_stab[i] = 0.5 * min_ceff * (min_sz * min_sz) / max_kk / dayseconds
dt_stab[i] = _DT_SAFETY_FACTOR * min_ceff * (min_sz * min_sz) / max_kk / dayseconds


@njit(parallel=True, cache=True)
Expand Down
Loading