Skip to content
Snippets Groups Projects
Commit 0ad87ae7 authored by Stephan Philips's avatar Stephan Philips
Browse files

bugfixes

parent f7ff5e8e
No related branches found
No related tags found
No related merge requests found
......@@ -15,13 +15,7 @@ def inv_cap_to_cap_mat(inv_cap):
'''
inv_cap_no_view = np.asarray(inv_cap)
cap = np.linalg.inv(inv_cap_no_view)
cap_no_norm = np.zeros(inv_cap_no_view.shape)
# unnormalize
for i in range(cap.shape[0]):
cap_no_norm[i, :] = cap[i]/np.sum(cap[i, :])
return np.round(cap_no_norm,3)
return cap
def cap_to_inv_cap_mat(cap):
'''
......@@ -31,13 +25,7 @@ def cap_to_inv_cap_mat(cap):
inv_cap (np.ndarray) : matrix representing the inverse of the capacitance of the dots (normalized).
'''
cap_no_view = np.asarray(cap)
inv_cap_no_view = np.linalg.inv(cap)
inv_cap_no_norm = np.zeros(inv_cap_no_view.shape)
# unnormalize
for i in range(inv_cap_no_view.shape[0]):
inv_cap_no_norm[i, :] = inv_cap_no_view[i, :]/inv_cap_no_view[i,i]
return np.round(inv_cap_no_norm,3)
return np.linalg.inv(cap_no_view)
class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
"""docstring for virt_gate_matrix_GUI"""
......@@ -226,36 +214,29 @@ class virt_gate_matrix_GUI(QtWidgets.QMainWindow, Ui_MainWindow):
doubleSpinBox.setMinimum(-5.0)
doubleSpinBox.setSingleStep(0.01)
doubleSpinBox.setDecimals(3)
inverted_matrix = np.linalg.inv(virtual_gate_set.virtual_gate_matrix)
inverted_matrix = np.linalg.inv(virtual_gate_set.virtual_gate_matrix_no_norm)
doubleSpinBox.setValue(inverted_matrix[i,j])
doubleSpinBox.setObjectName("doubleSpinBox")
doubleSpinBox.valueChanged.connect(partial(self.linked_result, virtual_gate_set.virtual_gate_matrix, i, j, doubleSpinBox))
doubleSpinBox.valueChanged.connect(partial(self.linked_result, virtual_gate_set.virtual_gate_matrix_no_norm, i, j, doubleSpinBox))
update_list.append((i,j, doubleSpinBox))
tableWidget.setCellWidget(i, j, doubleSpinBox)
# make a timer to refresh the data in the plot when the matrix is changed externally.
timer = QtCore.QTimer()
timer.timeout.connect(partial(self.update_v_gates, virtual_gate_set.virtual_gate_matrix, update_list))
timer.timeout.connect(partial(self.update_v_gates, virtual_gate_set.virtual_gate_matrix_no_norm, update_list))
timer.start(2000)
self.timers.append(timer)
def linked_result(self, matrix, i, j, spin_box):
def linked_result(self, matrix, i, j, spin_box):
matrix_no_view = np.asarray(matrix)
inv_cap = cap_to_inv_cap_mat(matrix)
inv_cap[i,j] = spin_box.value()
cap_mat = inv_cap_to_cap_mat(inv_cap)
matrix_no_view = np.asarray(matrix)
matrix_no_view[:, :] = cap_mat
print(inv_cap)
print(matrix_no_view)
# matrix_no_view = np.asarray(matrix)
# matrix_inv = np.linalg.inv(matrix_no_view)
# matrix_inv[i,j] = spin_box.value()
# matrix_nrml = np.linalg.inv(matrix_inv)
# matrix_no_view[:, :] = matrix_nrml
self.gates_object.hardware.sync_data()
def update_v_gates(self, matrix, update_list):
......@@ -277,7 +258,7 @@ if __name__ == "__main__":
import qcodes as qc
from V2_software.drivers.virtual_gates.examples.hardware_example import hardware_example
from V2_software.drivers.virtual_gates.instrument_drivers.virtual_dac import virtual_dac
from V2_software.drivers.virtual_gates.instrument_drivers.gates import gates
from core_tools.drivers.gates import gates
my_dac_1 = virtual_dac("dac_a", "virtual")
my_dac_2 = virtual_dac("dac_b", "virtual")
......
......@@ -21,7 +21,8 @@ class virtual_gate:
'''
self.name = name
self.real_gate_names = real_gate_names
self.virtual_gate_matrix = np.eye(len(real_gate_names)).data
self._virtual_gate_matrix = np.eye(len(real_gate_names)).data
self.virtual_gate_matrix_no_norm = np.eye(len(real_gate_names)).data
if virtual_gate_names != None:
self.virtual_gate_names = virtual_gate_names
else:
......@@ -32,6 +33,16 @@ class virtual_gate:
if len(self.real_gate_names) != len(self.virtual_gate_names):
raise ValueError("number of real gates and virtual gates is not equal, please fix the input.")
@property
def virtual_gate_matrix(self):
cap_no_norm = np.asarray(self.virtual_gate_matrix_no_norm)
cap = np.asarray(self._virtual_gate_matrix)
for i in range(cap.shape[0]):
cap[i, :] = cap_no_norm[i]/np.sum(cap_no_norm[i, :])
return self._virtual_gate_matrix
def __len__(self):
'''
get number of gate in the object.
......@@ -43,14 +54,16 @@ class virtual_gate:
overwrite state methods so object becomes pickable.
'''
state = self.__dict__.copy()
state["virtual_gate_matrix"] = np.asarray(self.virtual_gate_matrix)
state["_virtual_gate_matrix"] = np.asarray(self._virtual_gate_matrix)
state["virtual_gate_matrix_no_norm"] = np.asarray(self.virtual_gate_matrix_no_norm)
return state
def __setstate__(self, new_state):
'''
overwrite state methods so object becomes pickable.
'''
new_state["virtual_gate_matrix"] = np.asarray(new_state["virtual_gate_matrix"]).data
new_state["_virtual_gate_matrix"] = np.asarray(new_state["_virtual_gate_matrix"]).data
new_state["virtual_gate_matrix_no_norm"] = np.asarray(new_state["virtual_gate_matrix_no_norm"]).data
self.__dict__.update(new_state)
class virtual_gates_mgr(list):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment