Skip to content
Merged
Changes from 1 commit
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
17 changes: 15 additions & 2 deletions src/underworld3/systems/ddt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@ def __init__(
smoothing=0.0,
preserve_moments=False,
with_forcing_history: bool = False,
theta: float = 0.5,
):
super().__init__()

Expand All @@ -1185,6 +1186,18 @@ def __init__(
self.order = order
self.preserve_moments = preserve_moments
self.with_forcing_history = with_forcing_history
# Adams-Moulton θ for the implicit flux at order 1.
# The order-1 AM coefficients are ``[θ, 1-θ]``:
# θ=0.5 → Crank-Nicolson (A-stable, 2nd order accuracy on
# flux; NOT L-stable — stiff modes get amplification
# factor → -1, can ring on under-resolved sharp
# gradients in deformed cells)
# θ=1.0 → Backward Euler (L-stable, monotone for diffusion;
# 1st order accuracy on flux)
# Default 0.5 preserves the legacy SLCN behaviour.
# Settable after construction:
# ``adv_diff.DuDt.theta = 1.0``
self.theta = float(theta)

# Forcing-history storage. Allocated only if requested. Populated
# each step via update_forcing_history(forcing_fn) — used by ETD-2
Expand Down Expand Up @@ -1295,7 +1308,7 @@ def __init__(
self._exp_coeffs = _create_exp_coefficients(self.instance_number)
# Initialise to order-1 / viscous values
_update_bdf_values(self._bdf_coeffs, 1, None, [])
_update_am_values(self._am_coeffs, 1, 0.5)
_update_am_values(self._am_coeffs, 1, self.theta)
_update_exp_values(self._exp_coeffs, None, None)

# Working variable that has a potentially different discretisation from psi_star
Expand Down Expand Up @@ -1671,7 +1684,7 @@ def update_pre_solve(

# Update coefficient values for current effective_order and dt
_update_bdf_values(self._bdf_coeffs, self.effective_order, self._dt, self._dt_history)
_update_am_values(self._am_coeffs, self.effective_order, 0.5)
_update_am_values(self._am_coeffs, self.effective_order, self.theta)

## Progress from the oldest part of the history
# 1. Copy the stored values down the chain in preparation for the next timestep
Expand Down
Loading