  We report on our efforts to optimize the geometry of neutron moderators and
converters for the TRIUMF UltraCold Advanced Neutron (TUCAN) source using MCNP
simulations. It will use an existing spallation neutron source driven by a 19.3
kW proton beam delivered by TRIUMF's 520 MeV cyclotron. Spallation neutrons
will be moderated in heavy water at room temperature and in liquid deuterium at
20 K, and then superthermally converted to ultracold neutrons in superfluid,
isotopically purified $^4$He. The helium will be cooled by a $^3$He fridge
through a $^3$He-$^4$He heat exchanger. The optimization took into account a
range of engineering and safety requirements and guided the detailed design of
the source. The predicted ultracold-neutron density delivered to a typical
experiment is maximized for a production volume of 27 L, achieving a production
rate of $1.4 \cdot 10^7$ s$^{-1}$ to $1.6 \cdot 10^7$ s$^{-1}$ with a heat load
of 8.1 W. At that heat load, the fridge can cool the superfluid helium to 1.1
K, resulting in a storage lifetime for ultracold neutrons in the source of
about 30 s. The most critical performance parameters are the choice of cold
moderator and the volume, thickness, and material of the vessel containing the
superfluid helium. The source is scheduled to be installed in 2021 and will
enable the TUCAN collaboration to measure the electric dipole moment of the
neutron with a sensitivity of $10^{-27}$ e cm.
