Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement computed / observed states #13

Merged
merged 4 commits into from
Jan 15, 2025
Merged

Conversation

MasonProtter
Copy link
Collaborator

From the tests:

[...]
function GraphDynamics.subsystem_differential(sys::Subsystem{Oscillator}, F, t)
    (;x, v, x₀, m, k) = sys
    dx = v
    dv = (F - k*(x - x₀))/m
    SubsystemStates{Oscillator}((;x=dx, v=dv))
end
GraphDynamics.computed_properies(::Subsystem{Oscillator}) = (;ω₀ = ((;m, k),) -> (k/m))

[...]

@testset "solutions" begin
    sol = solve_particle_osc(;x1=1.0, x2=-1.0)

    k = GraphDynamics.getp(sol, :osc₊k)(sol)
    m = GraphDynamics.getp(sol, :osc₊m)(sol)
    @test sol[:osc₊ω₀, end] == (k/m)
end

I.e. this lets us access "computed quantities" at the solution level. Don't currently support full observed expressions, only pre-defined symbols for now.

@MasonProtter MasonProtter merged commit c1c25e0 into master Jan 15, 2025
6 checks passed
@MasonProtter MasonProtter deleted the observed_states branch January 15, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant