Skip to content

Public API

This page lists exported symbols of CTFlows.Systems.


From CTFlows.Systems

CTFlows.Systems [Module]

CTFlows.Systems Module
julia
Systems

System types and contracts for CTFlows.

This module defines the AbstractSystem type and its required methods:

  • get_ip_rhs: returns the in-place right-hand side function for integration

  • get_oop_rhs: returns the out-of-place right-hand side function for integration

  • get_ip_rhs_augmented: returns the augmented in-place right-hand side for Hamiltonian systems

  • dimensions: returns dimensional information (state, costate, control, variable)

AbstractHVFRHS [Abstract Type]

CTFlows.Systems.AbstractHVFRHS Type
julia
AbstractHVFRHS{T<:Traits.AbstractMutabilityTrait} <: AbstractRHS{T}

Abstract base type for HamiltonianVectorField RHS functors.

Provides a common supertype for all Hamiltonian vector field functors, enabling generic display methods that access the .hvf field.

Type Parameters

  • T <: Traits.AbstractMutabilityTrait: The mutability trait (InPlace or OutOfPlace).

AbstractHamRHS [Abstract Type]

CTFlows.Systems.AbstractHamRHS Type
julia
abstract type AbstractHamRHS{T<:CTBase.Traits.AbstractMutabilityTrait} <: CTFlows.Systems.AbstractRHS{T<:CTBase.Traits.AbstractMutabilityTrait}

Abstract supertype for Hamiltonian right-hand side (RHS) functors.

RHS functors compute the derivatives for Hamiltonian systems according to Hamilton's equations. The type parameter encodes the mutability trait (in-place vs out-of-place) for compile-time dispatch.

Type Parameters

  • T <: AbstractMutabilityTrait: Mutability trait (InPlace or OutOfPlace).

Interface Requirements

All subtypes must implement a callable interface:

  • In-place: (f::SubType)(du, u, λ, t) for mutating output

  • Out-of-place: (f::SubType)(u, λ, t) -> du for allocating output

Notes

See also: CTFlows.Systems.AbstractRHS, CTFlows.Systems.HamIpRHS, CTFlows.Systems.HamOoPRHS.

AbstractHamiltonianSystem [Abstract Type]

CTFlows.Systems.AbstractHamiltonianSystem Type
julia
abstract type AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Alias for Hamiltonian systems.

Matches any AbstractSystem with HamiltonianDynamics as the dynamics parameter. The AD capability is encoded as a plain trait (ad_trait) on the concrete type, not as a type parameter of this alias.

Type Parameters

  • TD <: TimeDependence: Time dependence trait (Autonomous or NonAutonomous)

  • VD <: VariableDependence: Variable dependence trait (Fixed or NonFixed)

Example

julia
julia> using CTFlows.Systems

julia> HamiltonianSystem <: Systems.AbstractHamiltonianSystem
true

See also: CTFlows.Systems.AbstractSystem, CTFlows.Systems.AbstractStateSystem.

AbstractIPHVFRHS [Abstract Type]

CTFlows.Systems.AbstractIPHVFRHS Type
julia
AbstractIPHVFRHS <: AbstractHVFRHS{Traits.InPlace}

Abstract base type for in-place HamiltonianVectorField RHS functors.

AbstractIPHamRHS [Abstract Type]

CTFlows.Systems.AbstractIPHamRHS Type
julia
abstract type AbstractIPHamRHS <: CTFlows.Systems.AbstractHamRHS{CTBase.Traits.InPlace}

Abstract supertype for in-place Hamiltonian RHS functors.

Subtypes of this abstract type implement in-place computation of Hamiltonian derivatives, mutating the output vector du rather than allocating a new one.

Notes

See also: CTFlows.Systems.AbstractHamRHS, CTFlows.Systems.AbstractOoPHamRHS.

AbstractIPPseudoHamRHS [Abstract Type]

CTFlows.Systems.AbstractIPPseudoHamRHS Type
julia
abstract type AbstractIPPseudoHamRHS <: CTFlows.Systems.AbstractPseudoHamRHS{CTBase.Traits.InPlace}

Abstract supertype for in-place pseudo-Hamiltonian RHS functors.

See also: CTFlows.Systems.AbstractPseudoHamRHS.

AbstractIPRHS [Abstract Type]

CTFlows.Systems.AbstractIPRHS Type
julia
AbstractIPRHS <: AbstractRHS{Traits.InPlace}

Abstract supertype for in-place RHS functors.

These functors have the signature (du, u, λ, t) -> nothing and modify du in place.

AbstractOoPHVFRHS [Abstract Type]

CTFlows.Systems.AbstractOoPHVFRHS Type
julia
AbstractOoPHVFRHS <: AbstractHVFRHS{Traits.OutOfPlace}

Abstract base type for out-of-place HamiltonianVectorField RHS functors.

AbstractOoPHamRHS [Abstract Type]

CTFlows.Systems.AbstractOoPHamRHS Type
julia
abstract type AbstractOoPHamRHS <: CTFlows.Systems.AbstractHamRHS{CTBase.Traits.OutOfPlace}

Abstract supertype for out-of-place Hamiltonian RHS functors.

Subtypes of this abstract type implement out-of-place computation of Hamiltonian derivatives, allocating and returning a new output vector.

Notes

See also: CTFlows.Systems.AbstractHamRHS, CTFlows.Systems.AbstractIPHamRHS.

AbstractOoPPseudoHamRHS [Abstract Type]

CTFlows.Systems.AbstractOoPPseudoHamRHS Type
julia
abstract type AbstractOoPPseudoHamRHS <: CTFlows.Systems.AbstractPseudoHamRHS{CTBase.Traits.OutOfPlace}

Abstract supertype for out-of-place pseudo-Hamiltonian RHS functors.

See also: CTFlows.Systems.AbstractPseudoHamRHS.

AbstractOoPRHS [Abstract Type]

CTFlows.Systems.AbstractOoPRHS Type
julia
AbstractOoPRHS <: AbstractRHS{Traits.OutOfPlace}

Abstract supertype for out-of-place RHS functors.

These functors have the signature (u, λ, t) -> du and return a new array without modifying the input.

AbstractPseudoHamRHS [Abstract Type]

CTFlows.Systems.AbstractPseudoHamRHS Type
julia
abstract type AbstractPseudoHamRHS{T<:CTBase.Traits.AbstractMutabilityTrait} <: CTFlows.Systems.AbstractRHS{T<:CTBase.Traits.AbstractMutabilityTrait}

Abstract supertype for pseudo-Hamiltonian right-hand side (RHS) functors. The type parameter encodes the mutability trait (in-place vs out-of-place).

See also: CTFlows.Systems.AbstractRHS, CTFlows.Systems.PseudoHamIpRHS.

AbstractRHS [Abstract Type]

CTFlows.Systems.AbstractRHS Type
julia
AbstractRHS{T<:Traits.AbstractMutabilityTrait}

Abstract supertype for all RHS functors.

Parameterized by the interface mutability trait:

  • Traits.InPlace: in-place interface (du, u, λ, t) -> nothing

  • Traits.OutOfPlace: out-of-place interface (u, λ, t) -> du

AbstractStateSystem [Abstract Type]

CTFlows.Systems.AbstractStateSystem Type
julia
abstract type AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics}

Alias for state systems (non-Hamiltonian).

Matches any AbstractSystem with StateDynamics as the dynamics parameter.

Type Parameters

  • TD <: TimeDependence: Time dependence trait (Autonomous or NonAutonomous)

  • VD <: VariableDependence: Variable dependence trait (Fixed or NonFixed)

Example

julia
julia> using CTFlows.Systems

julia> VectorFieldSystem <: Systems.AbstractStateSystem
true

See also: CTFlows.Systems.AbstractSystem, CTFlows.Systems.AbstractHamiltonianSystem.

AbstractSystem [Abstract Type]

CTFlows.Systems.AbstractSystem Type
julia
abstract type AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}

Abstract type for all systems in CTFlows.

An AbstractSystem represents a fully assembled object that can be integrated. It embeds its own right-hand side, dimensional metadata, and solution-building logic.

Contract

All subtypes must implement:

  • get_ip_rhs(system::AbstractSystem, config): Returns a function (du, u, p, t) -> nothing that fills du in place.

  • get_oop_rhs(system::AbstractSystem, config): Returns a function (u, p, t) -> du that returns the derivative.

Hamiltonian systems supporting variable-costate integration additionally implement get_ip_rhs_augmented(system::AbstractHamiltonianSystem, config).

Example

julia
using CTFlows.Systems

# Define a concrete system
struct MySystem <: Systems.AbstractSystem{Traits.Autonomous, Traits.Fixed, Traits.StateDynamics}
    data::Vector{Float64}
end

# Implement required contract methods
function Systems.get_ip_rhs(sys::MySystem, config)
    return (du, u, p, t) -> du .= sys.data .* u
end

function Systems.get_oop_rhs(sys::MySystem, config)
    return (u, p, t) -> sys.data .* u
end

See also: CTFlows.Systems.get_ip_rhs, CTFlows.Systems.get_oop_rhs, CTFlows.Systems.get_ip_rhs_augmented, CTBase.Traits.time_dependence, CTBase.Traits.variable_dependence.

ConstrainedPseudoHamIpAugRHS [Struct]

