Ferrite.jl icon indicating copy to clipboard operation
Ferrite.jl copied to clipboard

Having to send a time into the function for constraints is a design failure.

Open KristofferC opened this issue 7 years ago • 8 comments

This should just be handled by sending in a closure f(x) = f(x, t, ...).

KristofferC avatar May 08 '18 08:05 KristofferC

So t should be a global variable then?

fredrikekre avatar May 08 '18 08:05 fredrikekre

No, t can be a local variable and you send in the closure x -> f(x, t). Just like always when you need to pass parameters.

KristofferC avatar May 08 '18 08:05 KristofferC

But we give the function only once, when creating the condition.

fredrikekre avatar May 08 '18 08:05 fredrikekre

Yeah but you can change t afterward. Perhaps that's what you meant.

KristofferC avatar May 08 '18 08:05 KristofferC

TIL

fredrikekre avatar May 08 '18 08:05 fredrikekre

Another proposal: Let user define f(x, args...; kwargs...) -> value and then call update!(ch, args...; kwargs...) as appropriate. update! would then splice in the x as f(x, args...; kwargs...).

fredrikekre avatar May 14 '18 12:05 fredrikekre

Maybe a NamedTuple is appropriate? User defines f(x, nt) -> value and call update!(ch, nt).

fredrikekre avatar Sep 05 '18 09:09 fredrikekre

Maybe, but I wonder if not just propagating args...; kwargs... (like you have in the PR I think) is easier in that case.

KristofferC avatar Sep 05 '18 13:09 KristofferC