diff --git a/src/lagrangian_degenerate.jl b/src/lagrangian_degenerate.jl index 0e12cc0..0f556ec 100644 --- a/src/lagrangian_degenerate.jl +++ b/src/lagrangian_degenerate.jl @@ -10,7 +10,7 @@ struct DegenerateLagrangianSystem equations functions - function DegenerateLagrangianSystem(θ, H, t, x, v, params = NamedTuple()) + function DegenerateLagrangianSystem(K, H, t, x, v, params = NamedTuple()) @assert eachindex(x) == eachindex(v) @@ -27,11 +27,10 @@ struct DegenerateLagrangianSystem ẋ = collect(Dt.(x)) - K = θ ⋅ v L = K - H EL = [expand_derivatives(Dx[i](L) - Dt(Dv[i](L))) for i in eachindex(Dx,Dv)] ∇H = [expand_derivatives(dx(H)) for dx in Dx] - ϑ = [expand_derivatives(dv(L)) for dv in Dv] + ϑ = [expand_derivatives(dv(K)) for dv in Dv] f = [expand_derivatives(dx(L)) for dx in Dx] u = [u for u in ẋ] g = [expand_derivatives(Dt.(ϑ))] diff --git a/test/lagrangian_lotka_volterra.jl b/test/lagrangian_lotka_volterra.jl index 49aa95f..1ca1ae6 100644 --- a/test/lagrangian_lotka_volterra.jl +++ b/test/lagrangian_lotka_volterra.jl @@ -3,9 +3,10 @@ using LinearAlgebra using Test -H(t, x, v, params) = params.a₁ * x[1] + params.a₂ * x[2] + params.b₁ * log(x[1]) + params.b₂ * log(x[2]) -L(t, x, v, params) = log(x[2]) / x[1] / 2 * v[1] - log(x[1]) / x[2] / 2 * v[2] - H(t,x,v,params) ϑ(t, x, v, params) = [log(x[2]) / x[1] / 2, - log(x[1]) / x[2] / 2] +H(t, x, v, params) = params.a₁ * x[1] + params.a₂ * x[2] + params.b₁ * log(x[1]) + params.b₂ * log(x[2]) +K(t, x, v, params) = ϑ(t, x, v, params) ⋅ v +L(t, x, v, params) = K(t, x, v, params) - H(t,x,v,params) dHd₁(t, q, params) = params.a₁ + params.b₁ / q[1] dHd₂(t, q, params) = params.a₂ + params.b₂ / q[2] @@ -93,7 +94,7 @@ f̃(ṗ₂, t₀, q₀, v₀, params) # DegenerateLagrangianSystem -deg_lag_sys = DegenerateLagrangianSystem(ϑ(t,x,v,sparams), H(t,x,v,sparams), t, x, v, sparams) +deg_lag_sys = DegenerateLagrangianSystem(K(t,x,v,sparams), H(t,x,v,sparams), t, x, v, sparams) q̇₁, q̇₂ = zero(q₀), zero(q₀) p₁, p₂ = zero(p₀), zero(p₀)