Skip to content

Commit 9dd0b79

Browse files
authored
Merge pull request #2 from ccdc-opensource/mof-workshop
Add MOF workshop files
2 parents b0a4ccf + 1e0ea7d commit 9dd0b79

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Analyse Pore Space
2+
3+
## Summary
4+
5+
This script shows a simple use case of Pore Analyser. It takes a list of selected CSD entries and computes their pore properties, prints the results and writes them to a CSV file.
6+
7+
## Requirements
8+
9+
CSD Python API (v 3.5.0 or later)
10+
11+
pandas (v 2.2.3 or later)
12+
13+
## Licensing Requirements
14+
15+
CSD-Core
16+
17+
## Instructions on Running
18+
19+
In a command prompt run `python pore_analyser.py`.
20+
21+
## Author
22+
23+
Andrew J. Peel (2025-10-10)
24+
25+
> For feedback or to report any issues please contact [support@ccdc.cam.ac.uk](mailto:support@ccdc.cam.ac.uk)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from ccdc.io import EntryReader
2+
from ccdc.descriptors import CrystalDescriptors
3+
from pathlib import Path
4+
import pandas as pd
5+
6+
7+
# Read CSD entries
8+
entry_reader = EntryReader('CSD')
9+
10+
# Selection of MOF-76 type structures M = lanthanoid, yttrium
11+
refcodes = ['MARXEK', 'NADZID', 'QOTZEG', 'SADLIU',
12+
'SEHXIN', 'UPIBOM', 'YIMPAP', 'YIMPIX', 'YIMSAS']
13+
14+
# Headers for table
15+
print(f"{'Refcode':<10} {'Formula':<20} {'He Volume (ų)':>15} {'System Vol (ų)':>18}")
16+
print("-" * 65)
17+
18+
# Calculate pore properties
19+
results = []
20+
for refcode in refcodes:
21+
mof = entry_reader.entry(refcode)
22+
formula = mof.formula
23+
crys = mof.crystal # Need crystal object to calcuate descriptors
24+
pore_analyser = CrystalDescriptors.PoreAnalyser(crys)
25+
He_vol_tot = pore_analyser.total_helium_volume
26+
sys_vol = pore_analyser.system_volume
27+
results.append({'Refcode': refcode,
28+
'Formula': formula,
29+
'He Volume (ų)': He_vol_tot,
30+
'System Vol (ų)': sys_vol})
31+
print(f"{refcode:<10} {formula:<20} {He_vol_tot:15.3f} {sys_vol:18.3f}")
32+
33+
# Create DataFrame
34+
df = pd.DataFrame(results)
35+
df = df.round(3)
36+
37+
# Write data to csv
38+
workdir = Path.cwd()
39+
df.to_csv(f'{workdir}/results.csv', index=False, encoding='utf-8-sig')

0 commit comments

Comments
 (0)