diff --git a/SQcircuit/circuit.py b/SQcircuit/circuit.py index 8271954..f287913 100755 --- a/SQcircuit/circuit.py +++ b/SQcircuit/circuit.py @@ -495,6 +495,8 @@ def safecopy(self, save_eigs=False): new_circuit._efreqs = sqf.array([]) new_circuit._evecs = [] + new_circuit.descrip_vars = None # TODO -- long-term change + # Deepcopy the whole thing return deepcopy(new_circuit) @@ -946,9 +948,9 @@ def compute_params(self): self.descrip_vars['charge_dim'] = np.sum(self.omega == 0) self.descrip_vars['omega'] = self.omega \ / (2 * np.pi * unt.get_unit_freq()) - + self.descrip_vars['phi_zp'] = (2 * np.pi / unt.Phi0) \ - * np.sqrt(unt.hbar / (2 * np.sqrt(np.diag(self.lTrans)[:harDim] + * np.sqrt(unt.hbar / (2 * np.sqrt(np.diag(self.lTrans)[:harDim] / np.diag(self.cInvTrans)[:harDim]))) self.descrip_vars['ng'] = [self.charge_islands[i].value() \ for i in range(harDim, self.n)] @@ -956,7 +958,7 @@ def compute_params(self): * unt.get_unit_freq())) \ * np.diag(np.repeat(0.5, self.n)) \ * self.cInvTrans - + self.descrip_vars['W'] = np.round(self.wTrans, 6) self.descrip_vars['S'] = np.round(self.S, 3) if self.loops: @@ -965,19 +967,14 @@ def compute_params(self): self.descrip_vars['B'] = np.zeros((len(self.elem_keys[Junction]) + len(self.elem_keys[Inductor]), 1)) - ## values of elements - def elem_value(val): - if get_optim_mode(): return val.item() - else: return val - - self.descrip_vars['EJ'] = [] + self.descrip_vars['EJ'] = [] for _, el, _, _ in self.elem_keys[Junction]: - self.descrip_vars['EJ'].append(elem_value(el.get_value()) / \ + self.descrip_vars['EJ'].append(sqf.numpy(el.get_value()) / \ (2 * np.pi * unt.get_unit_freq())) - self.descrip_vars['EL'] = [] + self.descrip_vars['EL'] = [] self.descrip_vars['EL_incl'] = [] for _, el, B_idx in self.elem_keys[Inductor]: - self.descrip_vars['EL'].append(elem_value(el.get_value(unt._unit_ind))) + self.descrip_vars['EL'].append(sqf.numpy(el.get_value(unt._unit_ind))) self.descrip_vars['EL_incl'].append( np.sum(np.abs(self.descrip_vars['B'][B_idx, :])) != 0) @@ -988,12 +985,12 @@ def elem_value(val): unt.hbar * 2 * np.pi * unt.get_unit_freq()) * \ self.cInvTrans[i, j] if i == j: - self.descrip_vars['EC'][(i,j)] /= 2 + self.descrip_vars['EC'][(i,j)] /= 2 ## values of loops self.descrip_vars['n_loops'] = len(self.loops) - self.descrip_vars['loops'] = [self.loops[i].value() / 2 / np.pi \ - for i in range(len(self.loops))] + self.descrip_vars['loops'] = [sqf.numpy(self.loops[i].value()) / 2 / np.pi \ + for i in range(len(self.loops))] def description( self, diff --git a/SQcircuit/symbolic.py b/SQcircuit/symbolic.py index add5adb..9872edc 100755 --- a/SQcircuit/symbolic.py +++ b/SQcircuit/symbolic.py @@ -20,7 +20,7 @@ def __new__(cls, plainname, latexname): def _latex(self, printer): return printer.doprint(self.lsymbol) - + class qOperator(Operator): """ @@ -36,7 +36,7 @@ def __new__(cls, name, subscript=None): self.opname = name self.sub = subscript return self - + def _latex(self, printer): if self.opname[-1] == 'd': tex = fr'\hat{{{self.opname[:-1]}}}^\dagger' @@ -51,7 +51,7 @@ def phi_op(i): fr'\hat{{\varphi}}_{{{i}}}') def a(i): - return qOperator('a', i) + return qOperator('a', i) def ad(i): return qOperator('ad', i) @@ -137,12 +137,12 @@ def jj_hamil(elem_keys, coeff_dict): sm.nsimplify(B_sym.dot(phi_exts)), evaluate=False)) return hamil - + def construct_hamiltonian(cr): LC_hamil = sm.Add(har_mode_hamil(cr.descrip_vars), charge_mode_hamil(cr.descrip_vars), evaluate=False) Ind_hamil = inductive_hamil(cr.elem_keys, cr.descrip_vars) JJ_hamil = jj_hamil(cr.elem_keys, cr.descrip_vars) - + return sm.Add(*[H for H in [LC_hamil, Ind_hamil, JJ_hamil] if H!=0], evaluate=False)