def get_D_square_min(atoms_now, atoms_old, i_now, j_now, delta_plus_epsilon=None):
nat = len(atoms_now)<EOL>assert len(atoms_now) == len(atoms_old)<EOL>pos_now = atoms_now.positions<EOL>pos_old = atoms_old.positions<EOL>dr_now = mic(pos_now[i_now] - pos_now[j_now], atoms_now.cell)<EOL>dr_old = mic(pos_old[i_now] - pos_old[j_now], atoms_old.cell)<EOL>assert dr_now.shape == dr_old.shape<EOL>if delta_plus_epsilon is None:<EOL><INDENT>delta_plus_epsilon = get_delta_plus_epsilon(nat, i_now, dr_now, dr_old)<EOL><DEDENT>delta_plus_epsilon_n = delta_plus_epsilon[i_now]<EOL>d_sq_n = np.sum(<EOL>(<EOL>dr_now-<EOL>np.sum(delta_plus_epsilon_n.reshape(-<NUM_LIT:1>,<NUM_LIT:3>,<NUM_LIT:3>)*dr_old.reshape(-<NUM_LIT:1>,<NUM_LIT:1>,<NUM_LIT:3>),<EOL>axis=<NUM_LIT:2>)<EOL>)**<NUM_LIT:2>,<EOL>axis=<NUM_LIT:1>)<EOL>d_sq = np.bincount(i_now, weights=d_sq_n)<EOL>return delta_plus_epsilon, d_sq<EOL>
Calculate the D^2_min norm of Falk and Langer