This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize
for the AI-speak, we are working on rewriting it!
basis_named(name) gives the Basis record (lib/basis/basis) of the basis
set PySCF would load for name. The name is read by PySCF's rule
(pyscf.gto.basis._format_basis_name): lower case, with -, _ and
spaces taken out, so "6-31G", "6-31g", "631g*" and "6-31Gs" are one set.
Then the key is looked up in the aliases PySCF 2.5.0 has for the eight sets
here:
Any other name stops the run and lists the eight. PySCF knows many more
sets; these are the ones lib/basis has tables for (H through Ar).
A program that imports none of the tables gets all eight, so any of the names
works. A program that imports one or more of them (import basis.pople631g)
links those alone, and a name whose table it does not import stops the run and
says which import line to add; the water story links one table this way.
(The eight imports are an #! if-none-used block, kept only when the
program's other imports reach none of the tables, and each branch of
the lookup is an #! if-used block, kept only when the program imports that
table: lang/viv/src/lib.rs, expand_uses.) basis.all imports all eight
on purpose.
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.
[1]lines 37–147
from basis.basis import Basis, BS_LEN, BS_PR_LEN
#! if-none-used basis.sto3g basis.pople631g basis.pople631gs basis.pople631gss basis.ccpvdz basis.ccpvtz basis.def2svp basis.def2tzvpfrom basis.sto3g import basis_sto3g, BASIS_STO3G_NSHELL
from basis.pople631g import basis_631g
from basis.pople631gs import basis_631gs
from basis.pople631gss import basis_631gss
from basis.ccpvdz import basis_ccpvdz
from basis.ccpvtz import basis_ccpvtz
from basis.def2svp import basis_def2svp
from basis.def2tzvp import basis_def2tzvp
#! end-if#| The names of the sets `basis_named` knows, as PySCF writes them.
BASIS_NAMES = ["sto-3g", "6-31g", "6-31g*", "6-31g**", "cc-pvdz", "cc-pvtz", "def2-svp", "def2-tzvp"]
#| PySCF's key for a basis name: lower case, no `-`, `_` or spaces.defbasis_key(name:Str) ->Str {
return name.lower().replace("-", "").replace("_", "").replace(" ", "")
}
#| The module of lib/basis whose table PySCF's key `k` names, or "" when no#| table here has that name.defbasis_module(k:Str) ->Str {
if k =="sto3g" {
return"basis.sto3g"
}
if k =="631g" {
return"basis.pople631g"
}
if k =="631g*"or k =="631gs" {
return"basis.pople631gs"
}
if k =="631g**"or k =="631gss" {
return"basis.pople631gss"
}
if k =="ccpvdz"or k =="ccpvtz"or k =="def2svp"or k =="def2tzvp" {
return"basis."+ k
}
return""
}
#| The basis set PySCF names `name`, from the tables of lib/basis the#| program uses.defbasis_named(name:Str) -> Basis {
k =basis_key(name)
#! if-used basis.sto3gif k =="sto3g" {
returnbasis_sto3g()
}
#! end-if#! if-used basis.pople631gif k =="631g" {
returnbasis_631g()
}
#! end-if#! if-used basis.pople631gsif k =="631g*"or k =="631gs" {
returnbasis_631gs()
}
#! end-if#! if-used basis.pople631gssif k =="631g**"or k =="631gss" {
returnbasis_631gss()
}
#! end-if#! if-used basis.ccpvdzif k =="ccpvdz" {
returnbasis_ccpvdz()
}
#! end-if#! if-used basis.ccpvtzif k =="ccpvtz" {
returnbasis_ccpvtz()
}
#! end-if#! if-used basis.def2svpif k =="def2svp" {
returnbasis_def2svp()
}
#! end-if#! if-used basis.def2tzvpif k =="def2tzvp" {
returnbasis_def2tzvp()
}
#! end-if
m =basis_module(k)
if m =="" {
stop(f"unknown basis set {name!r}: the sets here are "+join(", ", BASIS_NAMES) +" (any case, with or without the hyphens)")
}
stop(f"the basis set {name!r} is in {m}, which this program does not use: add `import {m}` (or `import basis.all` for every set)")
# not reached: `stop` ends the run; a def that returns a record ends in a returnreturn Basis { shells:zeros(0, BS_LEN), prims:zeros(0, BS_PR_LEN) }
}
# run on its own, the module uses none of the tables, so it has all eighttest"a basis set by PySCF's names, in any case" {
bn_w =basis_named("6-31G")
assert_true(all(bn_w.shells ==basis_631g().shells) andall(bn_w.prims ==basis_631g().prims))
assert_near(len(basis_named("STO-3G").shells), BASIS_STO3G_NSHELL, 0.0)
assert_true(all(basis_named("6-31g*").prims ==basis_named("631Gs").prims))
assert_true(all(basis_named("6-31G**").shells ==basis_631gss().shells))
assert_true(all(basis_named("cc-pVDZ").shells ==basis_ccpvdz().shells))
assert_true(all(basis_named("cc_pvtz").shells ==basis_ccpvtz().shells))
assert_true(all(basis_named("def2-SVP").prims ==basis_def2svp().prims))
assert_true(all(basis_named("Def2 TZVP").prims ==basis_def2tzvp().prims))
assert_true(basis_key("6-31G**") =="631g**"andbasis_key("def2_svp") =="def2svp")
assert_true(basis_module(basis_key("6-31G*")) =="basis.pople631gs"andbasis_module("6311g") =="")
}
# SPDX-License-Identifier: MIT OR Apache-2.0# SPDX-FileCopyrightText: 2026 The Viv authors