Skip to content

Commit 90906ef

Browse files
LorenzoFioronialbertomercurio
authored andcommitted
Update documentation to reflect changes in Wigner function plotting and computation
1 parent 82553ca commit 90906ef

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

docs/src/tutorials/logo.md

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,16 @@ Next, we construct the triangular cat state as a normalized superposition of thr
6767
normalize!(ψ)
6868
```
6969

70-
### Defining the Grid and calculating the Wigner function
70+
### Defining the Grid and plotting the Wigner function
7171

72-
We define the grid for the Wigner function and calculate it using the [`wigner`](@ref) function. We shift the grid in the imaginary direction to ensure that the Wigner function is centered around the origin of the figure. The [`wigner`](@ref) function also supports the `g` scaling factor, which we put here equal to ``2``.
72+
We define the grid for the Wigner function and plot it using the [`plot_wigner`](@ref) function. This, internally calls the [`wigner`](@ref) function for the computation. We shift the grid in the imaginary direction to ensure that the Wigner function is centered around the origin of the figure. The [`wigner`](@ref) function also supports the `g` scaling factor, which we put here equal to ``2``.
7373

7474
```@example logo
7575
xvec = range(-ρ, ρ, 500) .* 1.5
7676
yvec = xvec .+ (abs(imag(α1)) - abs(imag(α2))) / 2
7777
78-
wig = wigner(ψ, xvec, yvec, g = 2)
79-
```
80-
81-
### Plotting the Wigner function
82-
83-
Finally, we plot the Wigner function using the `heatmap` function from the `CairoMakie` package.
84-
85-
```@example logo
8678
fig = Figure(size = (250, 250), figure_padding = 0)
87-
ax = Axis(fig[1, 1])
88-
heatmap!(ax, xvec, yvec, wig', colormap = :RdBu, interpolate = true, rasterize = 1)
79+
fig, ax, hm = plot_wigner(ψ, library = Val(:CairoMakie), xvec = xvec, yvec = yvec, g = 2, location = fig[1,1])
8980
hidespines!(ax)
9081
hidexdecorations!(ax)
9182
hideydecorations!(ax)
@@ -118,12 +109,8 @@ nothing # hide
118109
And the Wigner function becomes more uniform:
119110

120111
```@example logo
121-
wig = wigner(sol.states[end], xvec, yvec, g = 2)
122-
123112
fig = Figure(size = (250, 250), figure_padding = 0)
124-
ax = Axis(fig[1, 1])
125-
126-
img_wig = heatmap!(ax, xvec, yvec, wig', colormap = :RdBu, interpolate = true, rasterize = 1)
113+
fig, ax, hm = plot_wigner(sol.states[end], library = Val(:CairoMakie), xvec = xvec, yvec = yvec, g = 2, location = fig[1,1])
127114
hidespines!(ax)
128115
hidexdecorations!(ax)
129116
hideydecorations!(ax)
@@ -135,7 +122,7 @@ At this stage, we have finished to use the `QuantumToolbox` package. From now on
135122

136123
### Custom Colormap
137124

138-
We define a custom colormap that changes depending on the Wigner function and spatial coordinates. Indeed, we want the three different colormaps, in the regions corresponding to the three coherent states, to match the colors of the Julia logo. We also want the colormap change to be smooth, so we use a Gaussian function to blend the colors. We introduce also a Wigner function dependent transparency to make the logo more appealing.
125+
We define a custom colormap that changes depending on the Wigner function and spatial coordinates. Indeed, we want the three different colormaps, in the regions corresponding to the three coherent states, to match the colors of the Julia logo. We also want the colormap change to be smooth, so we use a Gaussian function to blend the colors. We introduce also a Wigner function dependent transparency to make the logo more appealing. In order to do so, we are going to need the value of the wigner function at each point of the grid, rather than its plot. We will thus call the [`wigner`](@ref) function directly.
139126

140127
```@example logo
141128
function set_color_julia(x, y, wig::T, α1, α2, α3, cmap1, cmap2, cmap3, δ) where {T}
@@ -156,6 +143,7 @@ function set_color_julia(x, y, wig::T, α1, α2, α3, cmap1, cmap2, cmap3, δ) w
156143
return RGBAf(c_tot.r, c_tot.g, c_tot.b, alpha)
157144
end
158145
146+
wig = wigner(sol.states[end], xvec, yvec, g = 2)
159147
X, Y = meshgrid(xvec, yvec)
160148
δ = 1.25 # Smoothing parameter for the Gaussian functions
161149
```

0 commit comments

Comments
 (0)