c_ratio = 0.0
run_begin(calc_variables())

for blk in range(1, nblock + 1):  # Loop over blocks

    blk_begin()

    for stp in range(nstep):  # Loop over steps

        r_moves = 0
        c_moves = 0

        for i in range(n):  # Loop over atoms

            # Centre of mass move
            dc = random_translate_vector(dc_max / box,
                                         np.zeros(3, dtype=np.float_))
            partial_old = PotentialType(0.0, 0.0, False)
            partial_new = PotentialType(0.0, 0.0, False)
            for k in range(p):  # Loop over ring polymer indices
                rkj = np.delete(r[k, :, :], i,
                                0)  # Array of all other atoms for this k
                partial_old = partial_old + potential_1(
                    r[k, i, :], box, r_cut, rkj,
                    p)  # Old atom classical potential etc
                rki = r[k, i, :] + dc
                rki = rki - np.rint(rki)
                partial_new = partial_new + potential_1(
                    rki, box, r_cut, rkj,
                    p)  # New atom classical potential etc
            assert not partial_old.ovr, 'Overlap in current configuration'
            if not partial_new.ovr:  # Test for non-overlapping configuration
        ntry = n  # Each step consists of ntry tries (during which N might vary)

        for itry in range(ntry):

            zeta = np.random.rand()  # Uniform random number in range (0,1)

            if zeta < prob_move:
                m_try = m_try + 1
                i = np.random.randint(n)  # Choose moving particle at random
                rj = np.delete(r, i, 0)  # Array of all the other atoms
                partial_old = potential_1(r[i, :], box, r_cut,
                                          rj)  # Old atom potential, virial etc
                assert not partial_old.ovr, 'Overlap in current configuration'

                ri = random_translate_vector(
                    dr_max / box,
                    r[i, :])  # Trial move to new position (in box=1 units)
                ri = ri - np.rint(ri)  # Periodic boundary correction
                partial_new = potential_1(ri, box, r_cut,
                                          rj)  # New atom potential, virial etc

                if not partial_new.ovr:  # Test for non-overlapping configuration
                    delta = partial_new.pot - partial_old.pot  # Use cut (but not shifted) potential
                    delta = delta / temperature

                    if metropolis(delta):  # Accept Metropolis test
                        total = total + partial_new - partial_old  # Update total values
                        r[i, :] = ri  # Update position
                        m_acc = m_acc + 1  # Increment move counter

            elif zeta < prob_move + prob_create:  # Try create