Private API
This page lists non-exported (internal) symbols of CTFlows.Systems.
From CTFlows.Systems
HamIpAugRHS [Struct]
CTFlows.Systems.HamIpAugRHS — Type
struct HamIpAugRHS{F, TD, VD, B, CX, CP} <: CTFlows.Systems.AbstractIPHamRHSIn-place augmented RHS functor for Hamiltonian systems with variable costate.
This functor extends the standard Hamiltonian equations to include the variable costate evolution, used in sensitivity analysis and optimal control:
ẋ = ∂H/∂p
ṗ = -∂H/∂x
ṽ = -∂H/∂vThe state vector is augmented as [x; p; v] where v is the variable costate.
Fields
h::Data.Hamiltonian{F,TD,VD}: The Hamiltonian function.backend::B: The AD backend for gradient computation.n_x::Int: State dimension (number of state variables).n_v::Int: Variable dimension.cache::C: Pre-allocated AD cache (ornothingfor systems without AD).
Call Signature
(f::HamIpAugRHS)(du, u, λ, t)du: Output vector (mutated in-place).u: Augmented state vector[x; p; v].λ: ODE parameters containing the variable value.t: Time (for non-autonomous systems).
Notes
- Supports batch mode with matrix inputs (checks batch size compatibility).
- The AD cache is embedded in the functor for better composability.
- This functor is created by
CTFlows.Systems.build_rhs_augmentedfor Hamiltonian systems.
See also: CTFlows.Systems.HamIpRHS, CTFlows.Systems.HamOoPRHS.
HamIpRHS [Struct]
CTFlows.Systems.HamIpRHS — Type
struct HamIpRHS{F, TD, VD, B, CX, CP} <: CTFlows.Systems.AbstractIPHamRHSIn-place RHS functor for Hamiltonian systems with automatic differentiation.
This functor wraps a Hamiltonian and AD backend to compute the Hamiltonian gradient in-place, following the canonical Hamiltonian equations:
ẋ = ∂H/∂p
ṗ = -∂H/∂xFields
h::Data.Hamiltonian{F,TD,VD}: The Hamiltonian function.backend::B: The AD backend for gradient computation.N::Int: State dimension (number of state variables).cx::CX: State conversion function.cp::CP: Costate conversion function.cache::C: Pre-allocated AD cache (ornothingfor systems without AD).
Call Signature
(f::HamIpRHS)(du, u, λ, t)du: Output vector (mutated in-place).u: State vector[x; p](concatenated state and costate).λ: ODE parameters containing the variable value.t: Time (for non-autonomous systems).
Notes
- The AD cache is embedded in the functor for better composability.
- This functor is created by
CTFlows.Systems.build_rhsfor Hamiltonian systems.
See also: CTFlows.Systems.HamOoPRHS, CTFlows.Systems.HamIpAugRHS.
HamOoPRHS [Struct]
CTFlows.Systems.HamOoPRHS — Type
struct HamOoPRHS{F, TD, VD, B, CX, CP} <: CTFlows.Systems.AbstractOoPHamRHSOut-of-place RHS functor for Hamiltonian systems with automatic differentiation.
This functor wraps a Hamiltonian and AD backend to compute the Hamiltonian gradient out-of-place, following the canonical Hamiltonian equations:
ẋ = ∂H/∂p
ṗ = -∂H/∂xFields
h::Data.Hamiltonian{F,TD,VD}: The Hamiltonian function.backend::B: The AD backend for gradient computation.N::Int: State dimension (number of state variables).cx::CX: State conversion function.cp::CP: Costate conversion function.cache::C: Pre-allocated AD cache (ornothingfor systems without AD).
Call Signature
(f::HamOoPRHS)(u, λ, t) -> duu: State vector[x; p](concatenated state and costate).λ: ODE parameters containing the variable value.t: Time (for non-autonomous systems).- Returns: Output vector
du = [∂p; -∂x].
Notes
- The AD cache is embedded in the functor for better composability.
- This functor is created by
CTFlows.Systems.build_oop_rhsfor Hamiltonian systems.
See also: CTFlows.Systems.HamIpRHS, CTFlows.Systems.HamIpAugRHS.
IPHVFIpAugRHS [Struct]
CTFlows.Systems.IPHVFIpAugRHS — Type
IPHVFIpAugRHS{F,TD,VD} <: AbstractIPHVFRHSIn-place augmented RHS functor for an in-place HamiltonianVectorField.
Wraps an in-place HamiltonianVectorField and provides an in-place interface for the augmented system (state + costate + variable costate).
Fields
hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.n_x::Int: State dimension.n_v::Int: Variable costate dimension.
Call signature
(f::IPHVFIpAugRHS)(du, u, λ, t) -> nothing
IPHVFIpRHS [Struct]
CTFlows.Systems.IPHVFIpRHS — Type
IPHVFIpRHS{F,TD,VD,CX,CP} <: AbstractIPHVFRHSIn-place RHS functor for an in-place HamiltonianVectorField.
Wraps an in-place HamiltonianVectorField and provides an in-place interface by directly calling the function with pre-allocated buffers.
Fields
hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.N::Int: State dimension.cx::CX: Coercion function for state (e.g.,identityoronly).cp::CP: Coercion function for costate (e.g.,identityoronly).
Call signature
(f::IPHVFIpRHS)(du, u, λ, t) -> nothing
IPHVFOoPAugRHS [Struct]
CTFlows.Systems.IPHVFOoPAugRHS — Type
IPHVFOoPAugRHS{F,TD,VD} <: AbstractIPHVFRHSIn-place augmented RHS functor for an out-of-place HamiltonianVectorField.
Wraps an out-of-place HamiltonianVectorField and provides an in-place interface for the augmented system (state + costate + variable costate).
Fields
hvf::HamiltonianVectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped vector field.n_x::Int: State dimension.n_v::Int: Variable costate dimension.
Call signature
(f::IPHVFOoPAugRHS)(du, u, λ, t) -> nothing
IPHVFOoPRHS [Struct]
CTFlows.Systems.IPHVFOoPRHS — Type
IPHVFOoPRHS{F,TD,VD,CX,CP} <: AbstractIPHVFRHSIn-place RHS functor for an out-of-place HamiltonianVectorField.
Wraps an out-of-place HamiltonianVectorField and provides an in-place interface by allocating the result into the pre-allocated du buffer.
Fields
hvf::HamiltonianVectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped vector field.N::Int: State dimension.cx::CX: Coercion function for state (e.g.,identityoronly).cp::CP: Coercion function for costate (e.g.,identityoronly).
Call signature
(f::IPHVFOoPRHS)(du, u, λ, t) -> nothing
IPVFIpRHS [Struct]
CTFlows.Systems.IPVFIpRHS — Type
IPVFIpRHS{F,TD,VD} <: AbstractIPRHSIn-place RHS functor for an in-place VectorField.
Wraps an in-place VectorField and provides an in-place interface by directly calling the VectorField.
Fields
vf::Data.VectorField{F,TD,VD,Traits.InPlace}: The wrapped VectorField
Call signature
(f::IPVFIpRHS)(du, u, λ, t) -> nothing
IPVFOoPRHS [Struct]
CTFlows.Systems.IPVFOoPRHS — Type
IPVFOoPRHS{F,TD,VD} <: AbstractIPRHSIn-place RHS functor for an out-of-place VectorField.
Wraps an out-of-place VectorField and provides an in-place interface by allocating the result into the pre-allocated du buffer.
Fields
vf::Data.VectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped VectorField
Call signature
(f::IPVFOoPRHS)(du, u, λ, t) -> nothing
OoPHVFIpFinalizeRHS [Struct]
CTFlows.Systems.OoPHVFIpFinalizeRHS — Type
OoPHVFIpFinalizeRHS{F,TD,VD,CX,CP} <: AbstractOoPHVFRHSOut-of-place RHS functor for an in-place HamiltonianVectorField with type conversion.
Wraps an in-place HamiltonianVectorField and provides an out-of-place interface that converts the result to match the input type (e.g., Vector → SVector).
Fields
hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.N::Int: State dimension.cx::CX: Coercion function for state (e.g.,identityoronly).cp::CP: Coercion function for costate (e.g.,identityoronly).
Call signature
(f::OoPHVFIpFinalizeRHS)(u, λ, t) -> du
OoPHVFIpRHS [Struct]
CTFlows.Systems.OoPHVFIpRHS — Type
OoPHVFIpRHS{F,TD,VD,CX,CP} <: AbstractOoPHVFRHSOut-of-place RHS functor for an in-place HamiltonianVectorField.
Wraps an in-place HamiltonianVectorField and provides an out-of-place interface by allocating temporary buffers on each call.
Fields
hvf::HamiltonianVectorField{F,TD,VD,Traits.InPlace}: The wrapped vector field.N::Int: State dimension.cx::CX: Coercion function for state (e.g.,identityoronly).cp::CP: Coercion function for costate (e.g.,identityoronly).
Call signature
(f::OoPHVFIpRHS)(u, λ, t) -> du
OoPHVFOoPRHS [Struct]
CTFlows.Systems.OoPHVFOoPRHS — Type
OoPHVFOoPRHS{F,TD,VD,CX,CP} <: AbstractOoPHVFRHSOut-of-place RHS functor for an out-of-place HamiltonianVectorField.
Wraps an out-of-place HamiltonianVectorField and provides an out-of-place interface by directly calling the function and concatenating the results.
Fields
hvf::HamiltonianVectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped vector field.N::Int: State dimension.cx::CX: Coercion function for state (e.g.,identityoronly).cp::CP: Coercion function for costate (e.g.,identityoronly).
Call signature
(f::OoPHVFOoPRHS)(u, λ, t) -> du
OoPVFIpFinalizeRHS [Struct]
CTFlows.Systems.OoPVFIpFinalizeRHS — Type
OoPVFIpFinalizeRHS{F,TD,VD} <: AbstractOoPRHSOut-of-place RHS functor for an in-place VectorField with type conversion.
Wraps an in-place VectorField and provides an out-of-place interface that converts the result to match the input type (e.g., Vector → SVector).
Fields
vf::Data.VectorField{F,TD,VD,Traits.InPlace}: The wrapped VectorField
Call signature
(f::OoPVFIpFinalizeRHS)(u, λ, t) -> du
OoPVFIpRHS [Struct]
CTFlows.Systems.OoPVFIpRHS — Type
OoPVFIpRHS{F,TD,VD} <: AbstractOoPRHSOut-of-place RHS functor for an in-place VectorField.
Wraps an in-place VectorField and provides an out-of-place interface by allocating a temporary buffer on each call.
Fields
vf::Data.VectorField{F,TD,VD,Traits.InPlace}: The wrapped VectorField
Call signature
(f::OoPVFIpRHS)(u, λ, t) -> du
OoPVFOoPRHS [Struct]
CTFlows.Systems.OoPVFOoPRHS — Type
OoPVFOoPRHS{F,TD,VD} <: AbstractOoPRHSOut-of-place RHS functor for an out-of-place VectorField.
Wraps an out-of-place VectorField and provides an out-of-place interface by directly calling the VectorField.
Fields
vf::Data.VectorField{F,TD,VD,Traits.OutOfPlace}: The wrapped VectorField
Call signature
(f::OoPVFOoPRHS)(u, λ, t) -> du
_aug_assign! [Function]
CTFlows.Systems._aug_assign! — Function
_aug_assign!(
du::AbstractVector,
dx,
dp,
dpv,
n_x::Int64,
n_v::Int64
) -> Any
Assign derivatives to the augmented derivative vector for Hamiltonian systems with variable costate.
The augmented derivative vector has the form [dx; dp; dpv] where:
dxis the state derivative (firstn_xelements)dpis the costate derivative (nextn_xelements)dpvis the variable costate derivative (lastn_velements)
Arguments
du::AbstractVector: Augmented derivative vector to fill[dx; dp; dpv].dx: State derivative.dp: Costate derivative.dpv: Variable costate derivative.n_x::Int: State dimension.n_v::Int: Variable dimension.
Returns
nothing.
Notes
- Performs in-place assignment using broadcasting.
- For matrix inputs, broadcasts over columns.
- Used internally by
CTFlows.Systems.HamIpAugRHS.
See also: CTFlows.Systems._aug_split, CTFlows.Systems.HamIpAugRHS.
_aug_split [Function]
CTFlows.Systems._aug_split — Function
_aug_split(
u::AbstractVector,
n_x::Int64,
n_v::Int64
) -> Tuple{Any, Any, Any}
Split an augmented state vector into state, costate, and variable costate components.
The augmented state vector has the form [x; p; pv] where:
xis the state (firstn_xelements)pis the costate (nextn_xelements)pvis the variable costate (lastn_velements)
Arguments
u::AbstractVector: Augmented state vector[x; p; pv].n_x::Int: State dimension.n_v::Int: Variable dimension.
Returns
Tuple:(x, p, pv)where each component is a@viewslice.
Notes
- Always returns views (never scalars), consistent with
_ham_split. - For matrix inputs, returns column views.
- Used internally by
CTFlows.Systems.HamIpAugRHS.
See also: CTFlows.Systems._aug_assign!, CTFlows.Systems.HamIpAugRHS.
_check_aug_batch_compat [Function]
CTFlows.Systems._check_aug_batch_compat — Function
Check batch size compatibility for augmented Hamiltonian RHS with matrix inputs.
When using batch mode with matrix inputs, ensures that the state matrix u and variable matrix v have compatible batch sizes (same number of columns).
Arguments
u::AbstractMatrix: State matrix with shape(n, batch_size).v::AbstractMatrix: Variable matrix with shape(m, batch_size).
Returns
nothingif batch sizes match.
Throws
Exceptions.PreconditionError: Ifsize(u, 2) ≠ size(v, 2).
Notes
- No-op for non-matrix inputs (vectors or scalars).
- Used internally by
CTFlows.Systems.HamIpAugRHSto validate batch mode.
See also: CTFlows.Systems.HamIpAugRHS, CTFlows.Systems._aug_split.
No-op version of batch compatibility check for non-matrix inputs.
Arguments
u: State input (vector or scalar).v: Variable input (vector or scalar).
Returns
nothing.
Notes
- Used as fallback when inputs are not matrices.
- See
CTFlows.Systems._check_aug_batch_compat(::AbstractMatrix, ::AbstractMatrix)for the matrix version.
_check_vf_scalar_inplace [Function]
CTFlows.Systems._check_vf_scalar_inplace — Function
_check_vf_scalar_inplace(sys::VectorFieldSystem{F, TD, VD, Traits.InPlace}, u0::Number)Raise an error if an in-place vector field is used with a scalar initial condition. This combination is unsupported because in-place functions require mutable arrays.
Arguments
sys::VectorFieldSystem: The vector field system.u0: The initial condition.
Throws
ArgumentErrorifsysis in-place andu0is a scalar.
_ham_assign! [Function]
CTFlows.Systems._ham_assign! — Function
_ham_assign!(du::AbstractVector, dx, dp, N::Int64) -> Any
Assign derivatives dx and dp to the combined derivative du for Hamiltonian systems.
Dispatches on the array type (AbstractVector or AbstractMatrix) and the known dimension N (or nothing for runtime inference).
Arguments
du::AbstractVectororAbstractMatrix: Combined derivative to fill[dx; dp].dx: State derivative (same shape as state part ofdu).dp: Costate derivative (same shape as costate part ofdu).N::Intornothing: State dimension. Ifnothing, infers assize(du, 1) ÷ 2.
Returns
nothing
Notes
- Internal helper used by RHS builders for Hamiltonian systems.
- Performs in-place assignment using broadcasting.
_ham_split [Function]
CTFlows.Systems._ham_split — Function
_ham_split(u::AbstractVector, N::Int64) -> Tuple{Any, Any}
Split a combined state u into state x and costate p views for Hamiltonian systems.
Dispatches on the array type (AbstractVector or AbstractMatrix) and the known dimension N (or nothing for runtime inference).
Arguments
u::AbstractVectororAbstractMatrix: Combined state vector/matrix[x; p].N::Intornothing: State dimension. Ifnothing, infers assize(u, 1) ÷ 2.
Returns
Tuple: Tuple of views(x_view, p_view)where:- For vectors:
x_view = @view(u[1:N]),p_view = @view(u[N+1:2N]) - For matrices:
x_view = @view(u[1:N, :]),p_view = @view(u[N+1:2N, :])
- For vectors:
Notes
- Internal helper used by RHS builders for Hamiltonian systems.
- The
CTFlowsStaticArraysextension provides a type-stable method forStaticVector.
Type-stable split of a SVector into state and costate components.
Arguments
u::SVector: Combined state vector[x; p].N::Int: Known state dimension (compile-time).
Returns
Tuple{SVector{N}, SVector{N}}: Tuple of(x, p)asSVectors.
Notes
- This method provides type stability for SciML's out-of-place ODE solvers when using
StaticArrays. - Used automatically when the
CTFlowsStaticArraysextension is loaded.
Type-stable split of a SMatrix into state and costate components.
Arguments
u::SMatrix{NN,M,T}: Combined state matrix stacked vertically[X; P].N::Int: Known state dimension.
Returns
Tuple{SMatrix{N,M,T}, SMatrix{N,M,T}}: Tuple of(X, P)asSMatrixs.
Notes
- This method provides type stability for SciML's out-of-place ODE solvers when using
StaticArraysfor matrix initial conditions. - Constructs new
SMatrixobjects since views don't work with immutable static arrays. - Uses 1D column-major linear indexing to enumerate elements: for result element
k(1-based), row =(k-1) % N + 1, col =(k-1) ÷ N + 1. - Used automatically when the
CTFlowsStaticArraysextension is loaded.
_make_ip_hvf [Function]
CTFlows.Systems._make_ip_hvf — Function
_make_ip_hvf(
h,
backend,
_::Type{CTBase.Traits.Autonomous},
_::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##0#_make_ip_hvf##1"
Create an in-place Hamiltonian vector field closure for the Autonomous/Fixed case.
The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with fixed parameters, writing the result in-place. The signature is (dx, dp, x, p) -> nothing and fills dx .= ∂p, dp .= -∂x.
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.
Returns
Function: A closure(dx, dp, x, p) -> nothingthat fills the output arrays in-place.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - The closure uses automatic differentiation via the provided backend to compute gradients.
- Output arrays
dxanddpmust be pre-allocated with the correct dimensions.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient
_make_ip_hvf(
h,
backend,
_::Type{CTBase.Traits.NonAutonomous},
_::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##2#_make_ip_hvf##3"
Create an in-place Hamiltonian vector field closure for the NonAutonomous/Fixed case.
The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with fixed parameters, writing the result in-place. The signature is (dx, dp, t, x, p) -> nothing and fills dx .= ∂p, dp .= -∂x.
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.
Returns
Function: A closure(dx, dp, t, x, p) -> nothingthat fills the output arrays in-place.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - The closure uses automatic differentiation via the provided backend to compute gradients.
- Output arrays
dxanddpmust be pre-allocated with the correct dimensions.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient
_make_ip_hvf(
h,
backend,
_::Type{CTBase.Traits.Autonomous},
_::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##4#_make_ip_hvf##5"{CTFlows.Systems.var"#_make_ip_hvf##6#_make_ip_hvf##7"{h, backend}} where {h, backend}
Create an in-place Hamiltonian vector field closure for the Autonomous/NonFixed case.
The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with variable parameters, writing the result in-place. The signature is (dx, dp, x, p, v) -> nothing and fills dx .= ∂p, dp .= -∂x.
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.
Returns
Function: A closure(dx, dp, x, p, v; dpv=nothing, variable_costate=false) -> nothingthat fills the output arrays in-place.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - The closure uses automatic differentiation via the provided backend to compute gradients.
- Output arrays
dxanddpmust be pre-allocated with the correct dimensions. - When
variable_costate=true,dpvmust be a pre-allocated mutable array matching the shape ofv; it is filled with-∂H/∂v.
Throws
Exceptions.PreconditionError: Whenvariable_costate=true && dpv === nothing.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient
_make_ip_hvf(
h,
backend,
_::Type{CTBase.Traits.NonAutonomous},
_::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_ip_hvf##8#_make_ip_hvf##9"{CTFlows.Systems.var"#_make_ip_hvf##10#_make_ip_hvf##11"{h, backend}} where {h, backend}
Create an in-place Hamiltonian vector field closure for the NonAutonomous/NonFixed case.
The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with variable parameters, writing the result in-place. The signature is (dx, dp, t, x, p, v) -> nothing and fills dx .= ∂p, dp .= -∂x.
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.
Returns
Function: A closure(dx, dp, t, x, p, v; dpv=nothing, variable_costate=false) -> nothingthat fills the output arrays in-place.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - The closure uses automatic differentiation via the provided backend to compute gradients.
- Output arrays
dxanddpmust be pre-allocated with the correct dimensions. - When
variable_costate=true,dpvmust be a pre-allocated mutable array matching the shape ofv; it is filled with-∂H/∂v.
Throws
Exceptions.PreconditionError: Whenvariable_costate=true && dpv === nothing.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient
_make_oop_hvf [Function]
CTFlows.Systems._make_oop_hvf — Function
_make_oop_hvf(
h,
backend,
_::Type{CTBase.Traits.Autonomous},
_::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##0#_make_oop_hvf##1"
Create an out-of-place Hamiltonian vector field closure for the Autonomous/Fixed case.
The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with fixed parameters. The signature is (x, p) -> (∂p, -∂x).
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.- `::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.
::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.
Returns
Function: A closure(x, p) -> (∂p, -∂x)computing the Hamiltonian vector field.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - The closure uses automatic differentiation via the provided backend to compute gradients.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient
_make_oop_hvf(
h,
backend,
_::Type{CTBase.Traits.NonAutonomous},
_::Type{CTBase.Traits.Fixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##2#_make_oop_hvf##3"
Create an out-of-place Hamiltonian vector field closure for the NonAutonomous/Fixed case.
The closure computes the Hamiltonian vector field X_H = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with fixed parameters. The signature is (t, x, p) -> (∂p, -∂x).
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.::Type{Traits.Fixed}: Type parameter indicating fixed variable dependence.
Returns
Function: A closure(t, x, p) -> (∂p, -∂x)computing the Hamiltonian vector field.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - The closure uses automatic differentiation via the provided backend to compute gradients.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient
_make_oop_hvf(
h,
backend,
_::Type{CTBase.Traits.Autonomous},
_::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##4#_make_oop_hvf##5"{CTFlows.Systems.var"#_make_oop_hvf##6#_make_oop_hvf##7"{h, backend}} where {h, backend}
Create an out-of-place Hamiltonian vector field closure for the Autonomous/NonFixed case.
The closure computes the Hamiltonian vector field XH = (∂H/∂p, -∂H/∂x) for an autonomous Hamiltonian system with variable parameters. The signature is `(x, p, v; variablecostate=false) -> (∂p, -∂x)or(x, p, v; variable_costate=true) -> (∂p, -∂x, -∂v)` when the variable costate is requested.
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.::Type{Traits.Autonomous}: Type parameter indicating autonomous time dependence.::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.
Returns
Function: A closure(x, p, v; variable_costate=false)computing the Hamiltonian vector field.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - When
variable_costate=true, the closure also returns-∂H/∂v(the negative gradient with respect to variables). - The closure uses automatic differentiation via the provided backend to compute gradients.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient
_make_oop_hvf(
h,
backend,
_::Type{CTBase.Traits.NonAutonomous},
_::Type{CTBase.Traits.NonFixed}
) -> CTFlows.Systems.var"#_make_oop_hvf##8#_make_oop_hvf##9"{CTFlows.Systems.var"#_make_oop_hvf##10#_make_oop_hvf##11"{h, backend}} where {h, backend}
Create an out-of-place Hamiltonian vector field closure for the NonAutonomous/NonFixed case.
The closure computes the Hamiltonian vector field XH = (∂H/∂p, -∂H/∂x) for a non-autonomous Hamiltonian system with variable parameters. The signature is `(t, x, p, v; variablecostate=false) -> (∂p, -∂x)or(t, x, p, v; variable_costate=true) -> (∂p, -∂x, -∂v)` when the variable costate is requested.
Arguments
h::Data.Hamiltonian: The scalar Hamiltonian function.backend::Differentiation.AbstractADBackend: The AD backend for gradient computation.::Type{Traits.NonAutonomous}: Type parameter indicating non-autonomous time dependence.::Type{Traits.NonFixed}: Type parameter indicating non-fixed variable dependence.
Returns
Function: A closure(t, x, p, v; variable_costate=false)computing the Hamiltonian vector field.
Notes
- This is an internal factory function used by
CTFlows.Systems.hamiltonian_vector_field. - When
variable_costate=true, the closure also returns-∂H/∂v(the negative gradient with respect to variables). - The closure uses automatic differentiation via the provided backend to compute gradients.
See also: CTFlows.Systems.hamiltonian_vector_field, CTBase.Differentiation.hamiltonian_gradient, CTBase.Differentiation.variable_gradient
_rhs_conversion_label [Function]
CTFlows.Systems._rhs_conversion_label — Function
Return a descriptive label for the RHS conversion performed by a Hamiltonian functor.
Arguments
f::AbstractHamRHS: The Hamiltonian RHS functor.
Returns
String: Description of the conversion (e.g., "Hamiltonian AD → in-place interface").
Notes
- Used internally by
Base.showfor display. - Different functors have different conversion labels.
See also: CTFlows.Systems.AbstractHamRHS, CTFlows.Systems.HamIpRHS, CTFlows.Systems.HamOoPRHS.
_state_dim [Function]
CTFlows.Systems._state_dim — Function
_state_dim(x0::Number) = 1
_state_dim(x0::AbstractVector) = length(x0)
_state_dim(x0::AbstractMatrix) = size(x0, 1)Infer the state dimension from the initial condition shape.