Skip to content

Cannot initialize tspan from defaults or initialization equations #3359

Open
@hersle

Description

@hersle

It would be very nice of one could initialize t from an unknown, observed or parameter in the initialization system, just like one can already do for other variables:

using ModelingToolkit, Test
using ModelingToolkit: t_nounits as t, D_nounits as D
@variables x(t)
@named sys = ODESystem([D(x) ~ 0.0], t; defaults = [t => 1/x])
sys = structural_simplify(sys)

prob = ODEProblem(sys, [x => 2.0], (NaN, 1.0), [])
@test solve(prob).t[begin]  0.5

prob2 = remake(prob; u0 = [x => 4.0])
@test solve(prob2).t[begin]  0.25

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions