Vector Field

Index

Warning

In the examples in the documentation below, the methods are not prefixed by the module name even if they are private.

julia> using CTFlows
julia> x = 1
julia> private_fun(x) # throw an error

must be replaced by

julia> using CTFlows
julia> x = 1
julia> CTFlows.private_fun(x)

However, if the method is reexported by another package, then, there is no need of prefixing.

julia> module OptimalControl
           import CTFlows: private_fun
           export private_fun
       end
julia> using OptimalControl
julia> x = 1
julia> private_fun(x)

Documentation

CTFlows.FlowMethod
Flow(
    vf::CTFlows.VectorField;
    alg,
    abstol,
    reltol,
    saveat,
    internalnorm,
    kwargs_Flow...
) -> CTFlowsODE.VectorFieldFlow

Constructs a flow object for a classical (non-Hamiltonian) vector field.

This creates a VectorFieldFlow that integrates the ODE system dx/dt = vf(t, x, v) using DifferentialEquations.jl. It handles both fixed and parametric dynamics, as well as jump discontinuities and event stopping.

Keyword Arguments

  • alg, abstol, reltol, saveat, internalnorm: Solver options.
  • kwargs_Flow...: Additional arguments passed to the solver configuration.

Example

julia> vf(t, x, v) = -v * x
julia> flow = CTFlows.Flow(CTFlows.VectorField(vf))
julia> x1 = flow(0.0, 1.0, 1.0)
source
CTFlowsODE.vector_field_usageMethod
vector_field_usage(
    alg,
    abstol,
    reltol,
    saveat,
    internalnorm;
    kwargs_Flow...
) -> Any

Returns a function that solves the ODE associated with a classical vector field.

This utility creates a flow integrator for systems of the form dx/dt = f(t, x, v), where x is the state and v is an external parameter. It supports integration over a time span as well as direct queries for final state evaluation.

Two overloads are returned:

  • f(tspan, x0, v=default_variable; kwargs...) returns the full solution trajectory.
  • f(t0, x0, tf, v=default_variable; kwargs...) returns only the final state x(tf).

Internally uses OrdinaryDiffEq.solve, with support for stopping times and jump discontinuities.

Arguments

  • alg: Integration algorithm (e.g. Tsit5()).
  • abstol, reltol: Absolute and relative tolerances.
  • saveat: Output time step or vector of times.
  • internalnorm: Norm used for adaptive integration.
  • kwargs_Flow...: Default solver options (overridden by explicit kwargs at call site).

Example

julia> vf = (t, x, v) -> -v * x
julia> flowfun = vector_field_usage(Tsit5(), 1e-8, 1e-8, 0.1, norm)
julia> xf = flowfun(0.0, 1.0, 1.0, 2.0)
source