<commit_before>package etomica.integrator.mcmove;

import etomica.atom.AtomLeaf;
import etomica.atom.AtomSource;
import etomica.atom.iterator.AtomIterator;
import etomica.atom.iterator.AtomIteratorSinglet;
import etomica.data.meter.MeterPotentialEnergy;
import etomica.phase.Phase;
import etomica.potential.PotentialMaster;
import etomica.simulation.Simulation;
import etomica.space.ICoordinateAngular;
import etomica.space.Orientation;

/**
 * Performs a rotation of an atom (not a molecule) that has an orientation coordinate.
 */
public class MCMoveRotate extends MCMovePhaseStep {
    
    private static final long serialVersionUID = 2L;
    private MeterPotentialEnergy energyMeter;
    private final AtomIteratorSinglet affectedAtomIterator = new AtomIteratorSinglet();
    private final Orientation oldOrientation;
    private AtomSource atomSource;

    private transient AtomLeaf molecule;
    private transient double uOld;
    private transient double uNew = Double.NaN;
    private transient Orientation orientation;

    public MCMoveRotate(Simulation sim) {
        this(sim.getPotentialMaster());
    }
    
    public MCMoveRotate(PotentialMaster potentialMaster) {
        super(potentialMaster);
        energyMeter = new MeterPotentialEnergy(potentialMaster);
        oldOrientation = potentialMaster.getSpace().makeOrientation();
        setStepSizeMax(Math.PI);
        setStepSizeMin(0.0);
        setStepSize(Math.PI/2.0);
        perParticleFrequency = true;
        energyMeter.setIncludeLrc(false);
    }
    
    /**
     * Sets the AtomSource used to select Atoms acted on by MC trials.
     */
    public void setAtomSource(AtomSource newAtomSource) {
        atomSource = newAtomSource;
    }
     
    /**
     * Sets the AtomSource used to select Atoms acted on by MC trials.
     */
    public AtomSource getAtomSource() {
        return atomSource;
    }
     
    public boolean doTrial() {
        if(phase.moleculeCount()==0) {return false;}
        molecule = (AtomLeaf)atomSource.getAtom();

        energyMeter.setTarget(molecule);
        uOld = energyMeter.getDataAsScalar();
        orientation = ((ICoordinateAngular)molecule.getCoord()).getOrientation(); 
        oldOrientation.E(orientation);  //save old orientation
        orientation.randomRotation(stepSize);
        uNew = Double.NaN;
        return true;
    }//end of doTrial
    
    public double getA() {return 1.0;}
    
    public double getB() {
        energyMeter.setTarget(molecule);
        uNew = energyMeter.getDataAsScalar();
        return -(uNew - uOld);
    }
    
    public void acceptNotify() {  /* do nothing */}
    
    public void rejectNotify() {
        orientation.E(oldOrientation);
    }

    public double energyChange() {return uNew - uOld;}
    
    public final AtomIterator affectedAtoms() {
        affectedAtomIterator.setAtom(molecule);
        affectedAtomIterator.reset();
        return affectedAtomIterator;
    }
    
    public void setPhase(Phase p) {
        super.setPhase(p);
        energyMeter.setPhase(p);
    }
}
<commit_msg>fix comment<commit_after>package etomica.integrator.mcmove;

import etomica.atom.AtomLeaf;
import etomica.atom.AtomSource;
import etomica.atom.iterator.AtomIterator;
import etomica.atom.iterator.AtomIteratorSinglet;
import etomica.data.meter.MeterPotentialEnergy;
import etomica.phase.Phase;
import etomica.potential.PotentialMaster;
import etomica.simulation.Simulation;
import etomica.space.ICoordinateAngular;
import etomica.space.Orientation;

/**
 * Performs a rotation of an atom (not a molecule) that has an orientation coordinate.
 */
public class MCMoveRotate extends MCMovePhaseStep {
    
    private static final long serialVersionUID = 2L;
    private MeterPotentialEnergy energyMeter;
    private final AtomIteratorSinglet affectedAtomIterator = new AtomIteratorSinglet();
    private final Orientation oldOrientation;
    private AtomSource atomSource;

    private transient AtomLeaf molecule;
    private transient double uOld;
    private transient double uNew = Double.NaN;
    private transient Orientation orientation;

    public MCMoveRotate(Simulation sim) {
        this(sim.getPotentialMaster());
    }
    
    public MCMoveRotate(PotentialMaster potentialMaster) {
        super(potentialMaster);
        energyMeter = new MeterPotentialEnergy(potentialMaster);
        oldOrientation = potentialMaster.getSpace().makeOrientation();
        setStepSizeMax(Math.PI);
        setStepSizeMin(0.0);
        setStepSize(Math.PI/2.0);
        perParticleFrequency = true;
        energyMeter.setIncludeLrc(false);
    }
    
    /**
     * Sets the AtomSource used to select Atoms acted on by MC trials.
     */
    public void setAtomSource(AtomSource newAtomSource) {
        atomSource = newAtomSource;
    }
     
    /**
     * Returns the AtomSource used to select Atoms acted on by MC trials.
     */
    public AtomSource getAtomSource() {
        return atomSource;
    }
     
    public boolean doTrial() {
        if(phase.moleculeCount()==0) {return false;}
        molecule = (AtomLeaf)atomSource.getAtom();

        energyMeter.setTarget(molecule);
        uOld = energyMeter.getDataAsScalar();
        orientation = ((ICoordinateAngular)molecule.getCoord()).getOrientation(); 
        oldOrientation.E(orientation);  //save old orientation
        orientation.randomRotation(stepSize);
        uNew = Double.NaN;
        return true;
    }//end of doTrial
    
    public double getA() {return 1.0;}
    
    public double getB() {
        energyMeter.setTarget(molecule);
        uNew = energyMeter.getDataAsScalar();
        return -(uNew - uOld);
    }
    
    public void acceptNotify() {  /* do nothing */}
    
    public void rejectNotify() {
        orientation.E(oldOrientation);
    }

    public double energyChange() {return uNew - uOld;}
    
    public final AtomIterator affectedAtoms() {
        affectedAtomIterator.setAtom(molecule);
        affectedAtomIterator.reset();
        return affectedAtomIterator;
    }
    
    public void setPhase(Phase p) {
        super.setPhase(p);
        energyMeter.setPhase(p);
    }
}

{'fraction_non_alphanumeric': 0.0869988638208083, 'fraction_numerical': 0.0025969810095763674, 'mean_word_length': 3.0221932114882506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7048377', 'n_tokens_mistral': 1850, 'n_tokens_neox': 1771, 'n_words': 405}