text
stringlengths 0
828
|
---|
slaves = len(gauge)
|
oper['O'] = np.array([spin_gen(slaves, i, c) for i, c in enumerate(gauge)])
|
oper['O_d'] = np.transpose(oper['O'], (0, 2, 1))
|
oper['O_dO'] = np.einsum('...ij,...jk->...ik', oper['O_d'], oper['O'])
|
oper['Sfliphop'] = spinflipandhop(slaves)"
|
4871,"def set_filling(self, populations):
|
""""""Sets the orbital enenergies for on the reference of the free case.
|
By setting the desired local populations on every orbital.
|
Then generate the necesary operators to respect such configuraion""""""
|
populations = np.asarray(populations)
|
#
|
# self.param['orbital_e'] -= bethe_findfill_zeroT( \
|
# self.param['avg_particles'],
|
# self.param['orbital_e'],
|
# self.param['hopping'])
|
efermi = - bethe_find_crystalfield(
|
populations, self.param['hopping'])
|
self.param['populations'] = populations
|
# fermion_avg(efermi, self.param['hopping'], 'ocupation')
|
self.param['ekin'] = fermion_avg(efermi, self.param['hopping'], 'ekin')
|
spin_gen_op(self.oper, estimate_gauge(populations))"
|
4872,"def reset(self, populations, lag, mu, u_int, j_coup, mean_f):
|
""""""Resets the system into the last known state as given by the input
|
values""""""
|
self.set_filling(populations)
|
self.param['lambda'] = lag
|
self.param['orbital_e'] = mu
|
self.selfconsistency(u_int, j_coup, mean_f)"
|
4873,"def update_H(self, mean_field, l):
|
""""""Updates the spin hamiltonian and recalculates its eigenbasis""""""
|
self.H_s = self.spin_hamiltonian(mean_field, l)
|
try:
|
self.eig_energies, self.eig_states = diagonalize(self.H_s)
|
except np.linalg.linalg.LinAlgError:
|
np.savez('errorhamil', H=self.H_s, fiel=mean_field, lamb=l)
|
raise
|
except ValueError:
|
np.savez('errorhamil', H=self.H_s, fiel=mean_field, lamb=l)
|
print(mean_field, l)
|
raise"
|
4874,"def spin_hamiltonian(self, h, l):
|
""""""Constructs the single site spin Hamiltonian""""""
|
h_spin = np.einsum('i,ijk', h[1], self.oper['O'])
|
h_spin += np.einsum('i,ijk', h[0], self.oper['O_d'])
|
h_spin += np.einsum('i,ijk', l, self.oper['Sz+1/2'])
|
h_spin += self.oper['Hint']
|
return h_spin"
|
4875,"def inter_spin_hamiltonian(self, u_int, J_coup):
|
""""""Calculates the interaction Hamiltonian. The Hund coupling is a
|
fraction of the coulom interaction""""""
|
J_coup *= u_int
|
h_int = (u_int - 2*J_coup)/2.*self.oper['sumSz2']
|
h_int += J_coup*self.oper['sumSz-sp2']
|
h_int -= J_coup/2.*self.oper['sumSz-or2']
|
h_int -= J_coup*self.oper['Sfliphop']
|
return h_int"
|
4876,"def expected(self, observable, beta=1e5):
|
""""""Wrapper to the expected_value function to fix the eigenbasis""""""
|
return expected_value(observable,
|
self.eig_energies,
|
self.eig_states,
|
beta)"
|
4877,"def quasiparticle_weight(self):
|
""""""Calculates quasiparticle weight""""""
|
return np.array([self.expected(op)**2 for op in self.oper['O']])"
|
4878,"def mean_field(self):
|
""""""Calculates mean field""""""
|
mean_field = []
|
for sp_oper in [self.oper['O'], self.oper['O_d']]:
|
avgO = np.array([self.expected(op) for op in sp_oper])
|
avgO[abs(avgO) < 1e-10] = 0.
|
mean_field.append(avgO*self.param['ekin'])
|
return np.array(mean_field)"
|
4879,"def selfconsistency(self, u_int, J_coup, mean_field_prev=None):
|
""""""Iterates over the hamiltonian to get the stable selfcosistent one""""""
|
if mean_field_prev is None:
|
mean_field_prev = np.array([self.param['ekin']]*2)
|
hlog = [mean_field_prev]
|
self.oper['Hint'] = self.inter_spin_hamiltonian(u_int, J_coup)
|
converging = True
|
half_fill = (self.param['populations'] == 0.5).all()
|
while converging:
|
if half_fill:
|
self.update_H(hlog[-1], self.param['lambda'])
|
else:
|
res = root(self.restriction, self.param['lambda'], (hlog[-1]))#, method='lm')
|
if not res.success:
|
res.x = res.x * 0.5 + 0.5*self.param['lambda']
|
self.update_H(self.mean_field()*0.5 + 0.5*hlog[-1], res.x)
|
print('fail', self.param['populations'][3:5])
|
if (self.quasiparticle_weight() < 0.001).all():
|
return hlog
|
self.param['lambda'] = res.x
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.