Skip to content

Flows

CTFlows.Flows.Flow Type
julia
struct Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait, S<:CTFlows.Systems.AbstractSystem{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}, I<:AbstractIntegrator} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}

Concrete flow combining an AbstractSystem with an AbstractIntegrator.

The dynamics axis is encoded in the type parameter D:

  • D = StateDynamics → state flow (access via StateFlow alias)

  • D = HamiltonianDynamics → Hamiltonian flow (access via HamiltonianFlow alias)

Type Parameters

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

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

  • D <: AbstractDynamicsTrait: Dynamics trait (StateDynamics or HamiltonianDynamics)

  • S <: AbstractSystem{TD, VD, D}: The system type

  • I <: AbstractIntegrator: The integrator type

Fields

  • system::S: The system to integrate

  • integrator::I: The integrator to use for integration

Example

julia
julia> using CTFlows.Flows, CTFlows.Systems, CTFlows.Integrators

julia> system = VectorFieldSystem(VectorField(x -> -x))

julia> integrator = SciML()

julia> flow = StateFlow(system, integrator)
StateFlow{...}

See also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.StateFlow, CTFlows.Flows.HamiltonianFlow.

CTFlows.Systems.control_law Function
julia
control_law(
    sys::CTFlows.Systems.PseudoHamiltonianSystem
) -> 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
) -> 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
) -> 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.

CTFlows.Systems.pseudo_hamiltonian Function
julia
pseudo_hamiltonian(
    sys::CTFlows.Systems.PseudoHamiltonianSystem
) -> 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
) -> 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
) -> 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.

CTFlows.Systems.hamiltonian Function
julia
hamiltonian(_::CTFlows.Systems.HamiltonianVectorFieldSystem)

Throw an IncorrectArgument error: a HamiltonianVectorFieldSystem stores the vector field X_H directly and carries no scalar Hamiltonian. Use CTFlows.Systems.hamiltonian_vector_field to retrieve X_H instead.

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

julia
hamiltonian(
    sys::CTFlows.Systems.HamiltonianSystem
) -> 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
) -> 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(
    _::CTFlows.Systems.PseudoHamiltonianVectorFieldSystem
)

Throw an IncorrectArgument error: a PseudoHamiltonianVectorFieldSystem stores the pseudo-Hamiltonian vector field X_H̃ directly and carries no scalar Hamiltonian. Use CTFlows.Systems.hamiltonian_vector_field to retrieve X_H̃ instead.

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

julia
hamiltonian(
    sys::CTFlows.Systems.ConstrainedPseudoHamiltonianSystem
) -> 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.

CTFlows.Systems.hamiltonian_vector_field Function
julia
hamiltonian_vector_field(
    h::AbstractHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence};
    ad_backend,
    inplace
) -> Union{HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:AbstractHamiltonian, B<:(CTBase.Differentiation.DifferentiationInterface{CPU, CTBase.Strategies.StrategyOptions{NT}} where NT<:NamedTuple)}, HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<:AbstractHamiltonian, B<:(CTBase.Differentiation.DifferentiationInterface{CPU, 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::Differentiation.AbstractADBackend: The AD backend to use (default: __hvf_ad_backend() = Differentiation.DifferentiationInterface(), the CPU default).

  • 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

  • ad_backend must already be a fully-built strategy (e.g. from Flow's registry-based routing, or constructed directly as Differentiation.DifferentiationInterface{Strategies.GPU}(...)). This function does not build or device-select a backend from a raw ADTypes.AbstractADType.

  • 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
) -> 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{HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}, HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<: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 returned by backend(sys) for gradient computation, passed through as-is (no unwrapping/rewrapping), so a device-specific backend (e.g. DifferentiationInterface{Strategies.GPU}) is preserved.

  • 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...
) -> 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{HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}, HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<: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::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<:AbstractHamiltonian{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}};
    inplace
) -> Union{HamiltonianVectorField{CTFlows.Systems.HVFIpFunctor{H, B}} where {H<:AbstractHamiltonian, B<:CTBase.Differentiation.AbstractADBackend}, HamiltonianVectorField{CTFlows.Systems.HVFOoPFunctor{H, B}} where {H<: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::Flow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics, <:CTFlows.Systems.HamiltonianVectorFieldSystem{<:Function, TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence}}
) -> 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

CTFlows.Systems.vector_field Function
julia
vector_field(
    sys::CTFlows.Systems.VectorFieldSystem
) -> 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.

