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.
No examples match your filter.
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_modelChoosing the kinetic energy functional
Switch between AdvanceSoft26 and the conventional kinetic energy functionals (TFvW, LKT) and compare the results and timings.
kin_typekin_modele_fermiControlling 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_thrWhat 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_nstoredFermi energy and smearing
See how the results depend on the smearing setting, and read the entropy term and the Fermi energy.
smearingdegausswithout_TSCutoff 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_gridsPseudopotential 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_namesbasisGPUs and OpenMP threads
Select the device (CPU or GPU) and the number of threads.
devicenum_threadscalc.deviceBatch 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_stressElectron 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_dataDensity 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_coordinatesDeformation 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_cubePlanar-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_gridsCharge 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.rhoDipole 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.saveAtomic charges and spin
Mulliken charges, orbital populations, spin-polarized calculations and magnetic moments.
Mulliken charges
Get the Mulliken charge of each atom, which is evaluated automatically after the SCF calculation.
atoms.arrays["charge"]atomic_chargeOrbital populations
Write the electron population of each atomic orbital to a file and sum it for the s, p and d shells.
population_fileAtom-wise eigenvalues and occupations
Write and read the eigenvalues, occupations and orbital coefficients of the eigenvalue problems that AOF-DFT solves for each atom.
wavefunc_filee_fermiSpin-polarized calculation (bcc Fe)
Run a spin-polarized calculation for ferromagnetic bcc Fe and get the spin of each atom and the total magnetic moment.
spin_typeatoms.arrays["spin"]scf_styleVisualizing the spin density
Extract the spin density and the up/down densities from a spin-polarized calculation and write CUBE files and a 2D map.
calc.rhospin_typetotal_magmomComparing magnetic orderings
Compare the energies of non-magnetic, ferromagnetic and antiferromagnetic states by changing the initial spins.
atoms.arrays["spin"]spin_typescf_convergedFixed spin moment calculations
Fix the total spin moment of the cell during the SCF and examine how the energy changes with magnetization.
total_spine_fermi_upe_fermi_dwStructures and energetics
Structure and cell optimization, equation of state and molecular dynamics with ASE.
Structure optimization and potential curve of a molecule
Optimize an isolated methane molecule with an ASE optimizer and scan the potential curve along the C-H bond length.
kin_model="Molecule26"scf_style="molecule"ase.optimize.BFGSStress tensor and cell optimization
Get the stress tensor and optimize atomic positions and the lattice together with an ASE cell filter.
get_stressmax_cell_strainase.filters.FrechetCellFilterEquation of state and bulk modulus
Compute the total energy at several volumes and fit an equation of state to get the equilibrium volume and bulk modulus.
get_potential_energyase.eos.EquationOfStateFirst-principles molecular dynamics
Run first-principles molecular dynamics at constant temperature (NVT) with a Langevin thermostat, using the ASE MD modules.
ase.md.langevin.LangevinMaxwellBoltzmannDistributionase.constraints.FixComMolecular dynamics of liquid Al and the radial distribution function
Melt 108 Al atoms with a classical potential, equilibrate the liquid with AOF-DFT and a Langevin thermostat (NVT), and compute the radial distribution function g(r), with a guide to choosing the time step.
ase.md.langevin.Langevinase.calculators.emt.EMTMaxwellBoltzmannDistributionMixing energy of a solid solution
Place Mg and Ca at random on the cation sites of a 64-atom supercell of MgO and CaO, and compute the mixing energy at each composition from the difference to the pure oxides.
ase.build.bulkAtoms.symbolsnumpy.randomDefects, surfaces and diffusion
Formation energies of point defects, surface energies, adsorption energies on surfaces and diffusion barriers.
Vacancy formation energy
Remove one atom from an fcc Al supercell, relax the surrounding atoms and compute the vacancy formation energy, checking its convergence with the supercell size.
ase.build.bulkAtoms.repeatase.optimize.BFGSVacancy migration barrier with the NEB method
Find the path along which a neighbouring atom hops into a vacancy in fcc Al with ASE's climbing-image NEB method, and compute the activation energy of vacancy migration.
ase.mep.NEBNEBToolsase.optimize.FIRESurface energy
Calculate fcc Al(111), (100) and (110) slabs with different numbers of layers and obtain the surface energy from the difference between the slab and bulk energies.
ase.build.fcc111fcc100fcc110Adsorption energy and adsorption site
Relax an Al(111) slab with its bottom layers fixed, optimize a Na atom on four adsorption sites, and compare the adsorption energies to find the preferred site.
ase.build.add_adsorbateFixAtomsFixCartesianApplications
Band gaps from charge doping, large systems, and comparison with Kohn-Sham DFT.
Band gap estimation by charge doping
Fit the total energy as a function of the total charge with a quadratic and estimate the band gap from its second derivative.
total_chargeget_potential_energynumpy.polynomial.PolynomialLarge systems and O(N) scaling
Measure the SCF time for supercells of increasing size and confirm that the cost grows linearly with the number of atoms.
kin_typenum_threadsdeviceComparison with Kohn-Sham DFT by OpenMX
Use the bundled CustomOpenMX class to run Kohn-Sham DFT with the same pseudopotentials and basis as AOF-DFT and compare the results.
CustomOpenMXaofdft_paramsnum_process