  It is known that if $p$ is a sufficiently large prime then for every function
$f:\mathbb{Z}_p\to [0,1]$ there exists a continuous function on the circle
$f':\mathbb{T}\to [0,1]$ such that the averages of $f$ and $f'$ across any
prescribed system of linear forms of complexity 1 differ by at most $\epsilon$.
This result follows from work of Sisask, building on Fourier-analytic arguments
of Croot that answered a question of Green. We generalize this result to
systems of complexity at most 2, replacing $\mathbb{T}$ with the torus
$\mathbb{T}^2$ equipped with a specific filtration. To this end we use a notion
of modelling for filtered nilmanifolds, that we define in terms of
equidistributed maps, and we combine this with tools of quadratic Fourier
analysis. Our results yield expressions on the torus for limits of
combinatorial quantities involving systems of complexity 2 on $\mathbb{Z}_p$.
For instance, let $m_4(\alpha,\mathbb{Z}_p)$ denote the minimum, over all sets
$A\subset \mathbb{Z}_p$ of cardinality at least $\alpha p$, of the density of
4-term arithmetic progressions inside $A$. We show that $\lim_{p\to \infty}
m_4(\alpha,\mathbb{Z}_p)$ is equal to the infimum, over all measurable
functions $f:\mathbb{T}^2\to [0,1]$ with $\int_{\mathbb{T}^2}f\geq \alpha$, of
the following integral: $$ \int_{\mathbb{T}^5} f\binom{x_1}{y_1}\;
f\binom{x_1+x_2}{y_1+y_2}\;
  f\binom{x_1+2x_2}{y_1+2y_2+y_3}\; f\binom{x_1+3 x_2}{y_1+3y_2+3y_3}
\,d\mu_{\mathbb{T}^5}(x_1,x_2,y_1,y_2,y_3). $$
