Modules¶
Todo
Authors? I always think its nice to have authors defined in the module, so that when you want to contact the right person you know who to follow up with. -RJM
Imports seem to have a random order. Set lint to give us a specific order and then stick to that. -RJM
Non-interacting Solver¶
- Summary
Solve non-interacting 1d system numerically on a grid (position-space basis). Each eigenstate will be occupied by one electron.
Module author: Ryan Pederson ORCID: 0000-0002-7228-9478, Chris (Jielun) Chen, Li Li
Note
Both solvers (EigenSolver, SparseEigenSolver) here are based on directly diagonalizing the Hamiltonian matrix.
Todo
Figure out what to do about joint copyright holders (Google + other)
Clean out unused example rst content in here.
-
class
non_interacting_solver.SolverBase(grids, potential_fn=None, num_electrons=1, k_point=None, boundary_condition='open', n_point_stencil=3, perturbation=None)[source]¶ Bases:
objectBase Solver for non-interacting 1d system. Subclasses should define solve_ground_state method.
-
class
non_interacting_solver.EigenSolver(grids, potential_fn=None, num_electrons=1, k_point=None, boundary_condition='open', n_point_stencil=3, perturbation=None)[source]¶ Bases:
non_interacting_solver.SolverBaseRepresents the Hamiltonian as a matrix and diagonalizes it directly.
This is the most stable and accurate eigensolver. Use SparseEigenSolver for a faster iterative eigensolver.
-
update_potential(potential_fn)[source]¶ Replace the current potential grids with a new potential grids. Delete all attributes created by solving eigenvalues, set _solved to False.
- Parameters
potential_fn – potential function taking grids as argument.
-
get_kinetic_matrix()[source]¶ Kinetic matrix. Here the finite difference method is used to generate a kinetic energy operator in discrete space while satisfying desired boundary conditions.
- Returns
Kinetic matrix with shape (num_grids, num_grids)
- Return type
ndarray
-
-
class
non_interacting_solver.SparseEigenSolver(grids, potential_fn=None, num_electrons=1, k_point=None, boundary_condition='open', n_point_stencil=3, tol=1e-06)[source]¶ Bases:
non_interacting_solver.EigenSolverRepresents the Hamiltonian as a matrix and solve with sparse eigensolver.
This eigensolver is iterative and approximate. It is in general much faster than EigenSolver but less robust.
External Potentials¶
-
ext_potentials.gaussian_dips(grids, coeff, sigma, mu)[source]¶ Potential of sum of Gaussian dips.
- The i-th Gaussian dip is
-coeff[i] * np.exp(-(grids - mu[i]) ** 2 / (2 * sigma[i] ** 2))
- Parameters
grids – numpy array of grid points for evaluating 1d potential. (num_grids,)
coeff – numpy array of coefficient for each gaussian dip. (num_dips,)
sigma – numpy array of standard deviation for each gaussian dip. (num_dips,)
mu – numpy array of mean for each gaussian dip. (num_dips,)
- Returns
- Potential on grid.
(num_grids,)
- Return type
vp
-
ext_potentials.harmonic_oscillator(grids, k=1.0)[source]¶ Potential of quantum harmonic oscillator.
- Parameters
grids – numpy array of grid points for evaluating 1d potential. (num_grids,)
k – strength constant for potential vp = 0.5 * k * grids ** 2.
- Returns
- Potential on grid.
(num_grid,)
- Return type
vp
-
ext_potentials.quartic_oscillator(grids, k=1.0)[source]¶ Potential of quantum quartic oscillator.
- Parameters
grids – numpy array of grid points for evaluating 1d potential. (num_grids,)
k – strength constant for potential.
- Returns
- Potential on grid.
(num_grid,)
- Return type
vp
-
ext_potentials.kronig_penney(grids, a, b, v0)[source]¶ Kronig-Penney model potential. For more information, see:
https://en.wikipedia.org/wiki/Particle_in_a_one-dimensional_lattice#Kronig%E2%80%93Penney_model
- Parameters
grids – numpy array of grid points for evaluating 1d potential. (num_grids,)
a – periodicity of 1d lattice
b – width of potential well
v0 – negative float. It is the depth of potential well.
- Returns
- Potential on grid.
(num_grid,)
- Return type
vp
-
ext_potentials.exp_hydrogenic(grids, A=1.071295, k=0.4192265689030308, center=0, Z=1)[source]¶ Exponential potential for 1D Hydrogenic atom.
A 1D potential which can be used to mimic corresponding 3D electronic structure. Similar in form to the soft-Coulomb interaction, however there is a cusp occurring at x = 0 for a -> 0. Please refer to:
Thomas E Baker, E Miles Stoudenmire, Lucas O Wagner, Kieron Burke, and Steven R White. One-dimensional mimicking of electronic structure: The case for exponentials. Physical Review B,91(23):235141, 2015.
The cusp should lie exactly on a grid point to avoid missing any kinetic energy.
- Parameters
grids – numpy array of grid points for evaluating 1d potential. (num_grids,)
A – fitting parameter.
k – fitting parameter.
Z – the “charge” felt by an electron from the nucleus.
center – the center of the potential.
- Returns
- Potential on grid.
(num_grid,)
- Return type
vp
-
ext_potentials.poschl_teller(grids, lam, a=1.0, center=0.0)[source]¶ Poschl-Teller potential.
Poschl-Teller potential is a special class of potentials for which the one-dimensional Schrodinger equation can be solved in terms of Special functions.
https://en.wikipedia.org/wiki/P%C3%B6schl%E2%80%93Teller_potential
The general form of the potential is
v(x) = -frac{lambda(lambda + 1)}{2} a^2 frac{1}{cosh^2(a x)}
It holds M=ceil(lambda) levels, where lambda is a positive float.
- Parameters
grids – numpy array of grid points for evaluating 1d potential. (num_grids,)
lam – float, lambda in the Poschl-Teller potential function.
a – float, coefficient in the Poschl-Teller potential function.
center – float, the center of the potential.
- Returns
Potential on grid with shape (num_grid,)
- Raises
ValueError – If lam is not positive.
-
ext_potentials.poschl_teller_energy(level, lam, a=1.0)[source]¶ Analytic solution of the total energy filled up to level-th eigenstate.
The solution can be found in second row of Table 1 in
Leading corrections to local approximations. II. The case with turning points Raphael F. Ribeiro and Kieron Burke, Phys. Rev. B 95, 115115 https://journals.aps.org/prb/abstract/10.1103/PhysRevB.95.115115
- Parameters
level – positive integer, the ground state is level=1.
lam – positive float, lambda.
a – float, coefficient in Poschl-Teller potential.
- Returns
Float, the total energy from first to the level-th eigenstate.
-
ext_potentials.poschl_teller_eigen_energy(level, lam, a=1.0)[source]¶ Analytic solution of the level-th eigen energy for Poschl-Teller potential.
This is the energy level for Poschl-Teller potential with float lambda. The solution can be found in second row of Table 1 in
Leading corrections to local approximations. II. The case with turning points Raphael F. Ribeiro and Kieron Burke, Phys. Rev. B 95, 115115 https://journals.aps.org/prb/abstract/10.1103/PhysRevB.95.115115
- Parameters
level – positive integer, the ground state is level=1.
lam – positive float, lambda.
a – float, coefficient in Poschl-Teller potential.
- Returns
Float, the energy of the level-th eigenstate.
Functionals¶
- Summary
Defined grid-based exchange-correlation functionals, fock operator, and potentials for 1D systems.
Module author: Ryan Pederson ORCID: 0000-0002-7228-9478, Chris (Jielun) Chen, Johnny Kozlowski
Todo
hf: replace with Chris’ matrix muliplication code. Much cleaner.
Docs need love.
-
class
functionals.ExponentialHF(grids, A=1.071295, k=0.4192265689030308)[source]¶ Bases:
functionals.BaseHartreeFock
-
class
functionals.ExponentialLDAFunctional(grids, A=1.071295, k=0.4192265689030308)[source]¶ Bases:
functionals.BaseExchangeCorrelationFunctionallocal density approximation (LDA) for exponentially repelling electrons. For more details see [Baker2015].
-
v_xc_up(n, n_up, n_down)[source]¶ Exchange-Correlation Potential for up electrons, \(v_{xc, \uparrow} = d/dn_{\uparrow} e_{xc}\).
- Parameters
n – system density on a grid.
n_up – up spin density on a grid.
n_down – down spin density on a grid.
- Returns
the up XC potential on a grid.
- Return type
ndarray
-
v_xc_down(n, n_up, n_down)[source]¶ Exchange-Correlation Potential for up electrons, \(v_{xc, \downarrow} = d/dn_{\downarrow} e_{xc}\).
- Parameters
n – system density on a grid.
n_up – up spin density on a grid.
n_down – down spin density on a grid.
- Returns
the down XC potential on a grid.
- Return type
ndarray
-
Kohn-Sham DFT solver¶
- Summary
Kohn-Sham DFT solver for 1-dimensional systems on a grid.
Module author: Ryan Pederson ORCID: 0000-0002-7228-9478
Todo
Comments in KS solver funciton should be in doc format
solve_self_consistent_density needs summary sentence
Linting?
-
class
ks_dft.KS_Solver(grids, v_ext, xc, num_electrons=1, boundary_condition='open')[source]¶ Bases:
scf_base.SCF_SolverBaseKS-DFT solver for non-periodic systems.
Hartree-Fock solver¶
- Summary
This is the summary
Module author: Ryan Pederson ORCID: 0000-0002-7228-9478
Todo
Comments in HF solver funciton should be in doc format
solve_self_consistent_density needs summary sentence
Clean out unused example rst content in here.
linting?
Default constants used in this library.
Exponential Coulomb interaction.
v(x) = amplitude * exp(-abs(x) * kappa)
See also ext_potentials.exp_hydrogenic. Further details in:
Thomas E Baker, E Miles Stoudenmire, Lucas O Wagner, Kieron Burke, and Steven R White. One-dimensional mimicking of electronic structure: The case for exponentials. Physical Review B,91(23):235141, 2015.
-
utils.get_dx(grids)[source]¶ Gets the grid spacing from a grids array.
- Parameters
grids – Numpy array with shape (num_grids,).
- Returns
Grid spacing.
- Return type
h
-
utils.vw_grid(density, dx)[source]¶ von Weizsacker kinetic energy functional on grid.
- Parameters
density – numpy array, density on grid. (num_grids,)
dx – grid spacing.
- Returns
von Weizsacker kinetic energy.
- Return type
kinetic_energy
-
utils.quadratic(mat, x)[source]¶ Compute the quadratic form of matrix and vector.
- Parameters
mat – matrix. (n, n)
x – vector. (n,)
- Returns
scalar value as result of x A x.T.
- Return type
output