  Optical second harmonic generation is a second-order nonlinear process that
combines two photons of a given frequency into a third photon at twice the
frequency. Due to the symmetry constraints, it is widely used as a sensitive
probe to detect broken inversion symmetry and local polar order. Analytical
modeling of the electric-dipole SHG response is essential to extract
fundamental properties of materials from experiments. However, complexity
builds up dramatically in the analytical model when the probed crystal is of a
low bulk crystal symmetry, with a low-symmetry surface orientation, exhibits
absorption and dispersion, and consists of multiple interfaces. As a result,
there is a largely uneven landscape in the literature on the SHG modeling of
new materials, involving numerous approximations and a wide range of
(in)accuracies, leading to a rather scattered dataset of reported SHG nonlinear
susceptibility. Towards streamlining the reliability and accuracy of this
process, we have developed an open-source package called the Second Harmonic
Analysis of Anisotropic Rotational Polarimetry (SHAARP) which derives
analytical solutions and performs numerical simulations of reflection SHG from
a single interface for homogeneous crystals. Five key generalizations in SHG
modeling are implemented, including all crystal symmetries down to triclinic,
any crystal orientation, complex dielectric tensor (refractive indices) with
frequency dispersion, and general polarization states of the light. SHAARP
enables accurate anisotropic modeling of SHG response for a broad range of
materials systems. The method is extendible to multiple interfaces. The code is
free to download from https://github.com/Rui-Zu/SHAARP
