Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
22a29ce
Implement Bloch Sphere rendering
Fe-r-oz May 28, 2025
248f268
make format done
Fe-r-oz May 28, 2025
e272bdf
add tests
Fe-r-oz May 28, 2025
00266d5
solve JET error
Fe-r-oz May 28, 2025
9482c63
add codereview suggestions
Fe-r-oz May 29, 2025
eaf01a5
add codereview suggestions
Fe-r-oz May 29, 2025
545c9b9
Update ext/QuantumToolboxMakieExt.jl
Fe-r-oz Jun 2, 2025
3511c0a
Merge branch 'qutip:main' into fa/resolve
Fe-r-oz Jun 2, 2025
8ee40eb
add codereview suggestions
Fe-r-oz Jun 2, 2025
6ec3223
Update ext/QuantumToolboxMakieExt.jl
Fe-r-oz Jun 2, 2025
2cf634d
Update docs/make.jl
Fe-r-oz Jun 2, 2025
e8472ae
Update src/visualization.jl
Fe-r-oz Jun 2, 2025
ff9f97b
Update docs/src/users_guide/plotting_the_bloch_sphere.md
Fe-r-oz Jun 2, 2025
c4cb201
Update docs/src/users_guide/extensions/cairomakie.md
Fe-r-oz Jun 2, 2025
06e9bed
Update src/visualization.jl
Fe-r-oz Jun 2, 2025
d20a08e
add codereview suggestions
Fe-r-oz Jun 2, 2025
a2aa46c
fix CI errors and add some enhancments
Fe-r-oz Jun 4, 2025
fd3241e
Merge branch 'qutip:main' into fa/resolve
Fe-r-oz Jun 4, 2025
7593f0b
add changelog and polish documentation/tests
Fe-r-oz Jun 4, 2025
6055f6c
remove the font family
Fe-r-oz Jun 4, 2025
14d50f4
add review suggestions
Fe-r-oz Jun 4, 2025
e6d93bb
Merge branch 'fa/resolve' of https://github.com/Fe-r-oz/QuantumToolbo…
Fe-r-oz Jun 4, 2025
2542fbb
add codereview suggestions
Fe-r-oz Jun 4, 2025
351954a
make format changes
Fe-r-oz Jun 4, 2025
ad30f0f
minor polish
Fe-r-oz Jun 4, 2025
6edf90d
Update src/visualization.jl
Fe-r-oz Jun 4, 2025
20933e0
Update src/visualization.jl
Fe-r-oz Jun 4, 2025
fe446e7
fixup
Fe-r-oz Jun 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const PAGES = [
],
"Manipulating States and Operators" => "users_guide/states_and_operators.md",
"Tensor Products and Partial Traces" => "users_guide/tensor.md",
"Bloch Sphere Rendering" => "users_guide/plotting_the_bloch_sphere.md",
"Time Evolution and Dynamics" => [
"Introduction" => "users_guide/time_evolution/intro.md",
"Time Evolution Solutions" => "users_guide/time_evolution/solution.md",
Expand Down
3 changes: 2 additions & 1 deletion docs/src/users_guide/extensions/cairomakie.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | [Plotting on the Bloch Sphere](https://qutip.readthedocs.io/en/stable/guide/guide-bloch.html) |
102 changes: 102 additions & 0 deletions docs/src/users_guide/plotting_the_bloch_sphere.md
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)

```@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
```
Loading
Loading