PT Journal AU Figueroa, DG Florio, A Torrenti, F Valkenburg, W TI The art of simulating the early universe. Part I. Integration techniques and canonical cases SO Journal of Cosmology and Astroparticle Physics JI J. Cosmol. Astropart. Phys. PY 2021 BP 035 EP 108pp VL 04 IS 4 DI 10.1088/1475-7516/2021/04/035 LA English DE particle physics – cosmology connection; physics of the early universe; cosmological phase transitions; inflation AB We present a comprehensive discussion on lattice techniques for the simulation of scalar and gauge field dynamics in an expanding universe. After reviewing the continuum formulation of scalar and gauge field interactions in Minkowski and FLRW backgrounds, we introduce the basic tools for the discretization of field theories, including lattice gauge invariant techniques. Following, we discuss and classify numerical algorithms, ranging from methods of O(delta t(2)) accuracy like staggered leapfrog and Verlet integration, to Runge-Kutta methods up to O(delta t(4)) accuracy, and the Yoshida and Gauss-Legendre higher-order integrators, accurate up to O(delta t(10)) We adapt these methods for their use in classical lattice simulations of the non-linear dynamics of scalar and gauge fields in an expanding grid in 3+1 dimensions, including the case of 'self-consistent' expansion sourced by the volume average of the fields' energy and pressure densities. We present lattice formulations of canonical cases of: i) Interacting scalar fields, ii) Abelian U(1) gauge theories, and iii) Non-Abelian SU(2) gauge theories. In all three cases we provide symplectic integrators, with accuracy ranging from O(delta t(2)) up to O(delta t(10)) For each algorithm we provide the form of relevant observables, such as energy density components, field spectra and the Hubble constraint. We note that all our algorithms for gauge theories always respect the Gauss constraint to machine precision, including when 'self-consistent' expansion is considered. As a numerical example we analyze the post-inflationary dynamics of an oscillating inflaton charged under SU(2) x U(1). We note that the present manuscript is meant to be part of the theoretical basis for the code CosmoLattice, a multi-purpose MPI-based package for simulating the non-linear evolution of field theories in an expanding universe, publicly available at http://www.cosrnolattice.net. ER