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

# 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

import phun_reps.calc_presistent_diagram as cp
# Load .cif files from the specified folder
files = cp.get_cif_files(folder)

Build dataset

import phun_reps.calc_presistent_diagram as cp
# 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

import phun_reps.calc_presistent_diagram as cp
# 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

import phun_reps.feature_extraction as fe
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

import phun_reps.feature_extraction as fe
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.2.tar.gz (9.5 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.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: phun_reps-0.1.2.tar.gz
  • Upload date:
  • Size: 9.5 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.2.tar.gz
Algorithm Hash digest
SHA256 f95d7c9a888b65bee989844db9cae0daadd5e62ae1d5337106264b14dc5d5feb
MD5 f72adeae35b86f5ba91c86d0f8692e26
BLAKE2b-256 de7119b1d5d96056f1347aa7b66f7ed49e9b4d1d035eea7a85c07fa5d2946e84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phun_reps-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1a5db10e8569b6ccc4025e5305b9006212aac1ed87dc50df3092f255d6714585
MD5 01677aeb9aa56fb019839ab54b0e0cc7
BLAKE2b-256 6712837be6e6388f6bc1c13f8ed610cc43c9f0adcfc960e4ccb580e1414c0deb

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