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

Fixes to the amplitude noise implementation #768

Merged
merged 11 commits into from
Dec 2, 2024
18 changes: 17 additions & 1 deletion pulser-core/pulser/channels/base_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

ChannelType = TypeVar("ChannelType", bound="Channel")

OPTIONAL_ABSTR_CH_FIELDS = ("min_avg_amp",)
OPTIONAL_ABSTR_CH_FIELDS = ("min_avg_amp", "propagation_dir")

# States ranked in decreasing order of their associated eigenenergy
States = Literal["u", "d", "r", "g", "h", "x"]
Expand Down Expand Up @@ -78,6 +78,8 @@ class Channel(ABC):
min_avg_amp: The minimum average amplitude of a pulse (when not zero).
mod_bandwidth: The modulation bandwidth at -3dB (50% reduction), in
MHz.
propagation_dir: The propagation direction of the beam leaving the
HGSilveri marked this conversation as resolved.
Show resolved Hide resolved
channel, given as a vector in 3D space.

Example:
To create a channel targeting the 'ground-rydberg' transition globally,
Expand All @@ -96,6 +98,7 @@ class Channel(ABC):
min_avg_amp: float = 0
mod_bandwidth: Optional[float] = None # MHz
eom_config: Optional[BaseEOM] = field(init=False, default=None)
propagation_dir: tuple[float, float, float] | None = None

@property
def name(self) -> str:
Expand Down Expand Up @@ -244,6 +247,18 @@ def __post_init__(self) -> None:
"modulation bandwidth."
)

if self.propagation_dir is not None:
dir_vector = np.array(self.propagation_dir, dtype=float)
if dir_vector.size != 3 or np.sum(dir_vector) == 0.0:
raise ValueError(
"'propagation_dir' must be given as a non-zero 3D vector;"
f" got {self.propagation_dir} instead."
)
# Make sure it's stored as a tuple
object.__setattr__(
self, "propagation_dir", tuple(self.propagation_dir)
)

@property
def rise_time(self) -> int:
"""The rise time (in ns).
Expand Down Expand Up @@ -340,6 +355,7 @@ def Global(
cls: Type[ChannelType],
max_abs_detuning: Optional[float],
max_amp: Optional[float],
# TODO: Impose a default propagation_dir in pulser-core 1.3
**kwargs: Any,
) -> ChannelType:
"""Initializes the channel with global addressing.
Expand Down
9 changes: 8 additions & 1 deletion pulser-core/pulser/devices/_device_datacls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import numpy as np
from scipy.spatial.distance import squareform

import pulser
import pulser.json.abstract_repr as pulser_abstract_repr
import pulser.math as pm
from pulser.channels.base_channel import Channel, States, get_states_from_bases
Expand Down Expand Up @@ -565,7 +566,13 @@ def _to_abstract_repr(self) -> dict[str, Any]:
for ch_name, ch_obj in self.channels.items():
ch_list.append(ch_obj._to_abstract_repr(ch_name))
# Add version and channels to params
params.update({"version": "1", "channels": ch_list})
params.update(
{
"version": "1",
"pulser_version": pulser.__version__,
"channels": ch_list,
}
)
dmm_list = []
for dmm_name, dmm_obj in self.dmm_channels.items():
dmm_list.append(dmm_obj._to_abstract_repr(dmm_name))
Expand Down
224 changes: 224 additions & 0 deletions pulser-core/pulser/json/abstract_repr/schemas/device-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
},
"total_bottom_detuning": {
"description": "Minimum possible detuning of the whole DMM channel (in rad/µs), must be below zero.",
"type": [
Expand Down Expand Up @@ -520,6 +536,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -610,6 +642,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -700,6 +748,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -857,6 +921,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -950,6 +1030,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1043,6 +1139,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1193,6 +1305,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1274,6 +1402,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1355,6 +1499,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1500,6 +1660,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1581,6 +1757,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1662,6 +1854,22 @@
"number",
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
}
},
"required": [
Expand Down Expand Up @@ -1751,6 +1959,22 @@
"null"
]
},
"propagation_dir": {
"anyOf": [
{
"items": {
"type": "number"
},
"maxItems": 3,
"minItems": 3,
"type": "array"
},
{
"type": "null"
}
],
"description": "The propagation direction of the beam leaving the channel."
},
"total_bottom_detuning": {
"description": "Minimum possible detuning of the whole DMM channel (in rad/µs), must be below zero.",
"type": [
Expand Down
Loading