Skip to main content

3D crystal geometry engine for crystallographic visualization

Project description

Crystal Geometry

3D crystal geometry engine for crystallographic visualization. Computes polyhedra from Crystal Description Language (CDL) strings using half-space intersection with point group symmetry.

Part of the Gemmology Project.

Installation

pip install crystal-geometry

Quick Start

from crystal_geometry import cdl_string_to_geometry, create_octahedron

# Create geometry from CDL string
geom = cdl_string_to_geometry("cubic[m3m]:{111}@1.0 + {100}@1.3")
print(f"Vertices: {len(geom.vertices)}, Faces: {len(geom.faces)}")

# Use convenience constructors
octahedron = create_octahedron()
print(f"Octahedron has {len(octahedron.faces)} faces")

Features

  • CDL Integration: Parse Crystal Description Language strings to 3D geometry
  • Point Group Symmetry: All 32 crystallographic point groups supported
  • Half-Space Intersection: Robust geometry computation using scipy
  • 7 Crystal Systems: Cubic, tetragonal, orthorhombic, hexagonal, trigonal, monoclinic, triclinic
  • Miller Indices: Full support for 3-index (hkl) and 4-index (hkil) notation

Core API

Geometry Generation

from cdl_parser import parse_cdl
from crystal_geometry import cdl_to_geometry, cdl_string_to_geometry

# From CDL string directly
geom = cdl_string_to_geometry("cubic[m3m]:{111}")

# From parsed description (more control)
desc = parse_cdl("cubic[m3m]:{111}@1.0 + {100}@1.3")
geom = cdl_to_geometry(desc, c_ratio=1.0)

Convenience Constructors

from crystal_geometry import (
    create_octahedron,
    create_cube,
    create_dodecahedron,
    create_truncated_octahedron,
)

# Regular polyhedra
octahedron = create_octahedron(scale=1.0)
cube = create_cube(scale=1.0)
dodecahedron = create_dodecahedron(scale=1.0)
truncated = create_truncated_octahedron(octahedron_scale=1.0, cube_scale=1.3)

CrystalGeometry Class

from crystal_geometry import CrystalGeometry

geom = cdl_string_to_geometry("cubic[m3m]:{111}")

# Properties
geom.vertices      # Nx3 numpy array of vertex positions
geom.faces         # List of face vertex indices
geom.face_normals  # List of unit normal vectors
geom.face_forms    # Form index for each face
geom.face_millers  # Miller indices for each face

# Methods
geom.get_edges()           # Get unique edges as vertex pairs
geom.center()              # Compute centroid
geom.scale_to_unit()       # Scale to fit unit sphere
geom.translate(offset)     # Translate by vector
geom.euler_characteristic()  # V - E + F (should be 2)
geom.is_valid()            # Verify geometry integrity
geom.to_dict()             # Export to dictionary

Symmetry Operations

from crystal_geometry import (
    get_point_group_operations,
    generate_equivalent_faces,
    miller_to_normal,
    LatticeParams,
)

# Get symmetry operations for a point group
ops = get_point_group_operations('m3m')  # 48 operations
ops = get_point_group_operations('6/mmm')  # 24 operations

# Generate equivalent faces from one Miller index
faces = generate_equivalent_faces(1, 1, 1, 'm3m')  # 8 faces for {111}
faces = generate_equivalent_faces(1, 0, 0, 'm3m')  # 6 faces for {100}

# Convert Miller indices to normal vector
lattice = LatticeParams.cubic()
normal = miller_to_normal(1, 1, 1, lattice)

# Create lattice parameters
cubic = LatticeParams.cubic()
tetragonal = LatticeParams.tetragonal(c_ratio=1.5)
hexagonal = LatticeParams.hexagonal(c_ratio=1.2)

Crystal Systems and Point Groups

System Point Groups
Cubic m3m, 432, -43m, m-3, 23
Tetragonal 4/mmm, 422, 4mm, -42m, 4/m, -4, 4
Hexagonal 6/mmm, 622, 6mm, -6m2, 6/m, -6, 6
Trigonal -3m, 32, 3m, -3, 3
Orthorhombic mmm, 222, mm2
Monoclinic 2/m, 2, m
Triclinic -1, 1

Examples

Diamond-like Crystal

# Octahedron truncated by cube
geom = cdl_string_to_geometry("cubic[m3m]:{111}@1.0 + {100}@1.3")
assert len(geom.faces) == 14  # 8 octahedron + 6 cube

