# CurrentDensity¶

class CurrentDensity(configuration=None, kpoints=None, energies=None, energy_weights=None, spin=None, electrode_temperatures=None, self_energy_calculator=None, energy_zero_parameter=None, infinitesimal=None)

Constructor for the CurrentDensity object.

Parameters: configuration (DeviceConfiguration) – The device configuration to calculate the current density for. kpoints (MonkhorstPackGrid) – The kpoints to integrate over. Default: MonkhorstPackGrid(nx,ny), where nx, ny is the sampling used for the self consistent calculation. energies (PhysicalQuantity of type energy.) – The energies to integrate over. Default: An energy range that covers the bias window as specified by the DoubleContourIntegralParameters on the calculator attached to the configuration. energy_weights (Current | Left | Right | list of floats) – The weight of each energy point. The keyword Current gives an energy dependent weight, $$f_R(E) -f_L(E)$$, corresponding to the current integral. Left/Right gives an energy independent weight of 1, for current carrying states from Left/Right. Default: Current spin (Spin.All | Spin.Up | Spin.Down | Spin.Sum | Spin.RealUpDown | Spin.ImagUpDown | Spin.X | Spin.Y | Spin.Z) – The spin for which the current density should be calculated. Default: Spin.Sum for UNPOLARIZED, else Spin.All electrode_temperatures (PhysicalQuantity of type temperature) – The electrode temperatures to be used the current calculation. Must be given as 2 temperatures - for example, [100, 200]*Kelvin. Default: The temperature used for the self-consistent calculation. self_energy_calculator (DirectSelfEnergy | RecursionSelfEnergy | SparseRecursionSelfEnergy | KrylovSelfEnergy) – The self energy calculator to be used for the current density. Default: RecursionSelfEnergy(storage_strategy=NoStorage()) energy_zero_parameter (AverageFermiLevel | AbsoluteEnergy) – Specifies the choice for the energy zero. Default: AverageFermiLevel infinitesimal (PhysicalQuantity of type energy.) – Small positive energy, used to move the self-energy calculation away from the real axis. This is only relevant for recursion-style self-energy calculators. Default: 1.0e-6*eV.
electrodeFermiLevels()
Returns: The Fermi levels of the left and right electrodes in absolute energies. PhysicalQuantity of type energy.
electrodeFermiTemperatures()
Returns: The Fermi temperature of the left and right electrodes. PhysicalQuantity of type temperature.
energies()
Returns: The energies used in this current density PhysicalQuantity of type energy
energyWeights()
Returns: The energy weights used in this current density numpy.array
energyZero()
Returns: The energy zero used for the energy scale in this current density. PhysicalQuantity of type energy.
evaluate(x, y, z, spin=None)

Evaluate in the point x,y,z.

Parameters: x (PhysicalQuantity with type length) – The cartesian x coordinate. y (PhysicalQuantity with type length) – The cartesian y coordinate. z (PhysicalQuantity with type length) – The cartesian z coordinate. spin (Spin.All | Spin.Sum | Spin.X | Spin.Y | Spin.Z) – The spin component to project on. Default: The spin that the object was constructed with. The vector grid value at the specified point for the given spin. For Spin.All, a tuple with (Spin.Sum, Spin.X, Spin.Y, Spin.Z) components is returned. PhysicalQuantity
gridCoordinate(i, j, k)

Return the grid coordinate for a given grid index.

Parameters: i (int) – The grid index in the A direction. j (int) – The grid index in the B direction. k (int) – The grid index in the C direction. The Cartesian coornate of the given grid index. PhysicalQuantity of type length.
infinitesimal()
Returns: The infinitesimal used for calculating the current density. PhysicalQuantity of type energy
metatext()
Returns: The metatext of the object or None if no metatext is present. str | unicode | None
nlprint(stream=None)

Print a string containing an ASCII table useful for plotting the AnalysisSpin object.

Parameters: stream (python stream) – The stream the table should be written to. Default: NLPrintLogger()
scale(scale)

Scale the field with a float.

Parameters: scale (float) – The parameter to scale with.
setMetatext(metatext)

Set a given metatext string on the object.

Parameters: metatext (str | unicode | None) – The metatext string that should be set. A value of “None” can be given to remove the current metatext.
shape()
Returns: The number of grid points in each direction. tuple of three int.
spin()
Returns: The spins used in this current density. tuple of spin component flags.
spinProjection(spin=None)

Query method to get a spin component of the VectorGridValue object.

Parameters: spin (Spin.Sum | Spin.Up | Spin.Down | Spin.X | Spin.Y | Spin.Z | Spin.RealUpDown | Spin.ImagUpDown) – The spin component for which to return the GridValues object. Default: Spin.Sum A new VectorGridValues object for the specified spin. VectorGridValues
toArray()
Returns: The values of the grid as a numpy array slicing off any units. numpy.array.
unit()
Returns: The unit of the data in the grid. A physical unit.
unitCell()
Returns: The unit cell of the grid. PhysicalQuantity of type length.
volumeElement()
Returns: The volume element of the grid represented by three vectors. PhysicalQuantity of type length.

