Skip to content

Makie bloch sphere extension #216

Draft
Aniket-umass wants to merge 3 commits intoqojulia:masterfrom
Aniket-umass:makie-bloch-extension
Draft

Makie bloch sphere extension #216
Aniket-umass wants to merge 3 commits intoqojulia:masterfrom
Aniket-umass:makie-bloch-extension

Conversation

@Aniket-umass
Copy link

This PR introduces a new Makie-based Bloch sphere visualization extension for QuantumOpticsBase.

Features:

  • blochsphere(state::Ket) renders the Bloch sphere for any spin-1/2 quantum state.
  • The Bloch vector is calculated directly from the Ket input.
  • Supports CairoMakie and GLMakie backends.
  • Sphere and arrows fully represent the quantum state.
  • Project.toml updated to include Makie as a weak dependency and an extension.

Testing:

  • Example: ( in julia )

using QuantumOpticsBase
using CairoMakie
include("ext/QuantumOpticsBaseMakieExt.jl")
using .QuantumOpticsBaseMakieExt
b = SpinBasis(1//2)
state = spinup(b)
f = blochsphere(state)

Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

Thanks, this is a good start!

Check the comments I left in.

A few other things:

  • this new functionality needs tests (check PBCCompiler.jl for an example of how to structure the tests)
  • and it needs docs
  • for ease of review, it would be helpful to post in the comments what a rendering looks like so we can discuss it before a full in-depth review.

@Krastanov Krastanov marked this pull request as draft February 2, 2026 20:39
@Krastanov
Copy link
Member

include("ext/QuantumOpticsBaseMakieExt.jl")

You should not include extensions manually. They are supposed to be loaded when the library is imported together with the weakdeps for the extension. Check out the details in the Pkg.jl manual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants