  We present a scheme for engineering the joint spectrum of photon pairs
created via spontaneous parametric down conversion. Our method relies on
customizing the poling configuration of a quasi-phase-matched crystal. We use
simulated annealing to find an optimized poling configuration which allows
almost arbitrary shaping of the crystal's phase-matching function. This has
direct application in the creation of pure single photons---currently one of
the most important goals of single-photon quantum optics. We describe the
general algorithm and provide code, written in C++, that outputs an optimized
poling configuration given specific experimental parameters.
