You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
387 B
Julia
24 lines
387 B
Julia
module AdaptStep
|
|
using LinearAlgebra
|
|
using TypedPolynomials
|
|
|
|
export adapt_step
|
|
|
|
# Adaptive step size
|
|
function adapt_step(H, x, t, step, m)
|
|
Δ = norm([h(variables(H(t))=>x) for h in H(t-step)])
|
|
if Δ > 1e-10
|
|
step = 0.5 * step
|
|
m = 0
|
|
else
|
|
m+=1
|
|
if (m == 4)
|
|
step = 2 * step
|
|
m = 0
|
|
end
|
|
end
|
|
|
|
return (m, step)
|
|
end
|
|
end
|