def METHOD_NAME(unit_cell, T0, nimgs):
    T0 = numpy.asarray(T0)
    atom = []
    for n in range(-nimgs, nimgs+1):
        for i in range(unit_cell.natm):
            atom.append((unit_cell.atom_symbol(i), unit_cell.atom_coord(i)+n*T0))
    molN = unit_cell.copy()
    molN.atom = atom
    molN.build(0, 0)
    nao1 = unit_cell.nao_nr()
    naoN = molN.nao_nr()
    c = numpy.eye(nao1)
    c = numpy.vstack([c]*(nimgs*2+1))
    def energy_nuc(mol):
        Ts = numpy.array([T0*i for i in range(-nimgs, nimgs+1)])
        chargs = mol.atom_charges()
        coords = mol.atom_coords()
        enuc = 0
        for i, qi in enumerate(chargs):
            ri = coords[i]
            for j, qj in enumerate(chargs):
                rj = coords[j]
                r1 = ri-rj + Ts
                r = numpy.sqrt(numpy.einsum('ji,ji->j', r1, r1))
                r[r<1e-7] = 1e200
                enuc += (qi * qj / r).sum()
        return enuc * 0.5
    def madelung(nimgs):
        e = 0
        t = numpy.linalg.norm(T0)
        for j in range(nimgs*2+1):
            if j != nimgs:
                e += 1. / abs(t*(nimgs-j))
        return -e
    enuc = energy_nuc(unit_cell)
    mad = madelung(nimgs)
    lib.logger.debug(unit_cell, 'Enuc = %s  Madelung const = %s', enuc, mad)