Giter Club home page Giter Club logo

look4bas's Introduction

look4bas

PyPI version

look4bas is a Python script to search and obtain Gaussian basis sets. Currently we use the data of the EMSL basis set exchange or the ccrepo. An API to interact with the script directly from a python script on a high level is provided as well, see below.

On the first invocation (and from there on in regular intervals) the script downloads an archived catalogue of known basis sets to enable to search for them locally and on the commandline. Note, that the actual basis set data is not downloaded. This is only done if the user uses the flag --download, see below.

Commandline features

  • Use regular expressions (grep) for basis set names and descriptions:

    $ look4bas  "double zeta"
  • Ignore case when searching for patterns:

    $ look4bas "cc-pv.z" -i
  • Limit to basis sets which contain basis definitions for specific elements (e.g. helium, neon and argon):

    $ look4bas --elements He Ne Ar
  • Combine various filters:

    $ look4bas --elements H --regex "cc-pv.z" -i "zeta"
  • Not only list the matching basis sets by name and give a short description for them, but also list the elements for which this basis set defines basis functions:

    $ look4bas "double zeta" --format elements

    The same thing can be achieved by using the pre-defined --extra output format style, i.e

    $ look4bas --extra "double zeta"
  • Download the findings in Gaussian94 basis format to the current working directory:

    $ look4bas --elements H --regex "cc-pv.z" -i "zeta" --download

    Notice, that this will download the basis set definitions for all elements, for which this basis set is known at the corresponding source, even if once uses --elements to filter for particular elements.

  • Other basis formats are supported, too. For example

    $ look4bas --elements H --regex "cc-pv.z" -i "zeta" --download orca

    downloads in the format supported by ORCA. For a list of instructions how to use look4bas with certain quantum chemistry packages, see below.

  • More info about the commandline flags of look4bas can be obtained using look4bas -h

Installation

Either you clone the repo and make sure you have the appropriate dependencies installed (see next section), or you just use pip:

$ pip install look4bas

Requirements and Python dependencies

Python API

Searching for basis sets can be accomplished directly via a python API, which will return the search results in plain python dictionaries and lists. An example for such use can be found in examples/python_api.py.

Using look4bas with ...

This section contains some hints how to use look4bas specifically in combination with a few quantum-chemistry programs. If you use it with other codes or feel some explanation is missing, feel free to extend it here with a PR.

CFOUR

The CFOUR format is implemented, but not properly tested so far. Feel free to use it and please get in touch if you encounter problems.

Gaussian

No documentation for Gaussian is available so far.

NWChem

look4bas is able to download a file in the format expected for the basis section of the input file for NWChem.
Such a basis section has to be supplied after the geometry information and before further configuration, such as a task line or similar. One way to conveniently include the downloaded basis information is to split the input file into two parts, a head and a tail, where the information before the basis section goes into the head file and the information after the basis section goes into the tail file. Once the basis set info has been downloaded using look4bas one may use cat to concatenate all files and form a valid NWChem input.

For example, assume we want to perform a water geometry optimisation using pc-2 and download the basis with look4bas. We may proceed as follows:

  1. Define a NWChem head file water_head.nw with
geometry
  h 1 0 0
  h 0 1 0
  o 0 0 0
end

and a tail file water_tail.nw with

task scf optimize
  1. Download pc-2 basis with look4bas
$ look4bas "^pc-2$" --elem H O Fe --down nwchem
  1. Combine all files into water.nw
$ cat water_head.nw pc-2.nw water_tail.nw > water.nw
  1. Run the calculation
$ nwchem water.nw | tee water.out

Alternatively one may obviously just use a plain text editor and instead of typing the basis section read it from the file downloaded with look4bas.

ORCA

Here look4bas downloads the basis set in the format expected for a %basis block. By concatenation with a skeleton input file, which defines the rest of the calculation parameters, one can therefore quickly prepare an input file for Orca.

For example, consider again the water geometry optimisation using pc-2.

  1. Define a skeleton ORCA input file water_skel.in
! hf opt
* xyz 0 1
  H 1 0 0
  H 0 1 0
  O 0 0 0
*
  1. Download the pc-2 basis with look4bas
$ look4bas "^pc-2$" --elem H O Fe --down orca
  1. Create the actual input file
$ cat water_skel.in pc-2.orca water.in
  1. Run ORCA
