First order analysis
Looking at the code, it appears like this ACME.jl simulation uses a constant time step of Ts=1/44100
, and it is driven by a 1kHz
sinusoidal source.
Clean up code a bit
To start off, I would slightly modify your inputs for readability purposes:
fs = 44100 #Hz - should be integer value.
fsig = 1000 #Hz - pick integer value to ensure whole periods are simulated.
Tsim = 1 #sec - pick integer value to ensure whole periods of fsig are simulated.
Tsim = round(Int, Tsim) #Recommendation: always simulate for whole periods
Nsamples = round(Int, Tsim*fs) - 1 # "-1" generates "cleaner" fft() results
t = (0:Nsamples)'/fs
model = DiscreteModel(circ, 1/fs)
y = run!(model, sin.(2π*f .* t))
Plotting
For your first run, I suggest using Plots.jl. It seems to be the most popular on this forum, so more people can help you. It also supports multiple backends, so you can just switch to a different one by adding a single command later on. Here is the plotting code:
using Plots
plot(t', y')
NOTE: ACME.jl appears to use row vectors, whereas Plots.jl expects column vectors. That’s why you need to plot the transpose of t & y.
Switching backend
To switch backends, you simply select the desired backend after importing Plots.jl:
using Plots
inspectdr() #Select InspectDR backend instead of default (GR)
plot(t', y')
Other Plots.jl backends are listed here:
→ Backends · Plots
But for interactive circuit analysis, I suggest you use try out my own InspectDR backend. It was designed with exploring simulation results in mind:
- Large datasets.
- Mostly for functions of 1 argument (ex: voltage vs time; gain vs frequency, …)
- Quickly pan/zoom using bindkeys/mouse bindings.
- …
InspectDR repo (with link to sample plots):
→ https://github.com/ma-laforge/InspectDR.jl
Listing of bindkeys:
→ InspectDR.jl/input_bindings.md at master · ma-laforge/InspectDR.jl · GitHub