# pymatgen.io.vasp.optics module

Classes for parsing and manipulating VASP optical properties calculations.

class DielectricFunctionCalculator(cder_real: ndarray[Any, dtype[ScalarType]], cder_imag: ndarray[Any, dtype[ScalarType]], eigs: ndarray[Any, dtype[ScalarType]], kweights: ndarray[Any, dtype[ScalarType]], nedos: int, deltae: float, ismear: int, sigma: float, efermi: float, cshift: float, ispin: int, volume: float)[source]

Bases: `MSONable`

Class for postprocessing VASP optical properties calculations.

This objects helps load the different parameters from the vasprun.xml file but allows users to override them as needed.

The standard vasprun.xml from an `LOPTICS=.True.` calculation already contains the complex frequency dependent dielectric functions. However you have no way to decompose the different contributions. Since the `WAVEDER` file is also written during an optical calculation, you can reconstruct the dielectric functions purely in Python and have full control over contribution from different bands and k-points.

VASP’s linear optics follow these steps:
• Calculate the imaginary part

• Perform symmetry operations (this is not implemented here)

• Calculate the real part

Currently, this Calculator only works for `ISYM=0` calculations since we cannot gauranttee that our externally defined symmetry operations are the same as VASP’s. This can be fixed by printing the symmetry operators into the vasprun.xml file. If this happens in future versions of VASP, we can dramatically speed up the calculations here by considering only the irreducible kpoints.

property cder[source]

Complex CDER from WAVEDER.

cder_imag: ndarray[Any, dtype[ScalarType]][source]
cder_real: ndarray[Any, dtype[ScalarType]][source]
cshift: float[source]
deltae: float[source]
efermi: float[source]
eigs: ndarray[Any, dtype[ScalarType]][source]
classmethod from_directory(directory: Path | str)[source]

Construct a DielectricFunction from a directory containing vasprun.xml and WAVEDER files.

classmethod from_vasp_objects(vrun: Vasprun, waveder: Waveder)[source]

Construct a DielectricFunction from Vasprun, Kpoint, and Waveder objects.

Parameters:
• vrun – Vasprun object

• kpoint – Kpoint object

• waveder – Waveder object

get_epsilon(idir: int, jdir: int, efermi: float | None = None, nedos: int | None = None, deltae: float | None = None, ismear: int | None = None, sigma: float | None = None, cshift: float | None = None, mask: npt.NDArray | None = None) tuple[npt.NDArray, npt.NDArray][source]

Compute the frequency dependent dielectric function.

Parameters:
• idir – First direction of the dielectric tensor

• jdir – Second direction of the dielectric tensor

• efermi – Fermi energy

• nedos – Number of points in the DOS

• deltae – Energy step in the DOS

• ismear – Smearing method (only has 0:gaussian, >0:Methfessel-Paxton)

• sigma – Smearing width

• cshift – Complex shift used for Kramer-Kronig transformation

• mask – Mask for the bands/kpoint/spin index to include in the calculation

ismear: int[source]
ispin: int[source]
kweights: ndarray[Any, dtype[ScalarType]][source]
nedos: int[source]
plot_weighted_transition_data(idir: int, jdir: int, mask: npt.NDArray | None = None, min_val: float = 0.0)[source]

Data for plotting the weight matrix elements as a scatter plot.

Since the computation of the final spectrum (especially the smearing part) is still fairly expensive. This function can be used to check the values of some portion of the spectrum (defined by the mask). In a sense, we are lookin at the imaginary part of the dielectric function before the smearing is applied.

Parameters:
• idir – First direction of the dielectric tensor.

• jdir – Second direction of the dielectric tensor.

• mask – Mask to apply to the CDER for the bands/kpoint/spin index to include in the calculation

• min_val – Minimum value below this value the matrix element will not be shown.

sigma: float[source]
volume: float[source]
delta_func(x, ismear)[source]

Replication of VASP’s delta function

delta_methfessel_paxton(x, n)[source]

D_n (x) = exp -x^2 * sum_i=0^n A_i H_2i(x) where H is a Hermite polynomial and A_i = (-1)^i / ( i! 4^i sqrt(pi) )

