Skip to content
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
2 changes: 2 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Bug Fixes
+++++++++

- Fix `convert_complex_to_dm` to properly return arrays with real dtype.
- Fix `Cell.kappa` and `Cell.eta` to properly introspect `q` when first edge on the graph
happens to not be dipole-allowed.

Deprecations
++++++++++++
Expand Down
18 changes: 16 additions & 2 deletions src/rydiqule/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,14 @@ def kappa(self) -> float:
" = <value> prior to running calculations"
warnings.warn(msg)

q = self.couplings.edges[ground_manifold[0], excited_manifold[0]]["q"]
# extract q from coupling group, this ensures we find a dipole allowed edge with q defined
manifold_subgraph = self._coupling_subgraph(self.probe_tuple)
for (_, _, d) in manifold_subgraph.edges(data=True):
if 'q' in d:
q = d['q']
break
else:
raise RydiquleError(f"No 'q' defined for coupling {self.probe_tuple}")

omega_rad = self.atom.get_transition_frequency(probe_g_nlj, probe_e_nlj)*2*np.pi
dipole_moment = self.atom.get_dipole_matrix_element(probe_g_nlj, probe_e_nlj, q=q)*a0*e
Expand Down Expand Up @@ -481,7 +488,14 @@ def eta(self) -> float:
" = <value> prior to running calculations"
warnings.warn(msg)

q = self.couplings.edges[ground_manifold[0], excited_manifold[0]]["q"]
# extract q from coupling group, this ensures we find a dipole allowed edge with q defined
manifold_subgraph = self._coupling_subgraph(self.probe_tuple)
for (_, _, d) in manifold_subgraph.edges(data=True):
if 'q' in d:
q = d['q']
break
else:
raise RydiquleError(f"No 'q' defined for coupling {self.probe_tuple}")

omega_rad = self.atom.get_transition_frequency(probe_g_nlj, probe_e_nlj)*2.0*np.pi
dipole_moment = self.atom.get_dipole_matrix_element(probe_g_nlj, probe_e_nlj, q=q)*a0*e
Expand Down
23 changes: 23 additions & 0 deletions src/rydiqule/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3066,6 +3066,29 @@ def states_with_spec(self, statespec: StateSpec) -> List[State]:

"""
return match_states(statespec, self.states)


def _coupling_subgraph(self, coupling: StateSpecs) -> nx.Graph:
"""
Returns a subgraph view of the couplings graph corresponding to `coupling`.

Parameters
----------
coupling: StateSpecs
Coupling specification

Returns
-------
networkx.Graph
View of the corresponding subgraph
"""

states1 = self.states_with_spec(coupling[0])
states2 = self.states_with_spec(coupling[1])

subgraph = self.couplings.subgraph(states1 + states2)

return subgraph


def get_couplings(self) -> Dict[States, CouplingDict]:
Expand Down