Skip to main content

sphinx_parser - Your pyiron-like module.

Project description

Sphinx

Push-Pull Coverage Status

Overview

This hosts the python binder of the DFT code Sphinx.

How to use

Stinx'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 create. For example in order to generate the class kPoints, you can run:

kPoints = sphinx.basis.kPoints.create()

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

basis = sphinx.basis.create(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.create(scfDiag=sphinx.main.scfDiag.create(maxSteps=10, blockCCG={}))
pawPot_group = get_paw_from_structure(structure)
basis_group = sphinx.basis.create(eCut=25, kPoint=sphinx.basis.kPoint.create(coords=3 * [0.5]))
paw_group = sphinx.PAWHamiltonian.create(xc=1, spinPolarized=False, ekt=0.2)
initial_guess_group = sphinx.initialGuess.create(
    waves=sphinx.initialGuess.waves.create(lcao=sphinx.initialGuess.waves.lcao.create()), rho=sphinx.initialGuess.rho.create(atomicOrbitals=True)
)

input_sx = sphinx.create(
    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"))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_parser-0.0.2.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_parser-0.0.2-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_parser-0.0.2.tar.gz.

File metadata

  • Download URL: sphinx_parser-0.0.2.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sphinx_parser-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3f445ba316b408d1d76e99a669e8b776e03d3ad71b31c7039599c0694cf99fb6
MD5 39f29ec5174206f30df1fcab3f1025a4
BLAKE2b-256 7e270b6187f8d3a59970a19019b8f033595273e77f45fc2e8e8033cf899f687b

See more details on using hashes here.

File details

Details for the file sphinx_parser-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: sphinx_parser-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sphinx_parser-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe05acc905c70d9ca8e9aa8913571dc904e0a0a4c8545396de8d38d7484f707a
MD5 c51513b3acc9dee804f8d537bd62afa3
BLAKE2b-256 6f32b55f83b025629fc65aa75a3ff699e5e9274284a52d32db9b9a7716c5363b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page