Examples

Example scripts

Advance/OF-DFT is used from Python scripts through the ASE calculator AOFDFTCalculator. This collection of 37 ready-to-run scripts focuses on the features specific to AOFDFTCalculator. For ASE itself, please refer to the ASE documentation.

How to run: at the top of each script, set VPS_DIR and PAO_DIR to the pseudopotential and pseudo-atomic orbital folders shipped with the product (DFT_DATA19_AS/VPS and DFT_DATA19_AS/PAO), then run python script_name.py. The scripts target Advance/OF-DFT 1.0.0.

Basic calculations

How to use AOFDFTCalculator and set up the calculation conditions and hardware.

Your first SCF calculation

Run an SCF calculation for crystalline Si and get the total energy, Fermi energy and atomic forces.

AOFDFTCalculatorkin_typekin_model

Choosing the kinetic energy functional

Switch between AdvanceSoft26 and the conventional kinetic energy functionals (TFvW, LKT) and compare the results and timings.

kin_typekin_modele_fermi

Controlling and monitoring the SCF

Log output, SCF parameters, how to check convergence, and how to plot the convergence history from the log.

logging_filescf_styleconv_thr

What to do when the SCF does not converge

Compare the SCF convergence of a difficult Al(111) slab with different SCF settings, and learn the order in which to try the settings when the SCF does not converge.

scf_stylemix_betamix_nstored

Fermi energy and smearing

See how the results depend on the smearing setting, and read the entropy term and the Fermi energy.

smearingdegausswithout_TS

Cutoff energy convergence test

Vary the density cutoff energy e_cut, check the convergence of the total energy and inspect the FFT grid.

e_cutn_gridscalc.aofdft.lattice.n_grids

Pseudopotential and basis-set presets

Inspect the per-element presets of pseudopotentials, pseudo-atomic orbitals and basis sets, add basis functions and switch the XC functional.

vps_namespao_namesbasis

GPUs and OpenMP threads

Select the device (CPU or GPU) and the number of threads.

devicenum_threadscalc.device

Batch calculation of structure files and saving the results

Read CIF, POSCAR and other structure files with ASE, calculate them in a batch, and save the energies, forces, stresses and atomic charges to an extended XYZ file and a CSV table.

ase.io.readase.io.write (extxyz)get_stress

Electron density analysis

Exporting and visualizing the electron density, and deriving physical quantities from it.

Saving the electron density to a CUBE file

Take out the electron density from the SCF calculation and save it in the CUBE format for visualization tools.

calc.rhoase.io.cube.write_cubease.io.cube.read_cube_data

Density maps and line profiles

Take the density as a NumPy array and draw a 2D map on a plane containing the bonds and a 1D profile along a bond.

calc.rhomatplotlibscipy.ndimage.map_coordinates

Deformation density

Subtract the superposition of neutral atomic densities from the SCF density to visualize how bonding redistributes the electrons.

calc.rhocalc.aofdft.charge_density.neutral_density()write_cube

Planar-averaged electrostatic potential and work function

Obtain the electrostatic potential of a slab from its electron density, average it over the XY plane, and compute the work function from the vacuum level and the Fermi energy.

calc.rhocalc.e_fermicalc.aofdft.charge_density.neutral_density()

Charge redistribution by adsorption

Compute the densities of the combined system, the substrate and the adsorbate on the same grid, and visualize the charge transfer from their difference.

n_gridscalc.rhocalc.aofdft.lattice.n_grids

Charge doping and density differences

Dope one electron into GaAs with an As vacancy and locate it from the change in Mulliken charges and the density difference.

total_chargeatoms.arrays["charge"]calc.rho

Dipole moment of a molecule

Compute the dipole moment of an isolated molecule from the electron density and the valence charges of the pseudo-atoms.

calc.rhocalc.aofdft.atomic_data.species().zvalkin_model="Molecule26"

Saving and reusing the electron density

Save the converged density to a NumPy file and use it as the initial density of another calculation to reduce the number of SCF iterations.

calc.rho (setter)init_rhonumpy.save

Atomic charges and spin

Mulliken charges, orbital populations, spin-polarized calculations and magnetic moments.

Structures and energetics

Structure and cell optimization, equation of state and molecular dynamics with ASE.

Defects, surfaces and diffusion

Formation energies of point defects, surface energies, adsorption energies on surfaces and diffusion barriers.

Applications

Band gaps from charge doping, large systems, and comparison with Kohn-Sham DFT.