kin = 0.5*np.sum(v**2) / n
    print("{:40}{:15.6f}".format('Kinetic energy',kin) )

if np.fabs(delta_rho) < tol and np.fabs(delta_kin) < tol:
    print('No changes requested')
else:
    if np.fabs(delta_rho) > tol:
        assert rho+delta_rho > 0.0, 'New requested density would be negative'
        scale = ( rho / (rho+delta_rho) )**(1.0/3.0)
        box   = box * scale
        r     = r * scale
        rho   = n / box**3
        print("{:40}{:15.6f}".format('Density',rho) )
    if np.fabs(delta_kin) > tol:
        assert kin+delta_kin > 0.0, 'New requested kinetic energy would be negative'
        scale  = np.sqrt ( (kin+delta_kin) / kin )
        v      = v * scale
        kin    = 0.5*np.sum(v**2) / n
        print("{:40}{:15.6f}".format('New kinetic energy',kin) )

    if atomic:
        if velocities:
            write_cnf_atoms ( filename, n, box, r, v )
        else:
            write_cnf_atoms ( filename, n, box, r )
    else:
        if velocities:
            write_cnf_mols ( filename, n, box, r, e, v, w )
        else:
            write_cnf_mols ( filename, n, box, r, e )
        zeta = 2.0 * zeta - 1.0  # Now in range (-1,+1)
        box_scale = np.exp(zeta *
                           db_max)  # Sampling log(box) and log(vol) uniformly
        box_new = box * box_scale  # New box (in sigma units)
        den_scale = 1.0 / box_scale**3  # Density scaling factor

        if not overlap(box_new, r,
                       e):  # Test for non-overlapping configuration
            delta = pressure * (box_new**3 - box**3
                                )  # PV term (temperature = 1.0 )
            delta = delta + (n + 1) * np.log(
                den_scale)  # Factor (n+1) consistent with log(box) sampling
            if metropolis(delta):  # Accept Metropolis test
                box = box_new  # Update box
                v_ratio = 1.0  # Set move counter

        blk_add(calc_variables())

    blk_end(blk)  # Output block averages
    sav_tag = str(blk).zfill(
        3) if blk < 1000 else 'sav'  # Number configuration by block
    write_cnf_mols(cnf_prefix + sav_tag, n, box, r * box,
                   e)  # Save configuration

run_end(calc_variables())

assert not overlap(box, r, e), 'Overlap in final configuration'

write_cnf_mols(cnf_prefix + out_tag, n, box, r * box, e)  # Save configuration
conclusion()