External potential

External potentials are applied to all charged particles, i.e. electrons and nuclei.

Examples

>>> # 2.5 V/Ang along z:
>>> from gpaw.external import ConstantElectricField
>>> calc = GPAW(external=ConstantElectricField(2.5, [0, 0, 1]), ...)
class gpaw.external.ConstantElectricField(strength, direction=[0, 0, 1], tolerance=1e-07)[source]

External constant electric field.

strength: float

Field strength in V/Ang.

direction: vector

Polarization direction.

>>> # Two point-charges (in units of |e|):
>>> from gpaw.external import PointChargePotential
>>> pc = PointChargePotential([-1, 1], [[4.0, 4.0, 0.0], [4.0, 4.0, 10.0]])
>>> calc = GPAW(external=pc, ...)
class gpaw.external.PointChargePotential(charges, positions=None, rc=0.2, rc2=inf, width=1.0)[source]

Point-charge potential.

charges: list of float

Charges in units of \(|e|\).

positions: (N, 3)-shaped array-like of float

Positions of charges in Angstrom. Can be set later.

rc: float

Inner cutoff for Coulomb potential in Angstrom.

rc2: float

Outer cutoff for Coulomb potential in Angstrom.

width: float

Width for cutoff function for Coulomb part.

For r < rc, 1 / r is replaced by a third order polynomial in r^2 that has matching value, first derivative, second derivative and integral.

For rc2 - width < r < rc2, 1 / r is multiplied by a smooth cutoff function (a third order polynomium in r).

You can also give rc a negative value. In that case, this formula is used:

(r^4 - rc^4) / (r^5 - |rc|^5)

for all values of r - no cutoff at rc2!

>>> # Step potential in z-direction
>>> from gpaw.external import StepPotentialz
>>> step = StepPotentialz(zstep=10, value_right=-7)
>>> calc = GPAW(external=step, ...)
class gpaw.external.StepPotentialz(zstep, value_left=0, value_right=0)[source]

Step potential in z-direction

zstep: float

z-value that splits space into left and right [Angstrom]

value_left: float

Left side (z < zstep) potentential value [eV]. Default: 0

value_right: float

Right side (z >= zstep) potentential value [eV]. Default: 0

class gpaw.bfield.BField(field)[source]

Constant magnetic field.

field:

B-field vector in units of eV/bohr-magnoton.

Several potentials

A collection of potentials can be applied using PotentialCollection

>>> from gpaw.external import ConstantElectric, PointChargePotential
>>> from gpaw.external import PotentialCollection
>>> ext1 = ConstantElectricField(1)
>>> ext2 = PointChargePotential([1, -5], positions=((0, 0, -10), (0, 0, 10)))
>>> collection = PotentialCollection([ext1, ext2])
>>> calc = GPAW(external=collection, ...)
class gpaw.external.PotentialCollection(potentials)[source]

Collection of external potentials to be applied

potentials: list

List of potentials

Your own potential

See an example here: gpaw/test/ext_potential/test_harmonic.py.