def get_propagation(self, ham, psi_init, steps, dz, norm=False): """ Get the time evolution. :param ham: sparse.csr_matrix. Tight-Binding Hamilonian. :param psi_init: np.ndarray. Initial state. :param steps: Positive Integer. Number of steps. :param dz: Positive number. Step. :param norm: Boolean. Default value True. Normalize the norm to 1 at each step. """ error_handling.empty_ham(ham) error_handling.ndarray(psi_init, "psi_init", self.lat.sites) error_handling.positive_int(steps, "steps") error_handling.positive_real(dz, "dz") error_handling.boolean(norm, "norm") self.steps = steps self.dz = dz self.prop = np.empty((self.lat.sites, self.steps), "c16") self.prop[:, 0] = psi_init diag = 1j * np.ones(self.lat.sites, "c16") A = (sparse.diags(diag, 0) - 0.5 * self.dz * ham).toarray() B = (sparse.diags(diag, 0) + 0.5 * self.dz * ham).toarray() mat = np.dot(LA.inv(A), B) for i in range(1, self.steps): self.prop[:, i] = np.dot(mat, self.prop[:, i - 1]) if norm: self.prop[:, i] /= np.abs(self.prop[:, i]).sum()
def get_propagation(self, ham, psi_init, steps, dz, norm=False): ''' Get the time evolution. :param ham: sparse.csr_matrix. Tight-Binding Hamilonian. :param psi_init: np.ndarray. Initial state. :param steps: Positive Integer. Number of steps. :param dz: Positive number. Step. :param norm: Boolean. Default value True. Normalize the norm to 1 at each step. ''' error_handling.empty_ham(ham) error_handling.ndarray(psi_init, 'psi_init', self.lat.sites) error_handling.positive_int(steps, 'steps') error_handling.positive_real(dz, 'dz') error_handling.boolean(norm, 'norm') self.steps = steps self.dz = dz self.prop = np.empty((self.lat.sites, self.steps), 'c16') self.prop[:, 0] = psi_init diag = 1j*np.ones(self.lat.sites, 'c16') A = (sparse.diags(diag, 0) - 0.5 * self.dz * ham).toarray() B = (sparse.diags(diag, 0) + 0.5 * self.dz * ham).toarray() mat = (np.dot(LA.inv(A), B)) for i in range(1, self.steps): self.prop[:, i] = np.dot(mat, self.prop[:, i-1]) if norm: self.prop[:, i] /= np.abs(self.prop[:, i]).sum()
def get_pumping(self, hams, psi_init, steps, dz, norm=True): ''' Get the time evolution with adiabatic pumpings. :param hams: List of sparse.csr_matrices. Tight-Binding Hamilonians. :param psi_init: np.ndarray. Initial state. :param steps: Positive integer. Number of steps. :param dz: Positive number. Step. :param norm: Boolean. Default value True. Normalize the norm to 1 at each step. ''' error_handling.get_pump(hams) error_handling.ndarray(psi_init, 'psi_init', self.lat.sites) error_handling.positive_int(steps, 'steps') error_handling.positive_real(dz, 'dz') error_handling.boolean(norm, 'norm') self.steps = steps self.dz = dz no = len(hams) self.prop = np.empty((self.lat.sites, self.steps), 'c16') self.prop[:, 0] = psi_init diag = 1j * np.ones(self.lat.sites, 'c16') delta = self.steps // (1 + no) A = (sparse.diags(diag, 0) - 0.5 * self.dz * hams[0]).toarray() B = (sparse.diags(diag, 0) + 0.5 * self.dz * hams[0]).toarray() mat = (np.dot(LA.inv(A), B)) # before pumping for i in range(1, delta): self.prop[:, i] = np.dot(mat, self.prop[:, i-1]) if norm: self.prop[:, i] /= np.abs(self.prop[:, i]).sum() # pumping c = np.linspace(0, 1, delta) for j in range(0, no-1): for i in range(0, delta): ham = (1-c[i])*hams[j]+c[i]*hams[j+1] A = (sparse.diags(diag, 0) - 0.5 * self.dz * ham).toarray() B = (sparse.diags(diag, 0) + 0.5 * self.dz * ham).toarray() mat = (np.dot(LA.inv(A), B)) self.prop[:, (j+1)*delta+i] = np.dot(mat, self.prop[:, (j+1)*delta+i-1]) if norm: self.prop[:, (j+1)*delta+i] /= \ np.abs(self.prop[:, (j+1)*delta+i]).sum() # after pumping j = no for i in range(0, self.steps - no*delta): self.prop[:, no*delta+i] = np.dot(mat, self.prop[:, no*delta+i-1]) if norm: self.prop[:, no*delta+i] /= np.abs(self.prop[:, no*delta+i]).sum()
def get_pumping(self, hams, psi_init, steps, dz, norm=True): """ Get the time evolution with adiabatic pumpings. :param hams: List of sparse.csr_matrices. Tight-Binding Hamilonians. :param psi_init: np.ndarray. Initial state. :param steps: Positive integer. Number of steps. :param dz: Positive number. Step. :param norm: Boolean. Default value True. Normalize the norm to 1 at each step. """ error_handling.get_pump(hams) error_handling.ndarray(psi_init, "psi_init", self.lat.sites) error_handling.positive_int(steps, "steps") error_handling.positive_real(dz, "dz") error_handling.boolean(norm, "norm") self.steps = steps self.dz = dz no = len(hams) self.prop = np.empty((self.lat.sites, self.steps), "c16") self.prop[:, 0] = psi_init diag = 1j * np.ones(self.lat.sites, "c16") delta = self.steps // (1 + no) A = (sparse.diags(diag, 0) - 0.5 * self.dz * hams[0]).toarray() B = (sparse.diags(diag, 0) + 0.5 * self.dz * hams[0]).toarray() mat = np.dot(LA.inv(A), B) # before pumping for i in range(1, delta): self.prop[:, i] = np.dot(mat, self.prop[:, i - 1]) if norm: self.prop[:, i] /= np.abs(self.prop[:, i]).sum() # pumping c = np.linspace(0, 1, delta) for j in range(0, no - 1): for i in range(0, delta): ham = (1 - c[i]) * hams[j] + c[i] * hams[j + 1] A = (sparse.diags(diag, 0) - 0.5 * self.dz * ham).toarray() B = (sparse.diags(diag, 0) + 0.5 * self.dz * ham).toarray() mat = np.dot(LA.inv(A), B) self.prop[:, (j + 1) * delta + i] = np.dot(mat, self.prop[:, (j + 1) * delta + i - 1]) if norm: self.prop[:, (j + 1) * delta + i] /= np.abs(self.prop[:, (j + 1) * delta + i]).sum() # after pumping j = no for i in range(0, self.steps - no * delta): self.prop[:, no * delta + i] = np.dot(mat, self.prop[:, no * delta + i - 1]) if norm: self.prop[:, no * delta + i] /= np.abs(self.prop[:, no * delta + i]).sum()
def ani(self, ani, name, fps=10): error_handling.ani(ani) error_handling.string(name, 'name') error_handling.positive_int(fps, 'fps') name_file = self.dir_name + '/' + name + '.mp4' ani.save(name_file, fps=fps, extra_args=['-vcodec', 'libx264'])