CTFlows.Systems.get_hamiltonian_gradient Function
julia
get_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.get_variable_gradient.

julia
get_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.get_hamiltonian_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

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

CTFlows.Systems.get_variable_gradient Function
julia
get_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.get_hamiltonian_gradient.

julia
get_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.get_variable_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

See also: CTFlows.Systems.get_hamiltonian_gradient.

CTFlows.Systems.get_pseudo_hamiltonian_gradient Function
julia
get_pseudo_hamiltonian_gradient(
    sys::Union{CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.PseudoHamiltonianSystem};
    ad_backend
) -> CTFlows.Systems.PseudoHamiltonianGradient{H} where H<: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.get_pseudo_variable_gradient.

julia
get_pseudo_hamiltonian_gradient(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> CTFlows.Systems.PseudoHamiltonianGradient{H} where H<: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.get_pseudo_hamiltonian_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

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

CTFlows.Systems.get_pseudo_variable_gradient Function
julia
get_pseudo_variable_gradient(
    sys::Union{CTFlows.Systems.HamiltonianSystem, CTFlows.Systems.PseudoHamiltonianSystem};
    ad_backend
) -> CTFlows.Systems.PseudoHamiltonianVariableGradient{H} where H<: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.get_pseudo_hamiltonian_gradient.

julia
get_pseudo_variable_gradient(
    f::CTFlows.Flows.AbstractHamiltonianFlow;
    kwargs...
) -> CTFlows.Systems.PseudoHamiltonianVariableGradient{H} where H<: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.get_pseudo_variable_gradient; the ad_backend keyword (default: the system's backend) selects the AD backend.

See also: CTFlows.Systems.get_pseudo_hamiltonian_gradient.

CTFlows.MultiPhase.MultiPhaseFlow Type
julia
struct MultiPhaseFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait, FS<:Tuple, ST<:(Vector{<:Real}), J<:(Vector)} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}

Concrete multi-phase flow combining multiple flows of the same dynamics family with switching times and optional jumps.

The dynamics axis is encoded in D, following the same pattern as Flow:

  • D = StateDynamics → state multi-phase flow (alias MultiPhaseStateFlow)

  • D = HamiltonianDynamics → Hamiltonian multi-phase flow (alias MultiPhaseHamiltonianFlow)

flows is a heterogeneous tuple, lifting the previous homogeneous-S/I constraint: phases may wrap systems and integrators of different concrete types.

Type Parameters

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

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

  • D <: AbstractDynamicsTrait: Dynamics trait (StateDynamics or HamiltonianDynamics)

  • FS <: Tuple: Tuple of AbstractFlow{TD,VD,D} (heterogeneous allowed)

  • ST <: Vector{<:Real}: Type of the switching times vector

  • J <: Vector{<:Any}: Type of the jumps vector

Fields

  • flows::FS: Tuple of flows for each phase

  • switching_times::ST: Switching times between phases

  • jumps::J: Optional jump functions applied at switching times

See also: CTFlows.MultiPhase.MultiPhaseStateFlow, CTFlows.MultiPhase.MultiPhaseHamiltonianFlow, CTFlows.Flows.Flow.

CTFlows.MultiPhase.MultiPhaseStateFlow Type
julia
struct MultiPhaseFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics, FS<:Tuple, ST<:(Vector{<:Real}), J<:(Vector)} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.StateDynamics}

Alias for state multi-phase flows: MultiPhaseFlow{TD,VD,StateDynamics,FS,ST,J}.

See also: CTFlows.MultiPhase.MultiPhaseFlow, CTFlows.MultiPhase.MultiPhaseHamiltonianFlow.

CTFlows.MultiPhase.MultiPhaseHamiltonianFlow Type
julia
struct MultiPhaseFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics, FS<:Tuple, ST<:(Vector{<:Real}), J<:(Vector)} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, CTBase.Traits.HamiltonianDynamics}

Alias for Hamiltonian multi-phase flows: MultiPhaseFlow{TD,VD,HamiltonianDynamics,FS,ST,J}.

See also: CTFlows.MultiPhase.MultiPhaseFlow, CTFlows.MultiPhase.MultiPhaseStateFlow.

CTFlows.MultiPhase.AnyMultiPhaseFlow Type
julia
struct MultiPhaseFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait, FS<:Tuple, ST<:(Vector{<:Real}), J<:(Vector)} <: CTFlows.Flows.AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}

