def wavefunction( self, esys: Tuple[ndarray, ndarray] = None, which: int = 0, phi_grid: discretization.Grid1d = None, ) -> storage.WaveFunctionOnGrid: """ Return a flux qubit wave function in phi1, phi2 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 """ evals_count = max(which + 1, 3) if esys is None: _, evecs = self.eigensys(evals_count) else: _, evecs = esys phi_grid = phi_grid or self._default_grid dim = 2 * self.ncut + 1 state_amplitudes = np.reshape(evecs[:, which], (dim, dim)) n_vec = np.arange(-self.ncut, self.ncut + 1) phi_vec = phi_grid.make_linspace() a_1_phi = np.exp(1j * np.outer(phi_vec, n_vec)) / (2 * np.pi) ** 0.5 a_2_phi = a_1_phi.T wavefunc_amplitudes = np.matmul(a_1_phi, state_amplitudes) wavefunc_amplitudes = np.matmul(wavefunc_amplitudes, a_2_phi) wavefunc_amplitudes = spec_utils.standardize_phases(wavefunc_amplitudes) grid2d = discretization.GridSpec( np.asarray( [ [phi_grid.min_val, phi_grid.max_val, phi_grid.pt_count], [phi_grid.min_val, phi_grid.max_val, phi_grid.pt_count], ] ) ) return storage.WaveFunctionOnGrid(grid2d, wavefunc_amplitudes)
def wavefunction( self, esys: Tuple[ndarray, ndarray] = None, which: int = 0, theta_grid: Grid1d = None, ) -> WaveFunctionOnGrid: """Returns a zero-pi wave function in `phi`, `theta` basis Parameters ---------- esys: eigenvalues, eigenvectors which: index of desired wave function (default value = 0) theta_grid: used for setting a custom grid for theta; if None use self._default_grid """ evals_count = max(which + 1, 3) if esys is None: _, evecs = self.eigensys(evals_count) else: _, evecs = esys theta_grid = theta_grid or self._default_grid dim_theta = 2 * self.ncut + 1 state_amplitudes = evecs[:, which].reshape(self.grid.pt_count, dim_theta) # Calculate psi_{phi, theta} = sum_n state_amplitudes_{phi, n} A_{n, theta} # where a_{n, theta} = 1/sqrt(2 pi) e^{i n theta} n_vec = np.arange(-self.ncut, self.ncut + 1) theta_vec = theta_grid.make_linspace() a_n_theta = np.exp(1j * np.outer(n_vec, theta_vec)) / (2 * np.pi) ** 0.5 wavefunc_amplitudes = np.matmul(state_amplitudes, a_n_theta).T wavefunc_amplitudes = spec_utils.standardize_phases(wavefunc_amplitudes) grid2d = discretization.GridSpec( np.asarray( [ [self.grid.min_val, self.grid.max_val, self.grid.pt_count], [theta_grid.min_val, theta_grid.max_val, theta_grid.pt_count], ] ) ) return storage.WaveFunctionOnGrid(grid2d, wavefunc_amplitudes)
def wavefunction(self, esys=None, which=0, phi_grid=None, zeta_grid=None, theta_grid=None) -> WaveFunctionOnGrid: """ Return a 3D wave function in :math:`\\phi, \\zeta, \\theta` basis Parameters ---------- esys: ndarray, ndarray eigenvalues, eigenvectors which: int, optional index of desired wave function (default value = 0) phi_grid: Grid1d, option used for setting a custom grid for phi; if None use self._default_phi_grid zeta_grid: Grid1d, option used for setting a custom grid for zeta; if None use self._default_zeta_grid theta_grid: Grid1d, option used for setting a custom grid for theta; if None use self._default_theta_grid """ evals_count = max(which + 1, 3) if esys is None: _, evecs = self.eigensys(evals_count) else: _, evecs = esys phi_grid = phi_grid or self._default_phi_grid zeta_grid = zeta_grid or self._default_zeta_grid theta_grid = theta_grid or self._default_theta_grid phi_basis_labels = phi_grid.make_linspace() zeta_basis_labels = zeta_grid.make_linspace() theta_basis_labels = theta_grid.make_linspace() wavefunc_basis_amplitudes = evecs[:, which].reshape( self._dim_phi(), self._dim_zeta(), self._dim_theta()) wavefunc_amplitudes = np.zeros( (phi_grid.pt_count, zeta_grid.pt_count, theta_grid.pt_count), dtype=np.complex_, ) for i in range(self._dim_phi()): for j in range(self._dim_zeta()): for k in range(self._dim_theta()): n_phi, n_zeta, n_theta = i, j, k - self.ncut phi_wavefunc_amplitudes = osc.harm_osc_wavefunction( n_phi, phi_basis_labels, self.phi_osc()) zeta_wavefunc_amplitudes = osc.harm_osc_wavefunction( n_zeta, zeta_basis_labels, self.zeta_osc()) theta_wavefunc_amplitudes = ( np.exp(-1j * n_theta * theta_basis_labels) / (2 * np.pi)**0.5) wavefunc_amplitudes += wavefunc_basis_amplitudes[ i, j, k] * np.tensordot( np.tensordot(phi_wavefunc_amplitudes, zeta_wavefunc_amplitudes, 0), theta_wavefunc_amplitudes, 0, ) grid3d = discretization.GridSpec( np.asarray([ [phi_grid.min_val, phi_grid.max_val, phi_grid.pt_count], [zeta_grid.min_val, zeta_grid.max_val, zeta_grid.pt_count], [theta_grid.min_val, theta_grid.max_val, theta_grid.pt_count], ])) return storage.WaveFunctionOnGrid(grid3d, wavefunc_amplitudes)