|
197 | 197 | " smpl_wn = {'F': self.IR_basis_set.smpl_wn_f, 'B': self.IR_basis_set.smpl_wn_b }[statistics]\n", |
198 | 198 | " return smpl_tau, smpl_wn\n", |
199 | 199 | "\n", |
200 | | - " \n", |
| 200 | + "\n", |
201 | 201 | " def tau_to_wn(self, statistics, obj_tau):\n", |
202 | 202 | " \"\"\" Fourier transform from tau to iwn via IR basis \"\"\"\n", |
203 | 203 | " smpl_tau, smpl_wn = self.smpl_obj(statistics)\n", |
|
216 | 216 | " obj_tau = smpl_tau.evaluate(obj_l, axis=0).reshape((smpl_tau.tau.size, self.nk))\n", |
217 | 217 | " return obj_tau\n", |
218 | 218 | "\n", |
219 | | - " \n", |
| 219 | + "\n", |
220 | 220 | " def k_to_r(self,obj_k):\n", |
221 | 221 | " \"\"\" Fourier transform from k-space to real space \"\"\"\n", |
222 | 222 | " obj_k = obj_k.reshape(-1, self.nk1, self.nk2)\n", |
|
252 | 252 | " def __init__(self, mesh, U, n, U_sfc_tol=1e-12, verbose=True):\n", |
253 | 253 | " \"\"\"\n", |
254 | 254 | " Solver class to calculate the TPSC method.\n", |
255 | | - " After initializing the Solver by `solver = TPSCSolver(mesh, U, n, **kwargs)` it \n", |
| 255 | + " After initializing the Solver by `solver = TPSCSolver(mesh, U, n, **kwargs)` it\n", |
256 | 256 | " can be run by `solver.solve()`.\n", |
257 | 257 | " \"\"\"\n", |
258 | 258 | " ## set internal parameters for the solver\n", |
|
261 | 261 | " self.mesh = mesh\n", |
262 | 262 | " self.U_sfc_tol = U_sfc_tol\n", |
263 | 263 | " self.verbose = verbose\n", |
264 | | - " \n", |
| 264 | + "\n", |
265 | 265 | " ## set initial Green function and irreducible susceptibility\n", |
266 | 266 | " self.sigma = 0\n", |
267 | | - " \n", |
| 267 | + "\n", |
268 | 268 | " self.mu = 0\n", |
269 | 269 | " self.mu_calc()\n", |
270 | | - " \n", |
| 270 | + "\n", |
271 | 271 | " self.gkio_calc(self.mu)\n", |
272 | 272 | " self.grit_calc()\n", |
273 | 273 | " self.ckio_calc()\n", |
274 | | - " \n", |
| 274 | + "\n", |
275 | 275 | " # determine critical U_crit = 1/max(chi0) as an upper bound to U_sp\n", |
276 | 276 | " self.U_crit = 1/np.amax(self.ckio.real)\n", |
277 | | - " \n", |
278 | | - " \n", |
| 277 | + "\n", |
| 278 | + "\n", |
279 | 279 | " #%%%%%%%%%%% Solving instance\n", |
280 | 280 | " def solve(self):\n", |
281 | 281 | " \"\"\"\n", |
282 | 282 | " Determine spin and charge vertex self-consistently from sum rules and calculate self-energy.\n", |
283 | 283 | " \"\"\"\n", |
284 | 284 | " # determine spin vertex U_sp\n", |
285 | 285 | " self.spin_vertex_calc()\n", |
286 | | - " \n", |
| 286 | + "\n", |
287 | 287 | " # set double occupancy from Kanamori-Bruckner screening\n", |
288 | 288 | " self.docc_calc()\n", |
289 | | - " \n", |
| 289 | + "\n", |
290 | 290 | " # determine charge vertex U_ch\n", |
291 | 291 | " self.charge_vertex_calc()\n", |
292 | | - " \n", |
| 292 | + "\n", |
293 | 293 | " # set spin and charge susceptibility\n", |
294 | 294 | " self.chi_spin = self.RPA_term_calc( self.U_sp)\n", |
295 | 295 | " self.chi_charge = self.RPA_term_calc(-self.U_ch)\n", |
|
299 | 299 | " self.sigma_calc()\n", |
300 | 300 | " self.mu_calc()\n", |
301 | 301 | " self.gkio_calc(self.mu)\n", |
302 | | - " \n", |
| 302 | + "\n", |
303 | 303 | " #%%%%%%%%%%% Calculation steps for self.energy\n", |
304 | 304 | " def gkio_calc(self, mu):\n", |
305 | 305 | " \"\"\" Calculate Green function G(iw,k) \"\"\"\n", |
|
313 | 313 | "\n", |
314 | 314 | " def ckio_calc(self):\n", |
315 | 315 | " \"\"\" Calculate irreducible susciptibility chi0(iv,q) \"\"\"\n", |
316 | | - " # fix: from v1 to v2\n", |
317 | | - " ckio = - self.grit * self.grit[::-1, :]\n", |
| 316 | + " ckio = self.grit * self.grit[::-1, :]\n", |
318 | 317 | "\n", |
319 | 318 | " # Fourier transform\n", |
320 | 319 | " ckio = self.mesh.r_to_k(ckio)\n", |
|
333 | 332 | " def sigma_calc(self):\n", |
334 | 333 | " \"\"\" Calculate self-energy Sigma(iwn,k) \"\"\"\n", |
335 | 334 | " sigma = self.V * self.grit\n", |
336 | | - " \n", |
| 335 | + "\n", |
337 | 336 | " # Fourier transform\n", |
338 | 337 | " sigma = self.mesh.r_to_k(sigma)\n", |
339 | 338 | " self.sigma = self.mesh.tau_to_wn('F', sigma)\n", |
|
343 | 342 | " def RPA_term_calc(self, U):\n", |
344 | 343 | " \"\"\" Set RPA-like susceptibility \"\"\"\n", |
345 | 344 | " chi_RPA = self.ckio / (1 - U*self.ckio)\n", |
346 | | - " return chi_RPA \n", |
347 | | - " \n", |
| 345 | + " return chi_RPA\n", |
| 346 | + "\n", |
348 | 347 | " def chi_qtrace_calc(self, U):\n", |
349 | 348 | " \"\"\" Calculate (iv_m, q) trace of chi_RPA term \"\"\"\n", |
350 | 349 | " # chi_qtrace = sum_(m,q) chi(iv_m,q)\n", |
|
353 | 352 | " chi_trace_l = self.mesh.IR_basis_set.smpl_wn_b.fit(chi_trace)\n", |
354 | 353 | " chi_trace = self.mesh.IR_basis_set.basis_b.u(0)@chi_trace_l\n", |
355 | 354 | " return chi_trace.real\n", |
356 | | - " \n", |
| 355 | + "\n", |
357 | 356 | " def docc_calc(self):\n", |
358 | 357 | " \"\"\" Calculate double occupancy from Kanamori-Bruckner type screening \"\"\"\n", |
359 | 358 | " self.docc = 0.25 * self.U_sp/self.U * self.n**2\n", |
360 | | - " \n", |
| 359 | + "\n", |
361 | 360 | " def spin_vertex_calc(self):\n", |
362 | 361 | " \"\"\" Determine U_sp self-consistently from local sum rule \"\"\"\n", |
363 | 362 | " # interval [U_a, U_b] for root finding\n", |
364 | 363 | " U_a = 0\n", |
365 | 364 | " U_b = np.floor(self.U_crit*100)/100\n", |
366 | | - " \n", |
| 365 | + "\n", |
367 | 366 | " chi_trace = self.chi_qtrace_calc\n", |
368 | 367 | " sfc_eq = lambda U_sp : 2*chi_trace(U_sp) - self.n + 0.5*(U_sp/self.U)*self.n**2\n", |
369 | 368 | "\n", |
370 | | - " if sfc_eq(U_b) > 0: \n", |
| 369 | + " if sfc_eq(U_b) > 0:\n", |
371 | 370 | " self.U_sp = sc.optimize.brentq(sfc_eq, U_a, U_b, rtol = self.U_sfc_tol)\n", |
372 | 371 | " print(\"Setting U_sp = {}\".format(self.U_sp))\n", |
373 | 372 | " else:\n", |
374 | 373 | " print(\"Error\")\n", |
375 | 374 | " warn(\"System underwent phase transition, U^sp > U_crit = {}! U is too large or T too low for given doping.\".format(self.U_crit))\n", |
376 | | - " \n", |
| 375 | + "\n", |
377 | 376 | " def charge_vertex_calc(self):\n", |
378 | 377 | " \"\"\" Determine U_ch self-consistently from local sum rule \"\"\"\n", |
379 | 378 | " # interval [U_a, U_b] for root finding\n", |
380 | 379 | " U_a = 0\n", |
381 | 380 | " U_b = 100\n", |
382 | | - " \n", |
| 381 | + "\n", |
383 | 382 | " chi_trace = self.chi_qtrace_calc\n", |
384 | 383 | " sfc_eq = lambda U_ch : 2*chi_trace(-U_ch) - self.n + (1 - 2*self.docc)*self.n**2\n", |
385 | 384 | "\n", |
386 | 385 | " self.U_ch = sc.optimize.brentq(sfc_eq, U_a, U_b, rtol = self.U_sfc_tol)\n", |
387 | 386 | "\n", |
388 | | - " \n", |
| 387 | + "\n", |
389 | 388 | " #%%%%%%%%%%% Setting chemical potential mu\n", |
390 | 389 | " def calc_electron_density(self, mu):\n", |
391 | 390 | " \"\"\" Calculate chemical potential mu from Green function \"\"\"\n", |
392 | 391 | " self.gkio_calc(mu)\n", |
393 | 392 | " gio = np.sum(self.gkio,axis=1)/self.mesh.nk\n", |
394 | 393 | " g_l = self.mesh.IR_basis_set.smpl_wn_f.fit(gio)\n", |
395 | 394 | " g_tau0 = self.mesh.IR_basis_set.basis_f.u(0)@g_l\n", |
396 | | - " \n", |
| 395 | + "\n", |
397 | 396 | " n = 1 + np.real(g_tau0)\n", |
398 | 397 | " n = 2*n #for spin\n", |
399 | 398 | " return n\n", |
|
455 | 454 | "# plot 2D k-dependence of lowest Matsubara frequency of e.g. green function\n", |
456 | 455 | "plt.pcolormesh(2*mesh.k1.reshape(nk1,nk2), 2*mesh.k2.reshape(nk1,nk2), np.real(solver.gkio[mesh.iw0_f].reshape(mesh.nk1,mesh.nk2)), shading='auto')\n", |
457 | 456 | "ax = plt.gca()\n", |
458 | | - "ax.set_xlabel('$k_x/\\pi$')\n", |
| 457 | + "ax.set_xlabel(r'$k_x/\\pi$')\n", |
459 | 458 | "ax.set_xlim([0,2])\n", |
460 | | - "ax.set_ylabel('$k_y/\\pi$')\n", |
| 459 | + "ax.set_ylabel(r'$k_y/\\pi$')\n", |
461 | 460 | "ax.set_ylim([0,2])\n", |
462 | 461 | "ax.set_aspect('equal')\n", |
463 | | - "ax.set_title('Re $G(k,i\\omega_0)$')\n", |
| 462 | + "ax.set_title(r'Re $G(k,i\\omega_0)$')\n", |
464 | 463 | "plt.colorbar()\n", |
465 | 464 | "plt.show()" |
466 | 465 | ] |
|
475 | 474 | "# plot 2D k-dependence of lowest Matsubara frequency of e.g. self-energy\n", |
476 | 475 | "plt.pcolormesh(2*mesh.k1.reshape(nk1,nk2), 2*mesh.k2.reshape(nk1,nk2), np.imag(solver.sigma[mesh.iw0_f].reshape(mesh.nk1,mesh.nk2)), shading='auto')\n", |
477 | 476 | "ax = plt.gca()\n", |
478 | | - "ax.set_xlabel('$k_x/\\pi$')\n", |
| 477 | + "ax.set_xlabel(r'$k_x/\\pi$')\n", |
479 | 478 | "ax.set_xlim([0,2])\n", |
480 | | - "ax.set_ylabel('$k_y/\\pi$')\n", |
| 479 | + "ax.set_ylabel(r'$k_y/\\pi$')\n", |
481 | 480 | "ax.set_ylim([0,2])\n", |
482 | 481 | "ax.set_aspect('equal')\n", |
483 | | - "ax.set_title('Im $\\Sigma(k,i\\omega_0)$')\n", |
| 482 | + "ax.set_title(r'Im $\\Sigma(k,i\\omega_0)$')\n", |
484 | 483 | "plt.colorbar()\n", |
485 | 484 | "plt.show()" |
486 | 485 | ] |
|
495 | 494 | "# plot 2D k-dependence of lowest Matsubara frequency of e.g. chi_spin\n", |
496 | 495 | "plt.pcolormesh(2*mesh.k1.reshape(nk1,nk2), 2*mesh.k2.reshape(nk1,nk2), np.real(solver.chi_spin[mesh.iw0_b].reshape(mesh.nk1,mesh.nk2)), shading='auto')\n", |
497 | 496 | "ax = plt.gca()\n", |
498 | | - "ax.set_xlabel('$k_x/\\pi$')\n", |
| 497 | + "ax.set_xlabel(r'$k_x/\\pi$')\n", |
499 | 498 | "ax.set_xlim([0,2])\n", |
500 | | - "ax.set_ylabel('$k_y/\\pi$')\n", |
| 499 | + "ax.set_ylabel(r'$k_y/\\pi$')\n", |
501 | 500 | "ax.set_ylim([0,2])\n", |
502 | 501 | "ax.set_aspect('equal')\n", |
503 | | - "ax.set_title('$\\chi_{\\mathrm{sp}}(k,i\\nu_0)$')\n", |
| 502 | + "ax.set_title(r'$\\chi_{\\mathrm{sp}}(k,i\\nu_0)$')\n", |
504 | 503 | "plt.colorbar()\n", |
505 | 504 | "plt.show()" |
506 | 505 | ] |
|
559 | 558 | "print(\"Start TPSC loop...\")\n", |
560 | 559 | "for U_it, U in enumerate(U_array):\n", |
561 | 560 | " #print(\"Now: U = {:.1f}\".format(U))\n", |
562 | | - " \n", |
| 561 | + "\n", |
563 | 562 | " # TPSC solver\n", |
564 | 563 | " solver = TPSCSolver(mesh, U, n, verbose=False)\n", |
565 | 564 | " solver.solve()\n", |
566 | | - " \n", |
| 565 | + "\n", |
567 | 566 | " # save data for plotting\n", |
568 | 567 | " U_sp_array[U_it] = solver.U_sp\n", |
569 | 568 | " U_ch_array[U_it] = solver.U_ch\n", |
570 | 569 | "print(\"Finished. Plotting now.\")\n", |
571 | 570 | "\n", |
572 | 571 | "\n", |
573 | 572 | "#%%%%%%%%%%%%%%%% Plot results\n", |
574 | | - "plt.plot(U_array, U_ch_array, '-', label='$U_{\\mathrm{ch}}$')\n", |
575 | | - "plt.plot(U_array, U_sp_array, '-', label='$U_{\\mathrm{sp}}$')\n", |
| 573 | + "plt.plot(U_array, U_ch_array, '-', label=r'$U_{\\mathrm{ch}}$')\n", |
| 574 | + "plt.plot(U_array, U_sp_array, '-', label=r'$U_{\\mathrm{sp}}$')\n", |
576 | 575 | "ax = plt.gca()\n", |
577 | | - "ax.set_xlabel('$U$', fontsize=12)\n", |
| 576 | + "ax.set_xlabel(r'$U$', fontsize=12)\n", |
578 | 577 | "ax.set_xlim([0,5])\n", |
579 | | - "ax.set_ylabel('Interaction', fontsize=12)\n", |
| 578 | + "ax.set_ylabel(r'Interaction', fontsize=12)\n", |
580 | 579 | "ax.set_ylim([0,20])\n", |
581 | 580 | "ax.legend(frameon=False, fontsize=12)" |
582 | 581 | ] |
|
0 commit comments