DifferentialEquations.jl -- change in `remake`?

Has there been a change in the remake function recently?

The following code worked one month ago:

prob_rm = remake(prob, u0=[], p=p_modify)
sol = solve(prob_rm, QBDF(), reltol=1e-5,tstops=t_u_switch)

Now, I get an error message:

Mass matrix size is incompatible with initial condition
sizing. The mass matrix must represent the `vec`
form of the initial condition `u0`, i.e.
`size(mm,1) == size(mm,2) == length(u)`

size(prob.f.mass_matrix,1): 6
length(u0): 

What do you want to express by providing an empty initial condition? I mean, that can’t really make sense?

In the past, this has meant “keep default initial states”, and has made sense.

Has that been changed?

It only does if it’s a dictionary. prob_rm = remake(prob, u0=Dict(), p=p_modify) might do it? I’m surprised the first one ever worked.

I probably carried over theremake syntax pre-MTK. Setting u0=[] worked at least until late December 2023 for MTK based models; I think also until early January 2024 (I used the syntax in a notebook for a paper with revised sumbission ca Jan 12 2024.)

Since this is a kwarg, I’d perhaps think the default was an empty dictionary… Will check later

@ChrisRackauckas : Another change in remake…

ModelingToolkit.setp(prob,A)(prob,_A) #prob[A] = _A

Hm. This new syntax looks complex compared to the old one, but there is probably a reason for it.

However, the following does not work:

ModelingToolkit.setp(prob,A)(prob,_A) #prob[A] = _A
ModelingToolkit.setp(prob,m)(prob,_m) #prob[m] = _m

Why? Is this because one cannot have two statements in sequence (unlikely), or because m is a state (while A is a parameter)? Note that prob[m] = _m did work with the deprecated syntax.

You can use the simplified forms if you want, i.e. prob.ps[m] = _m.

The reason is because the previous form could never be type stable or fast, so people were bypassing the system with homebrewed solutions that were type-stable. So we changed the core syntax to something that is allowed to be optimal, with some syntactic sugar for simplifications that lose performance.

2 Likes

Would that work with states, too (like in the past), or does .ps mean ParameterS?

It means parameters. prob[x] = _x works for states, and is optimal because it’s now type-stable.

1 Like