StructuralVibration.jl is accompanied by two extensions CairoMakieExt.jl and GLMakieExt.jl providing visualization capabilities. The extensions provide a set of functions to visualize the results of the structural dynamics analysis.
To use one of these extensions, you need to import the desired plotting package by running the following command:
using CairoMakie
# or
using GLMakie
Bode plot
A Bode plot is a graph of the magnitude and phase of a transfer function versus frequency.
bode_plot
bode_plot(freq, y...; lw = 1., xlab = "Frequency (Hz)",
ylab = "Magnitude (dB)", xscale = identity,
axis_tight = true, isdeg = false, layout = :vertical,
ref_dB = 1., legend = (active = false, position = :rt, entry = " "),
fonts = DEFAULT_MAKIE_FONTS)
Plot Bode diagram of a frequency response or a FRF.
Inputs
freq: Frequency range of interest
y: Frequency response or FRF
lw: Line width
theme: Theme (default: :makie)
xlab: x-axis label
xscale: x-axis scale (default: :log)
axis_tight: Tight axis (default: false)
isdeg: Phase in degrees (default: false)
layout: Layout of the plot (default: :vertical)
ref_dB: Reference value for magnitude (default: 1.)
legend: Legend parameters (default: (active = false, position = :rt, entry = " "))
fonts: Fonts of the figure (default: DEFAULT_MAKIE_FONTS)
Output
# Initialize a Sdof type
m = 1 .
f₀ = 10 .
ξ = 0.01
sdof = Sdof (m, f₀, ξ)
# Computation parameters
freq = 1 .: 0.01 : 30 .
# Compute the FRF
prob_frf = SdofFRFProblem (sdof, freq)
H = solve (prob_frf).u
# Bode plot
bode_plot (freq, H)
Nyquist plot
The Nyquist plot is either a 2D or 3D plot. In 2D, it is a graph of the imaginary part versus the real part of the transfer function. In 3D, it is a graph of the imaginary part versus the real part of the transfer function and the frequency.
2D plot
nyquist_plot
nyquist_plot(y; theme = :makie fonts = DEFAULT_MAKIE_FONTS)
Plot Nyquist diagram
Inputs
Output
3D plot
nyquist_plot
nyquist_plot(freq, y, xlab = "Frequency (Hz)"; theme = :makie,
projection = false, fonts = DEFAULT_MAKIE_FONTS)
Plot Nyquist diagram in 3D
Inputs
freq: Frequency range
y: Complex vector
ylabel: y-axis label
theme: Theme (default: :makie)
projection: Projection of the curve on the xy, yz, and xz planes (default: false)
on the xy plane: (freq, real(y))
on the yz plane: (imag(y), freq)
on the xz plane: (real(y), imag(y))
fonts: Fonts of the figure (default: DEFAULT_MAKIE_FONTS)
Output
nyquist_plot (freq, H, projection = true )
Waterfall plot
A waterfall plot is a 3D plot with a partial curtain along the y-axis.
waterfall_plot
waterfall_plot(x, y, z; zmin = minimum(z), lw = 1.,
colorline = :auto, colmap = :viridis, colorband = (:white, 1.),
xlabel = "x", ylabel = "y", zlabel = "z", edge = true,
axis_tight = false, xlim = [minimum(x), maximum(x)],
ylim = [minimum(y), maximum(y)], zlim = [zmin, maximum(z)],
fonts = DEFAULT_MAKIE_FONTS)
Plot a waterfall plot.
Inputs
x: x-axis values
y: y-axis values
z: z-axis values
zmin: minimum value of z-axis
lw::Real: linewidth
colorline: color of the lines
colmap: Name of the colormap
colorband: Tuple defining the color of the band
xlabel: x-axis label
ylabel: y-axis label
zlabel: z-axis label
edge: Display edges (default: true)
axis_tight: Tight axis (default: false)
xlim: x-axis limits
ylim: y-axis limits
zlim: z-axis limits
fonts: Fonts of the figure (default: DEFAULT_MAKIE_FONTS)
Output
x = range (0 ., 2 π, 100 )
y = range (0 ., 1 ., 5 )
nx = length (x)
ny = length (y)
z = zeros (ny, nx)
for i in eachindex (y)
z[i, : ] = sin .(i* x/ 2 .)
end
waterfall_plot (x, y, z, xlim = [- 0.1 , 2 π + 0.1 ], ylim = [- 0.1 , 1.1 ])
SV plot
The SV plot (for StructuralVibration plot ) is a general function for 2D plotting. It is a helper function aiming at simplifying the plotting process.
sv_plot
sv_plot(x, y...; lw = 1., theme = :makie, xscale = identity, yscale = identity,
axis_tight = true, xlabel = "x", ylabel = "y",
legend = (active = false, position = :rt, orientation = :vertical, entry = " "),
fonts = DEFAULT_MAKIE_FONTS)
Plot a 2D plot.
Inputs
x: x-axis values
y: y-axis values
lw: linewidth
theme: Theme (default: :makie)
xscale: x-axis scale (default: identity)
yscale: y-axis scale (default: identity)
axis_tight: Tight axis (default: true)
xlabel: x-axis label
ylabel: y-axis label
legend: Legend parameters
active : Bool
position : Symbol
entry : String
fonts: Fonts of the figure (default: DEFAULT_MAKIE_FONTS)
Output
x = range (0 ., 2 π, 100 )
z_sv = ntuple (i -> sin .(i* x/ 2 ), 5 )
# SV plot
sv_plot (x, z_sv... , lw = 2 ., legend = (active = true ,))