Add your description here
Project description
pymultibinit - Python Interface to MULTIBINIT
Python bindings for ABINIT's MULTIBINIT effective potential library.
Installation
# 1. Build ABINIT library
cd abinit
rm -rf build && mkdir build && cd build
CC=mpicc FC=mpif90 cmake -C ~/.abinit/build/shared.cmake ..
make -j8
# 2. Set library path (choose one):
# Option A: LIBABINIT_PATH (recommended)
export LIBABINIT_PATH=/path/to/abinit/build/src/98_main/libabinit.dylib # macOS
export LIBABINIT_PATH=/path/to/abinit/build/src/98_main/libabinit.so # Linux
# Option B: Add to LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (macOS)
export LD_LIBRARY_PATH=/path/to/abinit/build/src/98_main:$LD_LIBRARY_PATH
# Add to ~/.bashrc or ~/.zshrc for persistence
# 3. Install Python package
pip install pymultibinit
# or: pip install -e .
Quick Start
from pymultibinit import MultibinitCalculator
from ase import Atoms
from ase.optimize import BFGS
# Load from config file (recommended)
calc = MultibinitCalculator.from_config_file("multibinit.conf")
# Or from parameters
calc = MultibinitCalculator.from_params(
ddb_file="system_DDB",
sys_file="system.xml",
ncell=(2, 2, 2),
ngqpt=(4, 4, 4)
)
# Build supercell (must match ncell!)
unit_cell = Atoms('BaTiO3',
scaled_positions=[[0,0,0], [0.5,0.5,0.5],
[0.5,0,0.5], [0,0.5,0.5], [0.5,0.5,0]],
cell=[4.0, 4.0, 4.0], pbc=True)
atoms = unit_cell * (2, 2, 2) # Match ncell=(2,2,2)
atoms.calc = calc
# Run calculation
energy = atoms.get_potential_energy() # eV
forces = atoms.get_forces() # eV/Angstrom
stress = atoms.get_stress() # eV/Angstrom^3
# Optimize structure
opt = BFGS(atoms)
opt.run(fmax=0.01)
Configuration File
Create multibinit.conf:
# Required
ddb_file: system_DDB
sys_file: system.xml
ncell: 2 2 2
# Optional
ngqpt: 4 4 4
dipdip: 1
API Reference
MultibinitCalculator (ASE interface)
# From config file (recommended)
calc = MultibinitCalculator.from_config_file("config.conf")
# From parameters
calc = MultibinitCalculator.from_params(
ddb_file="system_DDB",
sys_file="system.xml",
ncell=(2, 2, 2),
ngqpt=(4, 4, 4),
dipdip=1
)
# From .abi file
calc = MultibinitCalculator.from_abi("input.abi")
MultibinitPotential (Low-level interface)
from pymultibinit import MultibinitPotential
import numpy as np
pot = MultibinitPotential.from_params(
ddb_file="system_DDB",
sys_file="system.xml",
ncell=(2, 2, 2)
)
# Evaluate (Angstrom/eV by default)
positions = np.array([[0, 0, 0], [2.0, 0, 0]]) # Angstrom
lattice = np.array([[4, 0, 0], [0, 4, 0], [0, 0, 4]]) # Angstrom
energy, forces, stress = pot.evaluate(positions, lattice)
# Export structures
pot.export_supercell_to_file('supercell.cif') # Export to file
atoms = pot.export_supercell_to_ase() # Get ASE Atoms object
structure = pot.get_supercell_structure() # Get raw arrays
pot.free()
Exporting Structures
Export Reference/Supercell Structure
Command-Line Tools
# Export MULTIBINIT reference structure
mbtools export-ref config.conf output.cif
Important Notes
Supercell Size
Your structure must match the ncell parameter!
# Config: ncell: 2 2 2
calc = MultibinitCalculator.from_config_file("config.conf")
# ✓ CORRECT
atoms = unit_cell * (2, 2, 2) # Match ncell
# ✗ WRONG - will fail with "status 3" error
atoms = unit_cell # Size mismatch
Library Not Found?
If you get "Could not find libabinit":
# Option 1: Set LIBABINIT_PATH
export LIBABINIT_PATH=/full/path/to/libabinit.dylib
# Option 2: Add to library search path
export LD_LIBRARY_PATH=/path/to/dir/containing/libabinit:$LD_LIBRARY_PATH
# Verify
python -c "from pymultibinit.utils import find_library; print(find_library())"
Unit Conventions
| Quantity | Python API | Internal |
|---|---|---|
| Length | Angstrom | Bohr |
| Energy | eV | Hartree |
| Force | eV/Å | Ha/Bohr |
Conversions are automatic.
Examples
cd pymultibinit/examples
python simple_example.py
License
GPL v3 (same as ABINIT)
Citation
- ABINIT: https://www.abinit.org
- MULTIBINIT: https://docs.abinit.org/guide/multibinit/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymultibinit-0.2.0.tar.gz
(98.4 kB
view details)
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 pymultibinit-0.2.0.tar.gz.
File metadata
- Download URL: pymultibinit-0.2.0.tar.gz
- Upload date:
- Size: 98.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a514101678bbcc9358613928dea864d8edf9dd09df71a29ebc4f2844df01ae4
|
|
| MD5 |
1045e4d6745bf4a502582d22b22e4eea
|
|
| BLAKE2b-256 |
9bf3ccf0323bb29ffe1fc448cf5fe0bc654378212d4e95c628ee4adccefa4c23
|
File details
Details for the file pymultibinit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pymultibinit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb52d0b28bfca0afdaf7583c88674287077fec876f35a9d259db14123862a038
|
|
| MD5 |
2124a49ef3408a77da45b76c160240e5
|
|
| BLAKE2b-256 |
3091d27cc62a9eeb5ecfac2853688ba18c380c5df9adf1037f368ce1a1a50846
|