Skip to content
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

Added docstring for RydbergHamiltonian and hamiltonian method #990

Merged
merged 6 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions src/bloqade/emulate/ir/state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,20 @@ def tocsr(self, time: float) -> csr_matrix:

@dataclass(frozen=True)
class RydbergHamiltonian:
"""Hamiltonian for a given task.
With the `RydbergHamiltonian` you can convert the Hamiltonian to CSR matrix form
as well as obtaining the average energy/variance of a register.

Attributes:
emulator_ir (EmulatorProgram): A copy of the original program
used to generate the RydbergHamiltonian
space (Space): The Hilbert space of the Hamiltonian, should align with the register the
Hamiltonian is being applied on for average energy/variance
rydberg (NDArray): Rydberg interaction operator
detuning_ops (List[DetuningOperator]): Detuning Operators of the Hamiltonian
rabi_ops (List[RabiOperator]): Rabi Operators of the Hamiltonian
"""

emulator_ir: EmulatorProgram
space: Space
rydberg: NDArray
Expand Down
24 changes: 24 additions & 0 deletions src/bloqade/ir/routine/bloqade.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,31 @@ def hamiltonian(
waveform_runtime: str = "interpret",
cache_matrices: bool = False,
) -> List[BloqadeEmulation]:
"""
Generates a list of BloqadeEmulation objects which contain the Hamiltonian of your program.

If you have a variable(s) in your program you have assigned multiple values via `batch_assign()`
there will be multiple `BloqadeEmulation` objects, one for each value. On the other hand
if the program only assumes a singular value per each variable, there will only be
one `BloqadeEmulation` object but it will still be encapsulated in a list.


Args:
*args (LiteralType): If your program has a variable that was declared as run-time assignable
via `.args` you may pass a value to it here. If there are multiple
variables declared via `.args` the order in which you assign values to those variables
through this argument should follow the order in which the declaration occurred.
blockade_radius (float): The radius in which atoms blockade eachother. Default value is 0.0 micrometers.
use_hyperfine (bool): Should the Hamiltonian account for hyperfine levels. Default value is False.
waveform_runtime (str): Specify which runtime to use for waveforms. If "numba" is specify the waveform
is compiled, otherwise it is interpreted via the "interpret" argument. Defaults to "interpret".
cache_matrices (bool): Speed up Hamiltonian generation by reusing data (when possible) from previously generated Hamiltonians.
Default value is False.

Returns:
List[BloqadeEmulation]

"""
ir_iter = self._generate_ir(
args, blockade_radius, waveform_runtime, use_hyperfine
)
Expand Down