  We propose a general approach to the higher-order homogenization of discrete
elastic networks made up of linear elastic beams or springs in dimension 2 or
3. The network may be nearly (rather than exactly) periodic: its elastic and
geometric properties are allowed to vary slowly in space, in addition to being
periodic at the scale of the unit cell. The reference configuration may be
prestressed. A homogenized strain energy depending on both the macroscopic
strain $\boldsymbol{\varepsilon}$ and its gradient $\nabla
\boldsymbol{\varepsilon}$ is obtained by means of a two-scale expansion. The
homogenized energy is asymptotically exact two orders beyond that obtained by
classical homogenization. The homogenization method is implemented in a
symbolic calculation language and applied to various types of networks, such as
a 2D honeycomb, a 2D Kagome lattice, a 3D truss and a 1D pantograph. It is
validated by comparing the predictions of the microscopic displacement to that
obtained by full, discrete simulations. This second-order method remains highly
accurate even when the strain gradient effects are significant, such as near
the lips of a crack tip or in regions where a gradient of pre-strain is
imposed.
