Entering equations of motion

The struct DifferentialEquation is the primary input method; it holds an ODE or a coupled system of ODEs composed of terms with harmonic time-dependence The dependent variables are specified during input, any other symbols are identified as parameters. Information on which variable is to be expanded in which harmonic is specified using add_harmonic!.

DifferentialEquation.equations stores a dictionary assigning variables to equations. This information is necessary because the harmonics belonging to a variable are later used to Fourier-transform its corresponding ODE.

HarmonicBalance.DifferentialEquationType
mutable struct DifferentialEquation

Holds differential equation(s) of motion and a set of harmonics to expand each variable. This is the primary input for HarmonicBalance.jl ; after inputting the equations, the harmonics ansatz needs to be specified using add_harmonic!.

Fields

  • equations::OrderedCollections.OrderedDict{Symbolics.Num, Symbolics.Equation}

    Assigns to each variable an equation of motion.

  • harmonics::OrderedCollections.OrderedDict{Symbolics.Num, Vector{Symbolics.Num}}

    Assigns to each variable a set of harmonics.

Example

julia> @variables t, x(t), y(t), ω0, ω, F, k;

# equivalent ways to enter the simple harmonic oscillator
julia> DifferentialEquation(d(x,t,2) + ω0^2 * x - F * cos(ω*t), x);
julia> DifferentialEquation(d(x,t,2) + ω0^2 * x ~ F * cos(ω*t), x);

# two coupled oscillators, one of them driven
julia> DifferentialEquation([d(x,t,2) + ω0^2 * x - k*y, d(y,t,2) + ω0^2 * y - k*x] .~ [F * cos(ω*t), 0], [x,y]);
source
HarmonicBalance.add_harmonic!Function
add_harmonic!(diff_eom::DifferentialEquation, var::Symbolics.Num, ω) -> DifferentialEquation

Add the harmonic ω to the harmonic ansatz used to expand the variable var in diff_eom.

Example

define the simple harmonic oscillator and specify that x(t) oscillates with frequency ω

julia> @variables t, x(t), y(t), ω0, ω, F, k;
julia> diff_eq = DifferentialEquation(d(x,t,2) + ω0^2 * x ~ F * cos(ω*t), x);
julia> add_harmonic!(diff_eq, x, ω) # expand x using ω

System of 1 differential equations
Variables:       x(t)
Harmonic ansatz: x(t) => ω;   

(ω0^2)*x(t) + Differential(t)(Differential(t)(x(t))) ~ F*cos(t*ω)
source
Symbolics.get_variablesMethod
get_variables(diff_eom::DifferentialEquation) -> Vector{Symbolics.Num}

Return the dependent variables of diff_eom.

source