Type alias for any multi-phase flow.

See also: CTFlows.MultiPhase.MultiPhaseStateFlow, CTFlows.MultiPhase.MultiPhaseHamiltonianFlow.

CTFlows.MultiPhase.n_phases Function
julia
n_phases(mpf::MultiPhaseFlow) -> Int64

Return the number of phases in a multi-phase flow.

Arguments

  • mpf::MultiPhaseFlow: The multi-phase flow.

Returns

  • Int: Number of phases.

See also: CTFlows.MultiPhase.get_flow, CTFlows.MultiPhase.get_switching_time.

CTFlows.MultiPhase.get_flow Function
julia
get_flow(mpf::MultiPhaseFlow, i::Int64) -> Any

Return the flow for a specific phase.

Arguments

  • mpf::MultiPhaseFlow: The multi-phase flow.

  • i::Int: Phase index (1-based).

Returns

  • AbstractFlow: The flow for phase i.

See also: CTFlows.MultiPhase.n_phases, CTFlows.MultiPhase.get_switching_time.

CTFlows.MultiPhase.get_flows Function
julia
get_flows(f::CTFlows.Flows.AbstractFlow) -> Tuple

Get the flows from a single-phase flow as a 1-tuple.

julia
get_flows(mpf::MultiPhaseFlow) -> Tuple

Get the flows tuple from a multi-phase flow.

CTFlows.MultiPhase.get_switching_time Function
julia
get_switching_time(mpf::MultiPhaseFlow, i::Int64) -> Real

Return the switching time at a specific phase boundary.

Arguments

  • mpf::MultiPhaseFlow: The multi-phase flow.

  • i::Int: Phase index (1-based). Returns the switching time between phase i and i+1.

Returns

  • Real: The switching time.

See also: CTFlows.MultiPhase.n_phases, CTFlows.MultiPhase.get_flow.

CTFlows.MultiPhase.get_switching_times Function
julia
get_switching_times(
    _::CTFlows.Flows.AbstractFlow
) -> Vector{<:Real}

Get the switching times from a single-phase flow (empty vector).

julia
get_switching_times(mpf::MultiPhaseFlow) -> Vector{<:Real}

Get the switching times from a multi-phase flow.

CTFlows.MultiPhase.get_jump Function
julia
get_jump(mpf::MultiPhaseFlow, i::Int64) -> Any

Return the jump function at a specific phase boundary.

Arguments

  • mpf::MultiPhaseFlow: The multi-phase flow.

  • i::Int: Phase index (1-based). Returns the jump applied after phase i.

Returns

  • Union{Nothing, Function, Tuple}: The jump function, or nothing if no jump is defined.

See also: CTFlows.MultiPhase.n_phases, CTFlows.MultiPhase.get_flow.

CTFlows.MultiPhase.get_jumps Function
julia
get_jumps(_::CTFlows.Flows.AbstractFlow) -> Vector

Get the jumps from a single-phase flow (empty vector).

julia
get_jumps(mpf::MultiPhaseFlow) -> Vector

Get the jumps from a multi-phase flow.

CTSolvers.Integrators.SciML Type
julia
struct SciML{P<:Union{CPU, GPU}, O<:CTBase.Strategies.StrategyOptions, OP<:Dict{Symbol, Any}, OT<:Dict{Symbol, Any}} <: CTSolvers.Integrators.AbstractSciMLIntegrator

Generic SciML ODE integrator strategy.

Wraps any SciML algorithm (e.g. Tsit5, Rodas4) through a unified CTBase.Strategies-backed option system. The full implementation (metadata, builder and solve) is provided by the CTSolversSciMLIntegrator package extension; this file declares the type and stubs that throw ExtensionError until the extension is loaded.

Parameterized on the execution device P:

  • SciML{CPU}: CPU execution (default);

  • SciML{GPU}: GPU execution (state on device arrays, e.g. CuArray).

SciML(...) builds a SciML{CPU} — the device parameterization is fully backward compatible with existing call sites.

To activate the extension, load any of:

  • using OrdinaryDiffEqTsit5 (minimal)

  • using OrdinaryDiffEq

  • using DifferentialEquations

Fields

  • options::CTBase.Strategies.StrategyOptions: Validated option bundle.

  • options_point::Dict{Symbol, Any}: Pre-computed options for point (final-state) integration.

  • options_trajectory::Dict{Symbol, Any}: Pre-computed options for trajectory integration.