CTFlows.Systems.ConstrainedPseudoHamIpAugRHS Type
julia
struct ConstrainedPseudoHamIpAugRHS{PH<:CTBase.Data.PseudoHamiltonian, L<:CTBase.Data.ControlLaw, G, M, B<:CTBase.Differentiation.AbstractADBackend, CX<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}, CP<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}} <: CTFlows.Systems.AbstractIPPseudoHamRHS

In-place augmented RHS functor for a CTFlows.Systems.ConstrainedPseudoHamiltonianSystem with variable costate. Extends CTFlows.Systems.ConstrainedPseudoHamIpRHS with ṗv = -∂/∂v[H̃ + μ_·g] (control and multiplier frozen), computed by CTBase.Differentiation.pseudo_variable_gradient. The augmented state is [x; p; pv]; the ṗv block picks up −μ_ᵀ ∂g/∂v at frozen μ.

Fields

  • h̃::PH: base pseudo-Hamiltonian H̃(t, x, p, u, v).

  • law::L: dynamic closed-loop control law u(t, x, p, v).

  • g::G: path constraint g(t, x, u, v).

  • μ::M: multiplier μ(t, x, p, v).

  • backend::B: the AD backend.

  • n_x::Int: state dimension.

  • n_v::Int: variable dimension.

  • cx::CX: state coercion.

  • cp::CP: costate coercion.

See also: CTFlows.Systems.ConstrainedPseudoHamIpRHS, CTFlows.Systems.PseudoHamIpAugRHS.

ConstrainedPseudoHamIpRHS [Struct]

CTFlows.Systems.ConstrainedPseudoHamIpRHS Type
julia
struct ConstrainedPseudoHamIpRHS{PH<:CTBase.Data.PseudoHamiltonian, L<:CTBase.Data.ControlLaw, G, M, B<:CTBase.Differentiation.AbstractADBackend, CX<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}, CP<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}} <: CTFlows.Systems.AbstractIPPseudoHamRHS

In-place RHS functor for a CTFlows.Systems.ConstrainedPseudoHamiltonianSystem. Evaluates the feedback control u_ = law(t, x, p, v) and the multiplier value μ_ = μ(t, x, p, v), then computes, at that fixed (u_, μ_),

julia
=/∂p [ H̃ + μ_·g ]
= -/∂x [ H̃ + μ_·g ]

with g differentiated and μ_ frozen (constrained :partial mode).

Fields

  • h̃::PH: base pseudo-Hamiltonian H̃(t, x, p, u, v).

  • law::L: dynamic closed-loop control law u(t, x, p, v).

  • g::G: path constraint g(t, x, u, v).

  • μ::M: multiplier μ(t, x, p, v).

  • backend::B: the AD backend.

  • N::Int: state dimension.

  • cx::CX: state coercion.

  • cp::CP: costate coercion.

See also: CTFlows.Systems.ConstrainedPseudoHamOoPRHS, CTFlows.Systems.ConstrainedPseudoHamIpAugRHS, CTFlows.Systems.PseudoHamIpRHS.

ConstrainedPseudoHamOoPRHS [Struct]

CTFlows.Systems.ConstrainedPseudoHamOoPRHS Type
julia
struct ConstrainedPseudoHamOoPRHS{PH<:CTBase.Data.PseudoHamiltonian, L<:CTBase.Data.ControlLaw, G, M, B<:CTBase.Differentiation.AbstractADBackend, CX<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}, CP<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}} <: CTFlows.Systems.AbstractOoPPseudoHamRHS

Out-of-place RHS functor for a CTFlows.Systems.ConstrainedPseudoHamiltonianSystem; see CTFlows.Systems.ConstrainedPseudoHamIpRHS for the computation. Returns vcat(∂p, -∂x).

Fields

  • h̃::PH: base pseudo-Hamiltonian H̃(t, x, p, u, v).

  • law::L: dynamic closed-loop control law u(t, x, p, v).

  • g::G: path constraint g(t, x, u, v).

  • μ::M: multiplier μ(t, x, p, v).

  • backend::B: the AD backend.

  • N::Int: state dimension.

  • cx::CX: state coercion.

  • cp::CP: costate coercion.

See also: CTFlows.Systems.ConstrainedPseudoHamIpRHS.

ConstrainedPseudoHamiltonianSystem [Struct]

CTFlows.Systems.ConstrainedPseudoHamiltonianSystem Type
julia
struct ConstrainedPseudoHamiltonianSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, PH<:(CTBase.Data.PseudoHamiltonian{<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}), L<:(CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}), G, M, BACKEND<:CTBase.Differentiation.AbstractADBackend} <: CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Concrete AbstractHamiltonianSystem built from a pseudo-Hamiltonian H̃(t,x,p,u,v), a dynamic closed-loop control law u(t,x,p,v), a path constraint g(t,x,u,v) and a multiplier μ(t,x,p,v). It integrates the Hamiltonian system of the constrained pseudo-Hamiltonian H̃ + μ·g

julia
=/∂p [H̃ + μ·g] ,   ṗ = -/∂x [H̃ + μ·g]

with both the control u = u(t,x,p,v) and the multiplier value μ = μ(t,x,p,v) held fixed during differentiation (the constrained :partial mode): g is differentiated in (x,p,v), μ is not. This is the counterpart of CTFlows.Systems.PseudoHamiltonianSystem for constrained flows; the constrained :total mode instead bakes μ as a function and composes with the law (see CTFlows.Flows.ConstrainedPseudoHamiltonianFunction).

Type Parameters

  • TD <: TimeDependence, VD <: VariableDependence: traits of the pseudo-Hamiltonian.

  • PH <: PseudoHamiltonian: concrete pseudo-Hamiltonian type.

  • L <: ControlLaw: concrete control-law type (DynClosedLoopFeedback).

  • G: concrete path-constraint type.

  • M: concrete multiplier type.

  • BACKEND <: AbstractADBackend: concrete AD backend type.

Fields

  • h̃::PH: the (base) pseudo-Hamiltonian.

  • law::L: the dynamic closed-loop control law.

  • g::G: the path constraint g(t,x,u,v).

  • μ::M: the multiplier μ(t,x,p,v).

  • backend::BACKEND: the AD backend.

See also: CTFlows.Systems.PseudoHamiltonianSystem, CTFlows.Systems.FrozenConstrainedPseudoHamiltonian, CTBase.Data.PathConstraint, CTBase.Data.Multiplier.

FrozenConstrainedPseudoHamiltonian [Struct]

CTFlows.Systems.FrozenConstrainedPseudoHamiltonian Type
julia
struct FrozenConstrainedPseudoHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, PH, G, T} <: CTBase.Data.AbstractPseudoHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Constrained pseudo-Hamiltonian carrying a frozen multiplier value, used to compute the constrained :partial-mode gradients. Represents

julia
H̃c(t, x, p, u, v) =(t, x, p, u, v) + μ_ · g(t, x, u, v)

where μ_ is a numeric value (already evaluated at the current point), so automatic differentiation through this functor differentiates and g but treats μ_ as a constant — the constrained :partial semantics (μ frozen alongside u, g differentiated). It subtypes CTBase.Data.AbstractPseudoHamiltonian so it is accepted by CTBase.Differentiation.pseudo_hamiltonian_gradient and CTBase.Differentiation.pseudo_variable_gradient, which call it only through the uniform (t, x, p, u, v) signature.

Type Parameters

  • TD, VD: time- and variable-dependence traits, inherited from the base .

  • PH: type of the base pseudo-Hamiltonian .

  • G: type of the path constraint g.

  • T: type of the frozen multiplier value μ_.

Fields

  • h̃::PH: base pseudo-Hamiltonian, uniform call H̃(t, x, p, u, v).

  • g::G: path constraint, uniform call g(t, x, u, v).

  • μ_::T: frozen multiplier value (scalar or vector), captured as a constant.

See also: CTFlows.Systems.ConstrainedPseudoHamiltonianSystem, CTFlows.Systems.ConstrainedPseudoHamIpRHS.

HamiltonianGradient [Struct]

CTFlows.Systems.HamiltonianGradient Type
julia
struct HamiltonianGradient{H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}

Functor returning the gradient (∂H/∂x, ∂H/∂p) of a true Hamiltonian, evaluated as (t, x, p, v). For a Hamiltonian composed with a control law, the gradient is the total derivative (differentiated through the law). The tuple is non-negated.

Fields

  • h::H: the Hamiltonian to differentiate.

  • backend::B: the AD backend.

See also: CTFlows.Systems.hamiltonian_gradient, CTFlows.Systems.HamiltonianVariableGradient.

HamiltonianSystem [Struct]

CTFlows.Systems.HamiltonianSystem Type
julia
struct HamiltonianSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, H<:CTBase.Data.AbstractHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}, BACKEND<:CTBase.Differentiation.AbstractADBackend} <: CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Concrete AbstractHamiltonianSystem wrapping a scalar Hamiltonian function with an AD backend.

The system does not store pre-computed RHS closures. Instead, closures are built lazily by build_rhs and build_oop_rhs based on the actual initial condition types, ensuring correct handling of scalar, vector (including length-1), and matrix inputs with consistent output shapes.