Garnet-like Crystal

# Dodecahedron with trapezohedron
geom = cdl_string_to_geometry("cubic[m3m]:{110}@1.0 + {211}@0.6")

Hexagonal Prism

# Prism with pinacoid termination
geom = cdl_string_to_geometry("hexagonal[6/mmm]:{10-10}@1.0 + {0001}@0.5")

Quartz-like Crystal

# Prism with rhombohedron
geom = cdl_string_to_geometry("trigonal[-3m]:{10-10}@1.0 + {10-11}@0.8")

Requirements

  • Python >= 3.10
  • numpy >= 1.20.0
  • scipy >= 1.7.0
  • cdl-parser >= 1.0.0

Documentation

See crystal-geometry.gemmology.dev for full documentation.

License

MIT License - see LICENSE for details.

Related Packages

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

gemmology_crystal_geometry-1.0.5.tar.gz (79.2 kB view details)

Uploaded Source

Built Distributions

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

gemmology_crystal_geometry-1.0.5-cp313-cp313-win_amd64.whl (148.7 kB view details)

Uploaded CPython 3.13Windows x86-64

gemmology_crystal_geometry-1.0.5-cp313-cp313-win32.whl (139.8 kB view details)

Uploaded CPython 3.13Windows x86

gemmology_crystal_geometry-1.0.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (170.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

gemmology_crystal_geometry-1.0.5-cp313-cp313-macosx_11_0_arm64.whl (132.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gemmology_crystal_geometry-1.0.5-cp312-cp312-win_amd64.whl (148.7 kB view details)

Uploaded CPython 3.12Windows x86-64

gemmology_crystal_geometry-1.0.5-cp312-cp312-win32.whl (139.8 kB view details)

Uploaded CPython 3.12Windows x86

gemmology_crystal_geometry-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (170.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

gemmology_crystal_geometry-1.0.5-cp312-cp312-macosx_11_0_arm64.whl (131.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gemmology_crystal_geometry-1.0.5-cp311-cp311-win_amd64.whl (147.3 kB view details)

Uploaded CPython 3.11Windows x86-64

gemmology_crystal_geometry-1.0.5-cp311-cp311-win32.whl (139.0 kB view details)

Uploaded CPython 3.11Windows x86

gemmology_crystal_geometry-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (169.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

gemmology_crystal_geometry-1.0.5-cp311-cp311-macosx_11_0_arm64.whl (131.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gemmology_crystal_geometry-1.0.5-cp310-cp310-win_amd64.whl (146.6 kB view details)

Uploaded CPython 3.10Windows x86-64

gemmology_crystal_geometry-1.0.5-cp310-cp310-win32.whl (138.0 kB view details)

Uploaded CPython 3.10Windows x86

gemmology_crystal_geometry-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (168.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

gemmology_crystal_geometry-1.0.5-cp310-cp310-macosx_11_0_arm64.whl (130.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file gemmology_crystal_geometry-1.0.5.tar.gz.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5.tar.gz
Algorithm Hash digest
SHA256 d25fe9fb3f05f345d72d4afe61595f37e1342a55744b58ba99cd9a21f3f9543d
MD5 33542f11f90edb1cedc892ec1e1ef775
BLAKE2b-256 975a56cef1f89b1219a720e89cf1e7c7bdeebcebceac807538662a022dcf5c9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5.tar.gz:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2dced2a027bb4205acf59805070e3b60bdde585ec0557fb5c09dcad41b0f9e19
MD5 b743ffa0d9c0098705e905716a876cd6
BLAKE2b-256 ff02accc8cd7407b38fa8556696a04960b56eb1bd963df27cc3b1149ac81215d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp313-cp313-win_amd64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp313-cp313-win32.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 dcc2f16d2bd19101a6af4cb8ae6e4c961c187d25104e498ff9cd78fd832dac9b
MD5 add51cd5f86e477a4cc2cd2686a2acb6
BLAKE2b-256 8d32e0e00d443ec3c3b3ac12222a95161ad0aebf37810fac37dae56b54fa6e9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp313-cp313-win32.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 749fa10ef222a598615a9be818104be9763a1a0cf37418a0637b4a100377a248
MD5 5a532188ffb57bc8a6e447927c537e8b
BLAKE2b-256 ea474333f0f9d5be44a2280df1dd39d298139481b4a8c1e69aaaa14bd0d0bd6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc90ad6e9bbeee188268d1ac19bcd331a04c1618277c632b899abdaf1c7605d9
MD5 3d89964bfd9ba7a833b1e35fb882b17c
BLAKE2b-256 c526565da871e683a7ab0f46698e0f3732a0197ac4e802adca6893fbf38dafc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3afe971a491068d96ec39aaed5786e8caba5adbeec4810c0ef0b4d01887bbc07
MD5 74a1c96e1f8b039ed686853eb826ed20
BLAKE2b-256 58b9af69bf3fc428afd0e8893f96459520e66c5b3dec4196e9a4aeebcdf0af91

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp312-cp312-win_amd64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 fe2941044945170016a6d8088695fd646910ad3ce956716a689c1d4ba70753f1
MD5 2f9319c606d8fe5f96be0ba8ba1a0d28
BLAKE2b-256 a1653a41d05372c3de44b30dc6584001bcf93852509fd48d6b9a67a188955168

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp312-cp312-win32.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4a7c9d496ed897bf37ffb1bd0f5b4976f058210d4b2d5b3e94451d15be909c2c
MD5 a9b740b0c4cda6a33f1a699d3e101877
BLAKE2b-256 f4059d07882ad62e1b258252e2c0cf7d6a3131106e1b8a91fb2d96b0318dc05e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc32069839519e1af4e20bb9b1efcf2212ab6cf9f72ecbd8ebe7a247ec123c5d
MD5 19a8cd20545e917e7ac8d78f4f6dc98d
BLAKE2b-256 f0b0018dcceb410bbb9a454125749703015259d589257c8fcd49bf06fcb1a7bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0ef0f4462fef942712ad6b633cacd051503132af77891e5ff1a0536cba76edaa
MD5 158a42831e4f3b43df1a9bff5496b25d
BLAKE2b-256 b7b2702a5790434f30f635bb62d4a755b3c3a5b321db1388134bb69745a3a427

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp311-cp311-win_amd64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 3fbab83c649aac0c6ed9d38b17d21eb7e93c2513d1eadee1c414b4949649b116
MD5 28cf74479a232262f01f18547c20e8d6
BLAKE2b-256 2ab6c0a39c196e245d8f9492458b9de21a7f8f457e435329bbc0e621403bca67

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp311-cp311-win32.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 532cc4a4388b4d187e9ba740a9bf9700d3116ae1bc63fc7bb411475674a1c14a
MD5 deedcb91560123107a87f96e3c9be84a
BLAKE2b-256 32a8b1c01fd713af3a02bee2e79fe10473cedf2bcf2ea0295967c9080980b7f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20a49d7cacffc673b313840fef7d2fa8a77878554f058305313ccd1ad01e5e03
MD5 23abd9bb17ee18fa8782745dd472be07
BLAKE2b-256 d3fa499601aabce00a2945aef20a95e69ba080dd9ceb2faf9c0da33e1a9d764e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 23e6164bf6a1c0accc58f4590876211ab03426b569e376a502e32531eeee00a8
MD5 ca1f3da5d2fd221fbb52e5db4820e2b3
BLAKE2b-256 9c08170dbd69b7cc253a7adcc554ed7a551c2245403fcf4cec7e57343fea41a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp310-cp310-win_amd64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 609961cfd65c49d01d289a49f30828cd8489775567dfa96c0f1d54fe59dc01fc
MD5 4b753ea00a0c924b6111f17257af379e
BLAKE2b-256 9b28868bacfc3a7ab4dcbc79fa9c21e789e10aac3928177c39a7a925f6bd31c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp310-cp310-win32.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 212d3a573f412fc9e03222641ba8c6648a1fe72f79eb797771d6e24c537cbf19
MD5 6fa752c2f52d0773f36b7f6b0391bf44
BLAKE2b-256 6be18833b6dac92d171f1309023d4be7d0a5f74d17bfedec97355a9ef56a78f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gemmology_crystal_geometry-1.0.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gemmology_crystal_geometry-1.0.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db29c646d3caa6b9a50f4aa236617ea320c62dca3e1138c4541ba180e4038a4f
MD5 7adf3b5adb8906784450a85e34fea720
BLAKE2b-256 a27069b1399eea987dcb77a6f2dc6d72a9e75646bc686230549df50e2645a52a

See more details on using hashes here.

Provenance

The following attestation bundles were made for gemmology_crystal_geometry-1.0.5-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: pypi-publish.yml on gemmology-dev/crystal-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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