Skip to content

Commit 5578015

Browse files
Merge pull request #4 from SpM-lab/tpsc-approximation
Fix TPSC approximation
2 parents 57eab36 + 0852121 commit 5578015

1 file changed

Lines changed: 40 additions & 41 deletions

File tree

‎src/TPSC_py.ipynb‎

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
" smpl_wn = {'F': self.IR_basis_set.smpl_wn_f, 'B': self.IR_basis_set.smpl_wn_b }[statistics]\n",
198198
" return smpl_tau, smpl_wn\n",
199199
"\n",
200-
" \n",
200+
"\n",
201201
" def tau_to_wn(self, statistics, obj_tau):\n",
202202
" \"\"\" Fourier transform from tau to iwn via IR basis \"\"\"\n",
203203
" smpl_tau, smpl_wn = self.smpl_obj(statistics)\n",
@@ -216,7 +216,7 @@
216216
" obj_tau = smpl_tau.evaluate(obj_l, axis=0).reshape((smpl_tau.tau.size, self.nk))\n",
217217
" return obj_tau\n",
218218
"\n",
219-
" \n",
219+
"\n",
220220
" def k_to_r(self,obj_k):\n",
221221
" \"\"\" Fourier transform from k-space to real space \"\"\"\n",
222222
" obj_k = obj_k.reshape(-1, self.nk1, self.nk2)\n",
@@ -252,7 +252,7 @@
252252
" def __init__(self, mesh, U, n, U_sfc_tol=1e-12, verbose=True):\n",
253253
" \"\"\"\n",
254254
" 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",
256256
" can be run by `solver.solve()`.\n",
257257
" \"\"\"\n",
258258
" ## set internal parameters for the solver\n",
@@ -261,35 +261,35 @@
261261
" self.mesh = mesh\n",
262262
" self.U_sfc_tol = U_sfc_tol\n",
263263
" self.verbose = verbose\n",
264-
" \n",
264+
"\n",
265265
" ## set initial Green function and irreducible susceptibility\n",
266266
" self.sigma = 0\n",
267-
" \n",
267+
"\n",
268268
" self.mu = 0\n",
269269
" self.mu_calc()\n",
270-
" \n",
270+
"\n",
271271
" self.gkio_calc(self.mu)\n",
272272
" self.grit_calc()\n",
273273
" self.ckio_calc()\n",
274-
" \n",
274+
"\n",
275275
" # determine critical U_crit = 1/max(chi0) as an upper bound to U_sp\n",
276276
" self.U_crit = 1/np.amax(self.ckio.real)\n",
277-
" \n",
278-
" \n",
277+
"\n",
278+
"\n",
279279
" #%%%%%%%%%%% Solving instance\n",
280280
" def solve(self):\n",
281281
" \"\"\"\n",
282282
" Determine spin and charge vertex self-consistently from sum rules and calculate self-energy.\n",
283283
" \"\"\"\n",
284284
" # determine spin vertex U_sp\n",
285285
" self.spin_vertex_calc()\n",
286-
" \n",
286+
"\n",
287287
" # set double occupancy from Kanamori-Bruckner screening\n",
288288
" self.docc_calc()\n",
289-
" \n",
289+
"\n",
290290
" # determine charge vertex U_ch\n",
291291
" self.charge_vertex_calc()\n",
292-
" \n",
292+
"\n",
293293
" # set spin and charge susceptibility\n",
294294
" self.chi_spin = self.RPA_term_calc( self.U_sp)\n",
295295
" self.chi_charge = self.RPA_term_calc(-self.U_ch)\n",
@@ -299,7 +299,7 @@
299299
" self.sigma_calc()\n",
300300
" self.mu_calc()\n",
301301
" self.gkio_calc(self.mu)\n",
302-
" \n",
302+
"\n",
303303
" #%%%%%%%%%%% Calculation steps for self.energy\n",
304304
" def gkio_calc(self, mu):\n",
305305
" \"\"\" Calculate Green function G(iw,k) \"\"\"\n",
@@ -313,8 +313,7 @@
313313
"\n",
314314
" def ckio_calc(self):\n",
315315
" \"\"\" 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",
318317
"\n",
319318
" # Fourier transform\n",
320319
" ckio = self.mesh.r_to_k(ckio)\n",
@@ -333,7 +332,7 @@
333332
" def sigma_calc(self):\n",
334333
" \"\"\" Calculate self-energy Sigma(iwn,k) \"\"\"\n",
335334
" sigma = self.V * self.grit\n",
336-
" \n",
335+
"\n",
337336
" # Fourier transform\n",
338337
" sigma = self.mesh.r_to_k(sigma)\n",
339338
" self.sigma = self.mesh.tau_to_wn('F', sigma)\n",
@@ -343,8 +342,8 @@
343342
" def RPA_term_calc(self, U):\n",
344343
" \"\"\" Set RPA-like susceptibility \"\"\"\n",
345344
" chi_RPA = self.ckio / (1 - U*self.ckio)\n",
346-
" return chi_RPA \n",
347-
" \n",
345+
" return chi_RPA\n",
346+
"\n",
348347
" def chi_qtrace_calc(self, U):\n",
349348
" \"\"\" Calculate (iv_m, q) trace of chi_RPA term \"\"\"\n",
350349
" # chi_qtrace = sum_(m,q) chi(iv_m,q)\n",
@@ -353,47 +352,47 @@
353352
" chi_trace_l = self.mesh.IR_basis_set.smpl_wn_b.fit(chi_trace)\n",
354353
" chi_trace = self.mesh.IR_basis_set.basis_b.u(0)@chi_trace_l\n",
355354
" return chi_trace.real\n",
356-
" \n",
355+
"\n",
357356
" def docc_calc(self):\n",
358357
" \"\"\" Calculate double occupancy from Kanamori-Bruckner type screening \"\"\"\n",
359358
" self.docc = 0.25 * self.U_sp/self.U * self.n**2\n",
360-
" \n",
359+
"\n",
361360
" def spin_vertex_calc(self):\n",
362361
" \"\"\" Determine U_sp self-consistently from local sum rule \"\"\"\n",
363362
" # interval [U_a, U_b] for root finding\n",
364363
" U_a = 0\n",
365364
" U_b = np.floor(self.U_crit*100)/100\n",
366-
" \n",
365+
"\n",
367366
" chi_trace = self.chi_qtrace_calc\n",
368367
" sfc_eq = lambda U_sp : 2*chi_trace(U_sp) - self.n + 0.5*(U_sp/self.U)*self.n**2\n",
369368
"\n",
370-
" if sfc_eq(U_b) > 0: \n",
369+
" if sfc_eq(U_b) > 0:\n",
371370
" self.U_sp = sc.optimize.brentq(sfc_eq, U_a, U_b, rtol = self.U_sfc_tol)\n",
372371
" print(\"Setting U_sp = {}\".format(self.U_sp))\n",
373372
" else:\n",
374373
" print(\"Error\")\n",
375374
" 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",
377376
" def charge_vertex_calc(self):\n",
378377
" \"\"\" Determine U_ch self-consistently from local sum rule \"\"\"\n",
379378
" # interval [U_a, U_b] for root finding\n",
380379
" U_a = 0\n",
381380
" U_b = 100\n",
382-
" \n",
381+
"\n",
383382
" chi_trace = self.chi_qtrace_calc\n",
384383
" sfc_eq = lambda U_ch : 2*chi_trace(-U_ch) - self.n + (1 - 2*self.docc)*self.n**2\n",
385384
"\n",
386385
" self.U_ch = sc.optimize.brentq(sfc_eq, U_a, U_b, rtol = self.U_sfc_tol)\n",
387386
"\n",
388-
" \n",
387+
"\n",
389388
" #%%%%%%%%%%% Setting chemical potential mu\n",
390389
" def calc_electron_density(self, mu):\n",
391390
" \"\"\" Calculate chemical potential mu from Green function \"\"\"\n",
392391
" self.gkio_calc(mu)\n",
393392
" gio = np.sum(self.gkio,axis=1)/self.mesh.nk\n",
394393
" g_l = self.mesh.IR_basis_set.smpl_wn_f.fit(gio)\n",
395394
" g_tau0 = self.mesh.IR_basis_set.basis_f.u(0)@g_l\n",
396-
" \n",
395+
"\n",
397396
" n = 1 + np.real(g_tau0)\n",
398397
" n = 2*n #for spin\n",
399398
" return n\n",
@@ -455,12 +454,12 @@
455454
"# plot 2D k-dependence of lowest Matsubara frequency of e.g. green function\n",
456455
"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",
457456
"ax = plt.gca()\n",
458-
"ax.set_xlabel('$k_x/\\pi$')\n",
457+
"ax.set_xlabel(r'$k_x/\\pi$')\n",
459458
"ax.set_xlim([0,2])\n",
460-
"ax.set_ylabel('$k_y/\\pi$')\n",
459+
"ax.set_ylabel(r'$k_y/\\pi$')\n",
461460
"ax.set_ylim([0,2])\n",
462461
"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",
464463
"plt.colorbar()\n",
465464
"plt.show()"
466465
]
@@ -475,12 +474,12 @@
475474
"# plot 2D k-dependence of lowest Matsubara frequency of e.g. self-energy\n",
476475
"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",
477476
"ax = plt.gca()\n",
478-
"ax.set_xlabel('$k_x/\\pi$')\n",
477+
"ax.set_xlabel(r'$k_x/\\pi$')\n",
479478
"ax.set_xlim([0,2])\n",
480-
"ax.set_ylabel('$k_y/\\pi$')\n",
479+
"ax.set_ylabel(r'$k_y/\\pi$')\n",
481480
"ax.set_ylim([0,2])\n",
482481
"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",
484483
"plt.colorbar()\n",
485484
"plt.show()"
486485
]
@@ -495,12 +494,12 @@
495494
"# plot 2D k-dependence of lowest Matsubara frequency of e.g. chi_spin\n",
496495
"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",
497496
"ax = plt.gca()\n",
498-
"ax.set_xlabel('$k_x/\\pi$')\n",
497+
"ax.set_xlabel(r'$k_x/\\pi$')\n",
499498
"ax.set_xlim([0,2])\n",
500-
"ax.set_ylabel('$k_y/\\pi$')\n",
499+
"ax.set_ylabel(r'$k_y/\\pi$')\n",
501500
"ax.set_ylim([0,2])\n",
502501
"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",
504503
"plt.colorbar()\n",
505504
"plt.show()"
506505
]
@@ -559,24 +558,24 @@
559558
"print(\"Start TPSC loop...\")\n",
560559
"for U_it, U in enumerate(U_array):\n",
561560
" #print(\"Now: U = {:.1f}\".format(U))\n",
562-
" \n",
561+
"\n",
563562
" # TPSC solver\n",
564563
" solver = TPSCSolver(mesh, U, n, verbose=False)\n",
565564
" solver.solve()\n",
566-
" \n",
565+
"\n",
567566
" # save data for plotting\n",
568567
" U_sp_array[U_it] = solver.U_sp\n",
569568
" U_ch_array[U_it] = solver.U_ch\n",
570569
"print(\"Finished. Plotting now.\")\n",
571570
"\n",
572571
"\n",
573572
"#%%%%%%%%%%%%%%%% 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",
576575
"ax = plt.gca()\n",
577-
"ax.set_xlabel('$U$', fontsize=12)\n",
576+
"ax.set_xlabel(r'$U$', fontsize=12)\n",
578577
"ax.set_xlim([0,5])\n",
579-
"ax.set_ylabel('Interaction', fontsize=12)\n",
578+
"ax.set_ylabel(r'Interaction', fontsize=12)\n",
580579
"ax.set_ylim([0,20])\n",
581580
"ax.legend(frameon=False, fontsize=12)"
582581
]

0 commit comments

Comments
 (0)