-
Notifications
You must be signed in to change notification settings - Fork 0
Home
PynAbi exports directly some classes and functions, but has many submodules too:
- crystal: creation of atoms, atom basis, and lattices
- kspace: all you need to handle the k-space definition, including BZ, grids, and paths
- calculation: options for SCF cycles and non-SCF, energy cutoff, and tolerances
- relaxation: molecular dynamics, structural optimization, Monte Carlo sampling, cell optimization
- units: energy and length units and values
While everything else can be hopefully understood looking at the docs strings in your code editor, the concepts here reported are more silent, but nonetheless essential to use PynAbi.
A Stampable
is a (hidden) base class that represent anything that can be put in a dataset. It is called sampable because each child class is responsible for the production of a piece of text of the Abinit file (through a method called stamp
). Each child class can also define a compatible
function that is called to assert the compatibility with the current and base datasets (during the createAbi
call).
There are some properties that, more frequently than other, are assigned different values to, for example, study convergence. To avoid instaciating the same class over and over with almost similar parameters, you can leverage the value delaying system.
Classes that can delay the value of some property inherit from the (hidden) class CanDelay
. These classes will have classmethods which allow to change these properties (usually named set<property
>) by creating an instance of Delayed
(which in turn is a Stampable
). The Delayed
instance will then check if the base dataset has an instance of the respective CanDelay
class.
When the constructor of a CanDelay
subclass does not require a value for an argument because it can be delayed, the default value is Later()
.
NOTE: errors are thown only when invoking createAbi
from pynabi import Dataset, createAbi
from pynabi.crystal import Atom, AtomBasis, Lattice
from pynabi.occupation import Metal, Smearing
crystal = (
AtomBasis.ofOne(Atom.of("Al")),
Lattice.CUB(5.6)
)
base1 = Dataset(
crystal,
Metal(Smearing.Gaussian, broadening=0.05),
Metal.setBroadening(0.07)
)
createAbi(base1) # error: metal broadening already defined in same set
# ====================
base2 = Dataset( crystal )
d2 = Dataset( Metal.setBroadening(0.07) )
createAbi(base2,d2) # error: base dataset does not define Metal
# ====================
base3 = Dataset( crystal, Metal(Smearing.Gaussian) )
d3 = Dataset( Metal.setBroadening(0.07) )
createABi(base3,d3) # ok
# ====================
base4 = Dataset( crystal, Metal(Smearing.Gaussian, broadening=0.05) )
d4 = Dataset( Metal.setBroadening(0.07) )
createAbi(base4,d4) # ok: 0.07 overwrites the base value 0.05
def createAbi(setup: DataSet | None, *datasets: DataSet) -> str: ...