Example charge diagram

[1]:
import os

from qcodes import Station, load_or_create_experiment
from qcodes.dataset.plotting import plot_dataset
from qcodes.dataset.data_set import load_by_run_spec

import nanotune as nt
from nanotune.tests.mock_classifier import MockClassifer
from nanotune.tuningstages.chargediagram import ChargeDiagram
from nanotune.tuningstages.settings import DataSettings, SetpointSettings, Classifiers
from nanotune.device.device import Readout, NormalizationConstants

from sim.data_providers import QcodesDataProvider
from sim.qcodes_mocks import MockDoubleQuantumDotInstrument

nt_path = os.path.dirname(os.path.dirname(os.path.abspath(nt.__file__)))
Logging hadn't been started.
Activating auto-logging. Current session state plus future input saved.
Filename       : /Users/jana/.qcodes/logs/command_history.log
Mode           : append
Output logging : True
Raw input log  : False
Timestamping   : True
State          : active
Qcodes Logfile : /Users/jana/.qcodes/logs/210816-14975-qcodes.log

Define databases

[2]:
db_name_original_data2D = "dot_tuning_sequences.db"
db_folder_original_data = os.path.join(nt_path, "data", "tuning")
chargediagram_path = os.path.join(db_folder_original_data, db_name_original_data2D)

db_name_replay = 'qdsim_test.db'
db_folder_replay = os.getcwd()

Create qc.Station

[3]:
station = Station()

qd_mock_instrument = MockDoubleQuantumDotInstrument()
station.add_component(qd_mock_instrument, name="qdmock")

qdsim = qd_mock_instrument.mock_device

Create the data provider

[4]:
charge_state_data = QcodesDataProvider(
    input_providers=[qdsim.left_plunger, qdsim.right_plunger],
    db_path=chargediagram_path,
    exp_name="GB_Newtown_Dev_1_1",
    run_id = 19,
)
qd_mock_instrument.drain.set_data_provider(charge_state_data)
[5]:
ds = nt.Dataset(19, db_name_original_data2D, db_folder_original_data)
range_to_sweep = [
    (min(ds.data.voltage_x.values), max(ds.data.voltage_x.values)),
    (min(ds.data.voltage_y.values), max(ds.data.voltage_y.values)),
]
# range_to_sweep
[6]:
nt.set_database(db_name_replay, db_folder_replay)
exp = load_or_create_experiment("simtest")
[7]:

chadiag = ChargeDiagram( data_settings=DataSettings( db_name=db_name_replay, db_folder=db_folder_replay, normalization_constants=NormalizationConstants(**ds.normalization_constants), segment_size=0.2, ), setpoint_settings=SetpointSettings( voltage_precision=0.01, parameters_to_sweep=[qd_mock_instrument.left_plunger, qd_mock_instrument.right_plunger], safety_voltage_ranges=[(-3, 0)], ranges_to_sweep=range_to_sweep, ), readout=Readout(transport=qd_mock_instrument.drain), classifiers=Classifiers( singledot=MockClassifer('singledot'), doubledot=MockClassifer('doubledot'), dotregime=MockClassifer('dotregime')), )
[8]:
tuning_result = chadiag.run_stage()
Starting experimental run with id: 6.
Starting experimental run with id: 25.
Starting experimental run with id: 26.
Starting experimental run with id: 27.
Starting experimental run with id: 28.
Starting experimental run with id: 29.
Starting experimental run with id: 30.
../_images/examples_Example_charge_diagram_stage_11_1.png
chargediagram: Good result measured. Regime: doubledot. Termination reasons: None.
[9]:
tuning_result.success
[9]:
True
[10]:
# Note that a mock classifier was used, which always returns True == good result
tuning_result.ml_result
[10]:
{'dot_segments': {25: {'voltage_ranges': [(-0.622073578595318,
     -0.428312955754153),
    (-0.451505016722408, -0.236013986013986)],
   'predicted_regime': 3},
  26: {'voltage_ranges': [(-0.622073578595318, -0.428312955754153),
    (-0.225752508361204, 0.0)],
   'predicted_regime': 3},
  27: {'voltage_ranges': [(-0.418115028236197, -0.224354405395033),
    (-0.451505016722408, -0.236013986013986)],
   'predicted_regime': 3},
  28: {'voltage_ranges': [(-0.418115028236197, -0.224354405395033),
    (-0.225752508361204, 0.0)],
   'predicted_regime': 3},
  29: {'voltage_ranges': [(-0.214156477877077, 0.0),
    (-0.451505016722408, -0.236013986013986)],
   'predicted_regime': 3},
  30: {'voltage_ranges': [(-0.214156477877077, 0.0),
    (-0.225752508361204, 0.0)],
   'predicted_regime': 3}},
 'regime': 'doubledot',
 'quality': True,
 'features': {'transport': {'triple_points': [([0.01446705392538605, None],
     [0.010197927517956007, 0.010261477652781958],
     [-0.193760622841165, -0.30784432958346],
     [-0.203958550359121, -0.297582851930678]),
    ([0.04583402317648589, None],
     [0.02039585503591196, 0.041045910611128],
     [-0.377323318164373, -0.082091821222256],
     [-0.356927463128461, -0.041045910611128]),
    ([0.014467053925386079, None],
     [0.010197927517956007, 0.010261477652782],
     [-0.499698448379846, -0.061568865916692],
     [-0.509896375897802, -0.05130738826391]),
    ([0.014467053925386079, None],
     [0.010197927517956007, 0.010261477652782],
     [-0.132573057733428, -0.061568865916692],
     [-0.142770985251384, -0.05130738826391])]}}}
[11]:
tuning_result.data_ids
[11]:
[6]
[ ]: