Metadata-Version: 2.4
Name: sphinx_parser
Version: 0.1.0
Summary: sphinx_parser - Your pyiron-like module.
Author-email: Lorem Ipsum <lorem@ipsum.com>
License: BSD 3-Clause License
        
        Copyright (c) 2024, Max-Planck-Institut für Nachhaltige Materialien GmbH - Computational Materials Design (CM) Department
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://pyiron.org/
Project-URL: Documentation, https://sphinx_parser.readthedocs.io
Project-URL: Repository, https://github.com/pyiron/sphinx_parser
Keywords: pyiron
Classifier: Development Status :: 3 - Alpha
Classifier: Topic :: Scientific/Engineering
Classifier: License :: OSI Approved :: BSD License
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: <3.14,>=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy<2.4.0,>=1.26.4
Requires-Dist: ase<3.27.0,>=3.23.0
Requires-Dist: h5py<3.15.0,>=3.6.0
Requires-Dist: semantikon<=0.0.20,>=0.0.17
Requires-Dist: pint<=0.24.4,>=0.23
Dynamic: license-file

# Sphinx

[![Push-Pull](https://github.com/pyiron/sphinx_parser/actions/workflows/push-pull.yml/badge.svg)](https://github.com/pyiron/sphinx_parser/actions/workflows/push-pull.yml)
[![codecov](https://codecov.io/gh/pyiron/sphinx_parser/graph/badge.svg?token=YNZE8VS78Y)](https://codecov.io/gh/pyiron/sphinx_parser)

## Overview

This hosts the python binder of the DFT code [Sphinx](https://sxrepo.mpie.de).

## 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:

```python
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:

```pythoon
kPoints = sphinx.basis.kPoints()
```

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

```python
basis = sphinx.basis(kPoints=kPoints)
```

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

```python
from sphinx_parser.toolkit import to_sphinx

sphinx_input = to_sphinx(basis)
```

You can then write it to a file via:

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


## Minimum working example

```python
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:

```python
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"))
```
