-
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
22a29ce
Implement Bloch Sphere rendering
Fe-r-oz 248f268
make format done
Fe-r-oz e272bdf
add tests
Fe-r-oz 00266d5
solve JET error
Fe-r-oz 9482c63
add codereview suggestions
Fe-r-oz eaf01a5
add codereview suggestions
Fe-r-oz 545c9b9
Update ext/QuantumToolboxMakieExt.jl
Fe-r-oz 3511c0a
Merge branch 'qutip:main' into fa/resolve
Fe-r-oz 8ee40eb
add codereview suggestions
Fe-r-oz 6ec3223
Update ext/QuantumToolboxMakieExt.jl
Fe-r-oz 2cf634d
Update docs/make.jl
Fe-r-oz e8472ae
Update src/visualization.jl
Fe-r-oz ff9f97b
Update docs/src/users_guide/plotting_the_bloch_sphere.md
Fe-r-oz c4cb201
Update docs/src/users_guide/extensions/cairomakie.md
Fe-r-oz 06e9bed
Update src/visualization.jl
Fe-r-oz d20a08e
add codereview suggestions
Fe-r-oz a2aa46c
fix CI errors and add some enhancments
Fe-r-oz fd3241e
Merge branch 'qutip:main' into fa/resolve
Fe-r-oz 7593f0b
add changelog and polish documentation/tests
Fe-r-oz 6055f6c
remove the font family
Fe-r-oz 14d50f4
add review suggestions
Fe-r-oz e6d93bb
Merge branch 'fa/resolve' of https://github.com/Fe-r-oz/QuantumToolbo…
Fe-r-oz 2542fbb
add codereview suggestions
Fe-r-oz 351954a
make format changes
Fe-r-oz ad30f0f
minor polish
Fe-r-oz 6edf90d
Update src/visualization.jl
Fe-r-oz 20933e0
Update src/visualization.jl
Fe-r-oz fe446e7
fixup
Fe-r-oz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # [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 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://qutip.readthedocs.io/en/stable/guide/guide-bloch.html). | ||
|
|
||
| ## 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 | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.