Skip to main content

A fun Python package for creating topological descriptors for nanoporous materials with persistent homology using nets (PHuN).

Project description

PHuN representations

This is a fun and computationally efficient Python package for computing persistent homology using nets (PHuN) representations of nanoporous materials. It enables the extraction of topological information for use as machine learning descriptors.

Installation Guide

Prerequisites

PHuN requires the CrystalNets.jl Julia interface, which is used to identify and extract the topological nets of nanoporous materials.

Install phun_reps using pip

pip install phun_reps

This package was built and tested with Python 3.10.13, and will automatically install its dependencies: ase==3.26.0, Cython==3.2.0, juliacall==0.9.28, pandas==2.3.3, and ripser==0.6.12.

Usage

PHuN provides tools to compute persistent homology diagrams for nanoporous materials using either:

  • Atomic coordinates

  • Topological nets derived from CrystalNets.jl.

It integrates with Ripser to compute persistence diagrams and can extract topological descriptors for machine learning.

PHuN can be used to:

  • Generate persistent diagrams/images from CIF files

  • Visualize persistence diagrams/images

  • Extract topological descriptors (persistent image features and persistent statistics features) that can be used for machine learning

For a complete example of usage, see the Example Usage section below.

Example Usage

Initial setup

import os
# Folder containing .cif files to process
folder = "test-cif"

# Folder where CrystalNets.jl outputs will be saved
# Default is /tmp if not specified
export_folder = "/tmp"

# Clustering option for CrystalNets.jl
# Determines how topological nets are identified
clustering = 'SingleNodes'

Load .cif files

# Load .cif files from the specified folder
files = cp.get_cif_files(folder)

Build dataset

# Build dataset:
# - Uses CrystalNets.jl to identify topological nets based on clustering option. If ACPH features are wanted, set clustering to 'input'
dataset, top_nets, names = cp.build_dataset(files, export_folder, clustering)

Compute persistent diagrams

# Compute persistent homology diagrams from the dataset
diagrams_tuples = cp.get_persistent_diagrams(
    dataset, names, top_nets,
    maxdim=2, coeff=2,
    save_file=f"diagrams_{folder}_{clustering}.pkl"
)

Extract persistent image features from diagrams using persim

image_features_df = fe.get_persistent_image_features(
    diagrams_tuples,
    output_image_size=(30, 30),
    savefig=True,
    export_folder="test_images"
)

Extract statistical features from persistent diagrams

stats_features_df = fe.get_persistent_stats_features(diagrams_tuples)

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

phun_reps-0.1.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

phun_reps-0.1.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file phun_reps-0.1.1.tar.gz.

File metadata

  • Download URL: phun_reps-0.1.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for phun_reps-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0d692f1db79cf5143437e5a735e3a478f37456e3e30dec7f56e3accb304b6521
MD5 f4392f2159d360faa6ecd82ad3f3324f
BLAKE2b-256 6441e6ef6e3f8aba374c5726be738a0ece6b82309fef5f7ec39d5f6e81b259e9

See more details on using hashes here.

File details

Details for the file phun_reps-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: phun_reps-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for phun_reps-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 994580cb04128b9bd93ea958328ca83aa37e859205566628984cd685e529f50d
MD5 37ec42bee42c96f08e55da1620c1c37e
BLAKE2b-256 27df8378d99bd10a84c43b73ad38dd32ca66a186654e1240737cce8d86c603f9

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