Skip to content

Commit

Permalink
Rename the error-scale function
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkraemer committed Oct 25, 2024
1 parent 0ac1b79 commit 74a76ef
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions probdiffeq/ivpsolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ def body_fn(state: _RejectionState) -> _RejectionState:
state_control = self.control.clip(state.control, t=state.step_from.t, t1=t1)

# Perform the actual step.
# todo: error estimate should be a tuple (abs, rel)
error_estimate, state_proposed = self.solver.step(
state=state.step_from,
vector_field=vector_field,
Expand All @@ -209,7 +208,7 @@ def body_fn(state: _RejectionState) -> _RejectionState:
u_proposed = self.ssm.stats.qoi(state_proposed.strategy.hidden)[0]
u_step_from = self.ssm.stats.qoi(state_proposed.strategy.hidden)[0]
u = np.maximum(np.abs(u_proposed), np.abs(u_step_from))
error_power = _normalise_error(error_estimate, u=u)
error_power = _error_scale_and_normalize(error_estimate, u=u)

# Propose a new step
state_control = self.control.apply(state_control, error_power=error_power)
Expand All @@ -220,7 +219,7 @@ def body_fn(state: _RejectionState) -> _RejectionState:
step_from=state.step_from,
)

def _normalise_error(error_estimate, *, u):
def _error_scale_and_normalize(error_estimate, *, u):
error_relative = error_estimate / (self.atol + self.rtol * np.abs(u))
dim = np.atleast_1d(u).size
error_norm = linalg.vector_norm(error_relative, order=self.norm_ord)
Expand Down

0 comments on commit 74a76ef

Please sign in to comment.