(sec:essentialelements.finEfield)=
# Finite Electric Fields

Electric fields can have significant influences on the electronic structure
of molecules. In general, when an electric field is applied to a molecule,
the electron cloud of the molecule will polarize along the direction of the
field. The redistribution of charges across the molecule will then influence
the wavefunction of the molecule. Even when polarization effects are not
significant, the electric field still exerts a drag on the negatively and
positively charged atoms of the molecule in opposite directions, and therefore
affect the orientation and structure of the molecule. The combination of
electrostatic and polarization effects make electric fields a useful degree
of freedom in tuning e.g. reactivities, molecular structures and spectra
{cite}`shaik2018CSR`. Meanwhile, the energy/dipole moment/quadrupole moment
changes of the system in the presence of small dipolar or quadrupolar electric
fields are useful for calculating many electric properties of the system via
numerical differentiation, including the dipole moment, quadrupole moment,
dipole-dipole polarizability, quadrupole-quadrupole polarizability, etc.
Such finite difference property calculations can be conveniently done using
compound scripts in the [ORCA Compound Scripts Repository](https://github.com/ORCAQuantumChemistry/CompoundScripts/tree/main/Polarizabilities).

An overview of relevant keywords is given in {numref}`tab:essentialelements.finEfield.keywords.block`.

(sec:essentialelements.finEfield.dipolar)=
## Dipolar Electric Fields

A uniform or equivalently speaking, dipolar electric field can
be added to a calculation via the `EField` keyword in the `%scf` block:

```orca
%scf
  EField 0.1, 0.0, 0.0 # x, y, z components (in au) of the electric field
end
```

Although the keyword is in the `%scf` block, it applies the electric field to
all other methods (post-HF methods, multireference methods, TDDFT, etc.) as
well. Analytic gradient contributions of the electric field are available for all supported methods 
that already support analytic gradients, but analytic Hessian contributions are not.

:::{warning}
The electric field functionality is not available for [GFN-xTB](sec:modelchemistries.semiempirical.xtb) and force field methods (as well as any method that
involves GFN-xTB or force fields, e.g. [QM/XTB](sec:multiscalesimulations.qmmm.orca) and [QM/MM](sec:multiscalesimulations.qmmm.orca)! Combination with these
method will result in an abort.
:::

The sign convention of the electric field is chosen in the following way:
suppose that the electric field is generated by a positive charge in the
negative z direction, and a negative charge in the positive z direction,
then the z component of the electric field is positive. This convention is
consistent with most but not all other programs {cite}`shaik2018CSR`, so
care must be taken when comparing the results of ORCA with other programs.

Another important aspect is the gauge origin of the electric field. The gauge
origin of the electric field is the point (or more accurately speaking, one
of the points - as there are infinitely many such points) where the electric
potential due to the electric field is zero. Different choices of the gauge
origin do not affect the geometry and wavefunction of the molecule, as
they do not change the electric field felt by the molecule, but they do change
the energy of the molecule. The default gauge origin is the (0,0,0) point of
the Cartesian coordinate system, but it is possible to choose other gauge origins
via the `EFieldOrigin` keyword in the `%scf` block.

```orca
%scf
 EFieldOrigin CenterOfMass      # use center of mass
              CenterOfNucCharge # use center of nuclear charge
              0.0, 0.0, 0.0     # use given X,Y,Z as origin (default: 0,0,0)
                                # in the units chosen for the coordinates (Angstrom/Bohr)
end
```

Note the default gauge origin of the electric field is different from the
default gauge origin of the ELPROP module, which is the center of mass. If
the user chooses the center of mass/nuclear charge as the gauge origin of the electric field, the gauge
origin will move as the molecule translates; this has important consequences.
For example, in an MD simulation of a charged molecule in an electric field, the molecule will
not accelerate, unlike when `EFieldOrigin` is fixed at a given set of coordinates, where the
molecule will accelerate forever. In general, `CenterOfMass`  and
`CenterOfNucCharge` are mostly suited for the finite difference calculation of
electric properties, where one frequently wants to choose the center of mass
or nuclear charge as the gauge origin of the resulting multipole moment or
polarizability tensor. Instead, a fixed origin is
expected to be more useful for simulating the changes of wavefunction, geometry,
reactivity, spectra etc. under an externally applied electric field, as experimentally
the electric field is usually applied in the lab frame, rather than the comoving
frame of the molecule.

(sec:essentialelements.finEfield.quadrupolar)=
## Quadrupolar Electric Fields

Similar to dipolar electric fields, quadrupolar fields can be added via the `QField` keyword in the `%scf` block:

```orca
%scf
  QField 0.1, 0.0, 0.0, 0.05, 0.0, 0.0 # xx, yy, zz, xy, xz, yz components (in au)
                                       # of the quadrupolar field
end
```

The gauge origin of the quadrupolar field is the same as that of the [dipolar electric field](sec:essentialelements.finEfield.dipolar). 

(sec:essentialelements.finEfield.combi)=
## Combination of Dipolar and Quadrupolar Electric Fields

[Dipolar](sec:essentialelements.finEfield.dipolar) and [quadrupolar electric fields](sec:essentialelements.finEfield.quadrupolar) 
can be combined using the respective `EField` and `QField` keywords in the `%scf` block. This allows one to
simulate a gradually varying electric field, for example the following input
specifies an electric field that has a strength of 0.01 au at the gauge origin
((0,0,0) by default), pointing to the positive z direction, and increases by 0.001 au for
every Bohr as one goes in the positive z direction:


```orca
%scf
  EField 0.0, 0.0, 0.01
  QField 0.0, 0.0, 0.001, 0.0, 0.0, 0.0
end
```

As a second example, one can also simulate an ion trap:


```orca
%scf
  QField -0.01, -0.01, -0.01, 0.0, 0.0, 0.0
end
```

Under this quadrupolar field setting, a particle will feel an electric field that points
towards the gauge origin, whose strength (in au) is 0.01 times the distance to the gauge origin
(in Bohr). This will keep cations close to the origin, but pushes anions away from the origin.
Unfortunately, there is no analytic gradient available for quadrupolar fields.

:::{admonition} Notes on Electric Fields
:class: note

-   An au (atomic unit) is a fairly large unit for electric fields:
    1 au = 51.4 V/Angstrom. By comparison, charged residues in proteins,
    as well as scanning tunneling microscope (STM) tips, typically generate
    electric fields within about 1 V/Angstrom; electrode surfaces usually
    generate electric fields within 0.1 V/Angstrom under typical electrolysis
    conditions {cite}`shaik2018CSR`. If the molecule is not close to the
    source of the electric field, it is even harder to generate strong
    electric fields: for example, a 100 V voltage across two metal plates
    that are 1 mm apart generates an electric field of merely $10^{-5}$ V/Angstrom.
    Therefore, if experimentally a certain strength of homogeneous electric field seems
    to promote a reaction, but no such effect is found in calculation,
    please consider the possibility that the experimentally observed reactivity
    is due to a strong local electric field near the electrode surface
    (that is much higher than the average field strength in the system), or
    due to other effects such as electrolysis. Conversely, if you predict
    a certain molecular property change at an electric field strength of, e.g.
    $>$ 0.1 au, it may be a non-trivial question whether such an electric field
    can be easily realized experimentally.

-   The electric field breaks the rotational symmetry of the molecule, in the
    sense that rotating the molecule can change its energy. Therefore, geometry
    optimizations in electric fields cannot be done with internal coordinates.
    When the user requests geometry optimization, the program automatically
    switches to Cartesian coordinates if it detects an electric field. While
    Cartesian coordinates allow the correct treatment of molecular rotation, they
    generally lead to poor convergence, so a large number of iterations is
    frequently necessary. Also, since certain geometry optimization tasks (notably
    transition state optimization) can currently only be done under internal coordinates,
    electric fields cannot be used in such types of optimization tasks yet.

-   Similarly, when the molecule is charged, its energy is not invariant with
    respect to translations. However, when there is only a dipolar electric field
    but no other translational symmetry-breaking forces (quadrupolar field, point
    charges, wall potentials), a charged molecule will accelerate forever in
    the field, and its position will never converge. Therefore, for geometry
    optimizations within a purely dipolar electric field and no wall potentials, we
    do not allow global translations of the molecule, even when translation can reduce its energy.
    For MD simulations we however do allow the global translations of the molecule
    by default. If this is not desired, one can fix the center of mass in the MD run
    using the `CenterCOM` keyword (section {ref}`moldyn:cmd_run`).

-   For [frequency calculations](sec:structurereactivity.frequencies) in electric fields, we do not project out the
    translational and rotational contributions of the Hessian (equivalent to setting
    `ProjectTR false` in `%freq`; see {ref}`sec:structurereactivity.frequencies` for details).
    Therefore, the frequencies of translational and rotational modes can be different
    from zero, and can mix with the vibrational modes. When the electric field is
    extremely small but not zero, the "true" translational/rotational symmetry breaking
    of the Hessian may be smaller than the symmetry breaking due to numerical error;
    this must be kept in mind when comparing the frequency results under small electric
    fields versus under zero electric field (in the latter case `ProjectTR` is by
    default true). Besides, when the translational and rotational frequencies exceed
    `CutOffFreq` (which is 1 cm$^{-1}$ by default; see section {ref}`sec:structurereactivity.frequencies`),
    their thermochemical contributions are calculated as if they are vibrations.

-   While the program allows the combination of electric fields with an [implicit solvation model](sec:essentialelements.solvationmodels), 
    the results must be interpreted with caution, because the solvent
    medium does not feel the electric field. The results may therefore differ
    substantially from those given by experimental setups where both the solute and
    the solvent are subjected to the electric field. If the solvent's response to
    the electric field is important, one should use an explicit solvation model instead.
    Alternatively, one can also simulate the electric field in the implicit solvent
    by adding inert ions (e.g. Na$^+$, Cl$^-$) to the system.
    Similarly, implicit solvation models cannot describe the formation of electrical
    double layers in the electric field and their influence on solute properties, so
    in case electrical double layers are important, [MD simulations](sec:moldyn) with explicit
    treatment of the ions must be carried out.

-   The electric field not only contributes to the core Hamiltonian, but has extra
    contributions in GIAO calculations, due to the magnetic field derivatives of dipole
    integrals. In the case of a dipolar electric field, the
    GIAO contributions have been implemented, making it possible to study e.g. the
    effect of electric fields on [NMR shieldings](sec:spectroscopyproperties.nmr), and as a special case, nucleus
    independent chemical shieldings ([NICSs](sec:spectroscopyproperties.nmr.NICS)), which are useful tools for analyzing aromaticity.
    [Quadrupolar fields](sec:essentialelements.finEfield.quadrupolar) cannot be used in GIAO calculations at the moment.

:::

(sec:essentialelements.finEfield.keywords)=
## Keywords

(tab:essentialelements.finEfield.keywords.block)=
:::{table} `%scf` block input keywords and options for finite electric fields.
| Keyword          | Option                      | Description                                                                                                           |
|:-----------------|:----------------------------|:----------------------------------------------------------------------------------------------------------------------|
| `EField`         | `<x, y, z>`                 | Activates [dipolar electric field](sec:essentialelements.finEfield.dipolar) with x, y, z components (in au)           |
| `QField`         | `<xx, yy, zz, xz, xz, yz>`  | Activates [quadrupolar electric field](sec:essentialelements.finEfield.quadrupolar) with xx, yy, zz, xz, xz, yz components (in au)           |
| `EFieldOrigin`   | `CenterOfMass`              | Sets origin to center of mass                                                                                         |
|                  | `CenterOfNucCharge`         | Sets origin to center of nuclear charge                                                                               |
|                  | `<X, Y, Z>`                 | Sets origin to X,Y,Z coordinates (default: 0,0,0) in the units chosen for the coordinates (Angstrom/Bohr)             |
:::