Public API

This page lists exported symbols of CTFlows.Flows.


From CTFlows.Flows

CTFlows.Flows [Module]

CTFlows.FlowsModule
Flows

Flow types and contracts for CTFlows.

This module defines the AbstractFlow type and its required methods:

  • (flow)(t0, x0, tf): callable interface for state integration
  • (flow)(t0, x0, p0, tf): callable interface for state + costate integration
  • system: returns the system associated with the flow
  • integrator: returns the integrator used by the flow

AbstractFlow [Abstract Type]

CTFlows.Flows.AbstractFlowType
abstract type AbstractFlow{TD<:CTBase.Traits.TimeDependence, VD<:CTBase.Traits.VariableDependence, D<:CTBase.Traits.AbstractDynamicsTrait}

Abstract type for all flows in CTFlows.

An AbstractFlow is a callable object that combines an AbstractSystem with an AbstractIntegrator. It carries no business logic of its own — its job is to expose the integration protocol.

Interface Requirements

All subtypes must implement:

  • system(flow::AbstractFlow): Return the associated AbstractSystem.
  • integrator(flow::AbstractFlow): Return the associated AbstractIntegrator.

Traits

All AbstractFlow subtypes automatically support time-dependence and variable-dependence trait queries encoded in their type parameters:

  • time_dependence(flow): Returns the time-dependence trait type.
  • variable_dependence(flow): Returns the variable-dependence trait type.
  • is_autonomous(flow), is_nonautonomous(flow): Time-dependence predicates.
  • is_variable(flow), is_nonvariable(flow), has_variable(flow): Variable-dependence predicates.

Example

julia> using CTFlows.Flows

julia> MyFlow <: Flows.AbstractFlow
true

See also: CTFlows.Flows.Flow, CTFlows.Systems.AbstractSystem, CTFlows.Integrators.AbstractIntegrator.

AbstractHamiltonianFlow [Abstract Type]

CTFlows.Flows.AbstractHamiltonianFlowType
abstract type AbstractFlow{TD, VD, CTBase.Traits.HamiltonianDynamics}

Alias for Hamiltonian flows.

Matches any AbstractFlow with HamiltonianDynamics as the dynamics parameter.

Type Parameters

  • TD <: TimeDependence: Time dependence trait (Autonomous or NonAutonomous)
  • VD <: VariableDependence: Variable dependence trait (Fixed or NonFixed)

Example

julia> using CTFlows.Flows

julia> Flow(hvf) isa Flows.AbstractHamiltonianFlow
true

See also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.AbstractStateFlow.

AbstractStateFlow [Abstract Type]

CTFlows.Flows.AbstractStateFlowType
abstract type AbstractFlow{TD, VD, CTBase.Traits.StateDynamics}

Alias for state flows.

Matches any AbstractFlow 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> using CTFlows.Flows

julia> Flow(vf) isa Flows.AbstractStateFlow
true

See also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.AbstractHamiltonianFlow.

Flow [Struct]

CTFlows.Flows.FlowType
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<:CTFlows.Integrators.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> 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.

HamiltonianFlow [Struct]

StateFlow [Struct]

build_flow [Function]

CTFlows.Flows.build_flowFunction
build_flow(
    system::CTFlows.Systems.AbstractSystem,
    integrator::CTFlows.Integrators.AbstractIntegrator
) -> CTFlows.Flows.Flow

Build a Flow from a system and an integrator.

See also: CTFlows.Flows.Flow.

flow_registry [Function]

CTFlows.Flows.flow_registryFunction
flow_registry() -> CTBase.Strategies.StrategyRegistry

Return the strategy registry for flow construction.

The registry maps abstract strategy families to their concrete implementations for automatic differentiation backends and ODE integrators.

Returns

  • CTBase.Strategies.StrategyRegistry: Registry with :di (DifferentiationInterface) and :sciml (SciML) strategies registered.

Notes

  • This registry is used by _route_flow_options to resolve and build concrete strategy instances from keyword arguments.
  • The registry is precomputed and cached in _FLOW_REGISTRY for performance.

See also: _route_flow_options, _build_flow_components, CTBase.Strategies.create_registry

hamiltonian_vector_field [Function]

CTFlows.Systems.hamiltonian_vector_fieldFunction
hamiltonian_vector_field(
    h::CTBase.Data.Hamiltonian{F, TD, VD};
    ad_backend,
    inplace
) -> CTBase.Data.HamiltonianVectorField

Get the Hamiltonian vector field from a scalar Hamiltonian function.

This function computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for a given scalar Hamiltonian function using automatic differentiation. The returned vector field is a closure with the correct signature based on the Hamiltonian's time and variable dependence traits.

Arguments

  • h::Data.Hamiltonian{F, TD, VD}: The scalar Hamiltonian function 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 closure (default: Common.__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 closure 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

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

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

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: Common.__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

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).

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

hamiltonian_vector_field(
    flow::CTFlows.Flows.Flow{TD, VD, CTBase.Traits.HamiltonianDynamics, <:CTFlows.Systems.HamiltonianSystem};
    inplace
) -> CTBase.Data.HamiltonianVectorField

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

hamiltonian_vector_field(
    flow::CTFlows.Flows.Flow{TD, VD, CTBase.Traits.HamiltonianDynamics, <:CTFlows.Systems.HamiltonianVectorFieldSystem}
) -> 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

integrator [Function]

CTFlows.Flows.integratorFunction
integrator(
    flow::CTFlows.Flows.AbstractFlow
) -> CTFlows.Integrators.AbstractIntegrator

Return the associated AbstractIntegrator for the flow.

Throws

  • CTBase.Exceptions.NotImplemented: If not implemented by the concrete type.

See also: CTFlows.Flows.AbstractFlow, CTFlows.Integrators.AbstractIntegrator.

integrator(f::CTFlows.Flows.Flow{TD, VD, D, S, I}) -> Any

Return the integrator associated with a Flow.

See also: CTFlows.Flows.Flow, CTFlows.Flows.system.

integrator(mpsf::CTFlows.MultiPhase.MultiPhaseFlow) -> Any

Return the integrators associated with a multi-phase flow as a tuple.

See also: CTFlows.Flows.integrator.

system [Function]

CTFlows.Flows.systemFunction
system(flow::CTFlows.Flows.AbstractFlow)

Return the associated AbstractSystem for the flow.

Throws

  • CTBase.Exceptions.NotImplemented: If not implemented by the concrete type.

See also: CTFlows.Flows.AbstractFlow, CTFlows.Systems.AbstractSystem.

system(f::CTFlows.Flows.Flow{TD, VD, D, S, I}) -> Any

Return the system associated with a Flow.

See also: CTFlows.Flows.Flow, CTFlows.Flows.integrator.

system(mpsf::CTFlows.MultiPhase.MultiPhaseFlow) -> Any

Return the systems associated with a multi-phase flow as a tuple.

See also: CTFlows.Flows.system.