Skip to content

Analysis and plotting

The key method for visualization is transform_solutions, which parses a string into a symbolic expression and evaluates it for every steady state solution.

# HarmonicBalance.transform_solutionsFunction.
julia
transform_solutions(
    res::Result,
    func;
    branches,
    realify
) -> Vector

Takes a Result object and a string f representing a Symbolics.jl expression. Returns an array with the values of f evaluated for the respective solutions. Additional substitution rules can be specified in rules in the format ("a" => val) or (a => val)

source


Plotting solutions

The function plot is multiple-dispatched to plot 1D and 2D datasets. In 1D, the solutions are colour-coded according to the branches obtained by sort_solutions.

# RecipesBase.plotMethod.
julia
plot(res::Result, varargs...; cut, kwargs...) -> Plots.Plot

Plot a Result object.

Class selection done by passing String or Vector{String} as kwarg:

class       :   only plot solutions in this class(es) ("all" --> plot everything)
not_class   :   do not plot solutions in this class(es)

Other kwargs are passed onto Plots.gr().

See also plot!

The x,y,z arguments are Strings compatible with Symbolics.jl, e.g., y=2*sqrt(u1^2+v1^2) plots the amplitude of the first quadratures multiplied by 2.

1D plots

plot(res::Result; x::String, y::String, class="default", not_class=[], kwargs...)
plot(res::Result, y::String; kwargs...) # take x automatically from Result

Default behaviour is to plot stable solutions as full lines, unstable as dashed.

If a sweep in two parameters were done, i.e., dim(res)==2, a one dimensional cut can be plotted by using the keyword cut were it takes a Pair{Num, Float64} type entry. For example, plot(res, y="sqrt(u1^2+v1^2), cut=(λ => 0.2)) plots a cut at λ = 0.2.


2D plots

plot(res::Result; z::String, branch::Int64, class="physical", not_class=[], kwargs...)

To make the 2d plot less chaotic it is required to specify the specific branch to plot, labeled by a Int64.

The x and y axes are taken automatically from res

source


Plotting phase diagrams

In many problems, rather than in any property of the solutions themselves, we are interested in the phase diagrams, encoding the number of (stable) solutions in different regions of the parameter space. plot_phase_diagram handles this for 1D and 2D datasets.

# HarmonicBalance.plot_phase_diagramFunction.
julia
plot_phase_diagram(res::Result; kwargs...) -> Plots.Plot

Plot the number of solutions in a Result object as a function of the parameters. Works with 1D and 2D datasets.

Class selection done by passing String or Vector{String} as kwarg:

class::String       :   only count solutions in this class ("all" --> plot everything)
not_class::String   :   do not count solutions in this class

Other kwargs are passed onto Plots.gr()

source


Plot spaghetti plot

Sometimes, it is useful to plot the quadratures of the steady states (u, v) in function of a swept parameter. This is done with plot_spaghetti.

# HarmonicBalance.plot_spaghettiFunction.
julia
plot_spaghetti(res::Result; x, y, z, kwargs...)

Plot a three dimension line plot of a Result object as a function of the parameters. Works with 1D and 2D datasets.

Class selection done by passing String or Vector{String} as kwarg:

class::String       :   only count solutions in this class ("all" --> plot everything)
not_class::String   :   do not count solutions in this class

Other kwargs are passed onto Plots.gr()

source