A lightweight Python package for converting between fractional and Cartesian coordinates, supporting both forward and inverse transformations.
Project description
Frac-to-cart-coordinates
The Frac-to-cart-coordinates package allows users to easily convert atomic coordinates from Cartesian to fractional format and vice versa, based on the unit cell parameters.
Overview
In crystallography, atomic positions within a crystal's unit cell can be described using:
- Fractional coordinates $(x/a, y/b, z/c)$, which refer to the natural axes (a, b, c), scaled by their respective unit cell lengths.
- Orthogonal coordinates $(X, Y, Z)$, which use a right-angled Cartesian system with distances measured in Ångstroms.
For triclinic unit cells, the relationship between these coordinate systems involves a transformation matrix with non-trivial elements.
This implementation follows the methodology described on Jon Cooper's website, fractorth. It relies on the fundamental principles of spherical trigonometry (see implementation_details).
Installation
You can clone the repository and install the package using:
git clone https://github.com/n-deveaux/Frac-to-cart-coordinates.git
cd Frac-to-cart-coordinates
Make sure you have numpy installed and Python 3.6 or higher.
Usage
Importing the Module
from Fractocart import convert_to_fractional_coordinates, convert_to_cartesian_coordinates
Functions
-
Convert to Fractional Coordinates
fractional_coords = convert_to_fractional_coordinates(cartesian_coords, unit_cell)
-
Convert to Cartesian Coordinates
cartesian_coords = convert_to_cartesian_coordinates(fractional_coords, unit_cell)
Contributing
Contributions are welcome! To contribute:
- Clone the repository.
- Create a feature branch (
git checkout -b feature-name). - Commit your changes (
git commit -m "Add new feature"). - Push to the branch (
git push origin feature-name). - Open a merge request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Frac-to-cart-coordinates-1.1.0.tar.gz.
File metadata
- Download URL: Frac-to-cart-coordinates-1.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce0c3ee629d4f757075811d86249e75d8df785e9bdcad6cc2ed5d1db2a8f1188
|
|
| MD5 |
986198d16290843e2a846fb5b2593073
|
|
| BLAKE2b-256 |
1261fe7c67d35d17e5867f21051f36537bc06e965aab025df4a00ebbe2f64cfd
|
File details
Details for the file Frac_to_cart_coordinates-1.1.0-py3-none-any.whl.
File metadata
- Download URL: Frac_to_cart_coordinates-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdb79441f960737b336117d39e1b7066228a7d0598af2b7ccffbccf54feec7b3
|
|
| MD5 |
b7037fcddd1a313e2a1ff2b79fbb19e0
|
|
| BLAKE2b-256 |
b9bdea56b747d010191b1a990be62e9b5c0f6118c3b644310e11491c4d17b6fd
|