<div dir="ltr">Dear Prof. Giovanni Pizzi and Wannier90 community,<div><br></div><div>Kindly let me explain what I am attempting to do. Using the BoltzWann module, I want to reproduce the result computed by BoltzTraP code by varying carrier concentration n (cm-3) at constant temperature T (<a href="https://pubs.acs.org/cms/10.1021/cm504244b/asset/images/large/cm-2014-04244b_0004.jpeg">example</a>). However, in the Wannier90 input file, we can only input the chemical potential μ instead of n (cm-3). So, I need to convert the desired n (cm-3) into μ, for which I have come up with the below python code. Please excuse my coding inaccuracies as I am a beginner at it and kindly fix any mathematical mistakes (possibly in bisection algorithm) and coding errors. If it's all correct, it fails to give converged μ at higher n (e.g. 10^24 cm-3). I have also attached DOS output computed using quantum espresso code for reference.</div><div><br></div><div>Code:</div><div><br></div><div><font face="arial narrow, sans-serif">import numpy as np<br>from scipy import constants<br><br># Constants<br>T = 300 # Temperature in Kelvin<br>k_B = constants.k / constants.e # Boltzmann constant in eV/K (≈8.617333e-5)<br><br># --- Convert unit cell volume to cm³ ---<br>V_cell_au3 = 1805.5096 # Unit cell volume in (a.u.)³<br>bohr_to_angstrom = 0.52917721<br>V_cell_A3 = V_cell_au3 * (bohr_to_angstrom ** 3)<br>V_cell_cm3 = V_cell_A3 * 1e-24<br><br>print(f"Unit cell volume = {V_cell_cm3:.4e} cm³")<br><br># Fermi-Dirac function<br>def fermi_dirac(E, mu, T):<br> kT = k_B * T<br> x = (E - mu) / kT<br> <br> # Handle large values to prevent overflow<br> return np.piecewise(x, <br> [x < -100, x > 100], <br> [1.0, 0.0, lambda x: 1/(1 + np.exp(x))])<br><br># Load DOS data<br>data = np.loadtxt('case_dos.dat') <br>energy = data[:, 0] # Energy in eV<br>dos = data[:, 1] # DOS in states/eV/unit cell<br><br># Compute carrier concentration using trapezoid rule<br>def carrier_concentration(mu, energy, dos, T, V_cm3):<br> product = dos * fermi_dirac(energy, mu, T)<br> n_unit_cell = np.trapezoid(product, energy) <br> n_cm3 = n_unit_cell / V_cm3<br> return n_cm3<br><br># Bisection algorithm with auto-bound detection<br>def find_mu(target_n, energy, dos, T, V_cm3, tol=1e-3, max_iter=100):<br> # Auto-detect proper bounds<br> mu_low, mu_high = -100, 100 # Start with wide range<br> n_low = carrier_concentration(mu_low, energy, dos, T, V_cm3)<br> n_high = carrier_concentration(mu_high, energy, dos, T, V_cm3)<br> <br> # </font><span style="font-family:"arial narrow",sans-serif">adjust </span><span style="font-family:"arial narrow",sans-serif">lower bound</span></div><div><font face="arial narrow, sans-serif"> while n_low > target_n:<br> mu_low -= 50<br> n_low = carrier_concentration(mu_low, energy, dos, T, V_cm3)<br> print(f"Expanding lower bound to μ = {mu_low} eV, n = {n_low:.4e} cm⁻³")<br> <br> # </font><span style="font-family:"arial narrow",sans-serif">adjust</span><span style="font-family:"arial narrow",sans-serif">upper bound</span></div><div><font face="arial narrow, sans-serif"> while n_high < target_n:<br> mu_high += 50<br> n_high = carrier_concentration(mu_high, energy, dos, T, V_cm3)<br> print(f"Expanding upper bound to μ = {mu_high} eV, n = {n_high:.4e} cm⁻³")<br> <br> print(f"\nStarting bisection with bounds: μ = [{mu_low}, {mu_high}] eV")<br> print(f"Initial concentrations: n_low = {n_low:.4e} cm⁻³, n_high = {n_high:.4e} cm⁻³")<br> <br> # Bisection loop<br> for i in range(max_iter):<br> mu_mid = (mu_low + mu_high) / 2<br> n_mid = carrier_concentration(mu_mid, energy, dos, T, V_cm3)<br> <br> rel_error = abs(n_mid - target_n) / target_n<br> print(f"Iter {i+1}: μ = {mu_mid:.6f} eV, n = {n_mid:.4e} cm⁻³, error = {rel_error:.2%}")<br> <br> if rel_error < tol:<br> print("\nConverged!")<br> return mu_mid<br> <br> if n_mid < target_n:<br> mu_low = mu_mid<br> else:<br> mu_high = mu_mid<br> <br> print(f"Warning: Max iterations reached ({max_iter})")<br> return mu_mid<br><br>if __name__ == "__main__":<br> # Target carrier concentration (cm⁻³)<br> target_n = 1e18<br> <br> # Find chemical potential<br> print(f"\nSearching for μ for n = {target_n:.1e} cm⁻³")<br> mu_target = find_mu(target_n, energy, dos, T, V_cell_cm3)<br> <br> # Final verification<br> n_final = carrier_concentration(mu_target, energy, dos, T, V_cell_cm3)<br> print(f"\nResult: μ = {mu_target:.6f} eV gives n = {n_final:.4e} cm⁻³")</font></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Jun 23, 2025 at 4:02 PM Abhijeet Jaysingrao kale ic39253 <<a href="mailto:ic39253@imail.iitm.ac.in">ic39253@imail.iitm.ac.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Prof. Giovanni Pizzi,<div><br></div><div>Thank you very much for the information. I tried obtaining a Fermi-Dirac distribution but did not succeed. Can I get further help regarding how to obtain Fermi-Dirac distribution function from Wannier output and then finally compute carrier concentration?</div><div><br></div><div>Regards,</div><div>Abhijeet.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 19, 2025 at 8:26 PM Giovanni Pizzi <<a href="mailto:giovanni.pizzi@epfl.ch" target="_blank">giovanni.pizzi@epfl.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
Hi,<br id="m_1324317958925393557m_2810435913037611438lineBreakAtBeginningOfMessage">
<div>
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div style="color:rgb(0,0,0);letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<br>
</div>
</div>
</div>
</div>
</div>
</div>
<div>1. You should convert the carrier concentration into a chemical potential by integrating the product of the Fermi-Dirac distribution function and of the DOS, and looking for the chemical potential that gives you the expected number of electrons (e.g. with
a bisection algorithm).</div>
<div><br>
</div>
<div>2. Internally it should work, but indeed the code only prints the upper triangle for sigma, Sigma*S and kappa (electronic contribution) to thermal conductivity. If you want to check if there is a non-symmetric part, you need to adapt the code to print
all coordinates.</div>
<div>(Note that for the Seebeck coefficient, all 9 components are reported instead).</div>
<div><br>
</div>
<div>Best,</div>
<div>
<div>Giovanni Pizzi<br>
<br>
</div>
<div><i>Group leader, Materials Software and Data Group, PSI<br>
</i><a href="https://www.psi.ch/en/lms/people/giovanni-pizzi" target="_blank">https://www.psi.ch/en/lms/people/giovanni-pizzi</a></div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div><br>
<blockquote type="cite">
<div>On 18 Jun 2025, at 12:23, Abhijeet Jaysingrao kale ic39253 <<a href="mailto:ic39253@imail.iitm.ac.in" target="_blank">ic39253@imail.iitm.ac.in</a>> wrote:</div>
<br>
<div>
<div dir="ltr">Dear Wannier90 community,
<div><br>
</div>
<div>I am Abhijeet from IIT Madras (India). I am using the BoltzWann module to compute thermoelectric properties of monolayer systems. I'd be grateful if anyone could suggest me on following questions:</div>
<div><br>
</div>
<div>1. How to input carrier concentration range like chemical potential and temperature?</div>
<div>2. Can we use BoltzWann for thermoelectric properties of magnetic materials even though it outputs 6 components of electrical conductivity when it requires all 9?</div>
<div><br>
</div>
<div>Thanks in advance.</div>
<div>Regards,</div>
<div>Abhijeet.</div>
<div><br>
</div>
</div>
_______________________________________________<br>
Wannier mailing list<br>
<a href="mailto:Wannier@lists.quantum-espresso.org" target="_blank">Wannier@lists.quantum-espresso.org</a><br>
<a href="https://lists.quantum-espresso.org/mailman/listinfo/wannier" target="_blank">https://lists.quantum-espresso.org/mailman/listinfo/wannier</a><br>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote></div>
</blockquote></div>