Skip to content

Location

AtomArrangement

AtomArrangement(parent: Optional[Builder] = None)

Bases: ProgramStart


              flowchart TD
              bloqade.analog.ir.location.location.AtomArrangement[AtomArrangement]
              bloqade.analog.builder.start.ProgramStart[ProgramStart]
              bloqade.analog.builder.drive.Drive[Drive]
              bloqade.analog.builder.base.Builder[Builder]
              bloqade.analog.builder.parse.trait.Parse[Parse]
              bloqade.analog.builder.parse.trait.ParseRegister[ParseRegister]
              bloqade.analog.builder.parse.trait.ParseSequence[ParseSequence]
              bloqade.analog.builder.parse.trait.ParseCircuit[ParseCircuit]
              bloqade.analog.builder.parse.trait.ParseRoutine[ParseRoutine]
              bloqade.analog.builder.parse.trait.Show[Show]

                              bloqade.analog.builder.start.ProgramStart --> bloqade.analog.ir.location.location.AtomArrangement
                                bloqade.analog.builder.drive.Drive --> bloqade.analog.builder.start.ProgramStart
                
                bloqade.analog.builder.base.Builder --> bloqade.analog.builder.start.ProgramStart
                                bloqade.analog.builder.parse.trait.Parse --> bloqade.analog.builder.base.Builder
                                bloqade.analog.builder.parse.trait.ParseRegister --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseSequence --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseCircuit --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseRoutine --> bloqade.analog.builder.parse.trait.Parse
                

                bloqade.analog.builder.parse.trait.Show --> bloqade.analog.builder.base.Builder
                




              click bloqade.analog.ir.location.location.AtomArrangement href "" "bloqade.analog.ir.location.location.AtomArrangement"
              click bloqade.analog.builder.start.ProgramStart href "" "bloqade.analog.builder.start.ProgramStart"
              click bloqade.analog.builder.drive.Drive href "" "bloqade.analog.builder.drive.Drive"
              click bloqade.analog.builder.base.Builder href "" "bloqade.analog.builder.base.Builder"
              click bloqade.analog.builder.parse.trait.Parse href "" "bloqade.analog.builder.parse.trait.Parse"
              click bloqade.analog.builder.parse.trait.ParseRegister href "" "bloqade.analog.builder.parse.trait.ParseRegister"
              click bloqade.analog.builder.parse.trait.ParseSequence href "" "bloqade.analog.builder.parse.trait.ParseSequence"
              click bloqade.analog.builder.parse.trait.ParseCircuit href "" "bloqade.analog.builder.parse.trait.ParseCircuit"
              click bloqade.analog.builder.parse.trait.ParseRoutine href "" "bloqade.analog.builder.parse.trait.ParseRoutine"
              click bloqade.analog.builder.parse.trait.Show href "" "bloqade.analog.builder.parse.trait.Show"
            
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/builder/base.py
10
11
12
13
14
def __init__(
    self,
    parent: Optional["Builder"] = None,
) -> None:
    self.__parent__ = parent

n_atoms property

n_atoms: int

number of atoms (filled sites) in the register.

n_dims property

n_dims: int

number of dimensions in the register.

n_sites property

n_sites: int

number of sites in the register.

n_vacant property

n_vacant: int

number of vacant sites in the register.

add_position

add_position(
    position: Union[
        PositionArray,
        List[Tuple[ScalarType, ScalarType]],
        Tuple[ScalarType, ScalarType],
    ],
    filling: Optional[
        Union[BoolArray, List[bool], bool]
    ] = None,
) -> ListOfLocations

Add a position or multiple positions to a pre-existing geometry.

