Skip to content

projwfc

Classes for reading/manipulating Projwfc.x files.

Projwfc(parameters, filename, proj_source, structure=None, atomic_states=None, k=None, k_weights=None, eigenvals=None)

Bases: MSONable

Class to parse projwfc.x output. Supports parsing from projwfc.out (projwfc.x's stdout), filproj, and atomic_proj.xml files. filproj is recommended for parsing, as it is the most complete source of data. See this page for a comparison of the three files.

ATTRIBUTE DESCRIPTION
parameters

Parameters parsed from the header of the file. Contents depend on the source of the data.

TYPE: dict

structure

Structure object parsed from the file.

TYPE: Structure

lspinorb

Whether the calculation includes spin-orbit coupling.

TYPE: bool | None

noncolin

Whether the calculation is noncolinear.

TYPE: bool | None

lsda

Whether the calculation is spin-polarized.

TYPE: bool | None

nstates

Number of atomic states parsed from the file.

TYPE: int

atomic_states

List of AtomicState objects parsed from the file. Ordered in the same way projwfc.x orders them.

TYPE: list[AtomicState]

nk

Number of k-points parsed from the file.

TYPE: int

nbands

Number of bands parsed from the file.

TYPE: int

k

k-points parsed from the file. Shape is (nkstot, 3).

TYPE: ndarray | None

k_weights

k-point weights parsed from the file. Shape is (nkstot,).

TYPE: ndarray | None

eigenvals

Eigenvalues parsed from the file. Shape is (nkstot, nbnd).

TYPE: ndarray | None

proj_source

Source of the data. One of "projwfc.out", "filproj", or "atomic_proj.xml".

TYPE: str

A lot of arguments and parameters can be none since not all the files contain the same information. The parameters dictionary is parsed from the header of the file and can contain some or all of the following keys:

  • natomwfc: Number of atomic states
  • nr1x, nr2x, nr3x: Number of grid points on the coarse grid
  • nr1, nr2, nr3: Number of grid points on the fine grid
  • gcutm: plane wave cutoff as a g-vector
  • dual: ratio between charge density and plane wave cutoffs
  • nkstot: Number of k-points
  • nbnd: Number of bands
  • nine: Always the number 9
  • lsda: Whether the calculation is spin-polarized
  • lspinorb: Whether the calculation includes spin-orbit coupling
  • noncolin: Whether the calculation is noncolinear
PARAMETER DESCRIPTION
parameters

Parameters parsed from the header of the file. Contents depend on the source of the data.

TYPE: dict

filename

Path to the file

TYPE: str | PathLike

proj_source

Source of the data. One of "projwfc.out", "filproj", or "atomic_proj.xml".

TYPE: str

structure

Structure object parsed from the file.

TYPE: Structure DEFAULT: None

atomic_states

List of AtomicState objects parsed from the file. Ordered in the same way projwfc.x orders them.

TYPE: list[AtomicState] DEFAULT: None

k

k-points parsed from the file. Shape is (nkstot, 3).

TYPE: ndarray DEFAULT: None

k_weights

k-point weights parsed from the file. Shape is (nkstot,).

TYPE: ndarray DEFAULT: None

eigenvals

Eigenvalues parsed from the file. Shape is (nkstot, nbnd).

TYPE: ndarray DEFAULT: None

Source code in pymatgen/io/espresso/outputs/projwfc.py
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
def __init__(
    self,
    parameters: dict[str, Any],
    filename: str | os.PathLike,
    proj_source: str,
    structure: Structure | None = None,
    atomic_states: list["AtomicState"] | None = None,
    k: np.ndarray[float] | None = None,
    k_weights: np.ndarray[float] | None = None,
    eigenvals: np.ndarray[float] | None = None,
):
    """
    Constructor for Projwfc object. Shouldn't really be used directly, use one of the class methods instead: `from_projwfcout`, `from_filproj`, or `from_xml`.

    A lot of arguments and parameters can be none since not all the files contain
    the same information. The parameters dictionary is parsed from the header of the
    file and can contain some or all of the following keys:

    - `natomwfc`: Number of atomic states
    - `nr1x, nr2x, nr3x`: Number of grid points on the coarse grid
    - `nr1, nr2, nr3`: Number of grid points on the fine grid
    - `gcutm`: plane wave cutoff as a g-vector
    - `dual`: ratio between charge density and plane wave cutoffs
    - `nkstot`: Number of k-points
    - `nbnd`: Number of bands
    - `nine`: Always the number 9
    - `lsda`: Whether the calculation is spin-polarized
    - `lspinorb`: Whether the calculation includes spin-orbit coupling
    - `noncolin`: Whether the calculation is noncolinear

    Args:
        parameters (dict): Parameters parsed from the header of the file.
            Contents depend on the source of the data.
        filename (str | os.PathLike): Path to the file
        proj_source (str): Source of the data. One of "projwfc.out", "filproj",
            or "atomic_proj.xml".
        structure (Structure): Structure object parsed from the file.
        atomic_states (list[AtomicState]): List of AtomicState objects parsed from
            the file. Ordered in the same way projwfc.x orders them.
        k (np.ndarray): k-points parsed from the file. Shape is (nkstot, 3).
        k_weights (np.ndarray): k-point weights parsed from the file.
            Shape is (nkstot,).
        eigenvals (np.ndarray): Eigenvalues parsed from the file.
            Shape is (nkstot, nbnd).
    """
    self.parameters = parameters
    self.structure = structure
    self.lspinorb = parameters.get("lspinorb")
    self.noncolin = parameters.get("noncolin")
    self.lsda = parameters.get("lsda")
    self.nstates = parameters["natomwfc"]
    self.atomic_states = [] if atomic_states is None else atomic_states
    self.nk = parameters["nkstot"]
    self.nbands = parameters["nbnd"]
    self.k = [] if k is None else k
    self.k_weights = [] if k_weights is None else k_weights
    self.eigenvals = {} if eigenvals is None else eigenvals
    self.proj_source = proj_source
    self._filename = filename

__eq__(other)

Equality test. Meant for checking that the two objects come from the same calculation, not that they are identical. It also assumes that the atomic states are ordered identically, and it checks them against each other using the AtomicState.__eq__ method (see that method for a description of how the comparison is done).

This dunder method is really only intended as a check before adding two Projwfc objects together. See the Projwfc.__add__ method for more information.

Source code in pymatgen/io/espresso/outputs/projwfc.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def __eq__(self, other):
    """
    Equality test. Meant for checking that the two objects come from
    the same calculation, not that they are identical. It also assumes that the atomic states are ordered identically, and it checks them against each other using the `AtomicState.__eq__` method (see that method for a description of how the comparison is done).

    This dunder method is really only intended as a check before adding two Projwfc objects together. See the `Projwfc.__add__` method for more information.
    """
    if not isinstance(other, Projwfc):
        return False

    # Not all sources of Projwfc data will have a structure
    same_structure = (
        self.structure == other.structure
        if (self.structure and other.structure)
        else True
    )
    same_states = all(
        s1 == s2
        for s1, s2 in zip(self.atomic_states, other.atomic_states, strict=False)
    )
    return all(
        [
            same_structure,
            same_states,
            self.lspinorb == other.lspinorb,
            self.noncolin == other.noncolin,
            self.nstates == other.nstates,
            self.nk == other.nk,
            self.nbands == other.nbands,
        ]
    )

__add__(other)

Combine two Projwfc objects. This is intended for combining one object with the spin up channel and another with the spin down. This is only ever necessary when parsing filproj for a spin-polarized calculation, since the two channels are stored in separate files.

Before addition, this method checks that the two objects must come from the same calculation see the Projwfc.__eq__ method for more information. This check is guaranteed to pass if the two objects are parsed from two filproj files produced by the same calculation. Returns a new Projwfc object with the combined data.

Source code in pymatgen/io/espresso/outputs/projwfc.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
def __add__(self, other: "Projwfc"):
    """
    Combine two Projwfc objects. This is intended for combining one object with the
    spin up channel and another with the spin down. This is only ever necessary when
    parsing filproj for a spin-polarized calculation, since the two channels are
    stored in separate files.

    Before addition, this method checks that the two objects must come from
    the same calculation see the `Projwfc.__eq__` method for more information.
    This check is guaranteed to pass if the two objects are parsed from two filproj
    files produced by the same calculation. Returns a new Projwfc object with the
    combined data.
    """
    if not isinstance(other, Projwfc):
        raise ValueError("Can only add Projwfc objects to other Projwfc objects.")
    if self != other:
        raise InconsistentProjwfcDataError(
            "Can only add Projwfc objects from the same calculation."
        )

    # Check that one is spin up and the other is spin down
    # Get all the spins of each object. These are the keys of the projection
    # attribute.
    spin1 = {
        spin for state in self.atomic_states for spin in state.projections.keys()
    }
    spin2 = {
        spin for state in other.atomic_states for spin in state.projections.keys()
    }
    if len(spin1) != 1 or len(spin2) != 1:
        raise InconsistentProjwfcDataError(
            (
                "You are trying to add two Projwfc objects with multiple spins. "
                "This should only be used to add objects with one spin each."
            )
        )
    spin1, spin2 = spin1.pop(), spin2.pop()
    if spin1 == spin2:
        raise InconsistentProjwfcDataError(
            "Can only add Projwfc objects with opposite spins."
        )

    result = deepcopy(self)
    for s1, s2 in zip(result.atomic_states, other.atomic_states, strict=True):
        s1.projections |= s2.projections

    return result

__str__()

String representation of the object. This is intended to be a human-readable summary of the data parsed from the file. It includes the header information, a summary of the structure, and a summary of the atomic states. It also includes information about which data was parsed and which was not.

Source code in pymatgen/io/espresso/outputs/projwfc.py
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
def __str__(self):
    """
    String representation of the object. This is intended to be a human-readable
    summary of the data parsed from the file. It includes the header information,
    a summary of the structure, and a summary of the atomic states. It also
    includes information about which data was parsed and which was not.
    """

    # Incompletely parsed calculations (xml) won't have the noncolin or lspinorb
    if self.noncolin is None:
        header = "Unknown "
    elif self.lspinorb:
        header = "Spin-orbit "
    elif self.noncolin:
        header = "Noncolinear "
    else:
        header = "Colinear "
    if self.lsda:
        header += "(spin-polarized) "
    header += f"calculation with {self.nk} k-points and {self.nbands} bands."
    out = [header, f"Filename: {self._filename}"]
    k_parsed = f"K-points parsed: {np.any(self.k)} "
    if np.any(self.k):
        k_parsed += f"(Units: {self.parameters['k_unit']})"
    out.extend(
        (
            k_parsed,
            f"K-point weights parsed: {np.any(self.k_weights)}",
            f"Eigenvalues parsed: {bool(self.eigenvals)}",
            f"Projections data source: {self.proj_source}",
            "\n------------ Structure ------------",
        )
    )
    if self.structure:
        out.extend(str(self.structure).split("\n")[:5])
        out.append(f"Sites ({self.structure.num_sites})")
        # Almost identical to Structure.__str__
        data = []
        for site in self.structure.sites:
            row = [
                site.atom_i,
                site.species_string,
                *[f"{j:0.6f}" for j in site.frac_coords],
                site.Z,
            ]
            data.append(row)
        out.append(
            tabulate(
                data,
                headers=["#", "SP", "a", "b", "c", "Z val."],
            )
        )
    else:
        out.append("Structure not parsed.")
    out.append("\n---------- Atomic States ----------")

    if self.atomic_states and self.atomic_states[0].l is not None:
        data = []
        headers = ["State #", "SP (#)", "Orbital", "l"]
        if self.lspinorb:
            headers.extend(["j", "mj"])
        elif self.noncolin:
            headers.extend(["m", "s_z"])
        else:
            headers.extend(["m"])

        for state in self.atomic_states:
            _, orbital_str = state._to_projwfc_state_string()
            orb = orbital_str.split()[1]
            atom = state.site.species_string + " (" + str(state.site.atom_i) + ")"
            row = [state.state_i, atom, orb, state.l]
            if state.j:
                row.extend([state.j, state.mj])
            elif state.s_z:
                row.extend([state.m, state.s_z])
            else:
                row.extend([state.m])
            data.append(row)

        out.append(tabulate(data, headers=headers))
    else:
        out.append(
            f"Found {self.nstates} atomic states, but their type is unknown."
        )

    return "\n".join(out)

from_projwfcout(filename, parse_projections=True) classmethod

Initialize from a projwfc.out file (stdout of projwfc.x)

PARAMETER DESCRIPTION
filename

Path to the file

TYPE: str | PathLike

parse_projections

Whether to parse the projections. If False, only the header of the file is parsed.

TYPE: bool DEFAULT: True

Source code in pymatgen/io/espresso/outputs/projwfc.py
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
@classmethod
def from_projwfcout(
    cls, filename: str | os.PathLike, parse_projections: bool = True
):
    """
    Initialize from a projwfc.out file (stdout of projwfc.x)

    Args:
        filename (str | os.PathLike): Path to the file
        parse_projections (bool): Whether to parse the projections. If False, only
            the header of the file is parsed.
    """

    with open(filename, "r") as f:
        if parse_projections:
            data = f.read()
        else:
            # TODO: Does it matter how many lines you read if you don't parse
            # the projections? Need benchmarking
            nlines = 1000
            head = list(itertools.islice(f, nlines))
            data = "\n".join(head)

    parameters, atomic_states = cls._parse_projwfcout_header(data)
    k, eigenvals = [], {}
    if parse_projections:
        k, eigenvals, atomic_states, projections = cls._parse_projwfcout_body(
            data, parameters, atomic_states
        )
        parameters.update({"k_unit": "2pi/alat"})

    return cls(
        parameters,
        filename,
        proj_source="projwfc.out" if parse_projections else None,
        atomic_states=atomic_states,
        k=k,
        eigenvals=eigenvals,
    )

from_filproj(filename, parse_projections=True) classmethod

Construct a Projwfc object from a filproj file. This is the file generated by projwfc.x and is called filproj.projwfc_up by default.

Spin-polarized calculations will also have a filproj.projwfc_down file. This method is intended to parse only one of the two files. If you want to parse both, you should parse them separately and then add them together as projwfc_total = projwfc_up + projwfc_down

See the docstring of the Projwfc.__add__ method for more information.

PARAMETER DESCRIPTION
filename

Path to the file

TYPE: str

parse_projections

Whether to parse the projections. If False, only the header of the file is read.

TYPE: bool DEFAULT: True

Source code in pymatgen/io/espresso/outputs/projwfc.py
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
@classmethod
def from_filproj(cls, filename: str | os.PathLike, parse_projections: bool = True):
    """
    Construct a Projwfc object from a filproj file. This is the file
    generated by projwfc.x and is called `filproj.projwfc_up` by default.

    Spin-polarized calculations will also have a `filproj.projwfc_down` file. This method is intended to parse only one of the two files. If you want to parse both, you should parse them separately and then add them together as
        `projwfc_total = projwfc_up + projwfc_down`

    See the docstring of the `Projwfc.__add__` method for more information.

    Args:
        filename (str): Path to the file
        parse_projections (bool): Whether to parse the projections.
            If False, only the header of the file is read.
    """
    parameters, structure, skip = cls._parse_filproj_header(filename)

    nstates = parameters["natomwfc"]
    nkpnt = parameters["nkstot"]
    nbnd = parameters["nbnd"]
    noncolin = parameters["noncolin"]
    atomic_states = {}

    if parse_projections:
        # The length of an atomic state block in the filproj file
        nlines = nbnd * nkpnt + 1

        columns = np.arange(8) if noncolin else np.arange(7)
        data = pd.read_csv(
            filename,
            skiprows=skip,
            header=None,
            sep=r'\s+',
            names=columns,
            dtype=str,
        )

        orbital_headers = data.values[::nlines, :]
        projections = data.values[:, 2]
        projections = np.delete(projections, slice(None, None, nlines))
        # k-point indices always run from 1 to nkpnt EXCEPT for the spin down
        # channel in spin polarized calculations (in filproj.projwfc_down)
        parameters["lsda"] = int(data.values[1, 0]) == nkpnt + 1
        spin = Spin.down if parameters["lsda"] else Spin.up
        projections = projections.reshape((nstates, nkpnt, nbnd), order="C").astype(
            float
        )

        # Process headers and save overlap data
        atomic_states = [None] * nstates
        for n in range(nstates):
            state_parameters = cls._parse_filproj_state_header(
                orbital_headers[n], parameters, structure
            )
            atomic_states[n] = AtomicState(
                state_parameters, {spin: projections[n, :, :]}
            )

    return cls(
        parameters,
        filename,
        proj_source="filproj" if parse_projections else None,
        atomic_states=atomic_states,
        structure=structure,
    )

from_xml(filename, parse_eigenvals=True, parse_k=True, parse_projections=True, selection=None, store_phi_psi=False) classmethod

Constructs a Projwfc object from an atomic_proj.xml file. This uses a selective parsing method, where only the data requested is parsed. This is useful for large files where only a subset of the data is needed. However, please note that projwfc XML files are not symmetrized. Please see this page for a comparison of the three files and some important details.

PARAMETER DESCRIPTION
filename

Path to the file

TYPE: str | PathLike

parse_eigenvals

Whether to parse the eigenvalues

TYPE: bool DEFAULT: True

parse_k

Whether to parse the k-points

TYPE: bool DEFAULT: True

parse_projections

Whether to parse the projections. Note that the XML does not actually contain the projections, but \(\langle \phi | \psi \rangle\) where \(\phi\) is the local orbital and \(\psi\) is the Bloch function. The projections are computed as \(|\langle \phi | \psi\rangle|^2\).

TYPE: bool DEFAULT: True

selection

List of atomic states to parse. If None, all states are parsed. One indexed list (just like projwfc.x's ouptut)

TYPE: list DEFAULT: None

store_phi_psi

Whether to store the raw data in the AtomicState objects. This will increase memory usage.

TYPE: bool DEFAULT: False

Source code in pymatgen/io/espresso/outputs/projwfc.py
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
@classmethod
def from_xml(
    cls,
    filename: str | os.PathLike,
    parse_eigenvals: bool = True,
    parse_k: bool = True,
    parse_projections: bool = True,
    selection: list[int] | bool = None,
    store_phi_psi: bool = False,
):
    r"""
    Constructs a Projwfc object from an atomic_proj.xml file. This uses a selective parsing method, where only the data requested is parsed. This is useful for large files where only a subset of the data is needed. However, please note that projwfc XML files are *not* symmetrized. Please see [this page](../../../../../dev_notes/projwfc_output_comparison.md) for a comparison of the three files and some important details.

    Args:
        filename (str | os.PathLike): Path to the file
        parse_eigenvals (bool): Whether to parse the eigenvalues
        parse_k (bool): Whether to parse the k-points
        parse_projections (bool): Whether to parse the projections. Note that the
            XML does not actually contain the projections, but
            $\langle \phi | \psi \rangle$ where $\phi$ is the local orbital
            and $\psi$ is the Bloch function. The projections are computed as
            $|\langle \phi | \psi\rangle|^2$.
        selection (list): List of atomic states to parse. If None, all states
            are parsed. One indexed list (just like projwfc.x's ouptut)
        store_phi_psi (bool): Whether to store the raw data in the AtomicState
            objects. This will increase memory usage.
    """
    projections, phi_psi, eigenvals, k, weights, parameters = (
        cls._iterative_xml_parse(
            filename,
            parse_eigenvals,
            parse_k,
            parse_projections,
            selection,
            store_phi_psi,
        )
    )

    lsda = parameters["lsda"]
    natomwfc = parameters["natomwfc"]
    if selection is None:
        selection = np.arange(1, natomwfc + 1)

    # Create empty AtomicState objects for everything, only fill in parsed ones
    atomic_states = [AtomicState({"state_i": i + 1}) for i in np.arange(natomwfc)]
    if parse_projections:
        for state_i in selection - 1:
            state = atomic_states[state_i]
            state.projections[Spin.up] = projections[0, :, state_i, :]
            if lsda:
                state.projections[Spin.down] = projections[1, :, state_i, :]
            if store_phi_psi:
                state.phi_psi[Spin.up] = phi_psi[0, :, state_i, :]
                if lsda:
                    state.phi_psi[Spin.down] = phi_psi[1, :, state_i, :]

    proj_source = "atomic_proj.xml" if parse_projections else None
    return cls(
        parameters,
        filename,
        proj_source,
        atomic_states=atomic_states,
        k=k,
        k_weights=weights,
        eigenvals=eigenvals,
    )

AtomicState(parameters, projections=None, phi_psi=None, pdos=None, energies=None)

Bases: MSONable

Class to store information about a single atomic state from projwfc.x or dox.x

An atomic state is defined as an orbital one specific atom. The orbital is: - Defined by (n, l, m) if the calculation is colinear and not spin-polarized - Defined by (n, l, m) if the calculation is colinear spin-polarized. In this case, the spin up and spin down states are included in the same object. - Defined by (n, l, j, s_z) if the calculation is noncolinear without SOC. - Defined by (n, l, j, mj) if the calculation is noncolinear with SOC.

Where:

  • n is the principal quantum number
  • l is the orbital or angular quantum number
  • m is the magnetic quantum number
  • j is the total angular momentum quantum number
  • m_j is the magnetic quantum number of the total angular momentum
  • s_z is the z component of the local spin (+- 1/2)

QE also uses the notation of "wfc" to index the wavefunctions coming from a specific atom's pseudopotential. So these are unique l's or unique (l, j) pairs.

ATTRIBUTE DESCRIPTION
state_i

Index of this state, as indexed by projwfc.x

TYPE: int

wfc_i

Index of the wavefunction in the calculation

TYPE: int

l

Orbital angular momentum quantum number

TYPE: int

j

Total angular momentum quantum number

TYPE: float

mj

Magnetic quantum number of the total angular momentum

TYPE: float

s_z

S_z projection on a local z-axis (NCL calcs without SOC)

TYPE: float

m

Magnetic quantum number

TYPE: int

n

Principal quantum number

TYPE: int

site

Site object for the atom

TYPE: PeriodicSite

orbital

Orbital object

TYPE: Orbital

projections

Projections of the state onto the atomic orbitals

TYPE: dict

phi_psi

Overlap of the state with the wavefunction

TYPE: dict

pdos

Projected density of states of the state

TYPE: dict

energies

Energies for the PDOS

TYPE: ndarray

PARAMETER DESCRIPTION
parameters

Dictionary with the following keys

  • state_i (int): Index of this state, as indexed by projwfc.x
  • wfc_i (int): Index of the wavefunction in the pseudopotential
  • l (int): Orbital angular momentum quantum number
  • j (float): Total angular momentum quantum number
  • mj (float): Magnetic quantum number of the total angular momentum
  • s_z (float): S_z projection on a local z-axis (NCL calcs without SOC)
  • m (int): Magnetic quantum number
  • n (int): Principal quantum number
  • site (Site): Site object for the atom

TYPE: dict

projections

Projections from every band and k-point onto this atomic orbital.

TYPE: dict[Spin, ndarray] DEFAULT: None

phi_psi

Overlaps

TYPE: dict[Spin, ndarray] DEFAULT: None

pdos

Projected density of states

TYPE: dict[Spin, ndarray] DEFAULT: None

orbital

(pymatgen.electronic_structure.core.Orbital): Orbital object Undefined for calculations with SOC.

Source code in pymatgen/io/espresso/outputs/projwfc.py
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
def __init__(
    self,
    parameters: dict[str, Any],
    projections: dict[Spin, np.ndarray] = None,
    phi_psi: dict[Spin, np.ndarray] = None,
    pdos: dict[Spin, np.ndarray] = None,
    energies: np.ndarray = None,
):
    """
    Initialize an AtomicState object.

    Args:
        parameters (dict): Dictionary with the following keys

            - `state_i` (int): Index of this state, as indexed by projwfc.x
            - `wfc_i` (int): Index of the wavefunction in the pseudopotential
            - `l` (int): Orbital angular momentum quantum number
            - `j` (float): Total angular momentum quantum number
            - `mj` (float): Magnetic quantum number of the total angular momentum
            - `s_z` (float): S_z projection on a local z-axis (NCL calcs without SOC)
            - `m` (int): Magnetic quantum number
            - `n` (int): Principal quantum number
            - `site` (Site): Site object for the atom

        projections (dict[Spin, np.ndarray]): Projections from every band and
            k-point onto this atomic orbital.
        phi_psi (dict[Spin, np.ndarray]): Overlaps
        pdos (dict[Spin, np.ndarray]): Projected density of states
        orbital: (pymatgen.electronic_structure.core.Orbital): Orbital object
            Undefined for calculations with SOC.
    """
    self.state_i = parameters.get("state_i")
    self.wfc_i = parameters.get("wfc_i")
    self.l = parameters.get("l")
    self.j = parameters.get("j")
    self.mj = parameters.get("mj")
    self.s_z = parameters.get("s_z")
    self.m = parameters.get("m")
    self.n = parameters.get("n")
    self.site = parameters.get("site")
    self.orbital = None
    if self.l is not None and self.m is not None:
        self.orbital = Orbital(projwfc_orbital_to_vasp(self.l, self.m))
    self.projections = {} if projections is None else projections
    self.phi_psi = {} if phi_psi is None else phi_psi
    self.pdos = pdos
    self.energies = energies

__eq__(other)

Equality test. This tests that the two objects represent the same state, i.e., same quantum numbers, state index, etc.

Source code in pymatgen/io/espresso/outputs/projwfc.py
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
def __eq__(self, other):
    """
    Equality test. This tests that the two objects represent the same state,
    i.e., same quantum numbers, state index, etc.
    """
    if not isinstance(other, AtomicState):
        return False

    return all(
        [
            self.state_i == other.state_i,
            self.wfc_i == other.wfc_i,
            self.l == other.l,
            self.j == other.j,
            self.mj == other.mj,
            self.s_z == other.s_z,
            self.m == other.m,
            self.n == other.n,
            self.site == other.site,
            self.orbital == other.orbital,
        ]
    )

ProjwfcParserError

Bases: Exception

Exception class for Projwfc parsing.

InconsistentProjwfcDataError

Bases: Exception

Exception class for Projwfc addition.