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

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 package by running:

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

or 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.io
from pymbxas.calculators.pyscf import PySCF_mbxas

# read structure in ASE format
structure = ase.io.read("glycine.xyz")

# set up calculation parameters
channel   = 1 
charge    = 0 # charge of system
spin      = 0 # spin of system
to_excite = "N" # 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.3.1a0.tar.gz (47.6 kB view details)

Uploaded Source

File details

Details for the file pymbxas-0.3.1a0.tar.gz.

File metadata

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

File hashes

Hashes for pymbxas-0.3.1a0.tar.gz
Algorithm Hash digest
SHA256 8584c31ac85d843011e1fa48a8d333863af348975e3e314a05f50747897290cf
MD5 e9c939ff8f336d5dcdcd950ba03ab072
BLAKE2b-256 a42278e41e6ae8457b24cc11757759d9db06ae833d711287a56aeca48bb89db7

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