Skip to content

Commit 6ec21e2

Browse files
committed
initial commit
0 parents  commit 6ec21e2

File tree

14 files changed

+20677
-0
lines changed

14 files changed

+20677
-0
lines changed

.github/workflows/pyiron.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: pyiron
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: conda-incubator/setup-miniconda@v3
16+
with:
17+
auto-update-conda: true
18+
python-version: "3.12"
19+
environment-file: environment.yml
20+
auto-activate-base: false
21+
- name: Tests
22+
shell: bash -l {0}
23+
run: |
24+
pip install -e adis_tools
25+
pip install -e python_workflow_definition
26+
conda install -c conda-forge jupyter papermill
27+
export ESPRESSO_PSEUDO=$(pwd)/espresso/pseudo
28+
papermill universal_qe_to_pyiron_base.ipynb universal_qe_to_pyiron_base_out.ipynb -k "python3"

adis_tools/pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "adis_tools"
7+
version = "0.0.1"
8+
description = "Common functions for the Ab initio Description of Iron and Steel (ADIS2023): Digitalization and Workflows workshop"
9+
authors = [
10+
{ name = "Jan Janssen", email = "janssen@mpie.de" },
11+
{ name = "Janine George", email = "janine.geogre@bam.de" },
12+
{ name = "Marnik Bercx", email = "marnik.bercx@psi.ch" },
13+
{ name = "Christina Ertural", email = "christina.ertural@bam.de" },
14+
{ name = "Joerg Schaarschmidt", email = "joerg.schaarschmidt@kit.edu" },
15+
{ name = "Sam Dareska" },
16+
{ name = "Leopold Talirz", email = "leopold.talirz@gmail.com" },
17+
{ name = "Julian Geiger", email = "julian.geiger@psi.ch" },
18+
]
19+
license = { text = "MIT" }
20+
dependencies = ["numpy", "xmlschema", "qe_tools", "ase"]

adis_tools/src/adis_tools/__init__.py

Whitespace-only changes.

adis_tools/src/adis_tools/parsers.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import numpy
2+
3+
from xmlschema import XMLSchema
4+
from qe_tools import CONSTANTS
5+
6+
from ase import Atoms
7+
from importlib.resources import files
8+
9+
from . import schemas
10+
11+
12+
def parse_pw(xml_file):
13+
"""Parse a Quantum Espresso XML output file."""
14+
15+
xml_dict = XMLSchema(str(files(schemas) / 'qes_230310.xsd')).to_dict(xml_file)
16+
17+
parsed_results = {}
18+
19+
try:
20+
cell = numpy.array(
21+
[ v for v in xml_dict['output']['atomic_structure']['cell'].values()]
22+
) * CONSTANTS.bohr_to_ang
23+
symbols = [el['@name'] for el in xml_dict['output']['atomic_structure']['atomic_positions']['atom']]
24+
positions = numpy.array(
25+
[el['$'] for el in xml_dict['output']['atomic_structure']['atomic_positions']['atom']]
26+
) * CONSTANTS.bohr_to_ang
27+
28+
parsed_results['ase_structure'] = Atoms(
29+
cell=cell,
30+
positions=positions,
31+
symbols=symbols,
32+
pbc=True,
33+
)
34+
except KeyError:
35+
pass
36+
37+
try:
38+
parsed_results['energy'] = xml_dict['output']['total_energy']['etot'] * CONSTANTS.ry_to_ev
39+
except KeyError:
40+
pass
41+
42+
try:
43+
parsed_results['forces'] = (
44+
numpy.array(xml_dict['output']['forces']['$']).reshape(xml_dict['output']['forces']['@dims'])
45+
* 2 * CONSTANTS.ry_to_ev / CONSTANTS.bohr_to_ang
46+
)
47+
except KeyError:
48+
pass
49+
50+
return parsed_results

adis_tools/src/adis_tools/schemas/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)