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
transform_solutions(res::Result, f::String; rules) -> Any

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

Any function of the steady state solutions may be plotted. In 1D, the solutions are colour-coded according to the branches obtained by sort_solutions.

HarmonicBalance.plot_1D_solutionsFunction
plot_1D_solutions(res::Result; 
                    x::String, y::String, 
                    xscale="linear",yscale="linear"
                    ,plot_only=["physical"],
                    marker_classification="stable",filename=nothing, kwargs...)

Make a 1D plot of a Result object.

Keyword arguments

  • x, y: Expressions to plot on as independent/dependent variables (parsed into Symbolics.jl).
  • xscale, yscale: scale for x/y dimensions (e.g. "linear" or "log")
  • plot_only: a list of strings corresponding to the solution classes of Result. Only solutions which belong to the listed classes are plotted.
  • marker_classification: A class of the solutions (created by classify_solutions!) which is distinguished with different markers. Entering an inequality creates a new class "custom_class".
  • filename: if different from nothing, plotted data and parameter values are exported to ./filename.jld2. Otherwise, data is returned as a dictionary.
  • kwargs: any additional keywords arguments for the matplotlib plotting

The strings in marker_classification allows the user to stablish custom criteria for binary classification of solutions. For instance, if marker_classification = "ω^15* sqrt(u1^2 + v1^2) < 0.1", for a system with harmonic variables u1,v1, then solutions are classified as true according to that criterion and false according to its complement.

source
HarmonicBalance.plot_1D_jacobian_eigenvaluesFunction
plot_1D_jacobian_eigenvalues(res::Result; x::String, physical=true, stable=false,marker_re="o",marker_im="X", filename=nothing,kwargs...)

Make a 1D plot of the Jacobian eigenvalues for each of the solutions in a Result object.

Keyword arguments

  • x: The function on the x axis (a string parsed into Symbolics.jl).
  • physical, stable: Booleans specifying whether unphysical and/or unstable solutions are shown.
  • marker_re, marker_im: The markers to use for the Re and Im parts of the eigenvalues.
  • ax: axis object from PyCall.PyObject setting the coordinate system where data will be plotted. If not given, it is created automatically.
  • filename: if different from nothing, plotted data and parameter values are exported to ./filename.jld2. Otherwise, data is returned as a dictionary.
source
HarmonicBalance.plot_2D_solutionsFunction
plot_2D_solutions(res::Result,ax=nothing; filename=nothing)

Make a 2D plot of each of solutions vs swept parameters for a Result object, obtained from a get_steady_states applied to a 2D parameter grid.`.

Keyword arguments

  • ax: axis object from PyCall.PyObject setting the coordinate system where data will be plotted. If not given, it is created automatically.
  • filename: if different from nothing, plotted data and parameter values are exported to ./filename.jld2. Otherwise, data is returned as a dictionary.
  • z: The function on the z axis (a string parsed into Symbolics.jl). If z=nothing, raw solutions are displayed
  • plot_only: Array of labels to filter physical solutions (e.g. "stable") and multi-solution methods if z!=nothing (e.g. maximum)
source

Plotting phase diagrams (2D)

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. We provide functions to tackle solutions calculated over 2D parameter grids.

HarmonicBalance.plot_2D_phase_diagramFunction
plot_2D_phase_diagram(res::Result; stable=false,observable="nsols",ax=nothing, filename=nothing)

Make a 2D phase diagram plot of each of solutions vs swept parameters for a Result object, obtained from a get_steady_states applied to a 2D parameter grid.

Keyword arguments

  • stable: whether only stable solutions are depicted
  • observable: reference observable to represent dynamical phases in the problem. If observable="nsols", number of solutions for each point is shown. If instead observable="binary", the result of classification of bistrings [is_stable(solution_1),is_stable(solution_2),...] is presented (see classify_binaries!(Result) function).
  • filename: if different from nothing, plotted data and parameter values are exported to ./filename.jld2.Otherwise, data is returned as a dictionary.
source
HarmonicBalance.plot_2D_phase_diagram_interactiveFunction
plot_2D_phase_diagram_interactive(res::Result;
 observable="nsols",
  stable=false,nrows=2,
  ncols=2,cut_dim="1",
  cut_type="solutions",
  string_f=nothing,
  marker_classification="stable")

Interactive phase diagram of 2D solutions stored in Result. This includes a clickable version of a plot_2D_phase_diagram for a given observable and extra panels containing 1D cuts of solutions, functions of solutions, or Jacobian eigenvalues.

Keyword arguments

  • observable: reference observable to represent dynamical phases in the problem. If observable="nsols", number of solutions for each point is shown. If instead observable="binary", the result of classification of bistrings[isstable(solution1),isstable(solution2),...]is presented (seeclassify_binaries!(Result)` function).
  • ncols, nrows: number of rows and columns of the plot window.
  • cut_dim: dimension along which 1D quantities will be calculated. cut_dim="1" (cut_dim="2") takes a cut along the horizontal (vertical) parameter dimension of the 2D plot.
  • cut_type: quantity to be represented along the 1D cut. If cut_type=solutions, steady state variables are shown with a panel per Problem variable. Else if cut_type=jacobian eigenvalues, Re and Im parts of complex Jacobian eigenvalues for each solution are shown with a panel per solution. If instead cut_type=transform, functions of the solution variables passed to string_f (see below) are displayed.
  • string_f: list of strings for transformed observables to be plotted in 1D when cut_type=transform, e.g. string_f=["sqrt(u1^2 + v1^2)","sqrt(u2^2 + v2^2)"] for Problem variables u1,u2,v1,v2.
  • marker_classification: A class of the solutions (created by classify_solutions!) which is distinguished with different markers. Entering an inequality creates a new class "custom_class".
  • ylim: vertical limits for 1D cuts
source