CTSolvers.Integrators.AbstractIntegrator Type
julia
abstract type AbstractIntegrator <: CTBase.Strategies.AbstractStrategy

Abstract strategy for solving ODE Cauchy problems.

An AbstractIntegrator is a strategy that integrates an ODE problem over a time span. It inherits the CTBase.Strategies strategy contract:

Type-Level Contract (Static Metadata)

Methods defined on the type that describe what the integrator can do:

  • Strategies.id(::Type{<:S}) → Symbol: Unique identifier for routing and introspection.

  • Strategies.metadata(::Type{<:S}) → StrategyMetadata: Option specifications and validation rules.

Instance-Level Contract (Configured State)

Methods defined on instances that provide the actual configuration:

  • Strategies.options(s::S) → StrategyOptions: Current option values with provenance tracking.

Concrete Implementation

Concrete integrators implement, typically in a backend extension:

The cached per-call option dictionaries are exposed through the CTSolvers.Integrators.options_point / CTSolvers.Integrators.options_trajectory accessors.

See also: CTSolvers.Integrators.SciML, CTSolvers.Integrators.AbstractIntegrationResult.

CTSolvers.Integrators.AbstractIntegrationResult Type
julia
abstract type AbstractIntegrationResult

Abstract supertype for integration results produced by integrators.

This abstraction decouples the consumer (e.g. a trajectory layer) from the concrete types of the underlying ODE solvers (e.g. SciML). Integrators must produce a subtype of AbstractIntegrationResult which provides semantic accessors.

Interface Requirements

Subtypes must implement:

  • final_state(r::SubType): Return the final state vector.

  • times(r::SubType): Return the vector of time points.

  • evaluate_at(r::SubType, t::Real): Evaluate the continuous solution at time t.

  • status(r::SubType): Return the termination status as a Symbol.

  • successful(r::SubType): Return whether the integration succeeded.

See also: CTSolvers.Integrators.final_state, CTSolvers.Integrators.times, CTSolvers.Integrators.evaluate_at, CTSolvers.Integrators.status, CTSolvers.Integrators.successful.

CTSolvers.Integrators.final_state Function
julia
final_state(r::AbstractIntegrationResult) -> Any

Return the final state vector from the integration result.

Arguments

  • r::AbstractIntegrationResult: The integration result.

Throws

See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.times, CTSolvers.Integrators.evaluate_at.

julia
final_state(
    sol::CTFlows.Trajectories.VectorFieldTrajectory
) -> Any

Return the final state from the solution, coerced to a scalar for a 1-D state (issue #357) — see CTFlows.Systems._coerce_state.

Arguments

  • sol::VectorFieldTrajectory: The vector field solution.

Returns

  • The final state from the integration result.

See also: CTFlows.Systems._coerce_state, CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.final_state.

julia
final_state(
    sol::CTFlows.Trajectories.HamiltonianVectorFieldTrajectory
) -> Tuple{Any, Any}

Return the raw final ODE state vector [xf; pf] from the integration result.

Delegates directly to the underlying integration result without splitting. Callers that need the split form should use _ham_split_solution explicitly.

Arguments

  • sol::HamiltonianVectorFieldTrajectory: The Hamiltonian vector field solution.

Returns

  • AbstractVector: The concatenated final state [xf; pf].

See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.final_state.

julia
final_state(
    sol::CTFlows.Trajectories.StateFlowTrajectory
) -> Any

Return the final state of a StateFlowTrajectory.

julia
final_state(
    r::CTSolversSciMLIntegrator.SciMLIntegrationResult
) -> Any

Return the final state vector from the SciML ODE solution.

CTSolvers.Integrators.evaluate_at Function
julia
evaluate_at(r::AbstractIntegrationResult, t::Real) -> Any

Evaluate the integration result at a specific time t.

Arguments

  • r::AbstractIntegrationResult: The integration result.

  • t::Real: The time at which to evaluate the solution.

Throws

See also: CTSolvers.Integrators.AbstractIntegrationResult, CTSolvers.Integrators.final_state, CTSolvers.Integrators.times.

julia
evaluate_at(
    r::CTSolversSciMLIntegrator.SciMLIntegrationResult,
    t::Real
) -> Any

Evaluate the SciML ODE solution at a specific time t using its interpolation.