Type Parameters

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

  • H <: AbstractHamiltonian{TD, VD}: concrete Hamiltonian type. Any CTBase.Data.AbstractHamiltonian is accepted, including a CTBase.Data.ComposedHamiltonian (a pseudo-Hamiltonian composed with a control law), so the AD path differentiates through the control law.

  • BACKEND <: AbstractADBackend: concrete AD backend type.

Fields

  • h::H: the underlying scalar Hamiltonian function.

  • backend::BACKEND: the AD backend for gradient computation.

Example

julia
julia> using CTFlows.Systems, CTBase.Data

julia> h = Hamiltonian((t, x, p, v) -> 0.5 * sum(x.^2) + sum(p.^2); autonomous=true, variable=false)
Hamiltonian{var"#1", Autonomous, Fixed}

julia> sys = HamiltonianSystem(h, AutoForwardDiff())
HamiltonianSystem
  time_dependence: Autonomous
  variable_dependence: Fixed
  hamiltonian: Hamiltonian{var"#1", Autonomous, Fixed}
  backend: AutoForwardDiff()

See also: CTBase.Data.Hamiltonian, CTFlows.Systems.AbstractHamiltonianSystem, CTBase.Traits.AbstractADTrait, build_rhs, build_oop_rhs.

HamiltonianVariableGradient [Struct]

CTFlows.Systems.HamiltonianVariableGradient Type
julia
struct HamiltonianVariableGradient{H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}

Functor returning the variable gradient ∂H/∂v of a true Hamiltonian, evaluated as (t, x, p, v) — the quantity (before negation) that drives the augmented variable-costate equation ṗv = -∂H/∂v. Non-negated.

Fields

  • h::H: the Hamiltonian to differentiate.

  • backend::B: the AD backend.

See also: CTFlows.Systems.variable_gradient, CTFlows.Systems.HamiltonianGradient.

HamiltonianVectorFieldSystem [Struct]

CTFlows.Systems.HamiltonianVectorFieldSystem Type
julia
struct HamiltonianVectorFieldSystem{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait} <: CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Concrete AbstractHamiltonianSystem wrapping a HamiltonianVectorField.

The system does not store pre-computed RHS closures. Instead, closures are built lazily by build_rhs and build_oop_rhs based on the actual initial condition types, ensuring correct handling of scalar, vector (including length-1), and matrix inputs with consistent output shapes.

Type Parameters

  • F: concrete type of the wrapped HamiltonianVectorField function.

  • TD <: TimeDependence: Autonomous or NonAutonomous.

  • VD <: VariableDependence: Fixed or NonFixed.

  • MD <: AbstractMutabilityTrait: InPlace or OutOfPlace.

Fields

  • hvf::HamiltonianVectorField{F, TD, VD, MD}: the underlying Hamiltonian vector field.

Example

julia
julia> using CTFlows.Systems

julia> hvf = HamiltonianVectorField((x, p) -> (x, -p); autonomous=true, variable=false)
HamiltonianVectorField
  time_dependence: Autonomous
  variable_dependence: Fixed
  mutability: OutOfPlace
  function: var"#1"

julia> sys = HamiltonianVectorFieldSystem(hvf)
HamiltonianVectorFieldSystem
  time_dependence: Autonomous
  variable_dependence: Fixed
  mutability: OutOfPlace
  hamiltonian_vector_field: HamiltonianVectorField{var"#1", Autonomous, Fixed, OutOfPlace}

See also: CTBase.Data.HamiltonianVectorField, CTFlows.Systems.AbstractHamiltonianSystem, TimeDependence, CTBase.Traits.VariableDependence, build_rhs, build_oop_rhs.

ODEParameters [Struct]

CTFlows.Systems.ODEParameters Type
julia
struct ODEParameters{V}

Wrapper type for parameters passed through SciML's p slot.

This type formalizes the contract for what transits in the ODE problem's parameter slot. For CTFlows, the primary content is the variable parameter for NonFixed systems (or nothing for Fixed systems).

The wrapper makes the contract explicit and extensible — additional fields can be added later (callbacks, extra data) without breaking existing code.

Fields

  • variable::V: The variable parameter (or nothing for Fixed systems).

Constructor Validation

  • V can be Nothing (for Fixed systems) or any concrete type (for NonFixed).

  • No validation is performed at construction — the system's VariableDependence determines whether variable should be used.

Example

julia
using CTFlows.Systems

# Fixed system: variable is nothing
params_fixed = ODEParameters(nothing)

# NonFixed system: variable is a value
params_nonfixed = ODEParameters(0.5)

# NonFixed system: variable is a vector
params_vector = ODEParameters([1.0, 2.0])

Notes

  • This type is used exclusively by the SciML extension to wrap the variable before passing it to ODEProblem.

  • The RHS functor reads variable(p) to access the actual variable value.

See also: CTBase.Traits.VariableDependence, CTBase.Traits.Fixed, CTBase.Traits.NonFixed.

PseudoHamIpAugRHS [Struct]

CTFlows.Systems.PseudoHamIpAugRHS Type
julia
struct PseudoHamIpAugRHS{PH<:CTBase.Data.PseudoHamiltonian, L<:CTBase.Data.ControlLaw, B<:CTBase.Differentiation.AbstractADBackend, CX<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}, CP<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}} <: CTFlows.Systems.AbstractIPPseudoHamRHS

In-place augmented RHS functor for a PseudoHamiltonianSystem with variable costate. Extends CTFlows.Systems.PseudoHamIpRHS with ṗv = -∂H̃/∂v (control fixed), computed by CTBase.Differentiation.pseudo_variable_gradient. The augmented state is [x; p; pv].

Fields

  • h̃::PH: the pseudo-Hamiltonian H̃(t, x, p, u, v).

  • law::L: the dynamic closed-loop control law u(t, x, p, v).

  • backend::B: the AD backend.

  • n_x::Int: state dimension.

  • n_v::Int: variable dimension.

  • cx::CX: state coercion.

  • cp::CP: costate coercion.

See also: CTFlows.Systems.PseudoHamIpRHS, CTFlows.Systems.HamIpAugRHS.

PseudoHamIpRHS [Struct]

CTFlows.Systems.PseudoHamIpRHS Type
julia
struct PseudoHamIpRHS{PH<:CTBase.Data.PseudoHamiltonian, L<:CTBase.Data.ControlLaw, B<:CTBase.Differentiation.AbstractADBackend, CX<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}, CP<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}} <: CTFlows.Systems.AbstractIPPseudoHamRHS

In-place RHS functor for a PseudoHamiltonianSystem. Evaluates the feedback control u = law(t, x, p, v) and then computes, at that fixed u,

julia
=  ∂H̃/∂p
= -∂H̃/∂x

Fields

  • h̃::PH: the pseudo-Hamiltonian H̃(t, x, p, u, v).

  • law::L: the dynamic closed-loop control law u(t, x, p, v).

  • backend::B: the AD backend.

  • N::Int: state dimension.

  • cx::CX: state coercion.

  • cp::CP: costate coercion.

See also: CTFlows.Systems.PseudoHamOoPRHS, CTFlows.Systems.PseudoHamIpAugRHS.

PseudoHamOoPRHS [Struct]

CTFlows.Systems.PseudoHamOoPRHS Type
julia
struct PseudoHamOoPRHS{PH<:CTBase.Data.PseudoHamiltonian, L<:CTBase.Data.ControlLaw, B<:CTBase.Differentiation.AbstractADBackend, CX<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}, CP<:Union{typeof(identity), typeof(CTFlows.Systems._safe_only)}} <: CTFlows.Systems.AbstractOoPPseudoHamRHS

Out-of-place RHS functor for a PseudoHamiltonianSystem; see CTFlows.Systems.PseudoHamIpRHS for the computation. Returns vcat(∂p, -∂x).

Fields

  • h̃::PH: the pseudo-Hamiltonian H̃(t, x, p, u, v).

  • law::L: the dynamic closed-loop control law u(t, x, p, v).

  • backend::B: the AD backend.

  • N::Int: state dimension.

  • cx::CX: state coercion.

  • cp::CP: costate coercion.

See also: CTFlows.Systems.PseudoHamIpRHS.

PseudoHamiltonianGradient [Struct]

CTFlows.Systems.PseudoHamiltonianGradient Type
julia
struct PseudoHamiltonianGradient{H<:CTBase.Data.AbstractPseudoHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}

Functor returning the gradient (∂H̃/∂x, ∂H̃/∂p) of a pseudo-Hamiltonian, evaluated as (t, x, p, u, v) at fixed control u. Non-negated.

Fields

  • h̃::H: the pseudo-Hamiltonian to differentiate.

  • backend::B: the AD backend.

See also: CTFlows.Systems.pseudo_hamiltonian_gradient, CTFlows.Systems.PseudoHamiltonianVariableGradient.

PseudoHamiltonianSystem [Struct]

CTFlows.Systems.PseudoHamiltonianSystem Type
julia
struct PseudoHamiltonianSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, PH<:(CTBase.Data.PseudoHamiltonian{<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}), L<:(CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}), BACKEND<:CTBase.Differentiation.AbstractADBackend} <: CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Concrete AbstractHamiltonianSystem built from a pseudo-Hamiltonian H̃(t,x,p,u,v) and a dynamic closed-loop control law u(t,x,p,v). It integrates the Hamiltonian system

