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_solutions — Functiontransform_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)
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_solutions — Functionplot_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 ofResult. Only solutions which belong to the listed classes are plotted.marker_classification: A class of the solutions (created byclassify_solutions!) which is distinguished with different markers. Entering an inequality creates a new class "custom_class".filename: if different fromnothing, 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.
HarmonicBalance.plot_1D_jacobian_eigenvalues — Functionplot_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 fromPyCall.PyObjectsetting the coordinate system where data will be plotted. If not given, it is created automatically.filename: if different fromnothing, plotted data and parameter values are exported to./filename.jld2. Otherwise, data is returned as a dictionary.
HarmonicBalance.plot_2D_solutions — Functionplot_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 fromPyCall.PyObjectsetting the coordinate system where data will be plotted. If not given, it is created automatically.filename: if different fromnothing, 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). Ifz=nothing, raw solutions are displayedplot_only: Array of labels to filter physical solutions (e.g. "stable") and multi-solution methods ifz!=nothing(e.g. maximum)
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_diagram — Functionplot_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 depictedobservable: reference observable to represent dynamical phases in the problem. Ifobservable="nsols", number of solutions for each point is shown. If insteadobservable="binary", the result of classification of bistrings[is_stable(solution_1),is_stable(solution_2),...]is presented (seeclassify_binaries!(Result)function).filename: if different fromnothing, plotted data and parameter values are exported to./filename.jld2.Otherwise, data is returned as a dictionary.
HarmonicBalance.plot_2D_phase_diagram_interactive — Functionplot_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. Ifobservable="nsols", number of solutions for each point is shown. If insteadobservable="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. Ifcut_type=solutions, steady state variables are shown with a panel perProblemvariable. Else ifcut_type=jacobian eigenvalues, Re and Im parts of complex Jacobian eigenvalues for each solution are shown with a panel per solution. If insteadcut_type=transform, functions of the solution variables passed tostring_f(see below) are displayed.string_f: list of strings for transformed observables to be plotted in 1D whencut_type=transform, e.g.string_f=["sqrt(u1^2 + v1^2)","sqrt(u2^2 + v2^2)"]forProblemvariablesu1,u2,v1,v2.marker_classification: A class of the solutions (created byclassify_solutions!) which is distinguished with different markers. Entering an inequality creates a new class "custom_class".ylim: vertical limits for 1D cuts