Skip to content

Commit

Permalink
Updating GUI, putting it on port 9000
Browse files Browse the repository at this point in the history
test
pypi
documentation
  • Loading branch information
b-vanstraaten committed Aug 1, 2024
1 parent 32a304c commit 570192a
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 12 deletions.
8 changes: 1 addition & 7 deletions examples/paper_example.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
from pathlib import Path

import matplotlib
import matplotlib.pyplot as plt

from qarray import DotArray
from qarray import dot_occupation_changes

save_folder = Path(__file__).parent / 'figures'

matplotlib.rc('font', size=11)
plt.style.use(['science', 'no-latex'])

import matplotlib.pyplot as plt
from qarray import dot_occupation_changes

model = DotArray(
Cdd=[
[0.0, 0.1],
Expand Down
2 changes: 1 addition & 1 deletion qarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Qarray, a GPU accelerated quantum dot array simulator, leveraging parallelised Rust and JAX XLA acceleration
to compute charge stability diagrams of large both open and closed arrays in milliseconds.
"""
__version__ = "1.3.0"
__version__ = "1.3.1"

from .DotArrays import (DotArray, GateVoltageComposer, ChargeSensedDotArray)
from .functions import (_optimal_Vg, dot_occupation_changes, charge_state_contrast,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_against_brute_force.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from qarray.functions import dot_occupation_changes
from qarray.jax_implementations.brute_force_jax import ground_state_open_brute_force_jax, \
ground_state_closed_brute_force_jax
from qarray.python_implementations import ground_state_open_default_or_thresholded_python, \
ground_state_closed_default_or_thresholded_python
from qarray.rust_implemenations import ground_state_open_default_or_thresholded_rust, \
ground_state_closed_default_or_thresholded_rust
from .GLOBAL_OPTIONS import disable_tqdm, N_ITERATIONS, N_VOLTAGES
Expand All @@ -27,6 +29,8 @@ def test_double_dot_open(self):

n_rust = ground_state_open_default_or_thresholded_rust(vg, cgd, cdd_inv, 1)

n_python = ground_state_open_default_or_thresholded_python(vg, cgd, cdd_inv, 1)

max_number_of_changes = int(n_rust.max())
n_brute_force = ground_state_open_brute_force_jax(vg, cgd, cdd_inv, max_number_of_changes, T=0.0)

Expand All @@ -53,6 +57,9 @@ def test_double_dot_closed(self):
n_brute_force = ground_state_closed_brute_force_jax(vg, cgd=cgd, cdd_inv=cdd_inv, cdd=cdd, n_charge=1,
T=0.0)

n_python = ground_state_closed_default_or_thresholded_python(vg, cdd=cdd, cdd_inv=cdd_inv, cgd=cgd,
threshold=1, n_charge=1, T=0.0)

if too_different(n_rust, n_brute_force):
fig, ax = plt.subplots(3)
ax[0].imshow(n_rust.T, origin='lower')
Expand Down
98 changes: 94 additions & 4 deletions tests/test_threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,100 @@


class ThresholdTests(TestCase):

def test_threshold_double_dot_open_python(self):
"""
Test that the python and rust open double dot ground state functions return the same result.
The threshold is set to 1, so every nearest neighbour change state is considered
"""

n_dot = 2
n_gate = 2

models = randomly_generate_model(n_dot, n_gate, N_ITERATIONS)
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.implementation = 'python'
model.algorithm = 'thresholded'
vg = voltage_composer.do2d(1, -5, 5, N_VOLTAGES, 2, -5, 5, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_open(vg)

model.threshold = 1.
n_threshold_of_1 = model.ground_state_open(vg)
self.assertTrue(np.allclose(n_threshold_of_1, n_threshold_not_of_1))

def test_threshold_double_dot_closed_python(self):
"""
Test that the python and rust open double dot ground state functions return the same result.
The threshold is set to 1, so every nearest neighbour change state is considered
"""

n_dot = 2
n_gate = 2

models = randomly_generate_model(n_dot, n_gate, N_ITERATIONS)
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.implementation = 'python'
model.algorithm = 'thresholded'
vg = voltage_composer.do2d(1, -10, 5, N_VOLTAGES, 2, -10, 5, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_closed(vg, n_charges=5)

model.threshold = 1.
n_threshold_of_1 = model.ground_state_closed(vg, n_charges=5)
self.assertTrue(np.allclose(n_threshold_of_1, n_threshold_not_of_1))

def test_threshold_double_dot_open_jax(self):
"""
Test that the python and rust open double dot ground state functions return the same result.
The threshold is set to 1, so every nearest neighbour change state is considered
"""

n_dot = 2
n_gate = 2

models = randomly_generate_model(n_dot, n_gate, N_ITERATIONS)
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.implementation = 'jax'
model.algorithm = 'default'
vg = voltage_composer.do2d(1, -5, 5, N_VOLTAGES, 2, -5, 5, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_open(vg)

model.threshold = 1.
n_threshold_of_1 = model.ground_state_open(vg)
self.assertTrue(np.allclose(n_threshold_of_1, n_threshold_not_of_1))

def test_threshold_double_dot_closed_jax(self):
"""
Test that the python and rust open double dot ground state functions return the same result.
The threshold is set to 1, so every nearest neighbour change state is considered
"""

n_dot = 2
n_gate = 2

models = randomly_generate_model(n_dot, n_gate, N_ITERATIONS)
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.implementation = 'jax'
model.algorithm = 'default'
vg = voltage_composer.do2d(1, -10, 5, N_VOLTAGES, 2, -10, 5, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_closed(vg, n_charges=5)

model.threshold = 1.
n_threshold_of_1 = model.ground_state_closed(vg, n_charges=5)
self.assertTrue(np.allclose(n_threshold_of_1, n_threshold_not_of_1))


def test_threshold_double_dot_open(self):
"""
Test that the python and rust open double dot ground state functions return the same result.
Expand Down Expand Up @@ -49,7 +143,6 @@ def test_threshold_double_dot_closed(self):
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.core = 'python'
vg = voltage_composer.do2d(1, -10, 5, N_VOLTAGES, 2, -10, 5, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_closed(vg, n_charges=5)

Expand Down Expand Up @@ -101,7 +194,6 @@ def test_threshold_triple_dot_closed(self):
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.core = 'python'
vg = voltage_composer.do2d(1, -20, 5, N_VOLTAGES, 3, -20, 5, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_closed(vg, n_charges=2)

Expand Down Expand Up @@ -161,7 +253,6 @@ def test_threshold_quadruple_dot_closed(self):
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.core = 'python'
vg = voltage_composer.do2d(1, -4, 0, N_VOLTAGES, 4, -4, 0, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_closed(vg, 4)

Expand Down Expand Up @@ -226,7 +317,6 @@ def test_threshold_quadruple_dot_closed(self):
voltage_composer = GateVoltageComposer(n_gate=n_gate)

for model in models:
model.core = 'python'
print(model.threshold)
vg = voltage_composer.do2d(1, -20, 0, N_VOLTAGES, 5, -20, 0, N_VOLTAGES)
n_threshold_not_of_1 = model.ground_state_closed(vg, 4)
Expand Down

0 comments on commit 570192a

Please sign in to comment.