Public API
This page lists exported symbols of CTFlows.Flows.
From CTFlows.Flows
CTFlows.Flows [Module]
CTFlows.Flows — Module
FlowsFlow 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 integrationsystem: returns the system associated with the flowintegrator: returns the integrator used by the flow
AbstractFlow [Abstract Type]
CTFlows.Flows.AbstractFlow — Type
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 associatedAbstractSystem.integrator(flow::AbstractFlow): Return the associatedAbstractIntegrator.
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
trueSee also: CTFlows.Flows.Flow, CTFlows.Systems.AbstractSystem, CTFlows.Integrators.AbstractIntegrator.
AbstractHamiltonianFlow [Abstract Type]
CTFlows.Flows.AbstractHamiltonianFlow — Type
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
trueSee also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.AbstractStateFlow.
AbstractStateFlow [Abstract Type]
CTFlows.Flows.AbstractStateFlow — Type
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
trueSee also: CTFlows.Flows.AbstractFlow, CTFlows.Flows.AbstractHamiltonianFlow.
Flow [Struct]
CTFlows.Flows.Flow — Type
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 viaStateFlowalias)D = HamiltonianDynamics→ Hamiltonian flow (access viaHamiltonianFlowalias)
Type Parameters
TD <: TimeDependence: Time dependence trait (Autonomous or NonAutonomous)VD <: VariableDependence: Variable dependence trait (Fixed or NonFixed)D <: AbstractDynamicsTrait: Dynamics trait (StateDynamicsorHamiltonianDynamics)S <: AbstractSystem{TD, VD, D}: The system typeI <: AbstractIntegrator: The integrator type
Fields
system::S: The system to integrateintegrator::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]
CTFlows.Flows.HamiltonianFlow — Type
struct Flow{TD, VD, CTBase.Traits.HamiltonianDynamics, S, I} <: CTFlows.Flows.AbstractFlow{TD, VD, CTBase.Traits.HamiltonianDynamics}Alias for Hamiltonian flows: Flow{TD, VD, HamiltonianDynamics, S, I}.
See also: CTFlows.Flows.Flow, CTFlows.Flows.StateFlow.
StateFlow [Struct]
CTFlows.Flows.StateFlow — Type
struct Flow{TD, VD, CTBase.Traits.StateDynamics, S, I} <: CTFlows.Flows.AbstractFlow{TD, VD, CTBase.Traits.StateDynamics}Alias for state flows: Flow{TD, VD, StateDynamics, S, I}.
See also: CTFlows.Flows.Flow, CTFlows.Flows.HamiltonianFlow.
build_flow [Function]
CTFlows.Flows.build_flow — Function
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_registry — Function
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_optionsto resolve and build concrete strategy instances from keyword arguments. - The registry is precomputed and cached in
_FLOW_REGISTRYfor performance.
See also: _route_flow_options, _build_flow_components, CTBase.Strategies.create_registry
hamiltonian_vector_field [Function]
CTFlows.Systems.hamiltonian_vector_field — Function
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 traitsTD(time dependence) andVD(variable dependence).ad_backend: AD backend type (default:Differentiation.__ad_backend()=AutoForwardDiff()) or anAbstractADBackendinstance.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_backendis anAbstractADBackendinstance, it is used directly; otherwise it is wrapped viaDifferentiation.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)
- Autonomous/Fixed:
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 tosys.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.backendfor gradient computation. - The
inplaceparameter 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.
WithADsystems: computes the vector field via automatic differentiation usinghamiltonian(sys)andbackend(sys)(protocol methods the system must implement).WithoutADsystems: throwsNotImplemented— the system must implementhamiltonian_vector_fielddirectly (asHamiltonianVectorFieldSystemdoes).
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.integrator — Function
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.system — Function
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.