Skip to content

Calculate the Total Energy with Post-Processing

1. Introduction

Calculate the total energy of a material in Quantum ESPRESSO and, from the same self-consistent calculation, the wavefunction amplitude, the average electrostatic potential or both, with or without a relaxation first.

2. Open the notebook

In JupyterLite, the notebook is made/workflows/total_energy_post_processing.ipynb, entry 2.2.1 "Wavefunction Amplitude / Average Electrostatic Potential" of made/workflows/Introduction.ipynb.

3. Set the parameters

Cell 1.2 holds the material, workflow and compute parameters:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from datetime import datetime
from mat3ra.ide.compute import QueueName

# 2. Auth and organization parameters
ORGANIZATION_NAME = None

# 3. Material parameters
FOLDER = "../uploads"
MATERIAL_NAME = "Silicon"

# 4. Workflow parameters
APPLICATION_NAME = "espresso"
ADD_RELAXATION = False

# Post-processing (PP) properties to calculate — list one or more, or use [] for total energy only:
POST_PROCESSING_PROPERTIES = ["wavefunction_amplitude"] # e.g., ["wavefunction_amplitude", "average_electrostatic_potential"]

# Model parameters
MODEL_SUBTYPE = "gga"  # or "lda"

MY_WORKFLOW_NAME = "Total Energy" + (
    " + " + ", ".join(
        p.replace("_", " ").title() for p in POST_PROCESSING_PROPERTIES) if POST_PROCESSING_PROPERTIES else "")

# 5. Compute parameters
CLUSTER_NAME = None  # specify full or partial name i.e. "cluster-001" to select
QUEUE_NAME = QueueName.D
PPN = 1

# 6. Job parameters
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M")
POLL_INTERVAL = 30  # seconds

POST_PROCESSING_PROPERTIES lists the post-processing properties, "wavefunction_amplitude" and "average_electrostatic_potential"; [] calculates the total energy only.

The overview explains the account, material, workflow, compute and job parameters.

Cell 1.3 holds the method and post-processing parameters:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Method parameters
PSEUDOPOTENTIAL_TYPE = "us"  # ultrasoft pseudopotentials; alternatives: "nc" (norm-conserving), "paw"
FUNCTIONAL = "pbe"  # for gga: pbe, pbesol, etc.; for lda: pz, etc.

# set k-grid for relaxation and SCF (if not set, KPPRA is used by default)
RELAXATION_KGRID = None  # e.g., [4, 4, 4]
SCF_KGRID = None  # e.g., [4, 4, 4]

# Wavefunction amplitude parameters
# Band selection: "VBM" (Valence Band Maximum), "CBM" (Conduction Band Minimum = VBM+1), or an integer (1-based custom band index)
WFN_BAND = "VBM"
# XY fractional (crystal) coordinates of the sampling point; plot is always 1D along Z
WFN_X = 0.0  # x0(1) in fractional crystal coordinates [0, 1)
WFN_Y = 0.0  # x0(2) in fractional crystal coordinates [0, 1)

# Average electrostatic potential parameters
AVG_SAMPLING_SCALE = 1.0  # macroscopic average period factor
AVG_NUM_POINTS = 3000  # number of points along the averaging direction
AVG_SMOOTHING_WINDOW = 3.0  # smoothing window length (in Bohr)

WFN_BAND is the band whose amplitude is calculated: "VBM", "CBM" or a band index starting from 1. WFN_X and WFN_Y are the fractional in-plane coordinates of the line along z on which the amplitude is sampled. AVG_SAMPLING_SCALE, AVG_NUM_POINTS and AVG_SMOOTHING_WINDOW set the period factor of the macroscopic average, the number of points along the averaging direction and the smoothing window in Bohr.

The overview explains the model and k-point parameters.

4. Run and read the result

Run the notebook with Run > Run All and log in when it asks, as in Authentication in JupyterLite.

After the job finishes, section 8 shows the total energy and plots the selected post-processing properties.

5. Interactive JupyterLite notebook

The interactive JupyterLite notebook for calculating the total energy with post-processing can be accessed below.