-
Notifications
You must be signed in to change notification settings - Fork 31
Implement Bloch Sphere rendering #472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
22a29ce
248f268
e272bdf
00266d5
9482c63
eaf01a5
545c9b9
3511c0a
8ee40eb
6ec3223
2cf634d
e8472ae
ff9f97b
c4cb201
06e9bed
d20a08e
a2aa46c
fd3241e
7593f0b
6055f6c
14d50f4
e6d93bb
2542fbb
351954a
ad30f0f
6edf90d
20933e0
fe446e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,5 @@ The supported plotting functions are listed as follows: | |
| | **Plotting Function** | **Description** | | ||
| |:----------------------|:----------------| | ||
| | [`plot_wigner`](@ref) | [Wigner quasipropability distribution](https://en.wikipedia.org/wiki/Wigner_quasiprobability_distribution) | | ||
| | [`plot_fock_distribution`](@ref) | [Fock state](https://en.wikipedia.org/wiki/Fock_state) distribution | | ||
| | [`plot_fock_distribution`](@ref) | [Fock state](https://en.wikipedia.org/wiki/Fock_state) distribution | | ||
| | [`plot_bloch`](@ref) | [Qutip's Plotting on the Bloch Sphere](https://qutip.readthedocs.io/en/stable/guide/guide-bloch.html) | | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # [Plotting on the Bloch Sphere](@id doc: plotting_the_bloch_sphere.md) | ||
Fe-r-oz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```@setup Bloch_sphere_rendering | ||
| using QuantumToolbox | ||
| using Makie | ||
|
||
| using CairoMakie | ||
| CairoMakie.enable_only_mime!(MIME"image/svg+xml"()) | ||
| ``` | ||
|
|
||
| ## [Introduction](@id doc:Bloch_sphere_rendering) | ||
|
|
||
| When studying the dynamics of a two-level system, it's often convenient to visualize the state of the system by plotting the state vector or density matrix on the Bloch sphere. | ||
|
|
||
| In [QuantumToolbox.jl](https://qutip.org/QuantumToolbox.jl/), this can be done using the [`Bloch`](@ref) or [`plot_bloch`](@ref) methods that provide same syntax as [QuTiP](https://github.com/qutip/qutip). | ||
|
||
|
|
||
| ## Create a Bloch Sphere | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| b = Bloch(); | ||
| fig, _ = render(b) | ||
| ``` | ||
|
|
||
| ## Add a Single Data Point | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| pnt = [1 / sqrt(3), 1 / sqrt(3), 1 / sqrt(3)] | ||
| add_points!(b, pnt) | ||
| fig, _ = render(b) | ||
| fig | ||
| ``` | ||
|
|
||
| ## Add a Single Vector | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| clear!(b) | ||
| vec = [0, 1, 0]; | ||
| add_vectors!(b, vec) | ||
| fig, _ = render(b) | ||
| fig | ||
| ``` | ||
|
|
||
| ## Add Multiple Vectors | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| clear!(b) | ||
| vecs = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] | ||
| add_vectors!(b, vecs) | ||
| fig, _ = render(b) | ||
| fig | ||
| ``` | ||
|
|
||
| # Add Arc, Line, and Vector | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| clear!(b) | ||
| vec = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; | ||
| add_vectors!(b, vec); | ||
| add_line!(b, [1,0,0], [0,1,0]) | ||
| add_arc!(b, [1, 0, 0], [0, 1, 0], [0, 0, 1]) | ||
| fig, _ = render(b) | ||
| fig | ||
| ``` | ||
|
|
||
| # Add Quantum States | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| clear!(b) | ||
| x = basis(2, 0) + basis(2, 1) | ||
| y = basis(2, 0) - im * basis(2, 1) | ||
| z = basis(2, 0) | ||
| b = Bloch() | ||
| add_states!(b, [x, y, z]) | ||
| fig, _ = render(b) | ||
| fig | ||
| ``` | ||
|
|
||
| ## Add Multiple Points Around the Equator | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| th = range(0, 2π; length=20); | ||
| clear!(b) | ||
| xp = cos.(th); | ||
| yp = sin.(th); | ||
| zp = zeros(20); | ||
| pnts = [xp, yp, zp] ; | ||
| pnts = Matrix(hcat(xp, yp, zp)'); | ||
| add_points!(b, pnts); | ||
| fig, ax = render(b); | ||
| fig | ||
| ``` | ||
|
|
||
| ## Add Another Set of Points | ||
|
|
||
| ```@example Bloch_sphere_rendering | ||
| xz = zeros(20); | ||
| yz = sin.(th); | ||
| zz = cos.(th); | ||
| points = hcat(xz, yz, zz)'; | ||
| add_points!(b, Matrix(points), meth=:s, color="orange"); | ||
| fig, ax = render(b); | ||
| fig | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.