band-unfolding / banduppy

Python version ofthe BandUP code
GNU General Public License v3.0
21 stars 9 forks source link

Tutorial for using the effective mass calculator utility #34

Open josue-clavijo opened 1 month ago

josue-clavijo commented 1 month ago

Hi everyone. First, thanks to Stepan and to Badal for all your kind answers.

I'd like to ask for assistance to get working the effective mass calculator utility. The issue is that when I use the code

### For the dispersion type choice
Parabolic=True
UpwardHyp=False
DownwardHyp=False

m_star, optimized_parameters, convergence_measure = \
    unfolded_band_properties.calculate_effecfive_mass(kpath, band_energy,
                                                      initial_guess_params=None,
                                                      params_bounds = (-np.inf, np.inf),
                                                      fit_weights=None, absolute_weights=False,
                                                      parabolic_dispersion=True,
                                                      hyperbolic_dispersion_positive=False,
                                                      hyperbolic_dispersion_negative=False,
                                                      params_name = ['alpha', 'kshift', 'cbm', 'gamma'])
    #===================================
    band_energy_fit = unfolded_band_properties.fit_functions(kpath, optimized_parameters,
                                                            parabolic_dispersion=True,
                                                            hyperbolic_dispersion_positive=False,
                                                            hyperbolic_dispersion_negative=False)

Where kpath and band_energy arrays (see below) were constructed from both kpoints_unfolded.dat and bandstructure_unfolded.dat files, for the top valence band containing the valence band maximum eigenvalue. In the kpath array, 1.47478091 corresponds to gamma point on BZ (k in A^-1 units), and the 0.09504498 energy It's the valence maxima eigenvalue at this gamma point:

kpath=np.array([1.26888509, 1.30982946, 1.35077383, 1.39171820, 1.43383115, 1.47478091, 1.50244259, 1.53127822, 1.56011386, 1.58894949, 1.61778513])
band_energy=np.array([-0.20705563, -0.20705563, -0.07194677, 0.04673017, 0.13000076, 0.09504498, 0.14570526, 0.10571172, 0.04919766, -0.01404133, -0.07638066])

But when i run the code, i consistently get the following error:


ValueError Traceback (most recent call last) Cell In[36], line 31 28 UpwardHyp=False 29 DownwardHyp=False ---> 31 m_star, optimized_parameters, convergence_measure = \ 32 unfolded_band_properties.calculate_effecfive_mass(kpath, band_energy, 33 initial_guess_params=None, 34 params_bounds = (-np.inf, np.inf), 35 fit_weights=None, absolute_weights=False, 36 parabolic_dispersion=True, 37 hyperbolic_dispersion_positive=False, 38 hyperbolic_dispersion_negative=False, 39 params_name = ['alpha', 'kshift', 'cbm', 'gamma']) 41 band_energy_fit = unfolded_band_properties.fit_functions(kpath, optimized_parameters, 42 parabolic_dispersion=Parabolic, 43 hyperbolic_dispersion_positive=UpwardHyp, 44 hyperbolic_dispersion_negative=DownwardHyp)

ValueError: too many values to unpack (expected 3)

I don't know what am I missing or what am I doing wrong. Thanks in advance for all your corrections ands suggestions, since I'm not a hard coder, I'm a experimentalist exploring with the Banduppy code.

Best regards,

Josue

bmondal94 commented 1 month ago

Hi @josue-clavijo , Apologies for the delayed response - I missed your message earlier.

Regarding your question, I realized I forgot to update the README documentation. Thanks for pointing that out. The effective mass calculator is part of an active, ongoing project and is still under continuous development. Recently, I made some updates to this module, which included changes to the calculate_effective_mass() function. Instead of returning 3 values, the latest version now returns 4 values.

Could you please try the following?

# Get effective mass for parabolic dispersion
m_star, popt, pcov, params_error = unfolded_band_properties.calculate_effecfive_mass(kpath_, band_energy_,
                                                                             initial_guess_params=...,
                                                                             ignore_kshift_cbm_fit=False, #
                                                                             fit_weights=inv_bws_, absolute_weights=False,
                                                                             parabolic_dispersion=True)
band_energy_fit = unfolded_band_properties.fit_functions(kpath_, popt, parabolic_dispersion=1)
ignore_kshift_cbm_fit : bool, optional
            Ignore fitting kshift and cbm parameters during fitting. The default is True.
  Returns
        -------
        m_star : (float,float) => (m* +- m*_error)
            Calculated effective mass and error in m_0 unit. 
        popt : array <== optimized_parameters
            Optimal values for the parameters so that the sum of the squared
            residuals of ``f(xdata, *popt) - ydata`` is minimized.
        pcov : 2-D array
            The estimated approximate covariance of popt. 
        params_errors : 1-D array
            One standard deviation error in parameters.
            perr = np.sqrt(np.diag(pcov))

Also, for complete documentation, you can use Python's helper function instead: help(unfolded_band_properties.calculate_effecfive_mass) . Since the module is constantly evolving, I update the function docstrings, but I sometimes forget to update the README USAGE documentation.

Thanks for your understanding, and feel free to reach out if you have further questions!

Best regards, Badal

josue-clavijo commented 1 month ago

Badal, thank you for all of your kind assistance. The updated code now works like a charm. I'll test it against some reports on effective masses for hybrid perovskites. Again, thank you very much.