Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Introduce `Lanczos` solver for `spectrum`. ([#476])
- Add Bloch-Redfield master equation solver. ([#473])
- Implement Bloch Sphere rendering and align style with qutip. ([#472], [#480], [#485], [#487])
- Implement Bloch Sphere rendering and align style with qutip. ([#472], [#480], [#485], [#487], [#489])
- Add `Base.copy` method for `AbstractQuantumObject`. ([#486])

## [v0.31.1]
Expand Down Expand Up @@ -240,3 +240,4 @@ Release date: 2024-11-13
[#485]: https://github.com/qutip/QuantumToolbox.jl/issues/485
[#486]: https://github.com/qutip/QuantumToolbox.jl/issues/486
[#487]: https://github.com/qutip/QuantumToolbox.jl/issues/487
[#489]: https://github.com/qutip/QuantumToolbox.jl/issues/489
3 changes: 2 additions & 1 deletion docs/src/users_guide/plotting_the_bloch_sphere.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ At the end of the last section we saw that the colors and marker shapes of the d
|:----------|:----------------|:--------------------|
| `b.font_color` | Color of axis labels and text | `"black"` |
| `b.font_size` | Font size for labels | `20` |
| `b.frame_alpha` | Transparency of the wire frame | `0.1` |
| `b.frame_alpha` | Transparency of the wire frame | `0.2` |
| `b.frame_color` | Color of the wire frame | `"gray"` |
| `b.frame_width` | Width of wire frame | `1.0` |
| `b.point_default_color` | Default color cycle for points | `["blue", "red", "green", "#CC6600"]` |
| `b.point_color` | List of colors for Bloch point markers to cycle through | `Union{Nothing,String}[]` |
| `b.point_marker` | List of point marker shapes to cycle through | `[:circle, :rect, :diamond, :utriangle]` |
Expand Down
26 changes: 10 additions & 16 deletions ext/QuantumToolboxMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@

# highlight circles for XY and XZ planes
φ = range(0, 2π, length = 100)
lines!(lscene, [Point3f(cos(φi), sin(φi), 0) for φi in φ]; color = b.frame_color, linewidth = 1.0) # XY
lines!(lscene, [Point3f(cos(φi), 0, sin(φi)) for φi in φ]; color = b.frame_color, linewidth = 1.0) # XZ
lines!(lscene, [Point3f(cos(φi), sin(φi), 0) for φi in φ]; color = b.frame_color, linewidth = b.frame_width) # XY
lines!(lscene, [Point3f(cos(φi), 0, sin(φi)) for φi in φ]; color = b.frame_color, linewidth = b.frame_width) # XZ

# other curves of longitude (with polar angle φ and azimuthal angle θ)
φ_curve = range(0, 2π, 600)
Expand All @@ -424,7 +424,7 @@
x_line = radius * sin.(φ_curve) .* cos(θi)
y_line = radius * sin.(φ_curve) .* sin(θi)
z_line = radius * cos.(φ_curve)
lines!(lscene, x_line, y_line, z_line; color = b.frame_color, alpha = b.frame_alpha)
lines!(lscene, x_line, y_line, z_line; color = b.frame_color, alpha = b.frame_alpha, linewidth = b.frame_width)
end

# other curves of latitude (with polar angle φ and azimuthal angle θ)
Expand All @@ -434,7 +434,7 @@
x_ring = radius * sin(ϕ) .* cos.(θ_curve)
y_ring = radius * sin(ϕ) .* sin.(θ_curve)
z_ring = fill(radius * cos(ϕ), length(θ_curve))
lines!(lscene, x_ring, y_ring, z_ring; color = b.frame_color, alpha = b.frame_alpha)
lines!(lscene, x_ring, y_ring, z_ring; color = b.frame_color, alpha = b.frame_alpha, linewidth = b.frame_width)
end
return nothing
end
Expand Down Expand Up @@ -558,14 +558,11 @@
end
end
if style in (:s, :m)
xs = raw_x[indperm]
ys = raw_y[indperm]
zs = raw_z[indperm]
scatter!(
lscene,
xs,
ys,
zs;
raw_x[indperm],
raw_y[indperm],
raw_z[indperm];
color = colors,
markersize = b.point_size[mod1(k, length(b.point_size))],
marker = marker,
Expand All @@ -575,11 +572,8 @@
)

elseif style == :l
xs = raw_x
ys = raw_y
zs = raw_z
c = isa(colors, Vector) ? colors[1] : colors
lines!(lscene, xs, ys, zs; color = c, linewidth = 2.0, transparency = alpha < 1.0, alpha = alpha)
lines!(lscene, raw_x, raw_y, raw_z; color = c, transparency = alpha < 1.0, alpha = alpha)

Check warning on line 576 in ext/QuantumToolboxMakieExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/QuantumToolboxMakieExt.jl#L576

Added line #L576 was not covered by tests
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove the linewidth here so that Makie can automatically decide for us.

end
end
return nothing
Expand Down Expand Up @@ -613,7 +607,7 @@
else
:solid
end
lines!(lscene, x, y, z; color = color, linewidth = 1.0, linestyle = linestyle)
lines!(lscene, x, y, z; color = color, linestyle = linestyle)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove the linewidth here so that Makie can automatically decide for us.

end
return nothing
end
Expand Down Expand Up @@ -643,7 +637,7 @@
end
t_range = range(0, θ, length = 100)
arc_points = [Point3f((v1 * cos(t) + cross(n, v1) * sin(t))) for t in t_range]
lines!(lscene, arc_points; color = RGBAf(0.8, 0.4, 0.1, 0.9), linewidth = 2.0, linestyle = :solid)
lines!(lscene, arc_points; color = "blue", linestyle = :solid)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the default color of arcs to blue (align with qutip).

Also, I remove the linewidth here so that Makie can automatically decide for us.

end
return nothing
end
Expand Down
28 changes: 15 additions & 13 deletions src/visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,31 @@ A structure representing a Bloch sphere visualization for quantum states. Availa

## Style properties

- `font_color::String`: Color of axis labels and text
- `font_color::String`: Color of axis labels and text. Default: `"black"`
- `font_size::Int`: Font size for labels. Default: `20`
- `frame_alpha::Float64`: Transparency of the wire frame
- `frame_color::String`: Color of the wire frame
- `frame_alpha::Float64`: Transparency of the wire frame. Default: `0.2`
- `frame_color::String`: Color of the wire frame. Default: `"gray"`
- `frame_width::Float64` : Width of wire frame. Default: `1.0`

## Point properties

- `point_default_color::Vector{String}}`: Default color cycle for points
- `point_color::Vector{String}}`: List of colors for Bloch point markers to cycle through
- `point_default_color::Vector{String}}`: Default color cycle for points. Default: `["blue", "red", "green", "#CC6600"]`
- `point_color::Vector{String}}`: List of colors for Bloch point markers to cycle through. Default: `Union{Nothing,String}[]`
- `point_marker::Vector{Symbol}}`: List of point marker shapes to cycle through. Default: `[:circle, :rect, :diamond, :utriangle]`
- `point_size::Vector{Int}}`: List of point marker sizes (not all markers look the same size when plotted)
- `point_style::Vector{Symbol}}`: List of marker styles
- `point_alpha::Vector{Float64}}`: List of marker transparencies
- `point_size::Vector{Int}}`: List of point marker sizes (not all markers look the same size when plotted). Default: `[5.5, 6.2, 6.5, 7.5]`
- `point_style::Vector{Symbol}}`: List of marker styles. Default: `Symbol[]`
- `point_alpha::Vector{Float64}}`: List of marker transparencies. Default: `Float64[]`

## Sphere properties

- `sphere_color::String`: Color of Bloch sphere surface
- `sphere_color::String`: Color of Bloch sphere surface. Default: `"#FFDDDD"`
- `sphere_alpha::Float64`: Transparency of sphere surface. Default: `0.2`

## Vector properties

- `vector_color::Vector{String}`: Colors for vectors
- `vector_width::Float64`: Width of vectors
- `vector_arrowsize::Vector{Float64}`: Scales the size of the arrow head. The first two elements scale the radius (in `x/y` direction) and the last one is the length of the cone.
- `vector_color::Vector{String}`: Colors for vectors. Default: `["green", "#CC6600", "blue", "red"]`
- `vector_width::Float64`: Width of vectors. Default: `0.025`
- `vector_arrowsize::Vector{Float64}`: Scales the size of the arrow head. The first two elements scale the radius (in `x/y` direction) and the last one is the length of the cone. Default: `[0.07, 0.08, 0.08]`

## Layout properties

Expand All @@ -124,8 +125,9 @@ A structure representing a Bloch sphere visualization for quantum states. Availa
arcs::Vector{Vector{Vector{Float64}}} = Vector{Vector{Vector{Float64}}}()
font_color::String = "black"
font_size::Int = 20
frame_alpha::Float64 = 0.1
frame_alpha::Float64 = 0.2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increase the frame_alpha to 0.2 (align with qutip)

frame_color::String = "gray"
frame_width::Float64 = 1.0
point_default_color::Vector{String} = ["blue", "red", "green", "#CC6600"]
point_color::Vector{Union{Nothing,String}} = Union{Nothing,String}[]
point_marker::Vector{Symbol} = [:circle, :rect, :diamond, :utriangle]
Expand Down
Loading