Skip to content

Commit

Permalink
Single atom hotfix (#114)
Browse files Browse the repository at this point in the history
* Correct VDW term creation for system size 1
  • Loading branch information
sebgrijalva authored Mar 31, 2021
1 parent 792ac4a commit 678877d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pulser/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def build_coeffs_ops(basis, addr):
qobj_list = []
else:
# Van der Waals Interaction Terms
qobj_list = [make_vdw_term()]
qobj_list = [make_vdw_term()] if self._size > 1 else []

# Time dependent terms:
for addr in self.samples:
Expand Down
12 changes: 11 additions & 1 deletion pulser/tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pulser import Sequence, Pulse, Register, Simulation
from pulser.devices import Chadoq2
from pulser.waveforms import BlackmanWaveform
from pulser.waveforms import BlackmanWaveform, ConstantWaveform

q_dict = {"control1": np.array([-4., 0.]),
"target": np.array([0., 4.]),
Expand Down Expand Up @@ -196,6 +196,16 @@ def test_empty_sequences():
Simulation(seq)


def test_single_atom_simulation():
one_reg = Register.from_coordinates([(0, 0)], 'atom')
one_seq = Sequence(one_reg, Chadoq2)
one_seq.declare_channel('ch0', 'rydberg_global')
one_seq.add(Pulse.ConstantDetuning(ConstantWaveform(16, 1.), 1., 0), 'ch0')
one_sim = Simulation(seq)
one_res = one_sim.run()
assert(one_res._size == one_sim._size)


def test_run():
sim = Simulation(seq, sampling_rate=0.01)
bad_initial = np.array([1.])
Expand Down

0 comments on commit 678877d

Please sign in to comment.