## ::pwtk::pwi::dipoleCorr

SYNOPSIS

```proc ::pwtk::pwi::dipoleCorr {args} {
```

USAGE

```   ::pwtk::pwi::dipoleCorr  ?-vac1st thicknessBohr?  ?-diplayer thicknessBohr?  ?-vac2nd thicknessBohr?  slab_thicknessBohr
```

PURPOSE

Set the dipole correction.

OPTIONS

• -vac1st thickness ... the thickness of vacuum from top of the slab to the dipole layer in Bohr
• -diplayer thickness ... the thickness of the dipole-layer in Bohr
• -vac2nd thickness ... the thickness of vacuum from top of the dipole-layer to the bottom of the adjecent slab in Bohr

ARGUMENTS

• slab_thicknessBohr ... slab thickness in Bohr

DESCRIPTION

This command presuposses that surface normal is along Z and a 2D slab structure is the following:

```      z=C ----------
|        | vac2nd
|        |
+--------+ diplayer
+--------+
|        | vac1st
|        |
+--------+ z=slab_thickness_bohr
|//SLAB//|
z=0 +--------+
```

Based on this assumption, edir=3 and the emaxpos and eopreg variables are set accordingly.

RETURN VALUE

The size of the C lattice vector in Bohr units. The C lattice vector points along the Z-direction, which is the surface-normal direction.

SOURCE

```    set narg 1
set options {
{vac1st.arg   {} "thickness of vacuum from top of the slab to the dipole layer in Bohr"}
{diplayer.arg {} "thickness of the dipole-layer in Bohr"}
{vac2nd.arg   {} "thickness of vacuum from top of the dipole-layer to the bottom of the adjecent slab in Bohr"}
}
set usage "?-vac1st thickness?  ?-diplayer thickness?  ?-vac2nd thickness?  slab_thickness"
::pwtk::parseOpt_

lassign [::pwtk::dipcorrDefault_ \$opt(vac1st) \$opt(diplayer) \$opt(vac2nd)] opt(vac1st) opt(diplayer) opt(vac2nd)

::pwtk::checkOTypeStrict_ -vac1st \$opt(vac1st) {number posreal} "positive number"
::pwtk::checkOTypeStrict_ -vac2nd \$opt(vac2nd) {number posreal} "positive number"
::pwtk::checkOTypeStrict_ -diplayer \$opt(diplayer) {number posreal} "positive number"

# BEWARE: all thicknesses are in Bohr !
set slab_height \$args

set dipZ [expr \$slab_height + \$opt(vac1st)]
set Z    [expr \$slab_height + \$opt(vac1st) + \$opt(diplayer) + \$opt(vac2nd)]

set emaxpos [expr \$dipZ / \$Z]
set eopreg  [expr \$opt(diplayer) / \$Z]

CONTROL {
dipfield = .true.
tefield = .true.
}
SYSTEM  [subst {
edir = 3
emaxpos = \$emaxpos
eopreg = \$eopreg
}]