[REQUEST] Direct Support for Basis-Set-Exchange
It would be nice if we could directly support the basis set exchange. Right now support is a bit roundabout (via a specified file format) if I understand correctly. One would want to add the feature mapping that basis-set dictionary to gbasis and then make an example notebook explaining the feature. It seems this is using data_dir which is based on the molssi basis set exchange json schema.
Is it okay if I write a new parse_bse() function that reads a basis set directly from the BSE without requiring the BSE Python library? Is that what’s requested?
Would it make sense to use the BSE web API to fetch the basis set in Gaussian94 format, and then convert that text into gbasis format?
I've been thinking some about this. I think it's OK, but arguably the right workflow is to go through iodata. I.e., you read in an iodata object (or a geometry, which is then used to make an iodata object). Then you add basis-set information into iodata. Then you construct the integrals therefrom. I think it is nicer to do it through the Python interface rather than scraping the web. But I'm curious why you prefer the G94 intermediate.
Thank you!
I preferred using the Gaussian format over JSON because I wanted to work with atom symbols instead of atomic numbers. I’m sorry, but I’m not sure I fully understand. Are you suggesting that we should pass an iodata object without the obasis attribute to gbasis, and then add the basis set information internally within gbasis? If so, how does this connect to the BSE? Are you saying to read the basis sets in JSON files from the BSE data_dir? I'm so sorry if my questions seem too basic. I just want to be sure I understand the intended workflow correctly.
I was thinking to leverage the iodata workflow in gbasis. Partly because that is useful in gbasis and partly because being able to take a file (with only a geometry, not a basis) in iodata and add a basis is useful itself.
@marco-2023 has a template Jupyter notebook that has some of the key components of the workflow.
Some observations regarding supporting BSE:
-
The code for parsing basis set files is located in
gbasis/parsers.py. -
This code currently cannot parse basis sets in the "Gaussian, system library" format. These are modified basis sets that:
- Share the same names as canonical BSE basis sets
- Are used internally by Gaussian
- Correspond to the basis sets extracted from
.fchkfiles
-
As the parser is already in
gbasis, it is probably easier to add the rest of the logic here. -
The
basis-set-exchangepackage has a friendly API that simplifies the process of fetching the correct basis set. I think we should consider one of these solutions:- Add
basis-set-exchangeas a required dependency for gbasis - Make it an optional dependency using lazy loading (print a warning if not present instead of failing)
- Add
basis-set-exchangeas a developer dependency and pre-compile all basis sets, fetching them later, as needed, either locally or from the web
- Add
Thank you, @marco-2023 for this.
If we add basis-set-exchange as a dependency, perhaps this would work (?):
import numpy as np
from basis_set_exchange import lut, get_basis
def parse_bse(basis_set, atoms=None):
bse_basis_set = get_basis(basis_set, elements=atoms)['elements']
basis = {}
for atom_num_str, info in bse_basis_set.items():
atom_symbol = lut.element_sym_from_Z(int(atom_num_str), normalize=True)
for shell in info['electron_shells']:
exponents = np.asarray(shell['exponents'], dtype=float)
for i, l in enumerate(shell['angular_momentum']):
coefficients = np.asarray(shell['coefficients'][i], dtype=float)
basis.setdefault(atom_symbol, []).append((l, exponents, coefficients))
return basis
I'm reading the JSON files from the basis-set-exchange library and converting the basis set data into the gbasis format.
@PaulWAyers I’ve added direct Basis Set Exchange support and opened a PR for it. Could you please review it when you have a chance? If any changes or adjustments are needed, feel free to let me know. Thanks!
Hi! I’m Lipika, participating in WOC 5.0. I’d like to work on this issue (#209).
I’m planning to add direct Basis Set Exchange (BSE) support by implementing a helper (optional dependency) to map BSE JSON basis dictionaries into gbasis basis objects, along with unit tests and an example notebook.
Could you please confirm the preferred API/module location (e.g., gbasis.wrappers.from_bse and functions like get_basis() / from_bse_dict()), and whether BSE should remain an optional dependency?
Hey @lipikaparida-web I already raised PR for this issue, let us wait for review from maintainers, you can take up the other issue till then.
@marco-2023 I think I remember you did something similar (in Jupyter notebook format) last year?
(you sent it by teams April 10-11, 2025)
Hi, I’m interested in contributing to this area.
I saw that a PR (#223) is already open for adding BSE support. I’d like to help by contributing improvements such as tests, edge-case handling, or documentation.
Would that be helpful? Are there specific gaps I could work on?