Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

np.(arange->linspace) in io/vasp/optics.py get_delta, get_setp and epsilon_imag #3286

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Replaced numpy.arange() with numpy.linspace() within io/vasp/optics.p…
…y for get_delta, get_step, and epsilon_imag. The lenght of the array generated by numpy.arange is not numerically stable (see https://numpy.org/doc/stable/reference/generated/numpy.arange.html) and can be different from NEDOS.
  • Loading branch information
LucasGVerga committed Aug 31, 2023
commit 53e2de0a006d4f6b556b86f1991cc4b91f832129
6 changes: 3 additions & 3 deletions pymatgen/io/vasp/optics.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def get_delta(x0: float, sigma: float, nx: int, dx: float, ismear: int = 3):
np.array: Array of size `nx` with delta function on the desired outputgrid.

"""
xgrid = np.arange(0, nx * dx, dx)
xgrid = np.linspace(0, nx * dx, nx,endpoint=False)
xgrid -= x0
x_scaled = (xgrid + (dx / 2)) / sigma
sfun = step_func(x_scaled, ismear)
Expand All @@ -334,7 +334,7 @@ def get_step(x0, sigma, nx, dx, ismear):
Return:
np.array: Array of size `nx` with step function on the desired outputgrid.
"""
xgrid = np.arange(0, nx * dx, dx)
xgrid = np.linspace(0, nx * dx, nx,endpoint=False)
xgrid -= x0
x_scaled = (xgrid + (dx / 2)) / sigma
return step_func(x_scaled, ismear)
Expand Down Expand Up @@ -373,7 +373,7 @@ def epsilon_imag(

"""
norm_kweights = np.array(kweights) / np.sum(kweights)
egrid = np.arange(0, nedos * deltae, deltae)
egrid = np.linspace(0, nedos * deltae, nedos,endpoint=False)
eigs_shifted = eigs - efermi
# np.subtract.outer results in a matrix of shape (nband, nband)
rspin = 3 - cder.shape[3]
Expand Down