Skip to content

Extension to the SciML ecosystem

The SciML ecosystem provides a rich set of tools to solve (non)-linear equations, differential equations and inverse problems. We provide an interface (in the form of Package extensions) to export the the derived harmonic equations computed with harmonic balance method or krylov-bogoliubov method to the SciML ecosystem.

ModeligToolkit.jl

The ModelingToolkit.jl (MTK) package provides a symbolic framework for defining and simplifying mathematical models. Through, MTK SciML provides a symbolic interface for their ecosystem

SciMLBase.ODEProblem Method
julia
ODEProblem(
    eom::Union{DifferentialEquation, HarmonicEquation},
    u0,
    tspan::Tuple,
    p;
    in_place,
    kwargs...
) -> Any

Creates and ModelingToolkitBase.ODEProblem from a DifferentialEquation or HarmonicEquation.

The parameters p can be any map of symbolic variables to values: a Dict, or a Vector or Tuple of pairs. Whether the generated function is in-place is set with the in_place keyword or, equivalently, with the ODEProblem{iip} type parameter.

Example

julia
using ModelingToolkitBase, StaticArrays

@variables α ω ω0 F γ t x(t)
diff_eq = DifferentialEquation(
    d(x, t, 2) + ω0^2 * x + α * x^3 + γ * d(x, t) ~ F * cos* t), x
)
add_harmonic!(diff_eq, x, ω) #
harmonic_eq = get_harmonic_equations(diff_eq)

param ==> 1.0, ω0 => 1.1, F => 0.01, γ => 0.01, ω => 1.1)

# in place (most performant for large systems)
ODEProblem(harmonic_eq, [1.0, 0.0], (0, 100), param)

# out of place (most performant for small systems with StaticArrays)
ODEProblem(
    harmonic_eq, [1.0, 0.0], (0, 100), param;
    in_place=false, u0_constructor=x -> SVector(x...)
)

# the in-placeness can also be set with a type parameter
ODEProblem{false}(harmonic_eq, [1.0, 0.0], (0, 100), param)
source
ModelingToolkitBase.System Type
julia
System(eom::HarmonicEquation) -> System

Creates and ModelingToolkitBase.System from a HarmonicEquation.

Example

julia
using ModelingToolkitBase

@variables α ω ω0 F γ t x(t)
diff_eq = DifferentialEquation(
    d(x, t, 2) + ω0^2 * x + α * x^3 + γ * d(x, t) ~ F * cos* t), x
)
add_harmonic!(diff_eq, x, ω) #
harmonic_eq = get_harmonic_equations(diff_eq)

sys = System(harmonic_eq)
param ==> 1.0, ω0 => 1.1, F => 0.01, γ => 0.01, ω => 1.1)
ODEProblem(sys, [1.0, 0.0], (0, 100), param)
source
julia
System(diff_eq::DifferentialEquation) -> System

Creates and ModelingToolkitBase.System from a DifferentialEquation.

Example

julia
using ModelingToolkitBase

@variables α ω ω0 F γ t x(t)
diff_eq = DifferentialEquation(
    d(x, t, 2) + ω0^2 * x + α * x^3 + γ * d(x, t) ~ F * cos* t), x
)
sys = System(diff_eq)

param ==> 1.0, ω0 => 1.1, F => 0.01, γ => 0.01, ω => 1.1)

ODEProblem(sys, [1.0, 0.0], (0, 100), param)
source
SciMLBase.SteadyStateProblem Type
julia
SteadyStateProblem(
    eom::HarmonicEquation,
    u0,
    p;
    in_place,
    kwargs...
) -> Any

Creates and ModelingToolkitBase.SteadyStateProblem from a HarmonicEquation.

The parameters p can be any map of symbolic variables to values: a Dict, or a Vector or Tuple of pairs. Whether the generated function is in-place is set with the in_place keyword or, equivalently, with the SteadyStateProblem{iip} type parameter.

Example

julia
using ModelingToolkitBase, StaticArrays

@variables α ω ω0 F γ t x(t)
diff_eq = DifferentialEquation(
    d(x, t, 2) + ω0^2 * x + α * x^3 + γ * d(x, t) ~ F * cos* t), x
)
add_harmonic!(diff_eq, x, ω) #
harmonic_eq = get_harmonic_equations(diff_eq)


param ==> 1.0, ω0 => 1.1, F => 0.01, γ => 0.01, ω => 1.1)

SteadyStateProblem(harmonic_eq, [1.0, 0.0], param)
source
SciMLBase.NonlinearProblem Type
julia
NonlinearProblem(
    eom::HarmonicEquation,
    u0,
    p;
    in_place,
    kwargs...
) -> Any

Creates and ModelingToolkitBase.NonlinearProblem from a HarmonicEquation.

The parameters p can be any map of symbolic variables to values: a Dict, or a Vector or Tuple of pairs. Whether the generated function is in-place is set with the in_place keyword or, equivalently, with the NonlinearProblem{iip} type parameter.

Example

julia
using ModelingToolkitBase, StaticArrays

@variables α ω ω0 F γ t x(t)
diff_eq = DifferentialEquation(
    d(x, t, 2) + ω0^2 * x + α * x^3 + γ * d(x, t) ~ F * cos* t), x
)
add_harmonic!(diff_eq, x, ω) #
harmonic_eq = get_harmonic_equations(diff_eq)


param ==> 1.0, ω0 => 1.1, F => 0.01, γ => 0.01, ω => 1.1)

NonlinearProblem(harmonic_eq, [1.0, 0.0], param)
source