epsilon_imag(cder: npt.NDArray, eigs: npt.NDArray, kweights: npt.ArrayLike, efermi: float, nedos: int, deltae: float, ismear: int, sigma: float, idir: int, jdir: int, mask: npt.NDArray | None = None)[source]

Replicate the EPSILON_IMAG function of VASP.

Parameters:
• cder – The data written to the WAVEDER (nbands, nbands, nkpoints, nspin, diri, dirj)

• eigs – The eigenvalues (nbands, nkpoints, nspin)

• kweights – The kpoint weights (nkpoints)

• efermi – The fermi energy

• nedos – The sampling of the energy values

• deltae – The energy grid spacing

• ismear – The smearing parameter used by the `step_func`.

• sigma – The width of the smearing

• idir – The first direction of the dielectric tensor

• jdir – The second direction of the dielectric tensor

• mask – Mask for the bands/kpoint/spin index to include in the calculation

Returns:

Array of size nedos with the imaginary part of the dielectric function.

Return type:

np.array

get_delta(x0: float, sigma: float, nx: int, dx: float, ismear: int = 3)[source]

Get the smeared delta function to be added to form the spectrum.

This replaces the SLOT function from VASP. Uses finite differences instead of evaluating the delta function since the step function is more likely to have analytic form.

Parameters:
• x0 – The center of the dielectric function.

• sigma – The width of the smearing

• nx – The number of grid points in the output grid.

• dx – The gridspacing of the output grid.

• ismear – The smearing parameter used by the `step_func`.

Returns:

Array of size nx with delta function on the desired outputgrid.

Return type:

np.array

get_step(x0, sigma, nx, dx, ismear)[source]

Get the smeared step function to be added to form the spectrum.

This replaces the SLOT function from VASP.

Parameters:
• x0 – The center of the dielectric function.

• sigma – The width of the smearing

• nx – The number of grid points in the output grid.

• dx – The gridspacing of the output grid.

• ismear – The smearing parameter used by the `step_func`.

Returns:

Array of size nx with step function on the desired outputgrid.

Return type:

np.array

kramers_kronig(eps: ndarray, nedos: int, deltae: float, cshift: float = 0.1) ndarray[Any, dtype[ScalarType]][source]

Perform the Kramers-Kronig transformation.

Perform the Kramers-Kronig transformation exactly as VASP does it. The input eps should be complex and the imaginary part of the dielectric function should be stored as the real part of the complex input array. The output should be the complex dielectric function.

Parameters:
• eps – The dielectric function with the imaginary part stored as the real part and nothing in the imaginary part.

• nedos – The sampling of the energy values

• deltae – The energy grid spacing

• cshift – The shift of the imaginary part of the dielectric function.

Returns:

Array of size nedos with the complex dielectric function.

Return type:

np.array

step_func(x, ismear)[source]

Replication of VASP’s step function

step_methfessel_paxton(x, n)[source]

S_n (x) = (1 + erf x)/2 - exp -x^2 * sum_i=1^n A_i H_{2i-1}(x) where H is a Hermite polynomial and A_i = (-1)^i / ( i! 4^i sqrt(pi) )
{"ft_lang_label":"__label__en","ft_lang_prob":0.64466226,"math_prob":0.97296524,"size":6512,"snap":"2023-14-2023-23","text_gpt3_token_len":1645,"char_repetition_ratio":0.14996926,"word_repetition_ratio":0.26593626,"special_character_ratio":0.22420147,"punctuation_ratio":0.16949153,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9875672,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-24T18:29:27Z\",\"WARC-Record-ID\":\"<urn:uuid:090f9222-d54f-4bf9-907f-a1ff4f4776fe>\",\"Content-Length\":\"54005\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:04672b6e-3228-4b08-ac97-31a773e9ac98>\",\"WARC-Concurrent-To\":\"<urn:uuid:fa949d69-8b97-4b01-9b17-4e22171a64d4>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://pymatgen.org/pymatgen.io.vasp.optics.html\",\"WARC-Payload-Digest\":\"sha1:H32X4HA767RBUH4GJJH3DFLP7GWOGZGR\",\"WARC-Block-Digest\":\"sha1:JUYBRVV2EQ4CROFH3N2BGHXEP7XM5LIV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296945288.47_warc_CC-MAIN-20230324180032-20230324210032-00528.warc.gz\"}"}