Skip to main content

Sphinx Parser

Push-Pull codecov

Overview

This hosts the python binder of the DFT code Sphinx.

How to use

Sphinx's input parser is created from the yaml-file located at src/input_data.yml. The input file is generated by src/generator.py. You can use the parser via:

from sphinx_parser.input import sphinx

This instance sphinx is used to create all possible input classes for Sphinx by choosing the class via dot-notation and call it. For example in order to generate the class kPoints, you can run:

kPoints = sphinx.basis.kPoints()

You can find the input in the parent class, i.e.:

basis = sphinx.basis(kPoints=kPoints)

Finally, you can translate it into the Sphinx format via:

from sphinx_parser.toolkit import to_sphinx

sphinx_input = to_sphinx(basis)

You can then write it to a file via:

with open('sphinx.in', 'w') as f:
    f.write(sphinx_input)

Minimum working example

import numpy as np
from ase.build import bulk
import os


cwd = "TEST"
if not os.path.exists(cwd):
    os.mkdir(cwd)

from sphinx_parser.toolkit import to_sphinx
from sphinx_parser.jobs import set_base_parameters
from sphinx_parser.output import collect_energy_dat

structure = bulk("Al", cubic=True)
structure[1].symbol = "Ni"

input_sx = set_base_parameters(structure)

with open(os.path.join(cwd, "input.sx"), "w") as f:
    f.write(to_sphinx(input_sx))

import subprocess

command = ["sphinx"]

process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=cwd)
stdout, stderr = process.communicate()

collect_energy_dat(os.path.join(cwd, "energy.dat"))

More detailed example:

import numpy as np
from ase.build import bulk
import os


cwd = "TEST"
# cwd.mkdir(exist_ok=True)
if not os.path.exists(cwd):
    os.mkdir(cwd)

from sphinx_parser.input import sphinx
from sphinx_parser.ase import get_structure_group
from sphinx_parser.toolkit import to_sphinx
from sphinx_parser.potential import get_paw_from_structure
from sphinx_parser.output import collect_energy_dat


structure = bulk("Al", cubic=True)
structure[1].symbol = "Ni"

struct_group, spin_lst = get_structure_group(structure)
main_group = sphinx.main(scfDiag=sphinx.main.scfDiag(maxSteps=10, blockCCG={}))
pawPot_group = get_paw_from_structure(structure)
basis_group = sphinx.basis(eCut=25, kPoint=sphinx.basis.kPoint(coords=3 * [0.5]))
paw_group = sphinx.PAWHamiltonian(xc=1, spinPolarized=False, ekt=0.2)
initial_guess_group = sphinx.initialGuess(
    waves=sphinx.initialGuess.waves(lcao=sphinx.initialGuess.waves.lcao()), rho=sphinx.initialGuess.rho(atomicOrbitals=True)
)

input_sx = sphinx(
    pawPot=pawPot_group, structure=struct_group, main=main_group, basis=basis_group, PAWHamiltonian=paw_group, initialGuess=initial_guess_group
)

with open(os.path.join(cwd, "input.sx"), "w") as f:
    f.write(to_sphinx(input_sx))

import subprocess

command = ["sphinx"]

process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=cwd)
stdout, stderr = process.communicate()

collect_energy_dat(os.path.join(cwd, "energy.dat"))

Metadata

Release files for sphinx-parser 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-parser 0.1.11
File Size Uploaded
sphinx_parser-0.1.11.tar.gz 61.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-parser 0.1.11
File Interpreter ABI Platform
sphinx_parser-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 98.5 kB

Release files / sphinx_parser-0.1.11.tar.gz

Download URL sphinx_parser-0.1.11.tar.gz
Size 61.7 kB
Tags Source
SHA-256 checksum
How to use checksums
31f0f6b40f4b20eb49c2a57939d3bb69577d1302c81d6f36198998be6ae7a4a8
BLAKE2b-256 checksum
How to use checksums
d7b38ad3f5d0f02f5e1d1e742926ca5cf65f21aba994c019efcd3d0a27e300df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sphinx_parser-0.1.11-py3-none-any.whl

Download URL sphinx_parser-0.1.11-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87d0d98253e4ee1562733f011bee454f696a6e729d4994a4d9b2d1cb62c588ad
BLAKE2b-256 checksum
How to use checksums
e78bc62a76f450dd18d3c25605f631dea0f74d79ed0848c1c8a3ce1c7d23906a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.9

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page