def wavefunction(self, esys: Tuple[ndarray, ndarray], which: int = 0, phi_grid: 'Grid1d' = None) -> storage.WaveFunction: """Returns a fluxonium wave function in `phi` basis Parameters ---------- esys: eigenvalues, eigenvectors which: index of desired wave function (default value = 0) phi_grid: used for setting a custom grid for phi; if None use self._default_grid """ if esys is None: evals_count = max(which + 1, 3) evals, evecs = self.eigensys(evals_count) else: evals, evecs = esys dim = self.hilbertdim() phi_grid = phi_grid or self._default_grid phi_basis_labels = phi_grid.make_linspace() wavefunc_osc_basis_amplitudes = evecs[:, which] phi_wavefunc_amplitudes = np.zeros(phi_grid.pt_count, dtype=np.complex_) phi_osc = self.phi_osc() for n in range(dim): phi_wavefunc_amplitudes += wavefunc_osc_basis_amplitudes[n] \ * osc.harm_osc_wavefunction(n, phi_basis_labels, phi_osc) return storage.WaveFunction(basis_labels=phi_basis_labels, amplitudes=phi_wavefunc_amplitudes, energy=evals[which])
def wavefunction( self, esys: Tuple[ndarray, ndarray] = None, which: int = 0, phi_grid: Grid1d = None, ) -> WaveFunction: """Return the transmon wave function in phase basis. The specific index of the wavefunction is `which`. `esys` can be provided, but if set to `None` then it is calculated on the fly. Parameters ---------- esys: if None, the eigensystem is calculated on the fly; otherwise, the provided eigenvalue, eigenvector arrays as obtained from `.eigensystem()` are used which: eigenfunction index (default value = 0) phi_grid: used for setting a custom grid for phi; if None use self._default_grid """ if esys is None: evals_count = max(which + 1, 3) evals, evecs = self.eigensys(evals_count) else: evals, evecs = esys n_wavefunc = self.numberbasis_wavefunction(esys, which=which) phi_grid = phi_grid or self._default_grid phi_basis_labels = phi_grid.make_linspace() phi_wavefunc_amplitudes = np.empty(phi_grid.pt_count, dtype=np.complex_) for k in range(phi_grid.pt_count): phi_wavefunc_amplitudes[k] = ( 1j**which / math.sqrt(2 * np.pi)) * np.sum( n_wavefunc.amplitudes * np.exp(1j * phi_basis_labels[k] * n_wavefunc.basis_labels)) return storage.WaveFunction( basis_labels=phi_basis_labels, amplitudes=phi_wavefunc_amplitudes, energy=evals[which], )
def numberbasis_wavefunction(self, esys: Tuple[ndarray, ndarray] = None, which: int = 0) -> WaveFunction: """Return the transmon wave function in number basis. The specific index of the wave function to be returned is `which`. Parameters ---------- esys: if `None`, the eigensystem is calculated on the fly; otherwise, the provided eigenvalue, eigenvector arrays as obtained from `.eigensystem()`, are used (default value = None) which: eigenfunction index (default value = 0) """ if esys is None: evals_count = max(which + 1, 3) esys = self.eigensys(evals_count) evals, evecs = esys n_vals = np.arange(-self.ncut, self.ncut + 1) return storage.WaveFunction(n_vals, evecs[:, which], evals[which])