<commit_before>package etomica.action;
import etomica.Atom;
import etomica.Space;
import etomica.data.DataSourceVelocityAverage;
import etomica.space.Vector;

/**
 * Sets the velocity of an atom to a specified vector value.  If applied
 * to a molecule, works with the average velocity of the atoms it comprises.
 */
public class AtomActionAccelerateTo extends AtomActionAdapter {
    
    private final Vector dr;
    private final Vector targetVelocity;
    private final AtomGroupAction atomAccelerator;
    private final AtomGroupAction velocityMeter;

    /**
     * Creates new action with atom position defined by its
     * center of mass (via DataSourceCOM).
     * @param space
     */
    public AtomActionAccelerateTo(Space space) {
        dr = space.makeVector();
        targetVelocity = space.makeVector();
        atomAccelerator = new AtomGroupAction(new AtomActionAccelerateBy(space));
        velocityMeter = new AtomGroupAction(new DataSourceVelocityAverage(space));
    }
    
    public void actionPerformed(Atom atom) {
        velocityMeter.actionPerformed(atom);
        Vector currentVelocity = ((DataSourceVelocityAverage)velocityMeter.getAction()).getVelocityAverage();
        dr.Ev1Mv2(targetVelocity, currentVelocity);
        ((AtomActionAccelerateBy)atomAccelerator.getAction()).setAccelerationVector(dr);
        atomAccelerator.actionPerformed(atom);
    }
       
    /**
     * @return Returns the targetVelocity, the velocity that the
     * atom will be accelerated to by this action.
     */
    public Vector getTargetVelocity() {
        return targetVelocity;
    }<commit_msg>fix up comments<commit_after>package etomica.action;
import etomica.Atom;
import etomica.Space;
import etomica.data.DataSourceVelocityAverage;
import etomica.space.ICoordinateKinetic;
import etomica.space.Vector;

/**
 * Sets the velocity of an atom to a specified vector value.  If applied
 * to a molecule, works with the mass-averaged velocity of the atoms it comprises,
 * and adds a constant velocity to all atoms to make the mass-averaged velocity
 * equal a target value.
 */
public class AtomActionAccelerateTo extends AtomActionAdapter {
    
    private final Vector dr;
    private final Vector targetVelocity;
    private final AtomGroupAction atomAccelerator;
    private final AtomGroupAction velocityMeter;

    /**
     * Creates new action with target velocity equal to zero.
     */
    public AtomActionAccelerateTo(Space space) {
        dr = space.makeVector();
        targetVelocity = space.makeVector();
        atomAccelerator = new AtomGroupAction(new AtomActionAccelerateBy(space));
        velocityMeter = new AtomGroupAction(new DataSourceVelocityAverage(space));
    }
    
    /**
     * Adds velocity vector to the atom (or to all atoms forming it) 
     * so that its mass-average velocity equals the target velocity.
     */
    public void actionPerformed(Atom atom) {
        if(atom.type.isLeaf()) {
            ((ICoordinateKinetic)atom.coord).velocity().E(targetVelocity);
        } else {
            velocityMeter.actionPerformed(atom);
            Vector currentVelocity = ((DataSourceVelocityAverage)velocityMeter.getAction()).getVelocityAverage();
            dr.Ev1Mv2(targetVelocity, currentVelocity);
            ((AtomActionAccelerateBy)atomAccelerator.getAction()).setAccelerationVector(dr);
            atomAccelerator.actionPerformed(atom);
        }
    }
       
    /**
     * @return Returns the targetVelocity, the mass-average velocity that the
     * atom will be accelerated to by this action.
     */
    public Vector getTargetVelocity() {
        return targetVelocity;
    }
{'fraction_non_alphanumeric': 0.07736468015308912, 'fraction_numerical': 0.0010934937124111536, 'mean_word_length': 3.3250591016548463, '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': '7308992', 'n_tokens_mistral': 1018, 'n_tokens_neox': 988, 'n_words': 281}