## Usage Examples¶

Calculate the CurrentDensity for a DeviceConfiguration and plot it density along z, integrated over the x,y plane:

# Calculate the current density at the fermi level from right to left going states
cd = CurrentDensity(
configuration,
energies = [0.0]*eV,
energy_weights = Right,
kpoints=MonkhorstPackGrid(1,11),
)

# Calculate the volume element and x,y integration area
dX, dY, dZ = cd.volumeElement()
dAXY = numpy.linalg.norm( numpy.cross(dX,dY) )

# Calculate the current density along z integrated over x,y
shape = cd.shape()
# Take out spin up (index 0) z component (index 2) in every grid point.
cd_z = numpy.array( [ [ [ cd[i,j,k][0][2] for k in range(shape[2])] for j in range(shape[1])] for i in range(shape[0]) ] )

# Sum across x and y dimensions
cd_z_integrated = numpy.array([cd_z[:,:,k].sum() * dAXY for k in range(shape[2])])

# Plot the data
import pylab
pylab.figure()
dz = dZ.norm()
z = numpy.arange(shape[2])*dz.inUnitsOf(Bohr)
pylab.plot(z,cd_z_integrated)
pylab.show()


current_density1.py

Calculate the CurrentDensity from right to left going states at the Fermi level. Plot the current density in the x-z plane as a contour plot:

from QuantumATK import *

# Calculate the current density at the fermi level from right to left going states
cd = CurrentDensity(
configuration,
energies = [0.0]*eV,
energy_weights = Right,
kpoints=MonkhorstPackGrid(1,11),
)

# Calculate the volume element
dX, dY, dZ = cd.volumeElement()
dx = dX.norm()
dy = dY.norm()
dz = dZ.norm()

# Calculate the current density along z integrated over x,y
shape = cd.shape()
# Take out spin up (index 0) z component (index 2) in every grid point.
cd_z = numpy.array( [ [ [ cd[i,j,k][0][2] for k in range(shape[2])] for j in range(shape[1])] for i in range(shape[0]) ] )

# Sum across y dimensions
cd_xz = numpy.array([ [cd_z[i,:,k].sum() * dy for k in range(shape[2])] for i in range(shape[0] )] )

# Make 2-d arrays for contour plot of the data
shape = cd.shape()
x = dx.inUnitsOf(Ang)*numpy.arange(shape[0])
z = dz.inUnitsOf(Ang)*numpy.arange(shape[2])
Z, X = numpy.meshgrid(z,x)
F = numpy.array(cd_xz).reshape(numpy.shape(Z))

#plot the current density in the (z,x) plane
import pylab
pylab.xlabel('z (Angstrom)',fontsize=12,family='sans-serif')
pylab.ylabel('x (Angstrom)',fontsize=12,family='sans-serif')
pylab.contourf(Z, X, F)
pylab.colorbar()
pylab.savefig('cd.png',dpi=100)
pylab.show()


current_density2.py

## Notes¶

The current density is given by

${\bf J}(r) = -\frac{e \hbar}{4 \pi m } \int dE \sum_{\mu, \nu} D_{\mu, \nu}(E) \phi_\nu(r) {\bf \nabla} \phi_\mu(r) (f_L(E) - f_R(E)),$

where $$D(E) = G(E) \, \Gamma_{L/R}(E) \, G^\dagger(E)$$, $$\phi_{\nu/\mu}(r)$$ are atomic basis orbitals, and $$f_{L/R}(E)$$ are the left and right Fermi functions. $$G$$ is the retarded Green function, $$\Gamma_{L/R}$$ the broadening function from either left or right electrode [LWWW08].

• The positive current direction is from left to right (corresponding to electron propagation from right to left).
• Through the energy_weights keyword, it is possible for the user to define the spectral weight $$w(E)=f_{R}(E) - f_{L}(E)$$. This is particular useful when using the current density to analyze zero bias calculations. Setting the energy weights to Right is a short cut for setting the energy_weights to 1 for all states Setting the energy weights to Left is short cut for setting the energy_weights to -1 for all states. Note that a positive weight corresponds to calculating right to left going modes (positive current) while a negative weight corresponds to calculating left to right going modes (negative current).
• The current density does not include the non-local potential correction [LWWW08] and spill in contributions from the electrodes. Thus, the area integrated current density is not constant along z but has a small fluctuating component from the non-local potential and larger errors near the electrodes from spill in components.

 [LWWW08] (1, 2) C. Li, L. Wan, Y. Wei, and J. Wang. Definition of current density in the presence of a non-local potential. Nanotechnology, 19(15):155401, 2008. URL: http://stacks.iop.org/0957-4484/19/i=15/a=155401.