Energy density inside anisotropic materials I'm taking some college courses on electromagnetism and there was some talk of energy stored by electromagnetic field and its density. The expression that we use to calculate energy density stored by electric field is was $\mathbf{E \cdot D}  /  2$ . However, reading my textbook it's unclear whether this expression applies to anisotropic materials too? 
 A: Yes, provided that the medium is linear. If the result applied only to isotropic media, it would not need to be expressed in terms of a dot product, because D would always be parallel to E.
Let a negative charge $-q$ have position vector ${\bf r}$, and let a positive charge $q$ have position vector ${{\bf r}+\boldsymbol{\ell}}$, so that $\boldsymbol{\ell}$ is the spatial displacement vector from $-q$ to $q$. These equal and opposite charges together constitute an electric dipole, whose dipole moment is defined as
\begin{equation}
  {\bf p} = q\boldsymbol{\ell} \,.
\end{equation}
Suppose that the dipole is immersed in an electric field ${\bf E}$. Let the position of $-q$ change by $d{\bf r}$, and let the position of $q$ change by ${d{\bf r}+d\boldsymbol{\ell}}$, so that the spatial displacement between them changes by $d\boldsymbol{\ell}$. Then the work done by the field on the charges is
\begin{equation}
  dW = q{\bf E}\cdot(d{\bf r}+d\boldsymbol{\ell}) - q{\bf E}\cdot d{\bf r}
     = q{\bf E}\cdot d\boldsymbol{\ell}
     = {\bf E}\cdot d(q\boldsymbol{\ell})
     = {\bf E}\cdot d{\bf p} \,,
\end{equation}
where $d{\bf p}$ is the change in the dipole moment. The corresponding change in potential energy is the work done against the field, which is
\begin{equation}\tag{1}
  -dW = -{\bf E}\cdot d{\bf p} \,.
\end{equation}
The electric displacement field ${\bf D}$ may be defined as minus the applied electric dipole moment per unit volume that would suffice to produce the ${\bf E}$ field. (See the Appendix for the more usual definition. I say "would suffice" because ${\bf E}$ and the associated ${\bf D}$ can also be induced by a changing magnetic field; but we ignore that option here.) Hence ${\bf D}$ has the dimension of charge times distance per unit volume, or charge per unit area (surface charge density). Indeed, if the applied dipole moment per unit volume is uniform throughout the volume, the internal changes cancel out, but at the outer surface the unmatched ends of the dipoles form a surface charge density. In practice, then, to "apply" the dipole moment per unit volume is to apply that surface charge density.
So, on a per-unit-volume basis, and accounting for the "minus" in the definition of ${\bf D}$, the stored energy given by (1) becomes
\begin{equation}\tag{2}
  dU_{\rm e} = {\bf E}\cdot d{\bf D} \,,
\end{equation}
where $U_{\rm e}$ is the energy density (energy per unit volume) of the electric field. To find the total $U_{\rm e}$, we may suppose for convenience that we build up the magnitude of ${\bf D}$ while maintaining its direction. Then $d{\bf D}$ is in the direction of ${\bf D}$, so that ${\bf E}$ in the dot product can be replaced by ${\bf E_D}$, meaning the projection of ${\bf E}$ on $d{\bf D}$ and ${\bf D}$. If the medium is linear, we can further substitute
\begin{equation}
  {\bf E_D} = k{\bf D} \,,
\end{equation}
where $k$ is constant for a given location and direction. So (2) becomes
\begin{equation}
  dU_{\rm e} = k{\bf D}\cdot d{\bf D}
             = d\Big(\tfrac{1}{2}k{\bf D}\cdot{\bf D}\Big)
             =d\Big(\tfrac{1}{2}{\bf E_D}\cdot{\bf D}\Big)
             =d\Big(\tfrac{1}{2}{\bf E}\cdot{\bf D}\Big) \,.
\end{equation}
Choosing the constant of integration so that a zero field has no energy, we find that the energy density of the electric field is
\begin{equation}\tag{3}
  U_{\rm e} = \tfrac{1}{2}{\bf E}\cdot{\bf D} \,.
\end{equation}
If the medium is not only linear but also isotropic, we can write ${{\bf D}=\epsilon{\bf E}}$, where $\epsilon$ is a scalar (called the permittivity of the medium). Then, if $E$ and $D$ are the magnitudes of ${\bf E}$ and ${\bf D}$, we have
\begin{equation}
  U_{\rm e} = \tfrac{1}{2} ED = \tfrac{1}{2}\epsilon E^2
            = \frac{\,D^2}{2\epsilon} \qquad \text{(isotropic medium).}
\end{equation}
But (3) is more general because it assumes only that the medium is linear.
Appendix
In a dielectric medium, the applied dipole is partly offset by induced dipoles in the medium, which produce a "bound" surface charge that partly offsets the applied ("free") surface charge, causing $\big|{\bf E}\big|$ to be less than it would be if the same ${\bf D}$ were applied in a vacuum. If the induced dipole moment per unit volume is ${\bf P}$ (called the "polarization" vector), then ${\bf D}$ is effectively replaced by ${\bf D}-{\bf P}$, which we might call the “net” displacement. This is the displacement “applied” to a vacuum and is therefore equal to $\epsilon_0{\bf E}$, where $\epsilon_0$ is the permittivity of the vacuum. Solving for ${\bf D}$ gives
\begin{equation}
{\bf D} = \epsilon_0{\bf E} + {\bf P} \,,
\end{equation}
which is the usual definition.
(Erratum: This appendix originally referred to ${\bf D}-{\bf P}$ as the net dipole moment per unit volume, whereas in fact it is minus the net dipole moment per unit volume; compare the “minus” in the definition of ${\bf D}$. The corrected text refers to the quantity replacing ${\bf D}$, which I hope is less confusing.)
(Disclosure: The above answer is an edited version of a passage in a book that I'm working on.)
A: No it does not. The formula you wrote is valid only for isotropic material. 
In general for an unit volume of material (irrespective of whether it is isotropic or not), the stored-energy is given by-
$U=\int \vec{E}.d\vec{D}$
If you carryout this integral you will end up with the area under $D-E$ curve. For isotropic materials $D$ vs $E$ relation is linear therefore area under the curve is nothing but the area of the triangle (see the figure below). That gives you $U=|\vec{E}||\vec{D}|/2$. (Again, be careful about vector and its magnitude).
However energy density in non-linear medium like Ferroelectric (FE) and Antiferroelectric (AFE) is quite different.

