Hi, I am using DifferentialEquations.jl and want to implement my own `internalnorm`

function with specific weights for the purpose of timestep adaptation. I would appreciate some extra information about how the function is used as “Required are two dispatches: one dispatch for the state variable and the other on the elements of the state variable (scalar norm)” creates more questions than answers.

I think I quite correctly assume that the two signatures of the function should be along the lines of `custom_norm(u::AbstractArray, t)`

and `custom_norm(u::Number, t)`

but I’m not quite sure when they are called. I am almost certain the first is called while adapting the timestep (as mentioned here) but I am unsure about the second. Also there might be other times when they are called I am oblivious to.

This isn’t a really well-defined or a simple question because when talking over 200 methods, yes there are more than a few ways it’s used. But it’s for initialization of dt, time step adaptivity, sometimes stiffness detection, instability checking, convergence checking in nonlinear solvers, consistent initialization checking in DAEs, etc.

Your answer makes me think I should come up with a better solution for saving and interpolating additional values (by-products) after the fact, than adding them to the state vector. I know it is a hacky solution but “dense” output is in my eyes such a brilliant idea and ComponentArrays.jl also makes the implementation convenient.

a SavingCallback sounds like what you want.

AFAIK SavingCallback saves values only at the end of each step. Dense output on the other hand uses individual stages of each step and therefore interpolates using much finer data (for example in the case of Tsit5).

That’s what ModelingToolkit’s system effectively does.