julia
=  ∂H̃/∂p ,   ṗ = -∂H̃/∂x

with the control held fixed at the feedback value u = u(t,x,p,v) during differentiation (the :partial mode). This coincides with the true Hamiltonian flow of CTBase.Data.ComposedHamiltonian only where the feedback is stationary (∂H̃/∂u = 0).

Type Parameters

  • TD <: TimeDependence, VD <: VariableDependence: traits of the pseudo-Hamiltonian.

  • PH <: PseudoHamiltonian: concrete pseudo-Hamiltonian type.

  • L <: ControlLaw: concrete control-law type (DynClosedLoopFeedback).

  • BACKEND <: AbstractADBackend: concrete AD backend type.

Fields

  • h̃::PH: the pseudo-Hamiltonian.

  • law::L: the dynamic closed-loop control law.

  • backend::BACKEND: the AD backend.

See also: CTFlows.Systems.HamiltonianSystem, CTBase.Data.PseudoHamiltonian, CTBase.Data.ComposedHamiltonian.

PseudoHamiltonianVariableGradient [Struct]

CTFlows.Systems.PseudoHamiltonianVariableGradient Type
julia
struct PseudoHamiltonianVariableGradient{H<:CTBase.Data.AbstractPseudoHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}

Functor returning the variable gradient ∂H̃/∂v of a pseudo-Hamiltonian, evaluated as (t, x, p, u, v) at fixed control u. Non-negated.

Fields

  • h̃::H: the pseudo-Hamiltonian to differentiate.

  • backend::B: the AD backend.

See also: CTFlows.Systems.pseudo_variable_gradient, CTFlows.Systems.PseudoHamiltonianGradient.

VectorFieldSystem [Struct]

CTFlows.Systems.VectorFieldSystem Type
julia
struct VectorFieldSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait, F<:CTBase.Data.AbstractVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, MD<:CTBase.Traits.AbstractMutabilityTrait}, RHS<:CTFlows.Systems.AbstractIPRHS, OOPROHS<:CTFlows.Systems.AbstractOoPRHS, FINRHS} <: CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics}

Concrete AbstractSystem wrapping an CTBase.Data.AbstractVectorField. The variable for NonFixed vector fields is not stored here; it is passed at flow-call time via the variable kwarg and threaded through ODEProblem's p slot wrapped in a Systems.ODEParameters struct.

Fields

  • vf::F: the underlying vector field (any Data.AbstractVectorField{TD,VD,MD}).

  • rhs::RHS: the pre-computed in-place right-hand side closure with signature (du, u, p, t) -> nothing.

  • rhs_oop::OOPROHS: the pre-computed out-of-place right-hand side closure with signature (u, p, t) -> du.

  • rhs_oop_finalize::FINRHS: the finalize closure for in-place vector fields with immutable initial conditions, or nothing for out-of-place vector fields.

Example

julia
julia> using CTFlows.Systems

julia> vf = VectorField(x -> -x; autonomous=true, variable=false)
VectorField
  time_dependence: Autonomous
  variable_dependence: Fixed
  mutability: OutOfPlace
  function: var"#1"

julia> sys = VectorFieldSystem(vf)
VectorFieldSystem
  time_dependence: Autonomous
  variable_dependence: Fixed
  mutability: OutOfPlace
  vector_field: VectorField{var"#1", Autonomous, Fixed, OutOfPlace}

See also: CTBase.Data.VectorField, TimeDependence, CTBase.Traits.VariableDependence, CTFlows.Systems.ODEParameters.

__hvf_inplace [Function]

CTFlows.Systems.__hvf_inplace Function
julia
__hvf_inplace() -> Bool

Default value for in-place flag in hamiltonian_vector_field getter.

Returns false by default, meaning the getter returns out-of-place vector fields unless specified otherwise.

backend [Function]

CTFlows.Systems.backend Function
julia
backend(
    sys::CTFlows.Systems.HamiltonianSystem
) -> CTBase.Differentiation.AbstractADBackend

Return the automatic differentiation backend from a HamiltonianSystem.

Arguments

  • sys::HamiltonianSystem: The Hamiltonian system.

Returns

  • Differentiation.AbstractADBackend: The AD backend used for gradient computation.

See also: CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.hamiltonian.

julia
backend(
    sys::CTFlows.Systems.PseudoHamiltonianSystem
) -> CTBase.Differentiation.AbstractADBackend

Return the AD backend of a PseudoHamiltonianSystem.

See also: CTFlows.Systems.PseudoHamiltonianSystem.

julia
backend(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem
) -> CTBase.Differentiation.AbstractADBackend

Return the AD backend of a ConstrainedPseudoHamiltonianSystem.

See also: CTFlows.Systems.ConstrainedPseudoHamiltonianSystem.

build_system [Function]

CTFlows.Systems.build_system Function
julia
build_system(
    vf::CTBase.Data.AbstractVectorField
) -> CTFlows.Systems.HamiltonianVectorFieldSystem

Build a VectorFieldSystem from a VectorField.

Constructs a concrete system that wraps the vector field and pre-computes its right-hand side function for integration. The resulting system is ready for use with flow integration pipelines.

Arguments

  • vf::Data.AbstractVectorField: The vector field to wrap into a system.

Returns

  • VectorFieldSystem: A concrete system wrapping the vector field with a pre-computed RHS function.

Example

julia
julia> using CTFlows.Systems

julia> vf = VectorField(x -> -x; autonomous=true, variable=false)
VectorField
  time_dependence: Autonomous
  variable_dependence: Fixed
  function: var"#1"

julia> sys = build_system(vf)
VectorFieldSystem
  time_dependence: Autonomous
  variable_dependence: Fixed
  vector_field: VectorField{var"#1", Autonomous, Fixed}

See also: CTBase.Data.VectorField, CTFlows.Systems.VectorFieldSystem.

julia
build_system(
    hvf::CTBase.Data.AbstractHamiltonianVectorField
) -> CTFlows.Systems.HamiltonianVectorFieldSystem

Build a HamiltonianVectorFieldSystem from a HamiltonianVectorField.

Constructs a concrete Hamiltonian system that wraps the Hamiltonian vector field. RHS closures are built lazily based on actual initial condition types during flow integration.

Arguments

  • hvf::Data.AbstractHamiltonianVectorField: The Hamiltonian vector field to wrap into a system.

Returns

  • HamiltonianVectorFieldSystem: A concrete Hamiltonian system.

Example

julia
julia> using CTFlows.Systems

julia> hvf = HamiltonianVectorField((x, p) -> (x, -p); autonomous=true, variable=false)
HamiltonianVectorField
  time_dependence: Autonomous
  variable_dependence: Fixed
  function: var"#1"

julia> sys = build_system(hvf)
HamiltonianVectorFieldSystem
  time_dependence: Autonomous
  variable_dependence: Fixed
  hamiltonian_vector_field: HamiltonianVectorField{var"#1", Autonomous, Fixed}

See also: CTBase.Data.HamiltonianVectorField, CTFlows.Systems.HamiltonianVectorFieldSystem.

julia
build_system(
    h::CTBase.Data.AbstractHamiltonian,
    backend::CTBase.Differentiation.AbstractADBackend
) -> CTFlows.Systems.HamiltonianSystem

Build a CTFlows.Systems.HamiltonianSystem from a scalar Hamiltonian function with automatic differentiation.

Constructs a concrete Hamiltonian system that wraps the scalar Hamiltonian function with an AD backend. RHS closures are built lazily based on actual initial condition types during flow integration.

Arguments

  • h::Data.AbstractHamiltonian: The scalar Hamiltonian function to wrap into a system.

  • backend::Differentiation.AbstractADBackend: The automatic differentiation backend (e.g., AutoForwardDiff, AutoZygote).

Returns

  • HamiltonianSystem: A concrete Hamiltonian system with automatic differentiation support.

Example

julia
julia> using CTFlows.Systems, CTBase.Data

julia> h = Hamiltonian((t, x, p, v) -> 0.5 * sum(x.^2) + sum(p.^2); autonomous=true, variable=false)
Hamiltonian{var"#1", Autonomous, Fixed}

julia> sys = build_system(h, AutoForwardDiff())
HamiltonianSystem
  time_dependence: Autonomous
  variable_dependence: Fixed
  hamiltonian: Hamiltonian{var"#1", Autonomous, Fixed}
  backend: AutoForwardDiff()

Notes

  • The AD backend is used to compute Hamiltonian gradients ∂H/∂x and ∂H/∂p automatically during integration.

  • This overload is for scalar Hamiltonian functions where gradients are computed via AD. For explicit vector fields, use CTFlows.Systems.HamiltonianVectorFieldSystem instead.

See also: CTBase.Data.Hamiltonian, CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.HamiltonianVectorFieldSystem, CTBase.Differentiation.AbstractADBackend.

julia
build_system(
::CTBase.Data.PseudoHamiltonian,
    law::CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback},
    backend::CTBase.Differentiation.AbstractADBackend
) -> CTFlows.Systems.PseudoHamiltonianSystem

Build a CTFlows.Systems.PseudoHamiltonianSystem from a pseudo-Hamiltonian H̃(t,x,p,u,v), a dynamic closed-loop control law u(t,x,p,v), and an AD backend.

