  We have developed a numerical method for calculating the second harmonic
generation (SHG) generated by an anisotropic material whose optical properties
present an arbitrary modulation in one dimension. The method is based on the
Berreman 4x4 matrix formalism, which is generalized to include nonlinear
optical phenomena. It can be used under oblique incidences of the input beam,
and is valid even when the SHG frequency is close to photonic bands, where the
usual slowly-varying-amplitude approximation breaks down. As an example of
application, we have studied the SHG performance of ferroelectric and
helielectric nematic liquid crystals. The latter present a helicoidal structure
that can be distorted under electric field. In the different tests of the
method we have analyzed the conditions for the most efficient SHG, and compared
with previous results in the case there were any. The obtained results indicate
that the present procedure may contribute to improve the structural design and
enlarge the variety of nonlinear optical materials for their application in
optical devices.
