Skip to content

Commit

Permalink
Merge pull request #1521 from pyiron/tests
Browse files Browse the repository at this point in the history
Add usecases to the tests
  • Loading branch information
jan-janssen authored Jul 10, 2024
2 parents 00c5c80 + 6279f8c commit cb73e18
Show file tree
Hide file tree
Showing 23 changed files with 20,516 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/usecase_ADIS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Usecase ADIS

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Merge Notebook environment
run: |
cp .ci_support/environment.yml environment.yml
tail --lines=+4 tests/usecases/ADIS/environment.yml >> environment.yml
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: "3.11"
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
activate-environment: my-env
environment-file: environment.yml
use-mamba: true
- name: Tests
shell: bash -l {0}
run: |
bash .ci_support/pip_install.sh
conda install -c conda-forge jupyter papermill
cd tests/usecases/ADIS
export ESPRESSO_PSEUDO=$(pwd)/espresso/pseudo
papermill notebook.ipynb notebook-out.ipynb -k "python3"
35 changes: 35 additions & 0 deletions .github/workflows/usecase_NFDI4ING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Usecase NFDI4Ing

on:
push:
branches: [ main ]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Merge Notebook environment
run: |
cp .ci_support/environment.yml environment.yml
tail --lines=+4 tests/usecases/NFDI4ING/environment.yml >> environment.yml
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.11'
miniforge-variant: Mambaforge
channels: conda-forge
channel-priority: strict
activate-environment: my-env
environment-file: environment.yml
use-mamba: true
- name: Test
shell: bash -l {0}
timeout-minutes: 60
run: |
bash .ci_support/pip_install.sh
conda install -y papermill jupyter
sudo apt-get install -y $(cat tests/usecases/NFDI4ING/apt.txt)
cd tests/usecases/NFDI4ING
papermill notebook.ipynb notebook.ipynb -k "python3"
Empty file.
70 changes: 70 additions & 0 deletions tests/usecases/ADIS/adis_tools/parsers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import numpy

from xmlschema import XMLSchema
from qe_tools import CONSTANTS

from ase import Atoms
from importlib.resources import files

from . import schemas


def parse_pw(xml_file):
"""Parse a Quantum Espresso XML output file."""

xml_dict = XMLSchema(str(files(schemas) / "qes_230310.xsd")).to_dict(xml_file)

parsed_results = {}

try:
cell = (
numpy.array(
[v for v in xml_dict["output"]["atomic_structure"]["cell"].values()]
)
* CONSTANTS.bohr_to_ang
)
symbols = [
el["@name"]
for el in xml_dict["output"]["atomic_structure"]["atomic_positions"]["atom"]
]
positions = (
numpy.array(
[
el["$"]
for el in xml_dict["output"]["atomic_structure"][
"atomic_positions"
]["atom"]
]
)
* CONSTANTS.bohr_to_ang
)

parsed_results["ase_structure"] = Atoms(
cell=cell,
positions=positions,
symbols=symbols,
pbc=True,
)
except KeyError:
pass

try:
parsed_results["energy"] = (
xml_dict["output"]["total_energy"]["etot"] * CONSTANTS.ry_to_ev
)
except KeyError:
pass

try:
parsed_results["forces"] = (
numpy.array(xml_dict["output"]["forces"]["$"]).reshape(
xml_dict["output"]["forces"]["@dims"]
)
* 2
* CONSTANTS.ry_to_ev
/ CONSTANTS.bohr_to_ang
)
except KeyError:
pass

return parsed_results
Empty file.
Loading

0 comments on commit cb73e18

Please sign in to comment.