The resulting system integrates ẋ = ∂H̃/∂p, ṗ = -∂H̃/∂x with the control held fixed at the feedback value u = u(t,x,p,v) during differentiation (the :partial mode).

Arguments

  • h̃::Data.PseudoHamiltonian: the pseudo-Hamiltonian.

  • law::Data.ControlLaw: the control law; must carry DynClosedLoopFeedback.

  • backend::Differentiation.AbstractADBackend: the AD backend.

See also: CTFlows.Systems.PseudoHamiltonianSystem, CTBase.Data.PseudoHamiltonian, CTBase.Data.ComposedHamiltonian.

julia
build_system(
::CTBase.Data.PseudoHamiltonian,
    law::CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback},
    g,
    μ,
    backend::CTBase.Differentiation.AbstractADBackend
) -> CTFlows.Systems.ConstrainedPseudoHamiltonianSystem

Build a CTFlows.Systems.ConstrainedPseudoHamiltonianSystem from a pseudo-Hamiltonian H̃(t,x,p,u,v), a dynamic closed-loop control law u(t,x,p,v), a path constraint g(t,x,u,v), a multiplier μ(t,x,p,v), and an AD backend.

The resulting system integrates the constrained Hamiltonian H̃ + μ·g in the :partial mode: both the control u = u(t,x,p,v) and the multiplier value μ = μ(t,x,p,v) are held fixed during differentiation (g is differentiated, μ is not).

Arguments

  • h̃::Data.PseudoHamiltonian: the base pseudo-Hamiltonian.

  • law::Data.ControlLaw: the control law; must carry DynClosedLoopFeedback.

  • g: the path constraint (uniform call g(t,x,u,v)), e.g. a CTBase.Data.PathConstraint.

  • μ: the multiplier (uniform call μ(t,x,p,v)), e.g. a CTBase.Data.Multiplier.

  • backend::Differentiation.AbstractADBackend: the AD backend.

See also: CTFlows.Systems.ConstrainedPseudoHamiltonianSystem, CTFlows.Systems.PseudoHamiltonianSystem.

control_law [Function]

CTFlows.Systems.control_law Function
julia
control_law(
    sys::CTFlows.Systems.PseudoHamiltonianSystem
) -> CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}

Return the control law u(t,x,p,v) of a PseudoHamiltonianSystem.

See also: CTFlows.Systems.PseudoHamiltonianSystem, CTFlows.Systems.pseudo_hamiltonian.

julia
control_law(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem
) -> CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}

Return the control law u(t,x,p,v) of a ConstrainedPseudoHamiltonianSystem.

See also: CTFlows.Systems.ConstrainedPseudoHamiltonianSystem.

julia
control_law(
    sys::CTFlows.Systems.HamiltonianSystem
) -> CTBase.Data.ControlLaw{<:Function, CTBase.Traits.DynClosedLoopFeedback}

Return the control law u(t, x, p, v) of a HamiltonianSystem built in the :total mode (wrapping a CTBase.Data.ComposedHamiltonian).

Throws

  • CTBase.Exceptions.IncorrectArgument: if the system wraps a plain Hamiltonian with no associated control law.

See also: CTFlows.Systems.pseudo_hamiltonian.

julia
control_law(f::CTFlows.Flows.AbstractHamiltonianFlow) -> Any

Return the control law u(t, x, p, v) carried by a Hamiltonian flow built from a control law. Delegates to CTFlows.Systems.control_law.

Throws

  • CTBase.Exceptions.IncorrectArgument: for a flow that carries no control law.

See also: CTFlows.Systems.pseudo_hamiltonian.

get_ip_rhs [Function]

CTFlows.Systems.get_ip_rhs Function
julia
get_ip_rhs(
    system::CTFlows.Systems.AbstractSystem,
    config
) -> CTFlows.Systems.HamIpRHS

Return the in-place right-hand side function for a system given a configuration.

The returned function must have the signature (du, u, p, t) -> nothing and fill du in place with the derivative at state u, parameters p, and time t.

Eager systems (e.g., VectorFieldSystem) ignore the config and return pre-computed closures. Lazy systems (e.g., HamiltonianSystem) read x0/p0 from the config to build type-specific closures.

Arguments

  • system::AbstractSystem: The system.

  • config: The configuration containing initial conditions and time span.

Returns

  • Function: The in-place RHS closure with signature (du, u, p, t) -> nothing.

Throws

See also: CTFlows.Systems.get_oop_rhs, CTFlows.Systems.get_ip_rhs_augmented.

julia
get_ip_rhs(
    sys::CTFlows.Systems.VectorFieldSystem,
    _
) -> CTFlows.Systems.AbstractIPRHS

Return the in-place right-hand side for a VectorFieldSystem.

Eager implementation: ignores the config and returns the pre-computed closure.

Arguments

  • sys::VectorFieldSystem: The vector field system.

  • _: The configuration (ignored).

Returns

  • Function: The pre-computed in-place closure with signature (du, u, p, t) -> nothing.

See also: CTFlows.Systems.get_oop_rhs, rhs.

julia
get_ip_rhs(
    sys::CTFlows.Systems.HamiltonianVectorFieldSystem{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.OutOfPlace},
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.IPHVFOoPRHS

Return the in-place right-hand side for a HamiltonianVectorFieldSystem.

Lazy implementation: reads x0/p0 from the config to build type-specific closures.

Arguments

  • sys::HamiltonianVectorFieldSystem{..., OutOfPlace, ...}: The out-of-place system.

  • config::Configs.AbstractHamiltonianConfig: The Hamiltonian configuration.

Returns

  • IPHVFOoPRHS: An in-place RHS functor.

See also: CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs(
    sys::CTFlows.Systems.HamiltonianVectorFieldSystem{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.InPlace},
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.IPHVFIpRHS

Return the in-place right-hand side for a HamiltonianVectorFieldSystem.

Lazy implementation: reads x0/p0 from the config to build type-specific closures.

Arguments

  • sys::HamiltonianVectorFieldSystem{..., InPlace, ...}: The in-place system.

  • config::Configs.AbstractHamiltonianConfig: The Hamiltonian configuration.

Returns

  • IPHVFIpRHS: An in-place RHS functor.

See also: CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs(
    sys::CTFlows.Systems.HamiltonianSystem,
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.HamIpRHS

Return the in-place right-hand side for a HamiltonianSystem.

Lazy implementation: reads x0/p0 from the config to build type-specific closures.

Arguments

  • sys::HamiltonianSystem: The Hamiltonian system.

  • config::Configs.AbstractHamiltonianConfig: The Hamiltonian configuration.

Returns

  • HamIpRHS: An in-place RHS functor with embedded AD cache.

See also: CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs(
    sys::CTFlows.Systems.PseudoHamiltonianSystem,
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.PseudoHamIpRHS

Return the in-place RHS (CTFlows.Systems.PseudoHamIpRHS) for a PseudoHamiltonianSystem.

See also: CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem,
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.ConstrainedPseudoHamIpRHS

Return the in-place RHS (CTFlows.Systems.ConstrainedPseudoHamIpRHS) for a ConstrainedPseudoHamiltonianSystem.

See also: CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs(
    sys::CTFlowsSciMLFlows.SciMLFunctionSystem,
    _
) -> CTFlows.Systems.AbstractIPRHS

Return the in-place right-hand side for a SciMLFunctionSystem.

Eager implementation: ignores the config and returns the pre-computed closure.

Arguments

  • sys::SciMLFunctionSystem: The system.

  • _: The configuration (ignored).

Returns

  • Systems.AbstractIPRHS: The pre-computed in-place closure with signature (du, u, λ, t) -> nothing.

See also: CTFlowsSciMLFlows.SciMLFunctionSystem, CTFlows.Systems.get_oop_rhs.

get_ip_rhs_augmented [Function]

CTFlows.Systems.get_ip_rhs_augmented Function
julia
get_ip_rhs_augmented(
    system::CTFlows.Systems.AbstractHamiltonianSystem,
    config
) -> CTFlows.Systems.IPHVFOoPAugRHS

Return the augmented in-place right-hand side function for a Hamiltonian system.

The returned function computes state, costate, and variable costate derivatives. Only applicable to Hamiltonian systems with variable costate support.

Arguments

  • system::AbstractHamiltonianSystem: The Hamiltonian system.

  • config: The augmented Hamiltonian configuration containing x0, p0, and pv0.

Returns

  • Function: The augmented in-place RHS closure with signature (du, u, p, t) -> nothing.

Throws

See also: CTFlows.Systems.get_ip_rhs, CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs_augmented(
    sys::CTFlows.Systems.HamiltonianVectorFieldSystem{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.OutOfPlace},
    config::CTFlows.Configs.AbstractAugmentedHamiltonianConfig
) -> CTFlows.Systems.IPHVFOoPAugRHS

Return the augmented in-place right-hand side for a HamiltonianVectorFieldSystem.

Lazy implementation: reads x0/p0/pv0 from the config to build the augmented closure.

Arguments

  • sys::HamiltonianVectorFieldSystem{..., OutOfPlace, ...}: The out-of-place system.

  • config::Configs.AbstractAugmentedHamiltonianConfig: The augmented Hamiltonian configuration.

Returns

  • IPHVFOoPAugRHS: An augmented in-place RHS functor.

See also: CTFlows.Systems.get_ip_rhs, CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs_augmented(
    sys::CTFlows.Systems.HamiltonianVectorFieldSystem{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.InPlace},
    config::CTFlows.Configs.AbstractAugmentedHamiltonianConfig
) -> CTFlows.Systems.IPHVFIpAugRHS

Return the augmented in-place right-hand side for a HamiltonianVectorFieldSystem.

Lazy implementation: reads x0/p0/pv0 from the config to build the augmented closure.

Arguments

  • sys::HamiltonianVectorFieldSystem{..., InPlace, ...}: The in-place system.

  • config::Configs.AbstractAugmentedHamiltonianConfig: The augmented Hamiltonian configuration.

Returns

  • IPHVFIpAugRHS: An augmented in-place RHS functor.

See also: CTFlows.Systems.get_ip_rhs, CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs_augmented(
    sys::CTFlows.Systems.HamiltonianSystem,
    config::CTFlows.Configs.AbstractAugmentedHamiltonianConfig
) -> CTFlows.Systems.HamIpAugRHS

Return the augmented in-place right-hand side for a HamiltonianSystem.

Lazy implementation: reads x0/p0/pv0 from the config to build the augmented closure.

Arguments

  • sys::HamiltonianSystem: The Hamiltonian system.

  • config::Configs.AbstractAugmentedHamiltonianConfig: The augmented Hamiltonian configuration.

Returns

  • HamIpAugRHS: An augmented in-place RHS functor with embedded AD cache.

See also: CTFlows.Systems.get_ip_rhs, CTFlows.Systems.get_oop_rhs.

julia
get_ip_rhs_augmented(
    sys::CTFlows.Systems.PseudoHamiltonianSystem,
    config::CTFlows.Configs.AbstractAugmentedHamiltonianConfig
) -> CTFlows.Systems.PseudoHamIpAugRHS

Return the augmented in-place RHS (CTFlows.Systems.PseudoHamIpAugRHS) for a PseudoHamiltonianSystem with variable costate.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_ip_rhs_augmented(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem,
    config::CTFlows.Configs.AbstractAugmentedHamiltonianConfig
) -> CTFlows.Systems.ConstrainedPseudoHamIpAugRHS

Return the augmented in-place RHS (CTFlows.Systems.ConstrainedPseudoHamIpAugRHS) for a ConstrainedPseudoHamiltonianSystem with variable costate.

See also: CTFlows.Systems.get_ip_rhs.

get_oop_rhs [Function]

CTFlows.Systems.get_oop_rhs Function
julia
get_oop_rhs(
    system::CTFlows.Systems.AbstractSystem,
    config
) -> CTFlows.Systems.HamOoPRHS

Return the out-of-place right-hand side function for a system given a configuration.

The returned function must have the signature (u, p, t) -> du and return the derivative at state u, parameters p, and time t without modifying u.

Eager systems ignore the config and return pre-computed closures. Lazy systems read x0/p0 from the config to build type-specific closures.

Arguments

  • system::AbstractSystem: The system.

  • config: The configuration containing initial conditions and time span.

Returns

  • Function: The out-of-place RHS closure with signature (u, p, t) -> du.

Throws

See also: CTFlows.Systems.get_ip_rhs, CTFlows.Systems.get_ip_rhs_augmented.

julia
get_oop_rhs(
    sys::CTFlows.Systems.VectorFieldSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.OutOfPlace, F<:CTBase.Data.AbstractVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.OutOfPlace}, RHS<:CTFlows.Systems.AbstractIPRHS, OOPROHS<:CTFlows.Systems.AbstractOoPRHS, Nothing},
    _
) -> CTFlows.Systems.AbstractOoPRHS

Return the out-of-place right-hand side for a VectorFieldSystem.

Eager implementation: ignores the config and returns the pre-computed closure. For InPlace systems, returns rhs_oop_finalize (the finalize path) since get_oop_rhs is only called when !ismutable(u0).

Arguments

  • sys::VectorFieldSystem{..., OutOfPlace, ...}: The out-of-place system.

  • _: The configuration (ignored).

Returns

  • Function: The pre-computed out-of-place closure with signature (u, p, t) -> du.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlows.Systems.VectorFieldSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.InPlace, F<:CTBase.Data.AbstractVectorField{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.InPlace}, RHS<:CTFlows.Systems.AbstractIPRHS, OOPROHS<:CTFlows.Systems.AbstractOoPRHS, FINRHS},
    _
) -> Any

