{
"cells": [
{
"cell_type": "markdown",
"id": "22d177dc-6cfb-4de2-9509-f1eb45e10cf2",
"metadata": {},
"source": [
"# Equation of state (EOS)\n",
"For the source code, see [eos](https://workgraph-collections.readthedocs.io/en/latest/qe/module.html#workgraph_collections.ase.espresso.eos.eos_workgraph).\n",
"\n",
"## Example: Silicon\n",
"### Prepare the inputs and visualize the WorkGraph"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from aiida import load_profile, orm\n",
"from ase.build import bulk\n",
"from workgraph_collections.qe.eos import EosWorkgraph\n",
"\n",
"load_profile()\n",
"\n",
"structure = orm.StructureData(ase=bulk(\"Si\"))\n",
"code = orm.load_code(\"pw-7.4@localhost\")\n",
"parameters = {\n",
" \"CONTROL\": {\n",
" \"calculation\": \"scf\",\n",
" },\n",
" \"SYSTEM\": {\n",
" \"ecutwfc\": 30,\n",
" \"ecutrho\": 240,\n",
" \"occupations\": \"smearing\",\n",
" \"smearing\": \"gaussian\",\n",
" \"degauss\": 0.1,\n",
" },\n",
"}\n",
"# Load the pseudopotential family.\n",
"pseudo_family = orm.load_group(\"SSSP/1.3/PBEsol/efficiency\")\n",
"pseudos = pseudo_family.get_pseudos(structure=structure)\n",
"kpoints = orm.KpointsData()\n",
"kpoints.set_kpoints_mesh([3, 3, 3])\n",
"#\n",
"metadata = {\n",
" \"options\": {\n",
" \"resources\": {\n",
" \"num_machines\": 1,\n",
" \"num_mpiprocs_per_machine\": 1,\n",
" },\n",
" }\n",
"}\n",
"\n",
"# ===============================================================================\n",
"wg = EosWorkgraph.build_graph(\n",
" structure=structure,\n",
" code=code,\n",
" scales=[0.98, 0.99, 1.0, 1.01, 1.02],\n",
" parameters=parameters,\n",
" kpoints=kpoints,\n",
" pseudos=pseudos,\n",
" metadata=metadata,\n",
")\n",
"wg.to_html()"
]
},
{
"cell_type": "markdown",
"id": "4e61ea35",
"metadata": {},
"source": [
"### Run the workflow"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "99092862",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"09/02/2025 01:10:17 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|continue_workgraph]: tasks ready to run: scale_structure\n",
"09/02/2025 01:10:17 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|update_task_state]: Task: scale_structure, type: CALCFUNCTION, finished.\n",
"09/02/2025 01:10:17 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|continue_workgraph]: tasks ready to run: all_scf\n",
"09/02/2025 01:10:19 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175190\n",
"09/02/2025 01:10:21 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|continue_workgraph]: tasks ready to run: PwCalculation,PwCalculation1,PwCalculation2,PwCalculation3,PwCalculation4\n",
"09/02/2025 01:10:23 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175191, 175192, 175193, 175194, 175195\n",
"09/02/2025 01:10:37 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|update_task_state]: Task: PwCalculation, type: CALCJOB, finished.\n",
"09/02/2025 01:10:39 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"09/02/2025 01:10:39 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175192, 175193, 175194, 175195\n",
"09/02/2025 01:10:48 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|update_task_state]: Task: PwCalculation1, type: CALCJOB, finished.\n",
"09/02/2025 01:10:48 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|update_task_state]: Task: PwCalculation2, type: CALCJOB, finished.\n",
"09/02/2025 01:10:48 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|update_task_state]: Task: PwCalculation3, type: CALCJOB, finished.\n",
"09/02/2025 01:10:49 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|update_task_state]: Task: PwCalculation4, type: CALCJOB, finished.\n",
"09/02/2025 01:10:50 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"09/02/2025 01:10:51 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175190|WorkGraphEngine|finalize]: Finalize workgraph.\n",
"09/02/2025 01:10:51 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|update_task_state]: Task: all_scf, type: GRAPH, finished.\n",
"09/02/2025 01:10:52 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|continue_workgraph]: tasks ready to run: fit_eos\n",
"09/02/2025 01:10:52 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|update_task_state]: Task: fit_eos, type: CALCFUNCTION, finished.\n",
"09/02/2025 01:10:52 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"09/02/2025 01:10:52 PM <1293550> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175182|WorkGraphEngine|finalize]: Finalize workgraph.\n"
]
}
],
"source": [
"wg.run()"
]
},
{
"cell_type": "markdown",
"id": "164a589f",
"metadata": {},
"source": [
"## Print the results"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "64c3f175",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Result: \n",
"B: 83.930472220061\n",
"v0: 40.947349586558\n",
"e0: -308.18973212512\n",
"v0: 40.947349586558\n"
]
}
],
"source": [
"#------------------------- Print the output -------------------------\n",
"data = wg.outputs.result.value.get_dict()\n",
"print('\\nResult: \\nB: {B}\\nv0: {v0}\\ne0: {e0}\\nv0: {v0}'.format(**data))\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "aiida",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}