magnopy.io.output_k_resolved#

magnopy.io.output_k_resolved(data, data_headers=None, output_filename=None, kpoints=None, relative=False, rcell=None, flat_indices=None, digits=4, scientific_notation=True)[source]#

Outputs any k-resolved data.

Parameters:
data(N, M) array-like

Some k-resolved data. N (\(\ge 1\)) is the amount of kpoints. M is the number of data modes/entries.

data_headers(N, ) list of str, optional

Header for the data columns. [f"data {i+1} for i in range(len(data))] by default.

output_filenamestr, optional

Name of the file for saving the data. If None, then return a list of lines.

kpoints(N, 3) array-like, optional

List of the kpoints. kpoints[i] correspond to the data[i].

relativebool, default False

If relative == True, then given kpoints are interpreted as relative to the reciprocal unit cell. Otherwise they are interpreted as absolute coordinates.

rcell(3, 3) array-like, optional

Reciprocal unit cell. Rows are interpreted as vectors, columns as Cartesian coordinates.

flat_indices(N, 3) array-like, optional

kpoints converted to the list of floats according to some rule. Typically used for plotting the band structure. If None provided, then computed automatically, based on the distance of the given kpoints (whether absolute or relative).

digitsint, default 4

Number of digits after the comma for the data elements.

scientific_notationbool, default True

Whether to use scientific notation for the data elements.

Returns:
linesstr

Only returned if output_filename is None. Use print("\n".join(lines)) to output the results to the standard output stream.

Notes

By default kpoints are interpreted as given in absolute coordinates in the reciprocal space.

>>> import magnopy.io as mio
>>> omegas = [[1, 2], [1.2, 2.3]]
>>> headers = ["mode 1", "mode 2"]
>>> kpoints = [[0, 0, 0], [0.1, 0.2, 0.3]]
>>> lines = mio.output_k_resolved(data=omegas, data_headers=headers, kpoints=kpoints)
>>> print("\n".join(lines))
#   flat index         mode 1         mode 2          k_x          k_y          k_z
    0.00000000     1.0000e+00     2.0000e+00   0.00000000   0.00000000   0.00000000
    0.37416574     1.2000e+00     2.3000e+00   0.10000000   0.20000000   0.30000000

One can tell it to interpret the kpoints as given in relative coordinates to some reciprocal cell

>>> lines = mio.output_k_resolved(data=omegas, data_headers=headers, kpoints=kpoints, relative=True)
>>> print("\n".join(lines))
#   flat index         mode 1         mode 2         k_b1         k_b2         k_b3
    0.00000000     1.0000e+00     2.0000e+00   0.00000000   0.00000000   0.00000000
    0.37416574     1.2000e+00     2.3000e+00   0.10000000   0.20000000   0.30000000

If the reciprocal cell is provided, then the kpoints are converter either way and both are printed

>>> lines = mio.output_k_resolved(data=omegas, data_headers=headers, kpoints=kpoints, relative=True, rcell=[[1, 0, 0], [0, 2, 0], [0, 0, 3]])
>>> print("\n".join(lines))
#   flat index         mode 1         mode 2         k_b1         k_b2         k_b3          k_x          k_y          k_z
    0.00000000     1.0000e+00     2.0000e+00   0.00000000   0.00000000   0.00000000   0.00000000   0.00000000   0.00000000
    0.37416574     1.2000e+00     2.3000e+00   0.10000000   0.20000000   0.30000000   0.10000000   0.40000000   0.90000000
>>> lines = mio.output_k_resolved(data=omegas, data_headers=headers, kpoints=kpoints, relative=False, rcell=[[1, 0, 0], [0, 2, 0], [0, 0, 3]])
>>> print("\n".join(lines))
#   flat index         mode 1         mode 2         k_b1         k_b2         k_b3          k_x          k_y          k_z
    0.00000000     1.0000e+00     2.0000e+00   0.00000000   0.00000000   0.00000000   0.00000000   0.00000000   0.00000000
    0.37416574     1.2000e+00     2.3000e+00   0.10000000   0.10000000   0.10000000   0.10000000   0.20000000   0.30000000

One can control the number of digits in data

>>> lines = mio.output_k_resolved(data=omegas, data_headers=headers, kpoints=kpoints, digits=6)
>>> print("\n".join(lines))
#   flat index           mode 1           mode 2          k_x          k_y          k_z
    0.00000000     1.000000e+00     2.000000e+00   0.00000000   0.00000000   0.00000000
    0.37416574     1.200000e+00     2.300000e+00   0.10000000   0.20000000   0.30000000

and whether the scientific notation should be used

>>> lines = mio.output_k_resolved(data=omegas, data_headers=headers, kpoints=kpoints, scientific_notation=False)
>>> print("\n".join(lines))
#   flat index    mode 1    mode 2          k_x          k_y          k_z
    0.00000000    1.0000    2.0000   0.00000000   0.00000000   0.00000000
    0.37416574    1.2000    2.3000   0.10000000   0.20000000   0.30000000