Return the out-of-place right-hand side for an InPlace VectorFieldSystem.

Eager implementation: ignores the config and returns the finalize closure. This method is called when !ismutable(u0), so we always return rhs_oop_finalize.

Arguments

  • sys::VectorFieldSystem{..., InPlace, ...}: The in-place system.

  • _: The configuration (ignored).

Returns

  • Function: The finalize closure with signature (u, p, t) -> du.

Notes

  • Emits a performance warning since this path is suboptimal for immutable arrays.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlows.Systems.HamiltonianVectorFieldSystem{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.OutOfPlace},
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.OoPHVFOoPRHS

Return the out-of-place right-hand side for a HamiltonianVectorFieldSystem.

Lazy implementation: reads x0/p0 from the config to build type-specific closures.

Arguments

  • sys::HamiltonianVectorFieldSystem{..., OutOfPlace, ...}: The out-of-place system.

  • config::Configs.AbstractHamiltonianConfig: The Hamiltonian configuration.

Returns

  • OoPHVFOoPRHS: An out-of-place RHS functor.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlows.Systems.HamiltonianVectorFieldSystem{F<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.InPlace},
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> Union{CTFlows.Systems.OoPHVFIpFinalizeRHS, CTFlows.Systems.OoPHVFIpRHS}

Return the out-of-place right-hand side for a HamiltonianVectorFieldSystem.

Lazy implementation: reads x0/p0 from the config to build type-specific closures. For immutable initial conditions, returns the finalize closure.

Arguments

  • sys::HamiltonianVectorFieldSystem{..., InPlace, ...}: The in-place system.

  • config::Configs.AbstractHamiltonianConfig: The Hamiltonian configuration.

Returns

  • OoPHVFIpRHS or OoPHVFIpFinalizeRHS: An out-of-place RHS functor.

Notes

  • Emits a performance warning when called with immutable initial conditions.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlows.Systems.HamiltonianSystem,
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.HamOoPRHS

Return the out-of-place right-hand side for a HamiltonianSystem.

Lazy implementation: reads x0/p0 from the config to build type-specific closures.

Arguments

  • sys::HamiltonianSystem: The Hamiltonian system.

  • config::Configs.AbstractHamiltonianConfig: The Hamiltonian configuration.

Returns

  • HamOoPRHS: An out-of-place RHS functor with embedded AD cache.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlows.Systems.PseudoHamiltonianSystem,
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.PseudoHamOoPRHS

Return the out-of-place RHS (CTFlows.Systems.PseudoHamOoPRHS) for a PseudoHamiltonianSystem.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem,
    config::CTFlows.Configs.AbstractHamiltonianConfig
) -> CTFlows.Systems.ConstrainedPseudoHamOoPRHS

Return the out-of-place RHS (CTFlows.Systems.ConstrainedPseudoHamOoPRHS) for a ConstrainedPseudoHamiltonianSystem.

See also: CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlowsSciMLFlows.SciMLFunctionSystem{F, RHS, OOPROHS, Nothing},
    _
) -> Any

Return the out-of-place right-hand side for an out-of-place SciMLFunctionSystem.

Eager implementation: ignores the config and returns the pre-computed closure.

Arguments

  • sys::SciMLFunctionSystem{..., Nothing}: The out-of-place system.

  • _: The configuration (ignored).

Returns

  • Systems.AbstractOoPRHS: The pre-computed out-of-place closure with signature (u, λ, t) -> du.

See also: CTFlowsSciMLFlows.SciMLFunctionSystem, CTFlows.Systems.get_ip_rhs.

julia
get_oop_rhs(
    sys::CTFlowsSciMLFlows.SciMLFunctionSystem{F, RHS, OOPROHS, FINRHS},
    _
) -> Any

Return the out-of-place right-hand side for an in-place SciMLFunctionSystem.

Eager implementation: ignores the config and returns the finalize closure. This method is called when !ismutable(u0), so always returns rhs_oop_finalize_fn.

Arguments

  • sys::SciMLFunctionSystem{..., FINRHS}: The in-place system.

  • _: The configuration (ignored).

Returns

  • Systems.AbstractOoPRHS: The finalize closure with signature (u, λ, t) -> du.

Notes

  • Emits a performance warning since this path is suboptimal for immutable arrays.

See also: CTFlowsSciMLFlows.SciMLFunctionSystem, CTFlows.Systems.get_ip_rhs.

hamiltonian [Function]

CTFlows.Systems.hamiltonian Function
julia
hamiltonian(
    sys::CTFlows.Systems.HamiltonianSystem
) -> CTBase.Data.AbstractHamiltonian

Return the Hamiltonian function from a HamiltonianSystem.

Arguments

  • sys::HamiltonianSystem: The Hamiltonian system.

Returns

  • Data.Hamiltonian: The Hamiltonian function wrapped by the system.

See also: CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.backend.

julia
hamiltonian(
    sys::CTFlows.Systems.PseudoHamiltonianSystem
) -> CTBase.Data.ComposedHamiltonian

