PiccoloPlots.jl
PiccoloPlots.jl is designed to hold plotting recipes for the Piccolo.jl package. It utilzes the plot
method of the NamedTrajectories.jl
.
Installation
PiccoloPlots.jl can be installed using the Julia package manager. From the Julia REPL, type ]
to enter the Pkg REPL mode and run:
julia> ] add PiccoloPlots
Usage
As a simple example, we provide the plot_unitary_populations
function which plots the populations of select columns of the unitary matrix. This can be employed as follows:
using NamedTrajectories
using PiccoloQuantumObjects
using PiccoloPlots
# Define the Hamiltonian H = X + a_1(t)Z + a_2(t)Y
H_drift = PAULIS[:X]
H_drives = [PAULIS[:Z], PAULIS[:Y]]
# Generate control trajectory
N = 100
Δt = 0.1
ts = collect(0:Δt:Δt*(N-1))
a = 0.1 * randn(length(H_drives), length(ts))
# Generate the unitaries
Us = exp.(-im * [(H_drift + sum(a[:, k] .* H_drives)) * ts[k] for k = 1:N])
# Create a NamedTrajectory
traj = NamedTrajectory(
(
Ũ⃗ = hcat(operator_to_iso_vec.(Us)...),
a = a,
Δt = ts,
);
controls = :a,
timestep = :Δt,
)
# Plot the populations of the first and second qubits
plot_unitary_populations(traj)
Building Documentation
This package uses a Documenter config that is shared with many of our other repositories. To build the docs, you will need to run the docs setup script to clone and pull down the utility.
# first time only
./docs/get_docs_utils.sh # or ./get_docs_utils.sh if cwd is in ./docs/
To build the docs pages:
julia --project=docs docs/make.jl
or editing the docs live:
julia --project=docs
> using LiveServer, PiccoloPlots, Revise
> servedocs(literate_dir="docs/literate", skip_dirs=["docs/src/generated", "docs/src/assets/"], skip_files=["docs/src/index.md"])
Note:
servedocs
needs to watch a subset of the files in thedocs/
folder. If it watches files that are generated on a docs build/re-build,servedocs
will continuously try to re-serve the pages.To prevent this, ensure all generated files are included in the skip dirs or skip files args for
servedocs
.
For example, if we forget index.md like so:
julia --project=docs
> using LiveServer, PiccoloPlots, Revise
> servedocs(literate_dir="docs/literate", skip_dirs=["docs/src/generated", "docs/src/assets/"])
it will not build and serve.
"It seems that perfection is attained not when there is nothing more to add, but when there is nothing more to take away." - Antoine de Saint-Exupéry