Elastic constants

For the source code, see elastic.

Example: Aluminum

Prepare the inputs and submit the workflow

[6]:
from ase.build import bulk
from aiida import load_profile
from workgraph_collections.ase.espresso.elastic import ElasticWorkgraph
from aiida_pythonjob.config import config
# allow pickle
config["allow_pickle"] = True

load_profile()

# create input structure
atoms = bulk("Al")


metadata = {
    "options": {
        'prepend_text' : """
eval "$(conda shell.posix hook)"
conda activate aiida
export OMP_NUM_THREADS=1
""",
    }
}

pseudopotentials = {"Al": "Al.pbe-nl-rrkjus_psl.1.0.0.UPF"}
pseudo_dir = "/home/xing/data/ase/espresso_pseudo"
# pseudo_dir = "/home/wang_x3/datas/pseudos/psl"

# we need use high conv_thr to get accurate elastic constants
input_data = {
    "control": {"calculation": "relax",
                "tstress": True,
                "tprnfor": True,
                "verbosity": "high",
                "etot_conv_thr": 1e-5,
                "forc_conv_thr": 1.0e-5,
                },
    "system": {"ecutwfc": 40, "ecutrho": 320,
               "occupations": "smearing",
               "smearing": "gaussian",
                "degauss": 0.01,
                },
    "electrons": {"conv_thr": 1e-11}
}
#------------------------- Set the inputs -------------------------
wg = ElasticWorkgraph.build_graph(atoms=atoms,
                   computer="localhost",
                   command="mpirun -np 4 pw.x",
                   pseudopotentials=pseudopotentials,
                   pseudo_dir=pseudo_dir,
                   input_data=input_data,
                   kpts=[25, 25, 25],
                   metadata=metadata)
wg.to_html()

[6]:

Run the calculation

[2]:
wg.run()
09/04/2025 07:04:36 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator
09/04/2025 07:04:38 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 179698
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 179698
09/04/2025 07:04:41 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.
09/04/2025 07:04:42 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: get_deformed_structure_set
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: get_deformed_structure_set
INFO:aiida_pythonjob.decorator:Executing process function, current stack status: 47 frames of 3000
09/04/2025 07:04:43 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|update_task_state]: Task: get_deformed_structure_set, type: PYFUNCTION, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|update_task_state]: Task: get_deformed_structure_set, type: PYFUNCTION, finished.
09/04/2025 07:04:43 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: run_relaxation
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: run_relaxation
09/04/2025 07:04:51 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 179749
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 179749
09/04/2025 07:04:57 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator,pw_calculator1,pw_calculator2,pw_calculator3,pw_calculator4,pw_calculator5
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator,pw_calculator1,pw_calculator2,pw_calculator3,pw_calculator4,pw_calculator5
09/04/2025 07:05:17 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 179753, 179766, 179779, 179792, 179805, 179818
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 179753, 179766, 179779, 179792, 179805, 179818
09/04/2025 07:05:24 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.
09/04/2025 07:05:25 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|update_task_state]: Task: pw_calculator1, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|update_task_state]: Task: pw_calculator1, type: PYTHONJOB, finished.
09/04/2025 07:05:25 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|update_task_state]: Task: pw_calculator2, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|update_task_state]: Task: pw_calculator2, type: PYTHONJOB, finished.
09/04/2025 07:05:26 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|update_task_state]: Task: pw_calculator3, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|update_task_state]: Task: pw_calculator3, type: PYTHONJOB, finished.
09/04/2025 07:05:27 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|update_task_state]: Task: pw_calculator4, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|update_task_state]: Task: pw_calculator4, type: PYTHONJOB, finished.
09/04/2025 07:05:28 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|update_task_state]: Task: pw_calculator5, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|update_task_state]: Task: pw_calculator5, type: PYTHONJOB, finished.
09/04/2025 07:05:33 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|continue_workgraph]: tasks ready to run:
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|continue_workgraph]: tasks ready to run:
09/04/2025 07:05:34 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179749|WorkGraphEngine|finalize]: Finalize workgraph.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179749|WorkGraphEngine|finalize]: Finalize workgraph.
09/04/2025 07:05:36 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|update_task_state]: Task: run_relaxation, type: GRAPH, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|update_task_state]: Task: run_relaxation, type: GRAPH, finished.
09/04/2025 07:05:38 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: fit_elastic_constants
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|continue_workgraph]: tasks ready to run: fit_elastic_constants
INFO:aiida_pythonjob.decorator:Executing process function, current stack status: 47 frames of 3000
/home/xing/apps/miniforge3/envs/aiida/lib/python3.11/site-packages/pymatgen/analysis/elasticity/elastic.py:473: UserWarning: Pseudo-inverse fitting of Strain/Stress lists may yield questionable results from vasp data, use with caution.
  warnings.warn(
09/04/2025 07:05:39 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|update_task_state]: Task: fit_elastic_constants, type: PYFUNCTION, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|update_task_state]: Task: fit_elastic_constants, type: PYFUNCTION, finished.
09/04/2025 07:05:40 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|continue_workgraph]: tasks ready to run:
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|continue_workgraph]: tasks ready to run:
09/04/2025 07:05:40 AM <526049> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179694|WorkGraphEngine|finalize]: Finalize workgraph.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[179694|WorkGraphEngine|finalize]: Finalize workgraph.
[5]:
#------------------------- Print the output -------------------------
import numpy as np
elastic_constants = wg.outputs.result.value.value
print("Elastic constants: ")
print(np.round(elastic_constants, 2))

Elastic constants:
[[-109.87  -61.3   -61.3    -0.      4.25   -4.25]
 [ -61.3  -109.87  -61.3    -4.25    0.      4.25]
 [ -61.3   -61.3  -109.87    4.25   -4.25    0.  ]
 [  -0.     -0.     -0.    -38.51   -0.     -0.  ]
 [  -0.     -0.     -0.      0.    -38.51   -0.  ]
 [   0.      0.      0.     -0.     -0.    -38.51]]

The calcualted elastic constants of aluminum are C11=117.3 GPa, C12=57.6 GPa, and C44=38.1 GPa, compared to the values reported by experiment: C11=116.3 GPa, C12=64.8 GPa, and C44=30.9 GPa.