Return the true Hamiltonian of a PseudoHamiltonianSystem — the CTBase.Data.ComposedHamiltonian H(t,x,p,v) = H̃(t,x,p,u(t,x,p,v),v) obtained by eliminating the control with the feedback law. Built on the fly.

See also: CTFlows.Systems.pseudo_hamiltonian, CTFlows.Systems.HamiltonianSystem.

julia
hamiltonian(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem
) -> CTBase.Data.ComposedHamiltonian

Return the base (unconstrained) true Hamiltonian of a ConstrainedPseudoHamiltonianSystem — the CTBase.Data.ComposedHamiltonian H(t,x,p,v) = H̃(t,x,p,u(t,x,p,v),v). The integrated dynamics additionally include the μ·g term (with μ frozen during differentiation); the constraint and multiplier are available via CTFlows.Systems.constraint / CTFlows.Systems.multiplier. On a boundary arc, where g ≡ 0, this base Hamiltonian coincides with the constrained one.

See also: CTFlows.Systems.pseudo_hamiltonian, CTFlows.Systems.constraint.

julia
hamiltonian(f::CTFlows.Flows.AbstractHamiltonianFlow) -> Any

Return the Hamiltonian H(t, x, p, v) underlying a Hamiltonian flow.

Delegates to the system-level getter CTFlows.Systems.hamiltonian. The returned object is callable as a scalar function of (t, x, p, v) (or the shorter signatures allowed by the flow's time/variable dependence). It is available for flows built from a scalar Hamiltonian — HamiltonianSystem (including the :total mode of an OCP-with-control flow) and PseudoHamiltonianSystem (the :partial mode, where it reconstructs the composed Hamiltonian). Flows built from a raw Hamiltonian vector field carry no scalar Hamiltonian and are not supported.

This is the getter to use when writing a transversality condition on a free time in a shooting method: with v = t0 and/or tf a variable, the augmented flow integrates the naive adjoint ṗv = -∂H/∂v (initialized at 0), and the mitigated transversality conditions read p_{t0}(tf) = -H(t0, x0, p0, v) and p_{tf}(tf) = H(tf, xf, pf, v).

Example

julia
H = CTFlows.Systems.hamiltonian(flow)
xf, pf, pvf = flow(t0, x0, p0, tf; variable = v, variable_costate = true)
s = pvf[idx_tf] - H(tf, xf, pf, v)   # transversality for free final time

See also: CTFlows.Systems.hamiltonian, CTFlows.Flows.system.

hamiltonian_gradient [Function]

CTFlows.Systems.hamiltonian_gradient Function
julia
hamiltonian_gradient(
    sys::Union{CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.PseudoHamiltonianSystem};
    ad_backend
) -> CTFlows.Systems.HamiltonianGradient

Return a CTFlows.Systems.HamiltonianGradient functor (t, x, p, v) -> (∂H/∂x, ∂H/∂p) for the true Hamiltonian of an AD-backed Hamiltonian system. For a PseudoHamiltonianSystem (or a :total HamiltonianSystem), the gradient is the total derivative — it differentiates through the control law.

The ad_backend keyword selects the AD backend used to differentiate; it defaults to the system's own backend but can be overridden (e.g. to use reverse mode for the gradient).

See also: CTFlows.Systems.hamiltonian, CTFlows.Systems.variable_gradient.

julia
hamiltonian_gradient(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> CTFlows.Systems.HamiltonianGradient

Return a callable (t, x, p, v) -> (∂H/∂x, ∂H/∂p) for the true Hamiltonian of a Hamiltonian flow. Delegates to CTFlows.Systems.hamiltonian_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

See also: CTFlows.Systems.hamiltonian, CTFlows.Systems.variable_gradient.

hamiltonian_vector_field [Function]

CTFlows.Systems.hamiltonian_vector_field Function
julia
hamiltonian_vector_field(
    h::CTBase.Data.AbstractHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence};
    ad_backend,
    inplace
) -> Union{CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:(CTBase.Differentiation.DifferentiationInterface{CTBase.Strategies.StrategyOptions{NT}} where NT<:NamedTuple)}, CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:(CTBase.Differentiation.DifferentiationInterface{CTBase.Strategies.StrategyOptions{NT}} where NT<:NamedTuple)}}

Get the Hamiltonian vector field from a Hamiltonian.

This function computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) (also known as the symplectic gradient of H) for a given Hamiltonian using automatic differentiation. It accepts any CTBase.Data.AbstractHamiltonian — a scalar Hamiltonian or a ComposedHamiltonian (as produced by an OCP + control law) — so it also covers pseudo-Hamiltonian flows. The returned vector field wraps a callable CTFlows.Systems.HVFOoPFunctor or CTFlows.Systems.HVFIpFunctor whose call signature matches the Hamiltonian's time and variable dependence traits.

Arguments

  • h::Data.AbstractHamiltonian{TD, VD}: The Hamiltonian with traits TD (time dependence) and VD (variable dependence).

  • ad_backend: AD backend type (default: Differentiation.__ad_backend() = AutoForwardDiff()) or an AbstractADBackend instance.

  • inplace::Bool: Whether to return an in-place functor (default: __hvf_inplace() = false).

Returns

  • Data.HamiltonianVectorField: The Hamiltonian vector field with correct traits matching the input Hamiltonian.

Notes

  • If ad_backend is an AbstractADBackend instance, it is used directly; otherwise it is wrapped via Differentiation.build_ad_backend.

  • The functor call signature depends on the Hamiltonian's traits:

    • Autonomous/Fixed: (x, p) -> (∂p, -∂x) or (dx, dp, x, p) -> nothing (in-place)

    • NonAutonomous/Fixed: (t, x, p) -> (∂p, -∂x) or (dx, dp, t, x, p) -> nothing (in-place)

    • Autonomous/NonFixed: (x, p, v; variable_costate=false) -> (∂p, -∂x) or (x, p, v; variable_costate=true) -> (∂p, -∂x, -∂v)

    • NonAutonomous/NonFixed: (t, x, p, v; variable_costate=false) -> (∂p, -∂x) or (t, x, p, v; variable_costate=true) -> (∂p, -∂x, -∂v)

See also: CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.HamiltonianVectorFieldSystem, CTBase.Data.HamiltonianVectorField

julia
hamiltonian_vector_field(
    sys::CTFlows.Systems.HamiltonianVectorFieldSystem;
    inplace
) -> CTBase.Data.HamiltonianVectorField

Get the Hamiltonian vector field from a HamiltonianVectorFieldSystem.

This is a trivial getter that returns the pre-stored Hamiltonian vector field from the system. No computation is performed since the vector field is already constructed.

Arguments

  • sys::HamiltonianVectorFieldSystem: The system with a pre-stored Hamiltonian vector field.

Returns

  • Data.HamiltonianVectorField: The stored Hamiltonian vector field (identical to sys.hvf).

Notes

  • This overload is used when the Hamiltonian vector field is already known and stored, avoiding redundant automatic differentiation.

  • The returned vector field is identical to sys.hvf (same object reference).

See also: CTFlows.Systems.HamiltonianVectorFieldSystem, CTBase.Data.HamiltonianVectorField

julia
hamiltonian_vector_field(
    sys::CTFlows.Systems.HamiltonianSystem;
    inplace
) -> Union{CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}, CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}}

Get the Hamiltonian vector field from a HamiltonianSystem (AD-backed).

This function extracts the Hamiltonian and AD backend from the system and delegates to the Hamiltonian overload to compute the vector field via automatic differentiation.

Arguments

  • sys::HamiltonianSystem: The system containing a Hamiltonian and AD backend.

  • inplace::Bool: Whether to return an in-place closure (default: __hvf_inplace() = false).

Returns

  • Data.HamiltonianVectorField: The Hamiltonian vector field with correct traits matching the system's Hamiltonian.

Notes

  • This overload uses the AD backend stored in sys.backend for gradient computation.

  • The inplace parameter controls whether the returned closure writes results in-place.

  • Delegates to CTFlows.Systems.hamiltonian_vector_field.

See also: CTFlows.Systems.HamiltonianSystem, CTBase.Data.Hamiltonian, CTBase.Differentiation.AbstractADBackend

julia
hamiltonian_vector_field(
    sys::CTFlows.Systems.AbstractHamiltonianSystem;
    inplace,
    kwargs...
) -> CTBase.Data.HamiltonianVectorField

Get the Hamiltonian vector field from any AbstractHamiltonianSystem, dispatching on ad_trait.

  • WithAD systems: computes the vector field via automatic differentiation using hamiltonian(sys) and backend(sys) (protocol methods the system must implement).

  • WithoutAD systems: throws NotImplemented — the system must implement hamiltonian_vector_field directly (as HamiltonianVectorFieldSystem does).

Throws

  • Exceptions.NotImplemented: when the system's AD trait is WithoutAD and no specialized hamiltonian_vector_field overload exists for the system type.

See also: CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.HamiltonianVectorFieldSystem.

julia
hamiltonian_vector_field(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> Union{CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}, CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}}

Return the (symplectic) Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) of a Hamiltonian flow, as a CTBase.Data.HamiltonianVectorField. Delegates to the system-level CTFlows.Systems.hamiltonian_vector_field, so it also covers flows built from a pseudo-Hamiltonian (or an OCP) and a control law (:partial / :total), whose Hamiltonian is a CTBase.Data.ComposedHamiltonian.