add_position is capable of accepting: - A single tuple for one atom coordinate: (1.0, 2.5) - A list of tuples: `[(0.0, 1.0), (2.0,1.5), etc.] - A numpy array of shape (N, 2) where N is the number of atoms

You may also intersperse variables anywhere a value may be present.

You can also pass in an optional argument which determines the atom "filling" (whether or not at a specified coordinate an atom should be present).

Usage Example:
# single coordinate
>>> reg = start.add_position((0,0))
# you may chain add_position calls
>>> reg_plus_two = reg.add_position([(2,2),(5.0, 2.1)])
# you can add variables anywhere a value may be present
>>> reg_with_var = reg_plus_two.add_position(("x", "y"))
# and specify your atom fillings
>>> reg_with_filling = reg_with_var.add_position([(3.1, 0.0), (4.1, 2.2)],
[True, False])
# alternatively you could use one boolean to specify
# all coordinates should be empty/filled
>>> reg_with_more_filling = reg_with_filling.add_positions([(3.1, 2.9),
(5.2, 2.2)], False)
  • Next possible steps are:
  • Continuing to build your geometry via:
    • ...add_position(positions).add_position(positions): to add more positions
    • ...add_position(positions).apply_defect_count(n_defects): to randomly drop out n_atoms
    • ...add_position(positions).apply_defect_density(defect_probability): to drop out atoms with a certain probability
    • ...add_position(positions).scale(scale): to scale the geometry
  • Targeting a level coupling once you're done with the atom geometry:
    • ...add_position(positions).rydberg: to specify Rydberg coupling
    • ...add_position(positions).hyperfine: to specify Hyperfine coupling
  • Visualizing your atom geometry:
    • ...add_position(positions).show(): shows your geometry in your web browser
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
def add_position(
    self,
    position: Union[
        PositionArray,
        List[Tuple[ScalarType, ScalarType]],
        Tuple[ScalarType, ScalarType],
    ],
    filling: Optional[Union[BoolArray, List[bool], bool]] = None,
) -> "ListOfLocations":
    """
    Add a position or multiple positions to a pre-existing geometry.

    `add_position` is capable of accepting:
    - A single tuple for one atom coordinate: `(1.0, 2.5)`
    - A list of tuples: `[(0.0, 1.0), (2.0,1.5), etc.]
    - A numpy array of shape (N, 2) where N is the number of atoms

    You may also intersperse variables anywhere a value may be present.

    You can also pass in an optional argument which determines the atom "filling"
    (whether or not at a specified coordinate an atom should be present).

    ### Usage Example:
    ```
    # single coordinate
    >>> reg = start.add_position((0,0))
    # you may chain add_position calls
    >>> reg_plus_two = reg.add_position([(2,2),(5.0, 2.1)])
    # you can add variables anywhere a value may be present
    >>> reg_with_var = reg_plus_two.add_position(("x", "y"))
    # and specify your atom fillings
    >>> reg_with_filling = reg_with_var.add_position([(3.1, 0.0), (4.1, 2.2)],
    [True, False])
    # alternatively you could use one boolean to specify
    # all coordinates should be empty/filled
    >>> reg_with_more_filling = reg_with_filling.add_positions([(3.1, 2.9),
    (5.2, 2.2)], False)
    ```

    - Next possible steps are:
    - Continuing to build your geometry via:
        - `...add_position(positions).add_position(positions)`:
            to add more positions
        - `...add_position(positions).apply_defect_count(n_defects)`:
        to randomly drop out n_atoms
        - `...add_position(positions).apply_defect_density(defect_probability)`:
        to drop out atoms with a certain probability
        - `...add_position(positions).scale(scale)`: to scale the geometry
    - Targeting a level coupling once you're done with the atom geometry:
        - `...add_position(positions).rydberg`: to specify Rydberg coupling
        - `...add_position(positions).hyperfine`: to specify Hyperfine coupling
    - Visualizing your atom geometry:
        - `...add_position(positions).show()`:
        shows your geometry in your web browser

    """

    if is_bearable(position, PositionArray) and is_bearable(
        filling, Optional[BoolArray]
    ):
        return self.add_position_ndarray(position, filling)
    elif is_bearable(position, List[Tuple[ScalarType, ScalarType]]) and is_bearable(
        filling, Optional[List[bool]]
    ):
        return self.add_position_list_tuples(position, filling)
    elif is_bearable(position, Tuple[ScalarType, ScalarType]) and is_bearable(
        filling, Optional[bool]
    ):
        return self.add_position_single_tupe(position, filling)
    else:
        raise TypeError("Invalid input types for add_position provided!")

apply_defect_count

apply_defect_count(
    n_defects: int, rng: Generator = np.random.default_rng()
)

Drop n_defects atoms from the geometry randomly. Internally this occurs by setting certain sites to have a SiteFilling set to false indicating no atom is present at the coordinate.

A default numpy-based Random Number Generator is used but you can explicitly override this by passing in your own.

Usage Example:
>>> from bloqade.analog.atom_arrangement import Chain
>>> import numpy as np
# set a custom seed for a numpy-based RNG
>>> custom_rng = np.random.default_rng(888)
# randomly remove two atoms from the geometry
>>> reg = Chain(11).apply_defect_count(2, custom_rng)
# you may also chain apply_defect_count calls
>>> reg.apply_defect_count(2, custom_rng)
# you can also use apply_defect_count on custom geometries
>>> from bloqade import start
>>> start.add_position([(0,0), (1,1)]).apply_defect_count(1, custom_rng)
  • Next possible steps are:
  • Continuing to build your geometry via:
    • ...apply_defect_count(defect_counts).add_position(positions): to add more positions
    • ...apply_defect_count(defect_counts) .apply_defect_count(n_defects): to randomly drop out n_atoms
    • ...apply_defect_count(defect_counts) .apply_defect_density(defect_probability): to drop out atoms with a certain probability
    • ...apply_defect_count(defect_counts).scale(scale): to scale the geometry
  • Targeting a level coupling once you're done with the atom geometry:
    • ...apply_defect_count(defect_counts).rydberg: to specify Rydberg coupling
    • ...apply_defect_count(defect_counts).hyperfine: to specify Hyperfine coupling
  • Visualizing your atom geometry:
    • ...apply_defect_count(defect_counts).show(): shows your geometry in your web browser
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
@beartype
def apply_defect_count(
    self, n_defects: int, rng: np.random.Generator = np.random.default_rng()
):
    """
    Drop `n_defects` atoms from the geometry randomly. Internally this occurs
    by setting certain sites to have a SiteFilling set to false indicating
    no atom is present at the coordinate.

    A default numpy-based Random Number Generator is used but you can
    explicitly override this by passing in your own.

    ### Usage Example:

    ```
    >>> from bloqade.analog.atom_arrangement import Chain
    >>> import numpy as np
    # set a custom seed for a numpy-based RNG
    >>> custom_rng = np.random.default_rng(888)
    # randomly remove two atoms from the geometry
    >>> reg = Chain(11).apply_defect_count(2, custom_rng)
    # you may also chain apply_defect_count calls
    >>> reg.apply_defect_count(2, custom_rng)
    # you can also use apply_defect_count on custom geometries
    >>> from bloqade import start
    >>> start.add_position([(0,0), (1,1)]).apply_defect_count(1, custom_rng)
    ```

    - Next possible steps are:
    - Continuing to build your geometry via:
        - `...apply_defect_count(defect_counts).add_position(positions)`:
            to add more positions
        - `...apply_defect_count(defect_counts)
            .apply_defect_count(n_defects)`: to randomly drop out n_atoms
        - `...apply_defect_count(defect_counts)
            .apply_defect_density(defect_probability)`:
            to drop out atoms with a certain probability
        - `...apply_defect_count(defect_counts).scale(scale)`:
            to scale the geometry
    - Targeting a level coupling once you're done with the atom geometry:
        - `...apply_defect_count(defect_counts).rydberg`: to specify
            Rydberg coupling
        - `...apply_defect_count(defect_counts).hyperfine`:
            to specify Hyperfine coupling
    - Visualizing your atom geometry:
        - `...apply_defect_count(defect_counts).show()`:
            shows your geometry in your web browser
    """

    location_list = []
    for location_info in self.enumerate():
        location_list.append(location_info)

    filled_sites = []

    for index, location_info in enumerate(location_list):
        if location_info.filling is SiteFilling.filled:
            filled_sites.append(index)

    if n_defects >= len(filled_sites):
        raise ValueError(
            f"n_defects {n_defects} must be less than the number of filled sites "
            f"({len(filled_sites)})"
        )

    for _ in range(n_defects):
        index = rng.choice(filled_sites)
        location_list[index] = LocationInfo.create(
            location_list[index].position,
            (False if location_list[index].filling is SiteFilling.filled else True),
        )
        filled_sites.remove(index)

    return ListOfLocations(location_list)

apply_defect_density

apply_defect_density(
    defect_probability: float,
    rng: Generator = np.random.default_rng(),
)

Drop atoms randomly with defect_probability probability (range of 0 to 1). Internally this occurs by setting certain sites to have a SiteFilling set to false indicating no atom is present at the coordinate.

A default numpy-based Random Number Generator is used but you can explicitly override this by passing in your own.

Usage Example:
>>> from bloqade.analog.atom_arrangement import Chain
>>> import numpy as np
# set a custom seed for a numpy-based RNG
>>> custom_rng = np.random.default_rng(888)
# randomly remove two atoms from the geometry
>>> reg = Chain(11).apply_defect_density(0.2, custom_rng)
# you may also chain apply_defect_density calls
>>> reg.apply_defect_count(0.1, custom_rng)
# you can also use apply_defect_density on custom geometries
>>> from bloqade import start
>>> start.add_position([(0,0), (1,1)])
.apply_defect_density(0.5, custom_rng)
  • Next possible steps are:
  • Continuing to build your geometry via:
    • ...apply_defect_count(defect_counts).add_position(positions): to add more positions
    • ...apply_defect_count(defect_counts).apply_defect_count(n_defects): to randomly drop out n_atoms
    • ...apply_defect_count(defect_counts) .apply_defect_density(defect_probability): to drop out atoms with a certain probability
    • ...apply_defect_count(defect_counts).scale(scale): to scale the geometry
  • Targeting a level coupling once you're done with the atom geometry:
    • ...apply_defect_count(defect_counts).rydberg: to specify Rydberg coupling
    • ...apply_defect_count(defect_counts).hyperfine: to specify Hyperfine coupling
  • Visualizing your atom geometry:
    • ...apply_defect_count(defect_counts).show(): shows your geometry in your web browser
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
@beartype
def apply_defect_density(
    self,
    defect_probability: float,
    rng: np.random.Generator = np.random.default_rng(),
):
    """
    Drop atoms randomly with `defect_probability` probability (range of 0 to 1).
    Internally this occurs by setting certain sites to have a SiteFilling
    set to false indicating no atom is present at the coordinate.

    A default numpy-based Random Number Generator is used but you can
    explicitly override this by passing in your own.

    ### Usage Example:

    ```
    >>> from bloqade.analog.atom_arrangement import Chain
    >>> import numpy as np
    # set a custom seed for a numpy-based RNG
    >>> custom_rng = np.random.default_rng(888)
    # randomly remove two atoms from the geometry
    >>> reg = Chain(11).apply_defect_density(0.2, custom_rng)
    # you may also chain apply_defect_density calls
    >>> reg.apply_defect_count(0.1, custom_rng)
    # you can also use apply_defect_density on custom geometries
    >>> from bloqade import start
    >>> start.add_position([(0,0), (1,1)])
    .apply_defect_density(0.5, custom_rng)
    ```

    - Next possible steps are:
    - Continuing to build your geometry via:
        - `...apply_defect_count(defect_counts).add_position(positions)`:
        to add more positions
        - `...apply_defect_count(defect_counts).apply_defect_count(n_defects)`:
        to randomly drop out n_atoms
        - `...apply_defect_count(defect_counts)
        .apply_defect_density(defect_probability)`:
        to drop out atoms with a certain probability
        - `...apply_defect_count(defect_counts).scale(scale)`:
        to scale the geometry
    - Targeting a level coupling once you're done with the atom geometry:
        - `...apply_defect_count(defect_counts).rydberg`:
        to specify Rydberg coupling
        - `...apply_defect_count(defect_counts).hyperfine`:
        to specify Hyperfine coupling
    - Visualizing your atom geometry:
        - `...apply_defect_count(defect_counts).show()`:
        shows your geometry in your web browser
    """

    p = min(1, max(0, defect_probability))
    location_list = []

    for location_info in self.enumerate():
        if rng.random() < p:
            location_list.append(
                LocationInfo.create(
                    location_info.position,
                    (
                        False
                        if location_info.filling is SiteFilling.filled
                        else True
                    ),
                )
            )
        else:
            location_list.append(location_info)

    return ListOfLocations(location_list=location_list)

enumerate

enumerate() -> Generator[LocationInfo, None, None]

enumerate all locations in the register.

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
128
129
130
def enumerate(self) -> Generator[LocationInfo, None, None]:
    """enumerate all locations in the register."""
    raise NotImplementedError

figure

figure(fig_kwargs=None, **assignments)

obtain a figure object from the atom arrangement.

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
132
133
134
def figure(self, fig_kwargs=None, **assignments):
    """obtain a figure object from the atom arrangement."""
    return get_atom_arrangement_figure(self, fig_kwargs=fig_kwargs, **assignments)

rydberg_interaction

rydberg_interaction(**assignments) -> NDArray

calculate the Rydberg interaction matrix.

Parameters:

Name Type Description Default
**assignments

the values to assign to the variables in the register.

{}

Returns:

Name Type Description
NDArray NDArray

the Rydberg interaction matrix in the lower triangular form.

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
def rydberg_interaction(self, **assignments) -> NDArray:
    """calculate the Rydberg interaction matrix.

    Args:
        **assignments: the values to assign to the variables in the register.

    Returns:
        NDArray: the Rydberg interaction matrix in the lower triangular form.

    """

    from bloqade.analog.constants import RB_C6

    # calculate the Interaction matrix
    V_ij = np.zeros((self.n_sites, self.n_sites))
    for i, site_i in enumerate(self.enumerate()):
        pos_i = np.array([float(ele(**assignments)) for ele in site_i.position])

        for j, site_j in enumerate(self.enumerate()):
            if j >= i:
                break  # enforce lower triangular form

            pos_j = np.array([float(ele(**assignments)) for ele in site_j.position])
            r_ij = np.linalg.norm(pos_i - pos_j)

            V_ij[i, j] = RB_C6 / r_ij**6

    return V_ij

scale

scale(scale: ScalarType)

Scale the geometry of your atoms.

Usage Example:
>>> reg = start.add_position([(0,0), (1,1)])
# atom positions are now (0,0), (2,2)
>>> new_reg = reg.scale(2)
# you may also use scale on pre-defined geometries
>>> from bloqade.analog.atom_arrangement import Chain
# atoms in the chain will now be 2 um apart versus
# the default 1 um
>>> Chain(11).scale(2)
  • Next possible steps are:
  • Continuing to build your geometry via:
    • ...add_position(positions).add_position(positions): to add more positions
    • ...add_position(positions).apply_defect_count(n_defects): to randomly drop out n_atoms
    • ...add_position(positions).apply_defect_density(defect_probability): to drop out atoms with a certain probability
    • ...add_position(positions).scale(scale): to scale the geometry
  • Targeting a level coupling once you're done with the atom geometry:
    • ...add_position(positions).rydberg: to specify Rydberg coupling
    • ...add_position(positions).hyperfine: to specify Hyperfine coupling
  • Visualizing your atom geometry:
    • ...add_position(positions).show(): shows your geometry in your web browser
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
@beartype
def scale(self, scale: ScalarType):
    """
    Scale the geometry of your atoms.

    ### Usage Example:
    ```
    >>> reg = start.add_position([(0,0), (1,1)])
    # atom positions are now (0,0), (2,2)
    >>> new_reg = reg.scale(2)
    # you may also use scale on pre-defined geometries
    >>> from bloqade.analog.atom_arrangement import Chain
    # atoms in the chain will now be 2 um apart versus
    # the default 1 um
    >>> Chain(11).scale(2)
    ```

    - Next possible steps are:
    - Continuing to build your geometry via:
        - `...add_position(positions).add_position(positions)`:
            to add more positions
        - `...add_position(positions).apply_defect_count(n_defects)`:
        to randomly drop out n_atoms
        - `...add_position(positions).apply_defect_density(defect_probability)`:
        to drop out atoms with a certain probability
        - `...add_position(positions).scale(scale)`: to scale the geometry
    - Targeting a level coupling once you're done with the atom geometry:
        - `...add_position(positions).rydberg`:
        to specify Rydberg coupling
        - `...add_position(positions).hyperfine`:
        to specify Hyperfine coupling
    - Visualizing your atom geometry:
        - `...add_position(positions).show()`:
        shows your geometry in your web browser

    """

    scale = cast(scale)
    location_list = []
    for location_info in self.enumerate():
        x, y = location_info.position
        new_position = (scale * x, scale * y)
        location_list.append(
            LocationInfo.create(new_position, bool(location_info.filling.value))
        )

    return ListOfLocations(location_list)

show

show(**assignments) -> None

Display the current program being defined with the given arguments and batch ID.

Parameters:

Name Type Description Default
*args

Additional arguments for display.

()
batch_id int

The batch ID to be displayed. Defaults to 0.

0
Note

This method uses the display_builder function to render the builder's state.

Example:

>>> class MyBuilder(Show):
...     pass
>>> builder = MyBuilder()
>>> builder.show()
>>> builder.show(batch_id=1)
>>> builder.show('arg1', 'arg2', batch_id=2)
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
136
137
def show(self, **assignments) -> None:
    display_ir(self, assignments)

ListOfLocations

ListOfLocations(
    location_list: List[
        Union[LocationInfo, Tuple[ScalarType, ScalarType]]
    ] = [],
)

Bases: AtomArrangement


              flowchart TD
              bloqade.analog.ir.location.location.ListOfLocations[ListOfLocations]
              bloqade.analog.ir.location.location.AtomArrangement[AtomArrangement]
              bloqade.analog.builder.start.ProgramStart[ProgramStart]
              bloqade.analog.builder.drive.Drive[Drive]
              bloqade.analog.builder.base.Builder[Builder]
              bloqade.analog.builder.parse.trait.Parse[Parse]
              bloqade.analog.builder.parse.trait.ParseRegister[ParseRegister]
              bloqade.analog.builder.parse.trait.ParseSequence[ParseSequence]
              bloqade.analog.builder.parse.trait.ParseCircuit[ParseCircuit]
              bloqade.analog.builder.parse.trait.ParseRoutine[ParseRoutine]
              bloqade.analog.builder.parse.trait.Show[Show]

                              bloqade.analog.ir.location.location.AtomArrangement --> bloqade.analog.ir.location.location.ListOfLocations
                                bloqade.analog.builder.start.ProgramStart --> bloqade.analog.ir.location.location.AtomArrangement
                                bloqade.analog.builder.drive.Drive --> bloqade.analog.builder.start.ProgramStart
                
                bloqade.analog.builder.base.Builder --> bloqade.analog.builder.start.ProgramStart
                                bloqade.analog.builder.parse.trait.Parse --> bloqade.analog.builder.base.Builder
                                bloqade.analog.builder.parse.trait.ParseRegister --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseSequence --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseCircuit --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseRoutine --> bloqade.analog.builder.parse.trait.Parse
                

                bloqade.analog.builder.parse.trait.Show --> bloqade.analog.builder.base.Builder
                





              click bloqade.analog.ir.location.location.ListOfLocations href "" "bloqade.analog.ir.location.location.ListOfLocations"
              click bloqade.analog.ir.location.location.AtomArrangement href "" "bloqade.analog.ir.location.location.AtomArrangement"
              click bloqade.analog.builder.start.ProgramStart href "" "bloqade.analog.builder.start.ProgramStart"
              click bloqade.analog.builder.drive.Drive href "" "bloqade.analog.builder.drive.Drive"
              click bloqade.analog.builder.base.Builder href "" "bloqade.analog.builder.base.Builder"
              click bloqade.analog.builder.parse.trait.Parse href "" "bloqade.analog.builder.parse.trait.Parse"
              click bloqade.analog.builder.parse.trait.ParseRegister href "" "bloqade.analog.builder.parse.trait.ParseRegister"
              click bloqade.analog.builder.parse.trait.ParseSequence href "" "bloqade.analog.builder.parse.trait.ParseSequence"
              click bloqade.analog.builder.parse.trait.ParseCircuit href "" "bloqade.analog.builder.parse.trait.ParseCircuit"
              click bloqade.analog.builder.parse.trait.ParseRoutine href "" "bloqade.analog.builder.parse.trait.ParseRoutine"
              click bloqade.analog.builder.parse.trait.Show href "" "bloqade.analog.builder.parse.trait.Show"
            
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
@beartype
def __init__(
    self,
    location_list: List[Union[LocationInfo, Tuple[ScalarType, ScalarType]]] = [],
):
    self.location_list = []
    for ele in location_list:
        if isinstance(ele, LocationInfo):
            self.location_list.append(ele)
        else:
            self.location_list.append(LocationInfo.create(ele, True))

    if self.location_list:
        self.__n_atoms = sum(
            1 for loc in self.location_list if loc.filling == SiteFilling.filled
        )
        self.__n_sites = len(self.location_list)
        self.__n_vacant = self.__n_sites - self.__n_atoms
        self.__n_dims = len(self.location_list[0].position)
    else:
        self.__n_sites = 0
        self.__n_atoms = 0
        self.__n_dims = None

    super().__init__()

n_atoms property

n_atoms

number of atoms (filled sites) in the register.

n_dims property

n_dims

number of dimensions in the register.

n_sites property

n_sites

number of sites in the register.

n_vacant property

n_vacant

number of vacant sites in the register.

enumerate

enumerate()

enumerate all locations in the register.

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
661
662
def enumerate(self):
    return iter(self.location_list)

ParallelRegister

ParallelRegister(parent: Optional[Builder] = None)

Bases: ProgramStart


              flowchart TD
              bloqade.analog.ir.location.location.ParallelRegister[ParallelRegister]
              bloqade.analog.builder.start.ProgramStart[ProgramStart]
              bloqade.analog.builder.drive.Drive[Drive]
              bloqade.analog.builder.base.Builder[Builder]
              bloqade.analog.builder.parse.trait.Parse[Parse]
              bloqade.analog.builder.parse.trait.ParseRegister[ParseRegister]
              bloqade.analog.builder.parse.trait.ParseSequence[ParseSequence]
              bloqade.analog.builder.parse.trait.ParseCircuit[ParseCircuit]
              bloqade.analog.builder.parse.trait.ParseRoutine[ParseRoutine]
              bloqade.analog.builder.parse.trait.Show[Show]

                              bloqade.analog.builder.start.ProgramStart --> bloqade.analog.ir.location.location.ParallelRegister
                                bloqade.analog.builder.drive.Drive --> bloqade.analog.builder.start.ProgramStart
                
                bloqade.analog.builder.base.Builder --> bloqade.analog.builder.start.ProgramStart
                                bloqade.analog.builder.parse.trait.Parse --> bloqade.analog.builder.base.Builder
                                bloqade.analog.builder.parse.trait.ParseRegister --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseSequence --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseCircuit --> bloqade.analog.builder.parse.trait.Parse
                
                bloqade.analog.builder.parse.trait.ParseRoutine --> bloqade.analog.builder.parse.trait.Parse
                

                bloqade.analog.builder.parse.trait.Show --> bloqade.analog.builder.base.Builder
                




              click bloqade.analog.ir.location.location.ParallelRegister href "" "bloqade.analog.ir.location.location.ParallelRegister"
              click bloqade.analog.builder.start.ProgramStart href "" "bloqade.analog.builder.start.ProgramStart"
              click bloqade.analog.builder.drive.Drive href "" "bloqade.analog.builder.drive.Drive"
              click bloqade.analog.builder.base.Builder href "" "bloqade.analog.builder.base.Builder"
              click bloqade.analog.builder.parse.trait.Parse href "" "bloqade.analog.builder.parse.trait.Parse"
              click bloqade.analog.builder.parse.trait.ParseRegister href "" "bloqade.analog.builder.parse.trait.ParseRegister"
              click bloqade.analog.builder.parse.trait.ParseSequence href "" "bloqade.analog.builder.parse.trait.ParseSequence"
              click bloqade.analog.builder.parse.trait.ParseCircuit href "" "bloqade.analog.builder.parse.trait.ParseCircuit"
              click bloqade.analog.builder.parse.trait.ParseRoutine href "" "bloqade.analog.builder.parse.trait.ParseRoutine"
              click bloqade.analog.builder.parse.trait.Show href "" "bloqade.analog.builder.parse.trait.Show"
            
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/builder/base.py
10
11
12
13
14
def __init__(
    self,
    parent: Optional["Builder"] = None,
) -> None:
    self.__parent__ = parent

n_atoms property

n_atoms

Return the number of atoms in the program.

Returns:

Name Type Description
int int

The number of atoms in the parsed register.

Raises:

Type Description
ValueError

If the register type is unsupported.

Note

If the register is of type ParallelRegister, the number of atoms is extracted from its internal register.

Example:

>>> class MyBuilder(Parse):
...     pass
>>> builder = MyBuilder()
>>> n_atoms = builder.n_atoms

show

show(**assignments) -> None

Display the current program being defined with the given arguments and batch ID.

Parameters:

Name Type Description Default
*args

Additional arguments for display.

()
batch_id int

The batch ID to be displayed. Defaults to 0.

0
Note

This method uses the display_builder function to render the builder's state.

Example:

>>> class MyBuilder(Show):
...     pass
>>> builder = MyBuilder()
>>> builder.show()
>>> builder.show(batch_id=1)
>>> builder.show('arg1', 'arg2', batch_id=2)
Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
559
560
def show(self, **assignments) -> None:
    display_ir(self, assignments)

ParallelRegisterInfo

ParallelRegisterInfo(parallel_register: ParallelRegister)

ParallelRegisterInfo

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/location/location.py
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
def __init__(self, parallel_register: ParallelRegister):
    atom_arrangement = parallel_register.atom_arrangement
    cluster_spacing = parallel_register.cluster_spacing

    if atom_arrangement.n_atoms > 0:
        # calculate bounding box
        # of this register
        location_iter = atom_arrangement.enumerate()
        (x, y) = next(location_iter).position
        x_min = x
        x_max = x
        y_min = y
        y_max = y

        for location_info in location_iter:
            (x, y) = location_info.position
            x_min = x.min(x_min)
            x_max = x.max(x_max)
            y_min = y.min(y_min)
            y_max = y.max(y_max)

        shift_x = (x_max - x_min) + cluster_spacing
        shift_y = (y_max - y_min) + cluster_spacing

        register_locations = [
            list(location_info.position)
            for location_info in atom_arrangement.enumerate()
        ]
        register_filling = [
            location_info.filling.value
            for location_info in atom_arrangement.enumerate()
        ]
        shift_vectors = [[shift_x, cast(0)], [cast(0), shift_y]]
    else:
        raise ValueError("No locations to parallelize.")

    self.register_locations = register_locations
    self.register_filling = register_filling
    self.shift_vectors = shift_vectors