Skip to content

Quick notes

A place to write down quick notes on the design decisions made for the qe-tools package.

Note

The purpose of these notes are to sketch ideas, not write design decisions down rigorously.

Class structure

The currently envisioned class structure is shown in the sketch below, for the pw.x calculation:

flowchart LR
    classDef io fill:#4caf50,stroke:#2e7d32
    classDef parser fill:#ffa726,stroke:#ef6c00
    classDef facade fill:#4285f4,stroke:#1565c0
    classDef file fill:#f5f5f5,stroke:#9e9e9e

    PWIN([pw.in]):::file <--> PWINP[PwInput]:::io
    PWINP --> CALC[PwCalc]:::facade
    PWOUT[PwOutput]:::io --> CALC
    STD([stdout]):::file --> SP[PwStdoutParser]:::parser
    XML([data-file-schema.xml]):::file --> XP[PwXMLParser]:::parser
    CRASH([CRASHFILE]):::file --> CP[PwCrashParser]:::parser
    SP --> PWOUT
    XP --> PWOUT
    CP --> PWOUT

Outputs

The notes on this topic have been moved to a separate page.

One input per code

Typically, each executable in the Quantum ESPRESSO suite will have a single input file.

The input class should allow for several use cases:

  1. Generate a Quantum ESPRESSO input file from various Python types.
  2. Parse an existing input file into various Python types.

How about "intermediate" files?

Some files can be both an output and an input of a calculation. Examples here are restart files such as the charge density/wave functions, but those are full (sometimes binary system-specific) files that don't require a Python object to represent. Other examples are the interatomic constants, for which we already have an AiiDA data node.

ASE/pymatgen/AiiDA/... support

Most users will want to provide e.g. the input structure or output data in the flavour of their choosing. We should provide tools for converting:

  1. The flavored Python types (Structure, Atoms, ...) into the Quantum ESPRESSO input file.
  2. The Quantum ESPRESSO raw parsed output into the flavour's Python type.

One class to rule both input/output

Would it instead not be useful to have one object that has both inputs and outputs?

Reasons could be:

  1. The user might want to just load both input/output from the directory in one fell swoop, since they might want to work with the output of the calculation differently depending on the input.
  2. Some parsing functionality might be easier to implement if the inputs are known. I think it may even be necessary for some outputs to know e.g. what the number of k-points are. Some of the inputs are also in the XML output though...

Example Usage

If you want to parse all the inputs and outputs from a pw.x run in the pw_run directory:

from qe_tools.parsers import PwParser

parser = PwParser.from_dir('pw_run')

Then you can obtain the outputs as

parser.outputs['structure']

similarly, the inputs can then be obtained from the inputs attribute:

parser.inputs['structure']

(Maybe this should not be a "parser", but a "calculation". E.g. PwCalc that has inputs and outputs.)