Skip to main content

PyMBXAS is a package for setting up, manipulating, running and visualizing MBXAS calculations using Python.

Project description

PyMBXAS: Python-based MBXAS implementation

PyPI version

PyMBXAS is a package for setting up, manipulating, running and visualizing MBXAS calculations using Python. It has an object-oriented approach to simplify the task of spectra analysis and post-processing. PyMBXAS leverages the PySCF electronic structure code and the Atomic Simulation Environment (ASE).

Requirements

You need to have both PySCF and ASE installed in your Python environment. If you want to use GPU capabilities make sure to install gpu4pyscf.

Installation

You can install the latest stable release of the package by running:

pip install pymbxas

or if you want the most up to date version:

pip install git+https://gitlab.com/roncofaber/pymbxas.git

Alternatively, you can clone the repo and add it to your PYTHONPATH.

Usage

To run a MBXAS calculation, you just need to set up the PySCF_mbxas object:

import ase 
import ase.build
from pymbxas.calculators.pyscf import PySCF_mbxas

# read structure in ASE format
structure = ase.build.molecule("H2O")

# set up calculation parameters
channel   = 1 
charge    = 0 # charge of system
spin      = 0 # spin of system
to_excite = "O" # index(es)/symbols of atom(s) to excite
basis     = "def2-svpd"
xc        = "lda"#"b3lyp"
pbc       = False

# set up object
obj = PySCF_mbxas(
    structure    = structure,
    charge       = charge,
    spin         = spin,
    xc           = xc, 
    basis        = basis,
    do_xch       = True, # do XCH for energy alignment
    target_dir   = None, # specify a target directory where to run calc
    verbose      = 3,     # level of verbose of pySCF output (4-5 is good)
    print_fchk   = False,  # print fchk files (requires MOKIT)
    print_output = False, # print output to console
    save         = True,  # save object as pkl file
    save_name    = "pyscf_obj.pkl", # name of saved file
    save_path    = None, # path of saved object
    loc_type     = "ibo",
    gpu          = True # if you want to use the GPU code
    )

# run calculation (GS + FCH + XCH)
obj.kernel(to_excite)

Output:

[10:52:59] |----------------------------------|
           |                                  |
           |>>>>>>   Starting PyMBXAS   <<<<<<|
           |                                  |
           |       ver  0.2.0a | 04 Apr. 2024 |
           |----------------------------------|
        
[10:52:59] |Started a new GS calculation
[10:53:03] |IBO localization : [3, 4, 2, 0, 1]
[10:53:03] |GS finished in 4.1 s.

[10:53:03] |-----> Exciting N  atom # 3 <-----|
[10:53:03] |>>> Started FCH calculation.
[10:53:08] |>>> FCH finished in 4.7 s.
[10:53:08] |>>> Started XCH calculation.
[10:53:12] |>>> XCH finished in 4.5 s.
[10:53:12] |>>> MBXAS finished in 0.0 s [✓].
[10:53:12] |----- Excitation successful! -----|

[10:53:12] |Saved everything as pyscf_obj.pkl
[10:53:12] |PyMBXAS finished successfully!

The spectra can then be obtained with:

import matplotlib.pyplot as plt

E, I = obj.get_mbxas_spectra(to_excite)#, erange=[395, 430], sigma=0.006)

plt.figure()
plt.plot(E,I)
plt.show()

Calculations can be stored as pkl files using the dill package. You can then simply reload a calculation doing:

obj = PySCF_mbxas(pkl_file="pyscf_obj.pkl")

Roadmap

Implement Machine Learning of spectral features (WIP). In the future, expand the method to interface and help manage multiple DFT codes, expand spectra visualization and analysis capabilities, ... (pretty much everything is WIP at the moment).

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

pymbxas-0.5.0.tar.gz (48.9 kB view details)

Uploaded Source

File details

Details for the file pymbxas-0.5.0.tar.gz.

File metadata

  • Download URL: pymbxas-0.5.0.tar.gz
  • Upload date:
  • Size: 48.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for pymbxas-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0f8152a521e1bb5cf3080549d21312ced80ac58df9199fad9bbd84d4803334bc
MD5 9bad5e47d30a3ed61ab8f21b30cd8f07
BLAKE2b-256 37c14325ef2b198aeccad64eeb32f650585c724aaffed544031b218a0eb1bb36

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