def test_compare_qtcurrent_to_tucker_theory(): """This test will compare the quasiparticle tunneling currents that are calculated by qmix.qtcurrent to results calculated from Tucker theory (Tucker & Feldman, 1985). Tucker theory uses much simpler equations to calculate the tunneling currents, so it is easier to be sure that the Tucker functions are working properly. The functions that are used calculate the currents from Tucker theory are found at the bottom of this file. Note: The Tucker theory functions that are included within this file only work for a single tone/single harmonic simulation.""" # Build embedding circuit cct = EmbeddingCircuit(1, 1, vb_min=0, vb_npts=101) freq = 0.33 cct.freq[1] = freq # Set voltage across junction to Vph * 0.8 alpha = 0.8 vj = cct.initialize_vj() vj[1, 1, :] = cct.freq[1] * alpha # Calculate QTC using QMix idc_qmix = qtcurrent(vj, cct, RESP, 0.) # DC iac_qmix = qtcurrent(vj, cct, RESP, cct.freq[1]) # AC # Calculate QTC using Tucker theory idc_tucker = _tucker_dc_current(VBIAS, RESP, alpha, freq) # DC iac_tucker = _tucker_ac_current(VBIAS, RESP, alpha, freq) # AC # Compare methods np.testing.assert_almost_equal(idc_qmix, idc_tucker, decimal=15) np.testing.assert_almost_equal(iac_qmix, iac_tucker, decimal=15)
def test_setting_up_simulation_using_different_harmonic(): """Simulate the QTCs using a one tone/one harmonic simulation. Then simulate the same setup using a higher-order harmonic. For example, simulate a signal at 200 GHz. Then simulate the second-harmonic from a 100 GHz fundamental tone. Both simulations should provide the same result.""" num_b = 15 # number of Bessel functions to include num_f = 1 # number of frequencies freq = 0.3 # frequency, normalized alpha = 0.8 # drive level # Basic simulation for comparison ---------------------------------------- num_p = 1 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = freq vj = cct.initialize_vj() vj[1, 1, :] = freq * alpha i1 = qtcurrent(vj, cct, RESP, cct.freq, num_b) i1_dc = i1[0].real i1_ac = i1[-1] # Using a fundamental tone that is half the original frequency ----------- num_p = 2 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = freq / 2. vj = cct.initialize_vj() vj[1, 2, :] = freq * alpha freq_list = [0, freq/2., freq] i2 = qtcurrent(vj, cct, RESP, freq_list, num_b*2) i2_dc = i2[0].real i2_ac = i2[-1] # Compare methods # dc np.testing.assert_almost_equal(i1_dc, i2_dc, decimal=15) # ac at fundamental np.testing.assert_almost_equal(i1_ac, i2_ac, decimal=15) # lower order harmonics should all be zero np.testing.assert_equal(i2[1], np.zeros_like(i2[1]))
def test_effect_of_adding_more_tones_on_if(): """Calculate the IF signal that is generated by a simple 2 tone simulation. Then, add the IF frequency to the simulation. This should not have any effect on the IF results.""" alpha1 = 0.8 freq1 = 0.3 freq2 = 0.35 freq_list = [0, freq1, freq2] num_b = (9, 5, 5, 5) # 2 tones ---------------------------------------------------------------- num_f = 2 num_p = 1 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = freq1 cct.freq[2] = freq2 vj = cct.initialize_vj() vj[1, 1, :] = cct.freq[1] * alpha1 vj[2, 1, :] = 1e-5 idc2, ilo2, iif2 = qtcurrent(vj, cct, RESP, freq_list, num_b) # 3 tones ---------------------------------------------------------------- num_f = 3 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = freq1 cct.freq[2] = freq2 cct.freq[3] = abs(freq1 - freq2) vj = cct.initialize_vj() vj[1, 1, :] = cct.freq[1] * alpha1 vj[2, 1, :] = 1e-5 idc3, ilo3, iif3 = qtcurrent(vj, cct, RESP, freq_list, num_b) # Compare results -------------------------------------------------------- # Compare methods np.testing.assert_almost_equal(idc2, idc3, decimal=15) np.testing.assert_almost_equal(iif2.real, iif3.real, decimal=15) np.testing.assert_almost_equal(iif2.imag, iif3.imag, decimal=15)
def two_tone(): qtcurrent(vj, cct, resp, 0., num_b=num_b, verbose=False)
def one_tone(): current = qtcurrent(vj, cct, resp, 0., num_b=num_b, verbose=False)
cct = qmix.circuit.EmbeddingCircuit(1, 1) cct.freq[1] = 0.3 vj = cct.initialize_vj() vj[1, 1, :] = 0.3 def one_tone(): current = qtcurrent(vj, cct, resp, 0., num_b=num_b, verbose=False) t_1tone = min(timeit.Timer(one_tone).repeat(3000, 1)) print("1 tone:\t\t{:7.2f} ms".format(t_1tone * 1000)) # Compare to previously calculated values current_test = qtcurrent(vj, cct, resp, 0., num_b=num_b, verbose=False) if args.overwrite: print(" -> Saving current") with open('data/qtcurrent1.data', 'wb') as f: pickle.dump(current_test, f) else: print(" -> Checking current") with open('data/qtcurrent1.data', 'rb') as f: current_known = pickle.load(f) numpy.testing.assert_almost_equal(current_test, current_known, decimal=15) # 2 tone --------------------------------------------------------------------- if args.tone is None or args.tone == 2:
def test_effect_of_adding_more_tones(): """This function simulates the QTCs using a 1 tone/1 harmonic simulation. Then, more and more tones are added except only the first tone is ever excited. This should result in the same tunnelling currents being calculated in each simulation. Note: 1, 2, 3 and 4 tone simulations use different calculation techniques, so this test should make sure that they are all equivalent.""" num_b = (9, 2, 2, 2) alpha1 = 0.8 # drive level, tone 1 freq1 = 0.33 # frequency, tone 1 # Setup 1st tone for comparison ------------------------------------------ num_f = 1 num_p = 1 cct1 = EmbeddingCircuit(num_f, num_p) cct1.freq[1] = freq1 vj = cct1.initialize_vj() vj[1, 1, :] = cct1.freq[1] * alpha1 i1 = qtcurrent(vj, cct1, RESP, cct1.freq, num_b) idc1 = np.real(i1[0, :]) iac1 = i1[1, :] # 2 tones ---------------------------------------------------------------- num_f = 2 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = cct1.freq[1] cct.freq[2] = cct1.freq[1] + 0.05 vj = cct.initialize_vj() vj[1, 1, :] = cct1.freq[1] * alpha1 i2 = qtcurrent(vj, cct, RESP, cct.freq, num_b) idc2 = np.real(i2[0, :]) iac2 = i2[1, :] # 3 tones ---------------------------------------------------------------- num_f = 3 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = cct1.freq[1] cct.freq[2] = cct1.freq[1] + 0.05 cct.freq[3] = cct1.freq[1] + 0.10 vj = cct.initialize_vj() vj[1, 1, :] = cct1.freq[1] * alpha1 i3 = qtcurrent(vj, cct, RESP, cct.freq, num_b) idc3 = np.real(i3[0, :]) iac3 = i3[1, :] # 4 tones ---------------------------------------------------------------- num_f = 4 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = cct1.freq[1] cct.freq[2] = cct1.freq[1] + 0.05 cct.freq[3] = cct1.freq[1] + 0.10 cct.freq[4] = cct1.freq[1] + 0.15 vj = cct.initialize_vj() vj[1, 1, :] = cct.freq[1] * alpha1 i4 = qtcurrent(vj, cct, RESP, cct.freq, num_b) idc4 = np.real(i4[0, :]) iac4 = i4[1, :] # Compare results -------------------------------------------------------- # Compare methods # dc np.testing.assert_equal(idc1, idc2) np.testing.assert_equal(idc1, idc3) np.testing.assert_equal(idc1, idc4) # ac np.testing.assert_equal(iac1, iac2) np.testing.assert_equal(iac1, iac3) np.testing.assert_equal(iac1, iac4) # ensure all other tones are zero np.testing.assert_equal(i2[2, :], np.zeros_like(i2[2, :])) np.testing.assert_equal(i3[2, :], np.zeros_like(i3[2, :])) np.testing.assert_equal(i3[3, :], np.zeros_like(i3[3, :])) np.testing.assert_equal(i4[2, :], np.zeros_like(i4[2, :])) np.testing.assert_equal(i4[3, :], np.zeros_like(i4[3, :])) np.testing.assert_equal(i4[4, :], np.zeros_like(i4[4, :]))
def test_excite_different_tones(): """Calculate the QTCs using a 4 tone simulation. Do this 4 times, each time exciting a different tone. Each simulation should be the same.""" # input signal properties vj_set = 0.25 # 1st tone excited num_f = 4 num_p = 1 num_b = (9, 3, 3, 3) cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = 0.3 cct.freq[2] = 0.4 cct.freq[3] = 0.5 cct.freq[4] = 0.6 vj = cct.initialize_vj() vj[1, 1, :] = vj_set idc1 = qtcurrent(vj, cct, RESP, 0, num_b) # 2nd tone excited num_f = 4 num_p = 1 num_b = (3, 9, 3, 3) cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = 0.4 cct.freq[2] = 0.3 cct.freq[3] = 0.5 cct.freq[4] = 0.6 vj = cct.initialize_vj() vj[2, 1, :] = vj_set idc2 = qtcurrent(vj, cct, RESP, 0, num_b) # 3rd tone excited num_f = 4 num_p = 1 num_b = (3, 3, 9, 3) cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = 0.5 cct.freq[2] = 0.4 cct.freq[3] = 0.3 cct.freq[4] = 0.6 vj = cct.initialize_vj() vj[3, 1, :] = vj_set idc3 = qtcurrent(vj, cct, RESP, 0, num_b) # 4th tone excited num_f = 4 num_p = 1 num_b = (3, 3, 3, 9) cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = 0.6 cct.freq[2] = 0.4 cct.freq[3] = 0.5 cct.freq[4] = 0.3 vj = cct.initialize_vj() vj[4, 1, :] = vj_set idc4 = qtcurrent(vj, cct, RESP, 0, num_b) # Compare methods np.testing.assert_almost_equal(idc1, idc2, decimal=15) np.testing.assert_almost_equal(idc1, idc3, decimal=15) np.testing.assert_almost_equal(idc1, idc4, decimal=15)
def test_effect_of_adding_more_harmonics(): """This test calculates the QTCs using a 1 tone/1 harmonic simulation. Then, more and more harmonics are added except only the first harmonic is ever excited. This should result in the same tunnelling currents being calculated in each simulation.""" num_b = 9 alpha1 = 0.8 # drive level, harmonic 1 freq1 = 0.33 # frequency, harmonic 1 # Setup 1st tone for comparison ------------------------------------------ num_f = 1 num_p = 1 cct1 = EmbeddingCircuit(num_f, num_p) cct1.freq[1] = freq1 vj = cct1.initialize_vj() vj[1, 1, :] = cct1.freq[1] * alpha1 freq_list = [0, freq1] i1 = qtcurrent(vj, cct1, RESP, freq_list, num_b) idc1 = i1[0, :].real # 2 harmonics ------------------------------------------------------------ num_p = 2 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = cct1.freq[1] vj = cct.initialize_vj() vj[1, 1, :] = cct1.freq[1] * alpha1 freq_list = [0, freq1, freq1*2] i2 = qtcurrent(vj, cct, RESP, freq_list, num_b) idc2 = i2[0, :].real # 3 harmonics ------------------------------------------------------------ num_p = 3 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = cct1.freq[1] vj = cct.initialize_vj() vj[1, 1, :] = cct1.freq[1] * alpha1 freq_list = [0, freq1, freq1*2, freq1*3] i3 = qtcurrent(vj, cct, RESP, freq_list, num_b) idc3 = i3[0, :].real # 4 harmonics ------------------------------------------------------------ num_p = 4 cct = EmbeddingCircuit(num_f, num_p) cct.freq[1] = cct1.freq[1] vj = cct.initialize_vj() vj[1, 1, :] = cct1.freq[1] * alpha1 freq_list = [0, freq1, freq1*2, freq1*3, freq1*4] i4 = qtcurrent(vj, cct, RESP, freq_list, num_b) idc4 = i4[0, :].real # Compare results -------------------------------------------------------- # Compare methods # dc np.testing.assert_equal(idc1, idc2) np.testing.assert_equal(idc1, idc3) np.testing.assert_equal(idc1, idc4) # ac at fundamental np.testing.assert_equal(i1[1, :], i2[1, :]) np.testing.assert_equal(i1[1, :], i3[1, :]) np.testing.assert_equal(i1[1, :], i4[1, :]) # ac at 2nd harmonic np.testing.assert_equal(i2[2, :], i3[2, :]) np.testing.assert_equal(i2[2, :], i4[2, :]) # ac at 3rd harmonic np.testing.assert_equal(i3[3, :], i4[3, :])