Extracting Solutions
After computing the steady-states of the harmonic equations, you'll want to extract the solutions from the HarmonicBalance.Result
struct.
Basic Solution Extraction
For plotting, you can extract the solutions using the get_solutions
function, which parses a string into a symbolic expression, evaluates it for every steady state solution and filters the solutions by the requested class.
HarmonicBalance.get_solutions Function
get_solutions(
res::Result, x::String;
branches=1:branch_count(res), realify=false, class=["stable"], not_class=[]
)
get_solutions(res::Result; branches=1:branch_count(res), class=["stable"], not_class=[])
Extract solution vectors from a Result
object based on specified filtering criteria given by the class
keywords. The first method allows extracting a specific solution component by name x
. The second method returns complete solution vectors.
Keyword arguments
branches=1:branch_count(res)
: Range of branches to include in the outputrealify=false
: Whether to convert complex solutions to real formclass=["physical", "stable"]
: Array of classification labels to includenot_class=[]
: Array of classification labels to exclude
Returns
Filtered solution vectors matching the specified criteria
sourceHarmonicBalance.get_single_solution Function
get_single_solution(
res::HarmonicBalance.Result{D, S, P, F} where F<:FunctionWrappers.FunctionWrapper{Array{S, 2}, Tuple{Array{S, 1}}};
branch,
index
)
Return an ordered dictionary specifying all variables and parameters of the solution in result
on branch
at the position index
.
Attractors
HarmonicBalance.attractors Function
attractors(res::Result{D}; class="stable", not_class=[]) where D
Extract attractors from a Result
object. Returns an array of dictionaries, where each dictionary maps branch identifier to the attractor. The attractors are filtered by their corresponding class.
Keyword arguments
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
Returns
Array{Dict,D}
: Vector of dictionaries mapping branch indices to points satisfying the stability criteria at each parameter value
HarmonicBalance.phase_diagram Function
phase_diagram(res::Result{D}; class="physical", not_class=[]) where {D}
Calculate the phase diagram from a Result
object by summing over the number of states at each swept parameters.
Keyword arguments
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
Returns
- Array{Int64,D}: Sum of states after applying the specified class masks
classifying solutions
HarmonicBalance.classify_solutions! Function
classify_solutions!(
res::HarmonicBalance.Result,
func::Union{Function, String},
name::String;
physical
) -> Any
Creates a solution class in res
using the function func
(parsed into Symbolics.jl input). The new class is labeled with name
and stored under res.classes[name]
. By default, only physical (real) solutions are classified, and false
is returned for the rest. To also classify complex solutions, set physical=false
.
Example
# solve a previously-defined problem
res = get_steady_states(problem, swept_parameters, fixed_parameters)
# classify, store in result.classes["large_amplitude"]
classify_solutions!(res, "sqrt(u1^2 + v1^2) > 1.0" , "large_amplitude")
HarmonicBalance.get_class Function
get_class(
res::HarmonicBalance.Result,
branch::Int64,
class::String
) -> Any
Returns an array of booleans classifying branch
in the solutions in res
according to class
.
get_class(
soln::HarmonicBalance.Result,
class::String
) -> Vector
Returns an array of booleans classifying each branch in the solutions in res
according to class
.
HarmonicBalance.filter_result! Function
filter_result!(res::HarmonicBalance.Result, class::String)
Removes all solution branches from res
where NONE of the solution falls into class
. Typically used to filter out unphysical solutions to prevent huge file sizes.