def _get_inter_grid(hw_isol, r_coarse, ngrid, ncell_grad=2):
    """ 
    Find the half-width and r_fine for an intermediate grid that guarantees
    that particles within the central hw_isol box will *not* be ghosts of the
    particles outside the box (i.e. they are completely excluded from that
    calculation)

    hw_isol        - half-width from centre which is excluded from outer region
    r_coarse       - force-splitting scale of the coarse grid
    ngrid          - number of grid cells (per dimension)
    [ncell_grad=2] - 5 point gradient uses 2 cells either side, so we need this 
                     buffer to avoid periodicity

    returns box_hw, dx, r_B
    box_hw   - half width of box
    dx       - size of single cell
    r_B      - hw in which force is calculated via this grid (outside is ghosts)

    Illustration of one corner of the intermediate force grid:
    
    -->| hw_isol
    ---------->| hw_isol + r_coarse
    ------------------>| hw_isol + 2*r_coarse
    -------------------->| box_hw := hw_isol + 2*r_coarse + ncell_grad * dx / 2
    A A B B B B C C C C .
    A A B B B B C C C C .
    B B B B B B C C C C .
    B B B B B B C C C C .
    B B B B B B C C C C .
    B B B B B B C C C C .
    C C C C C C C C C C .
    C C C C C C C C C . .
    C C C C C C C C . . .
    C C C C C C C . . . .
    . . . . . . . . . . .

    where dx is given by box_hw / (0.5 * ngrid)
    

    Zone . - empty cells just there as a buffer (for 5-point gradient)
    Zone C - contains 'ghost' particles for correct force on B, but whose force calculated elsewhere
    Zone B - Forces calculated here, but are also the ghosts for particles in C
    Zone A - Forces calculated here and only here
    """

    ncell_grad = 2 


    r_A = hw_isol # particles which will *only* have force calculations from short+med+long
    r_B = r_A + r_coarse # Zone B - these particles have short+med+long forces, but they are also the ghosts of particles in C, so they will be used outside too
    r_C = r_B + r_coarse # Zone C - these particles are just here as 'ghosts' to get the force on B correct
    hw = ngrid * r_C  / (ngrid - ncell_grad) # need an extra buffer to account for periodicity when doing displacement
    dx = 2 * hw / ngrid
    
    if hw>=0.5:
        raise Exception('Isolated box %.3f times bigger than periodic box (should be smaller)'%(hw*2))
    return hw, dx, r_B