$ orca water.in | tee water.out

pyscf

For supplying basis information to pyscf, the python API is best used. The script examples/pyscf.py, for example, performs the exemplary geometry optimisation of water, where the pc-2 basis is obtained using look4bas:

#!/usr/bin/env python3

import pyscf
import pyscf.geomopt.berny_solver
import look4bas
import look4bas.basis_format

# Search for basis set
db = look4bas.Database()
db.update()
findings = db.search_basisset("^pc-2$", regex=True,
                              has_atnums=[1, 8, 32])
assert len(findings) == 1
bset = db.lookup_basisset_full(findings[0])

# Setup water HF geometry optimisation in pyscf
mol = pyscf.gto.Mole()
mol.atom = "H 1 0 0; H 0 1 0; O 0 0 0"
mol.basis = look4bas.basis_format.convert_to("pyscf", bset["atoms"])
mol.build()

mf = pyscf.scf.RHF(mol)
mol_eq = pyscf.geomopt.berny_solver.optimize(mf)

Q-Chem

look4bas directly downloads a basis set in the format expected in a $basis section of a Q-Chem input file. Therefore one may simply concatenate a basis set definition downloaded with look4bas with a skeleton input file, which configures the rest of the calculation.

For example, we consider again a simple water geometry optimisation.

  1. We define a skeleton Q-Chem input file water_skel.qcin:
$molecule
0 1
  H 1 0 0
  H 0 1 0
  O 0 0 0
$end

$rem
    exchange  hf
    basis     gen
    jobtype   opt
$end
  1. We download, for example, the pc-2 basis with look4bas
$ look4bas "^pc-2$" --elem H O Fe --down qchem
  1. Finally the actual Q-Chem input file water.qcin of such a job, using exactly the downloaded basis, can be created just by:
$ cat water_skel.qcin pc-2.bas > water.qcin

Turbomole

The Turbomole format is implemented, but not properly tested so far. Feel free to use it and please get in touch if you encounter problems.

Citation DOI bibtex

You can cite look4bas using this bibtex entry or simply as

Michael F. Herbst. look4bas: Interactively search for Gaussian basis sets. (2018). DOI 10.5281/zenodo.1188991.

look4bas's People

Contributors

mfherbst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

look4bas's Issues

Add support for more output formats

With the python API in place adding support for a few further output formats beyond gaussian94 should not be too hard. Interesting candidates are:

  • ORCA
  • Turbomole
  • Gaussian
  • NWChem
  • Q-Chem
  • CFOUR
  • pyscf

Currently addressed in #12.

Implement explicit check for downloaded basis sets in database

  • Sometimes the basis sets are not downloaded properly, which yields to a rather cryptic error message for the user. We could improve this by an explicit check followed by a more helpful message.
  • Along this line we should have a commandline flag to explicitly force redownloading the data.

Unit tests and code sanity checks

At this stage some basic testing via Travis would be advantageous.

Ideas:
- Parsing of g94 data
- Writing of g94 data
- Some searches and their results

This could be combined with basic syntax checks and pylint.

Parse ECP sections

At least the EMSL returns ECP information as well for certain basis sets, causing the script to crash at the moment (to reproduce: look4bas "Def2-SVP$" --down). Implementing a parser for this data both resolves the bug and allows to use ECP information from the python API.

ModuleNotFoundError: No module named 'look4bas.basis_format'

Hi all,

I just simply use pip install look4bas in WSL-Ubuntu/Python3.7.1

root@chrinide:/home/chrinide# look4bas --elements He Ne Ar

But I got below error:

Traceback (most recent call last):
File "/home/chrinide/miniconda3/bin/look4bas", line 2, in
from look4bas.cli import main
File "/home/chrinide/miniconda3/lib/python3.7/site-packages/look4bas/init.py", line 3, in
from . import emsl, ccrepo, elements, tlsutil
File "/home/chrinide/miniconda3/lib/python3.7/site-packages/look4bas/emsl.py", line 6, in
from .basis_format import gaussian94
ModuleNotFoundError: No module named 'look4bas.basis_format'

Additional helpful utilities

Some helpful minor functionality:
- Decontraction
- Helper functionality to convert between an optimal representation for segmented basis sets and an optimal representation for general basis sets (e.g. by grouping identical exponents in some way)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.