See also: CTFlows.Systems.hamiltonian, CTFlows.Systems.vector_field.

julia
hamiltonian_vector_field(
    flow::CTFlows.Flows.Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics, <:CTFlows.Systems.HamiltonianSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, H} where H<:CTBase.Data.AbstractHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}};
    inplace
) -> Union{CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}, CTBase.Data.HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<:CTBase.Data.AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}}

Get the Hamiltonian vector field from a HamiltonianFlow with an AD-backed system.

Delegates to the system-level getter. The inplace parameter controls whether the returned closure writes results in-place.

See also: CTFlows.Flows.HamiltonianFlow, CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.hamiltonian_vector_field

julia
hamiltonian_vector_field(
    flow::CTFlows.Flows.Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics, <:CTFlows.Systems.HamiltonianVectorFieldSystem{<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}}
) -> CTBase.Data.HamiltonianVectorField

Get the Hamiltonian vector field from a HamiltonianFlow with an HVF-backed system.

Returns the pre-stored vector field from the HamiltonianVectorFieldSystem without any recomputation.

See also: CTFlows.Flows.HamiltonianFlow, CTFlows.Systems.HamiltonianVectorFieldSystem, CTFlows.Systems.hamiltonian_vector_field

pseudo_hamiltonian [Function]

CTFlows.Systems.pseudo_hamiltonian Function
julia
pseudo_hamiltonian(
    sys::CTFlows.Systems.PseudoHamiltonianSystem
) -> CTBase.Data.PseudoHamiltonian{<:Function, TD, VD} where {TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Return the pseudo-Hamiltonian of a PseudoHamiltonianSystem.

See also: CTFlows.Systems.PseudoHamiltonianSystem, CTFlows.Systems.control_law.

julia
pseudo_hamiltonian(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem
) -> CTBase.Data.PseudoHamiltonian{<:Function, TD, VD} where {TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}

Return the base pseudo-Hamiltonian of a ConstrainedPseudoHamiltonianSystem (without the μ·g term). The constraint and multiplier are exposed separately by CTFlows.Systems.constraint and CTFlows.Systems.multiplier.

See also: CTFlows.Systems.ConstrainedPseudoHamiltonianSystem.

julia
pseudo_hamiltonian(
    sys::CTFlows.Systems.HamiltonianSystem
) -> CTBase.Data.PseudoHamiltonian

Return the pseudo-Hamiltonian underlying a HamiltonianSystem, when the system wraps a CTBase.Data.ComposedHamiltonian — i.e. it was built in the :total mode of an OCP-with-control (or pseudo-Hamiltonian + control law) flow. The control is not eliminated: H̃(t, x, p, u, v) keeps u as an independent argument.

Throws

  • CTBase.Exceptions.IncorrectArgument: if the system wraps a plain Hamiltonian with no associated control law (no pseudo-Hamiltonian to recover).

See also: CTFlows.Systems.hamiltonian, CTFlows.Systems.control_law.

julia
pseudo_hamiltonian(
    f::CTFlows.Flows.AbstractHamiltonianFlow
) -> Any

Return the pseudo-Hamiltonian H̃(t, x, p, u, v) underlying a Hamiltonian flow, when available — i.e. when the flow was built from a pseudo-Hamiltonian (or an OCP) and a control law, in either the :partial or the :total mode. Delegates to CTFlows.Systems.pseudo_hamiltonian.

Throws

  • CTBase.Exceptions.IncorrectArgument: for a flow that carries no control law.

See also: CTFlows.Systems.hamiltonian, CTFlows.Systems.control_law.

pseudo_hamiltonian_gradient [Function]

CTFlows.Systems.pseudo_hamiltonian_gradient Function
julia
pseudo_hamiltonian_gradient(
    sys::Union{CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.PseudoHamiltonianSystem};
    ad_backend
) -> CTFlows.Systems.PseudoHamiltonianGradient{H} where H<:CTBase.Data.PseudoHamiltonian

Return a CTFlows.Systems.PseudoHamiltonianGradient functor (t, x, p, u, v) -> (∂H̃/∂x, ∂H̃/∂p) for the pseudo-Hamiltonian, differentiated at fixed control u. Available for a PseudoHamiltonianSystem and for a :total HamiltonianSystem wrapping a ComposedHamiltonian.

The ad_backend keyword selects the AD backend (default: the system's own backend).

See also: CTFlows.Systems.pseudo_hamiltonian, CTFlows.Systems.pseudo_variable_gradient.

julia
pseudo_hamiltonian_gradient(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> CTFlows.Systems.PseudoHamiltonianGradient{H} where H<:CTBase.Data.PseudoHamiltonian

Return a callable (t, x, p, u, v) -> (∂H̃/∂x, ∂H̃/∂p) for the pseudo-Hamiltonian of a Hamiltonian flow (differentiated at fixed control), when available. Delegates to CTFlows.Systems.pseudo_hamiltonian_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

See also: CTFlows.Systems.pseudo_hamiltonian, CTFlows.Systems.pseudo_variable_gradient.

pseudo_variable_gradient [Function]

CTFlows.Systems.pseudo_variable_gradient Function
julia
pseudo_variable_gradient(
    sys::Union{CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.PseudoHamiltonianSystem};
    ad_backend
) -> CTFlows.Systems.PseudoHamiltonianVariableGradient{H} where H<:CTBase.Data.PseudoHamiltonian

Return a CTFlows.Systems.PseudoHamiltonianVariableGradient functor (t, x, p, u, v) -> ∂H̃/∂v for the pseudo-Hamiltonian, differentiated at fixed control u.

The ad_backend keyword selects the AD backend (default: the system's own backend).

See also: CTFlows.Systems.pseudo_hamiltonian_gradient.

julia
pseudo_variable_gradient(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> CTFlows.Systems.PseudoHamiltonianVariableGradient{H} where H<:CTBase.Data.PseudoHamiltonian

Return a callable (t, x, p, u, v) -> ∂H̃/∂v for the pseudo-Hamiltonian of a Hamiltonian flow (differentiated at fixed control), when available. Delegates to CTFlows.Systems.pseudo_variable_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

See also: CTFlows.Systems.pseudo_hamiltonian_gradient.

variable [Function]

CTFlows.Systems.variable Function
julia
variable(p::CTFlows.Systems.ODEParameters) -> Any

Accessor for the variable field of ODEParameters.

Returns the variable parameter stored in the ODEParameters wrapper. For Fixed systems, this is nothing. For NonFixed systems, this is the actual variable value (scalar or vector).

Arguments

  • p::ODEParameters: The ODEParameters instance.

Returns

  • The variable value (or nothing for Fixed systems).

Example

julia
julia> using CTFlows.Systems

julia> params_fixed = ODEParameters(nothing)
ODEParameters{Nothing}(nothing)

julia> variable(params_fixed)
nothing

julia> params_nonfixed = ODEParameters(0.5)
ODEParameters{Float64}(0.5)

julia> variable(params_nonfixed)
0.5

See also: CTFlows.Systems.ODEParameters, CTBase.Traits.VariableDependence.

variable_gradient [Function]

CTFlows.Systems.variable_gradient Function
julia
variable_gradient(
    sys::Union{CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.PseudoHamiltonianSystem};
    ad_backend
) -> CTFlows.Systems.HamiltonianVariableGradient

Return a CTFlows.Systems.HamiltonianVariableGradient functor (t, x, p, v) -> ∂H/∂v for the true Hamiltonian of an AD-backed Hamiltonian system — the same quantity (before negation) that drives the augmented variable-costate equation ṗv = -∂H/∂v.

The ad_backend keyword selects the AD backend (default: the system's own backend).

See also: CTFlows.Systems.hamiltonian_gradient.

julia
variable_gradient(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> CTFlows.Systems.HamiltonianVariableGradient

Return a callable (t, x, p, v) -> ∂H/∂v for the true Hamiltonian of a Hamiltonian flow — the quantity (before negation) driving ṗv = -∂H/∂v. Delegates to CTFlows.Systems.variable_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

See also: CTFlows.Systems.hamiltonian_gradient.

vector_field [Function]

CTFlows.Systems.vector_field Function
julia
vector_field(
    sys::CTFlows.Systems.VectorFieldSystem
) -> CTBase.Data.AbstractVectorField

Return the underlying vector field of a VectorFieldSystem, as a CTBase.Data.AbstractVectorField — the field X(t, x, v) integrated by the state flow.

See also: CTFlows.Systems.VectorFieldSystem, CTFlows.Systems.hamiltonian_vector_field.

julia
vector_field(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> Any

Return the vector field of a flow: the (symplectic) Hamiltonian vector field X_H for a Hamiltonian flow. Alias of CTFlows.Systems.hamiltonian_vector_field on the Hamiltonian side; see the StateDynamics method for state flows.

See also: CTFlows.Systems.hamiltonian_vector_field.

julia
vector_field(f::CTFlows.Flows.AbstractStateFlow) -> Any

Return the underlying vector field X(t, x, v) of a state flow, as a CTBase.Data.AbstractVectorField. Delegates to the system-level CTFlows.Systems.vector_field.

See also: CTFlows.Systems.hamiltonian_vector_field.