<commit_before>package etomica.apps.junit.normalmode;

import junit.framework.TestCase;
import etomica.integrator.mcmove.MCMoveStepTracker;
import etomica.lattice.crystal.Primitive;
import etomica.listener.IntegratorListenerAction;
import etomica.normalmode.MeterNormalMode;
import etomica.normalmode.SimCalcSLJ;
import etomica.normalmode.WaveVectorFactory;
import etomica.normalmode.WaveVectorFactorySimple;
import etomica.normalmode.WriteS;
import etomica.space.Space;

/**
 * Tests calculating S for a simple (low T, low rho) LJ system.
 */
public class SimCalcSLJTest extends TestCase {

    /**
     * @param args
     */
    public static void main(String[] args) {
        new SimCalcSLJTest().testCalcS();
    }
    
    public void testCalcS() {
        // defaults
        int D = 3;
        int nA = 32;
        double density = 1.0;
        double temperature = .186;
        long simSteps = 50000;

        // construct simulation
        SimCalcSLJ sim = new SimCalcSLJ(Space.getInstance(D), nA, density, temperature);

        // set up initial configuration and save nominal positions
        Primitive primitive = sim.primitive;

        // set up normal-mode meter
        MeterNormalMode meterNormalMode = new MeterNormalMode();
        meterNormalMode.setCoordinateDefinition(sim.coordinateDefinition);
        WaveVectorFactory waveVectorFactory;
        waveVectorFactory = new WaveVectorFactorySimple(primitive, sim.getSpace());
        meterNormalMode.setWaveVectorFactory(waveVectorFactory);
        meterNormalMode.setBox(sim.box);

        IntegratorListenerAction meterListener = new IntegratorListenerAction(meterNormalMode);
        meterListener.setInterval(nA);
        sim.integrator.getEventManager().addListener(meterListener);
        
        ((MCMoveStepTracker)sim.integrator.getMoveManager().getMCMoves()[0].getTracker()).setNoisyAdjustment(false);

        sim.activityIntegrate.setMaxSteps(simSteps/10);
        sim.getController().actionPerformed();
        sim.integrator.getMoveManager().setEquilibrating(false);
        sim.getController().reset();
        meterNormalMode.reset();

        WriteS sWriter = new WriteS(sim.getSpace());
        sWriter.setFilename("test");
        sWriter.setOverwrite(true);
        sWriter.setMeter(meterNormalMode);
        sWriter.setWaveVectorFactory(waveVectorFactory);
        sWriter.setTemperature(temperature);
        
        sim.activityIntegrate.setMaxSteps(simSteps);
        sim.getController().actionPerformed();

        sWriter.actionPerformed();
        double A = sWriter.getLastA();
        // A ranges from 46.3 to 46.9, with 46.6 most popular.
        // value from a much longer simulation is 46.3

        assertTrue("harmonic reference free energy within expected limits "+A, Math.abs(A-46.6) < 0.3);
    }
}<commit_msg>update expected free energy based on new FE COM correction term<commit_after>package etomica.apps.junit.normalmode;

import junit.framework.TestCase;
import etomica.integrator.mcmove.MCMoveStepTracker;
import etomica.lattice.crystal.Primitive;
import etomica.listener.IntegratorListenerAction;
import etomica.normalmode.MeterNormalMode;
import etomica.normalmode.SimCalcSLJ;
import etomica.normalmode.WaveVectorFactory;
import etomica.normalmode.WaveVectorFactorySimple;
import etomica.normalmode.WriteS;
import etomica.space.Space;

/**
 * Tests calculating S for a simple (low T, low rho) LJ system.
 */
public class SimCalcSLJTest extends TestCase {

    /**
     * @param args
     */
    public static void main(String[] args) {
        new SimCalcSLJTest().testCalcS();
    }
    
    public void testCalcS() {
        // defaults
        int D = 3;
        int nA = 32;
        double density = 1.0;
        double temperature = .186;
        long simSteps = 50000;

        // construct simulation
        SimCalcSLJ sim = new SimCalcSLJ(Space.getInstance(D), nA, density, temperature);

        // set up initial configuration and save nominal positions
        Primitive primitive = sim.primitive;

        // set up normal-mode meter
        MeterNormalMode meterNormalMode = new MeterNormalMode();
        meterNormalMode.setCoordinateDefinition(sim.coordinateDefinition);
        WaveVectorFactory waveVectorFactory;
        waveVectorFactory = new WaveVectorFactorySimple(primitive, sim.getSpace());
        meterNormalMode.setWaveVectorFactory(waveVectorFactory);
        meterNormalMode.setBox(sim.box);

        IntegratorListenerAction meterListener = new IntegratorListenerAction(meterNormalMode);
        meterListener.setInterval(nA);
        sim.integrator.getEventManager().addListener(meterListener);
        
        ((MCMoveStepTracker)sim.integrator.getMoveManager().getMCMoves()[0].getTracker()).setNoisyAdjustment(false);

        sim.activityIntegrate.setMaxSteps(simSteps/10);
        sim.getController().actionPerformed();
        sim.integrator.getMoveManager().setEquilibrating(false);
        sim.getController().reset();
        meterNormalMode.reset();

        WriteS sWriter = new WriteS(sim.getSpace());
        sWriter.setFilename("test");
        sWriter.setOverwrite(true);
        sWriter.setMeter(meterNormalMode);
        sWriter.setWaveVectorFactory(waveVectorFactory);
        sWriter.setTemperature(temperature);
        
        sim.activityIntegrate.setMaxSteps(simSteps);
        sim.getController().actionPerformed();

        sWriter.actionPerformed();
        double A = sWriter.getLastA();
        // A ranges from 46.3 to 46.9, with 46.6 most popular.
        // value from a much longer simulation is 46.3

        assertTrue("harmonic reference free energy within expected limits "+A, Math.abs(A-44.7) < 0.3);
    }
}
{'fraction_non_alphanumeric': 0.0971588916169765, 'fraction_numerical': 0.011574886004910558, 'mean_word_length': 3.221317542561066, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4043040', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1595, 'n_words': 328}