Ejemplo n.º 1
0
 def print_x(self, xk, gap=np.nan, detr=np.nan):
     elapsed = time.time() - self.start
     data = [self.counter, self.args['results']['fun'], elapsed - self.prev]
     data += [gap, detr]
     data += xk.tolist()
     save_to_file(self.f, data, True)
     self.prev = elapsed
Ejemplo n.º 2
0
    def diag_obc(self):
        N = self.args['wire'].N
        nb = self.args['wire'].nsc

        h = self.args['wire'].make_OBC_hamiltonian()
        eigvals, eigvecs = np.linalg.eigh(h)
        save_to_file(self.f_diag_eig, eigvals, True)
        nbv = self.cb_opts['nb_eigvecs']
        save_to_file(
            self.f_diag_vec,
            [range(2*nb-nbv, 2*nb+nbv), eigvecs[:, 2*nb-nbv:2*nb+nbv].T], True
        )
Ejemplo n.º 3
0
    def getGap(self, bh_iter=False):
        sol = self.args['wire'].make_RGF_solver()
        energies = self.args['energies']
        cond = []
        for en in energies:
            cond.append(sol.conductance_BdeG('L', en + 1e-8))
        rMat = sol.rMatrix_majorana('L')
        detr = fctDef.getDetr(rMat, sol)

        save_to_file(self.fc, np.real(cond), True)

        return None, detr
Ejemplo n.º 4
0
 def open_files(self, name, iter):
     if self.cb_opts.get('print_cond', False):
         self.fc = self.filename('cond', iter)
         save_to_file(self.fc, [None], False)
     if self.cb_opts.get('print_dos', False):
         self.fd = self.filename('dos', iter)
         save_to_file(self.fd, [None], False)
     if self.cb_opts.get('print_ldos', False):
         self.f_ldos = self.filename('ldos', iter)
         save_to_file(self.f_ldos, [None], False)
     if self.cb_opts.get('print_diag_obc', False):
         self.f_diag_eig = self.filename('diag_eig', iter)
         save_to_file(self.f_diag_eig, [None], False)
         self.f_diag_vec = self.filename('diag_vec', iter)
         save_to_file(self.f_diag_vec, [None], False)
Ejemplo n.º 5
0
    def basinhopping_callback(self, xk, f, accept):
        elapsed = time.time() - self.start
        self.bh_counter += 1
        if self.cb_opts.get('bh_verbose', False):
            sent = 'Basin hopping callback: '
            print('{}\t{}\t{}'.format(sent, self.counter, elapsed))
            print(f, accept)

        dataline = [self.bh_counter, self.counter, f, int(accept)]
        dataline += [elapsed - self.bh_prev]
        dataline += [self.args.get('penalty_weight',0)]
        dataline += xk.tolist()
        save_to_file(self.fbh, dataline, True)
        self.bh_prev = elapsed

        self.close_files()
      
        if self.bh_best is None:
            self.bh_best = f
        elif f <= self.bh_best:
            self.bh_best = f
Ejemplo n.º 6
0
 def print_header_bh_file(self):
     title = ['iter', 'iter_opt', 'Phi', 'accept', 'iter_time', 'penalty_weight']
     title += ['x{}'.format(i) for i in range(self.dims)]
     save_to_file(self.fbh, title)
Ejemplo n.º 7
0
 def print_header_iter_file(self):
     title = ['iter', 'Phi', 'iter_time', 'hgap', 'det_r']
     title += ['x{}'.format(i) for i in range(self.dims)]
     save_to_file(self.f, title, False)
Ejemplo n.º 8
0
 def close_files(self):
     save_to_file(self.f, [None], True)
     if self.cb_opts.get('print_cond', False):
         save_to_file(self.fc, [None], True)
     if self.cb_opts.get('print_dos', False):
         save_to_file(self.fd, [None], True)
     if self.cb_opts.get('print_ldos', False):
         save_to_file(self.f_ldos, [None], True)
     if self.cb_opts.get('print_diag_obc', False):
         save_to_file(self.f_diag_eig, [None], True)
         save_to_file(self.f_diag_vec, [None], True)
Ejemplo n.º 9
0
 def print_ldos(self):
     sol = self.args['wire'].make_RGF_solver()
     ldos = ldos_utils.ldos_vs_X(sol, self.args['E0'], BdeG=True)
     save_to_file(self.f_ldos, ldos.real, True)
Ejemplo n.º 10
0
 def print_dos(self):
     sol = self.args['wire'].make_RGF_solver()
     dos = []
     for en in self.args['energies']:
         dos.append(np.sum(ldos_utils.ldos_vs_X(sol, en, BdeG=True)))
     save_to_file(self.fd, np.real(dos), True)