A simple CASTEP input files parser/writer
This package provide a basic framework for read/write input files of CASTEP.
There is already a excellent reader/writer implemented in ase
but they are ortentated to work with the Atoms and Calculator classes in ase.
It also requires a CASTEP binary to exist to work.
This package aim to provide a more generic framework with minimum dependency for
simple (but important) tasks of writing and reading inputs files of CASTEP.
Usage
The two classes to be used for reading/writing inputs are ParamInput and CellInput.
Keyword-value pairs can be set the same as dictionaries.
For example:
from castepinput import CellInput, ParamInput, Block
# ParamInput is in fact just a subclass of OrderedDict
param = ParamInput(cut_off_energy=300, task="singlepoint")
param["opt_strategy"] = "speed"
# Use the Block class to signal that it is a BLOCK
# The following line sets the positions_abs
cell = CellInput(positions_abs=Block(["C 0 0 0", "C 1 0 0"])
The two classes use simple string formatting when writing out the content. See the following code as example.
cell = CellInput(snap_to_symmetry=True)
# Should give 'snap_to_symmetry : True'
cell.get_string()
# Should give 'symmetry_genreate : true'
cell['snap_to_symmetry'] = 'true'
cell.get_string()
# Not all CASTEP keyword requires a value
# Use "" as the value will result just a keyword on a line
cell['symmetry_generate'] = ''
# Should give a string with a line 'symmetry_generate'
cell.get_string()
# Set cell and positions use the set methods
cell.set_cell([10 ,10 , 10])
cell.set_positions(["O", "O"], [[0, 0, 0], [1.4, 0, 0]])
# Save to file
cell.save("O2.cell")
To initialize from a existing param/cell file, use the ParamInput.from_file method.
cell = CellInput.from_file("O2.cell")
# This should give [[10, 0, 0], [0, 10, 0], [0, 0, 10]]
cell.get_cell()
# The value returned should be "" to be consistent with setting
cell["symmetry_generate"]
We also try to be smart and convert string into python types where it is possible.
Supported types are integer, floats and 1-d arrays made of integer/floats.
These coversions can be avoided by using ParamInput.from_file(filename, plain=True) when loading files.
Metadata
Release files for castepinput 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| castepinput-0.1.11.tar.gz | 19.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| castepinput-0.1.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.8 kB
Release files / castepinput-0.1.11.tar.gz
| Download URL | castepinput-0.1.11.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df7542255fc837e60d5286e6f1cd5df09ecac53cf786ca4aaa1f25296ba13ed7
|
|
BLAKE2b-256 checksum How to use checksums |
e54be13c3dba7fbdc8c8883a7f0efacae43ab5f929257c98c7a0d2e904c53552
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / castepinput-0.1.11-py3-none-any.whl
| Download URL | castepinput-0.1.11-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a0f522111e5304e89dbd273b0842e9ff2437981b6aa711d3bb5d0c6cb05a01e
|
|
BLAKE2b-256 checksum How to use checksums |
aa1c79a7f42b23446f10c06fc44de07a074b9c4e0ea6356e6722d3d10d4b4ee9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for castepinput 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.