def correction(self, it, pair):
        # Compute force table based on current iteration.
        rdf = distribution.iteration_rdf_files(it, pair)
        # Appends new force, energy, distance, table.
        self.compute(distribution.average_rdf(rdf))

        # Computes the correction to the force.
        df = self.force[-1] - self.force[0]
        self.force[-1] = self.force[-2] - df

        # Need to reintegrate energy
        rr = self.distance[-1]
        ff = self.force[-1]
        ff = smooth_force(rr, ff, len(self.force))[0]
        self.energy[-1] = -simpson_integrate(rr[::-1], ff[::-1])[::-1]
        self.energy[-1] -= self.energy[-1][-1]
    def __init__(self, md_temp, md_rdf):

        # Sets the temperature of the all-atom simulation.
        self.temperature  = md_temp 

        # Sets the smallest distance in the pair table.
        # If LAMMPS simulations crash with pair cutoff error, this needs to be smaller.
        self.min_distance = 0.00001
        self.npts = 1000

        # Pair force correct per unit pressure.
        self.pfactor = 1.0/5000.0
        self.last_p_error = 0.0

        # Computes the average distribution functions for the all-atom case.
        self.all_atom_rdf = distribution.average_rdf(distribution.md_rdf_files())

        # Initializes the pair tables as empty lists.        
        self.distance  = []
        self.force     = []
        self.energy    = []

        # Computes the initial potential with the all-atom data.
        self.allatomcompute(self.all_atom_rdf)