Skip to content

Commit 0852121

Browse files
Use r-string
1 parent 9b386ee commit 0852121

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

‎src/TPSC_py.ipynb‎

Lines changed: 39 additions & 39 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",
@@ -332,7 +332,7 @@
332332
" def sigma_calc(self):\n",
333333
" \"\"\" Calculate self-energy Sigma(iwn,k) \"\"\"\n",
334334
" sigma = self.V * self.grit\n",
335-
" \n",
335+
"\n",
336336
" # Fourier transform\n",
337337
" sigma = self.mesh.r_to_k(sigma)\n",
338338
" self.sigma = self.mesh.tau_to_wn('F', sigma)\n",
@@ -342,8 +342,8 @@
342342
" def RPA_term_calc(self, U):\n",
343343
" \"\"\" Set RPA-like susceptibility \"\"\"\n",
344344
" chi_RPA = self.ckio / (1 - U*self.ckio)\n",
345-
" return chi_RPA \n",
346-
" \n",
345+
" return chi_RPA\n",
346+
"\n",
347347
" def chi_qtrace_calc(self, U):\n",
348348
" \"\"\" Calculate (iv_m, q) trace of chi_RPA term \"\"\"\n",
349349
" # chi_qtrace = sum_(m,q) chi(iv_m,q)\n",
@@ -352,47 +352,47 @@
352352
" chi_trace_l = self.mesh.IR_basis_set.smpl_wn_b.fit(chi_trace)\n",
353353
" chi_trace = self.mesh.IR_basis_set.basis_b.u(0)@chi_trace_l\n",
354354
" return chi_trace.real\n",
355-
" \n",
355+
"\n",
356356
" def docc_calc(self):\n",
357357
" \"\"\" Calculate double occupancy from Kanamori-Bruckner type screening \"\"\"\n",
358358
" self.docc = 0.25 * self.U_sp/self.U * self.n**2\n",
359-
" \n",
359+
"\n",
360360
" def spin_vertex_calc(self):\n",
361361
" \"\"\" Determine U_sp self-consistently from local sum rule \"\"\"\n",
362362
" # interval [U_a, U_b] for root finding\n",
363363
" U_a = 0\n",
364364
" U_b = np.floor(self.U_crit*100)/100\n",
365-
" \n",
365+
"\n",
366366
" chi_trace = self.chi_qtrace_calc\n",
367367
" sfc_eq = lambda U_sp : 2*chi_trace(U_sp) - self.n + 0.5*(U_sp/self.U)*self.n**2\n",
368368
"\n",
369-
" if sfc_eq(U_b) > 0: \n",
369+
" if sfc_eq(U_b) > 0:\n",
370370
" self.U_sp = sc.optimize.brentq(sfc_eq, U_a, U_b, rtol = self.U_sfc_tol)\n",
371371
" print(\"Setting U_sp = {}\".format(self.U_sp))\n",
372372
" else:\n",
373373
" print(\"Error\")\n",
374374
" 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",
375-
" \n",
375+
"\n",
376376
" def charge_vertex_calc(self):\n",
377377
" \"\"\" Determine U_ch self-consistently from local sum rule \"\"\"\n",
378378
" # interval [U_a, U_b] for root finding\n",
379379
" U_a = 0\n",
380380
" U_b = 100\n",
381-
" \n",
381+
"\n",
382382
" chi_trace = self.chi_qtrace_calc\n",
383383
" sfc_eq = lambda U_ch : 2*chi_trace(-U_ch) - self.n + (1 - 2*self.docc)*self.n**2\n",
384384
"\n",
385385
" self.U_ch = sc.optimize.brentq(sfc_eq, U_a, U_b, rtol = self.U_sfc_tol)\n",
386386
"\n",
387-
" \n",
387+
"\n",
388388
" #%%%%%%%%%%% Setting chemical potential mu\n",
389389
" def calc_electron_density(self, mu):\n",
390390
" \"\"\" Calculate chemical potential mu from Green function \"\"\"\n",
391391
" self.gkio_calc(mu)\n",
392392
" gio = np.sum(self.gkio,axis=1)/self.mesh.nk\n",
393393
" g_l = self.mesh.IR_basis_set.smpl_wn_f.fit(gio)\n",
394394
" g_tau0 = self.mesh.IR_basis_set.basis_f.u(0)@g_l\n",
395-
" \n",
395+
"\n",
396396
" n = 1 + np.real(g_tau0)\n",
397397
" n = 2*n #for spin\n",
398398
" return n\n",
@@ -454,12 +454,12 @@
454454
"# plot 2D k-dependence of lowest Matsubara frequency of e.g. green function\n",
455455
"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",
456456
"ax = plt.gca()\n",
457-
"ax.set_xlabel('$k_x/\\pi$')\n",
457+
"ax.set_xlabel(r'$k_x/\\pi$')\n",
458458
"ax.set_xlim([0,2])\n",
459-
"ax.set_ylabel('$k_y/\\pi$')\n",
459+
"ax.set_ylabel(r'$k_y/\\pi$')\n",
460460
"ax.set_ylim([0,2])\n",
461461
"ax.set_aspect('equal')\n",
462-
"ax.set_title('Re $G(k,i\\omega_0)$')\n",
462+
"ax.set_title(r'Re $G(k,i\\omega_0)$')\n",
463463
"plt.colorbar()\n",
464464
"plt.show()"
465465
]
@@ -474,12 +474,12 @@
474474
"# plot 2D k-dependence of lowest Matsubara frequency of e.g. self-energy\n",
475475
"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",
476476
"ax = plt.gca()\n",
477-
"ax.set_xlabel('$k_x/\\pi$')\n",
477+
"ax.set_xlabel(r'$k_x/\\pi$')\n",
478478
"ax.set_xlim([0,2])\n",
479-
"ax.set_ylabel('$k_y/\\pi$')\n",
479+
"ax.set_ylabel(r'$k_y/\\pi$')\n",
480480
"ax.set_ylim([0,2])\n",
481481
"ax.set_aspect('equal')\n",
482-
"ax.set_title('Im $\\Sigma(k,i\\omega_0)$')\n",
482+
"ax.set_title(r'Im $\\Sigma(k,i\\omega_0)$')\n",
483483
"plt.colorbar()\n",
484484
"plt.show()"
485485
]
@@ -494,12 +494,12 @@
494494
"# plot 2D k-dependence of lowest Matsubara frequency of e.g. chi_spin\n",
495495
"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",
496496
"ax = plt.gca()\n",
497-
"ax.set_xlabel('$k_x/\\pi$')\n",
497+
"ax.set_xlabel(r'$k_x/\\pi$')\n",
498498
"ax.set_xlim([0,2])\n",
499-
"ax.set_ylabel('$k_y/\\pi$')\n",
499+
"ax.set_ylabel(r'$k_y/\\pi$')\n",
500500
"ax.set_ylim([0,2])\n",
501501
"ax.set_aspect('equal')\n",
502-
"ax.set_title('$\\chi_{\\mathrm{sp}}(k,i\\nu_0)$')\n",
502+
"ax.set_title(r'$\\chi_{\\mathrm{sp}}(k,i\\nu_0)$')\n",
503503
"plt.colorbar()\n",
504504
"plt.show()"
505505
]
@@ -558,24 +558,24 @@
558558
"print(\"Start TPSC loop...\")\n",
559559
"for U_it, U in enumerate(U_array):\n",
560560
" #print(\"Now: U = {:.1f}\".format(U))\n",
561-
" \n",
561+
"\n",
562562
" # TPSC solver\n",
563563
" solver = TPSCSolver(mesh, U, n, verbose=False)\n",
564564
" solver.solve()\n",
565-
" \n",
565+
"\n",
566566
" # save data for plotting\n",
567567
" U_sp_array[U_it] = solver.U_sp\n",
568568
" U_ch_array[U_it] = solver.U_ch\n",
569569
"print(\"Finished. Plotting now.\")\n",
570570
"\n",
571571
"\n",
572572
"#%%%%%%%%%%%%%%%% Plot results\n",
573-
"plt.plot(U_array, U_ch_array, '-', label='$U_{\\mathrm{ch}}$')\n",
574-
"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",
575575
"ax = plt.gca()\n",
576-
"ax.set_xlabel('$U$', fontsize=12)\n",
576+
"ax.set_xlabel(r'$U$', fontsize=12)\n",
577577
"ax.set_xlim([0,5])\n",
578-
"ax.set_ylabel('Interaction', fontsize=12)\n",
578+
"ax.set_ylabel(r'Interaction', fontsize=12)\n",
579579
"ax.set_ylim([0,20])\n",
580580
"ax.legend(frameon=False, fontsize=12)"
581581
]

0 commit comments

Comments
 (0)