<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package etomica.virial.simulations;

import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;

import org.json.simple.JSONObject;

import etomica.api.IAtomList;
import etomica.api.IIntegratorEvent;
import etomica.api.IIntegratorListener;
import etomica.api.IPotentialAtomic;
import etomica.api.IVectorMutable;
import etomica.atom.IAtomOriented;
import etomica.chem.elements.ElementSimple;
import etomica.data.IData;
import etomica.data.types.DataGroup;
import etomica.integrator.mcmove.MCMove;
import etomica.potential.P2NitrogenHellmann;
import etomica.potential.P3NitrogenHellmannNonAdditive;
import etomica.potential.PotentialMolecularMonatomic;
import etomica.space.Space;
import etomica.space3d.Space3D;
import etomica.species.SpeciesSpheresRotating;
import etomica.units.Kelvin;
import etomica.units.Mole;
import etomica.util.DoubleRange;
import etomica.util.HistogramSimple;
import etomica.util.ParameterBase;
import etomica.util.ParseArgs;
import etomica.virial.ClusterAbstract;
import etomica.virial.ClusterBonds;
import etomica.virial.ClusterSum;
import etomica.virial.ClusterWheatleyHS;
import etomica.virial.ClusterWheatleyMultibody;
import etomica.virial.ClusterWheatleySoft;
import etomica.virial.MCMoveClusterAtomMulti;
import etomica.virial.MCMoveClusterAtomRotateBob;
import etomica.virial.MayerFunction;
import etomica.virial.MayerFunctionMolecularThreeBody;
import etomica.virial.MayerFunctionNonAdditive;
import etomica.virial.MayerGeneral;
import etomica.virial.MayerHardSphere;
import etomica.virial.cluster.Standard;

public class VirialN2 {
    public static void main(String[] args) {
        VirialN2Param params = new VirialN2Param();
        boolean isCommandLine = args.length > 0;
        if (isCommandLine) {
            ParseArgs parseArgs = new ParseArgs(params);
            parseArgs.parseArgs(args, true);
        }
        else {
            // default options - choose these before committing to CVS
            params.potentialLevel = level.classical;
            params.temperatureK = 500;
            params.numSteps = (long)1E6;            

            // runtime options - make changes in these and not the default options above
//            params.nPoints = 3;
//            params.potentialLevel = level.semiClassical;
//            params.temperatureK = 700;
//            params.numSteps = (long)1E6;
//            params.nonAdditive = false;            
        }
        final int nPoints = params.nPoints;
        final double temperatureK = params.temperatureK;
        final double temperature = Kelvin.UNIT.toSim(temperatureK);
        final boolean pairOnly = params.pairOnly;
        long steps = params.numSteps;
        double sigmaHSRef = params.sigmaHSRef;
        double refFrac = params.refFrac;
        final boolean p2N2HellmannA = params.p2N2HellmannA;
        final boolean p3N2HellmannA = params.p3N2HellmannA;
        final boolean nonAdditive = params.nonAdditive;
        final level pLevel = params.potentialLevel;
        final int nT = params.nTimes;
        final boolean printInConvertedUnits = params.printInConvertedUnits;
        final double[] HSB = new double[8];

        HSB[2] = Standard.B2HS(sigmaHSRef);
        HSB[3] = Standard.B3HS(sigmaHSRef);
        HSB[4] = Standard.B4HS(sigmaHSRef);
        HSB[5] = Standard.B5HS(sigmaHSRef);
        HSB[6] = Standard.B6HS(sigmaHSRef);
        HSB[7] = Standard.B7HS(sigmaHSRef);
        
        System.out.println("Overlap sampling for N2 potential of Hellmann (2013) at " + temperatureK + " K");
        if (pLevel == level.semiClassical) System.out.println("Quadratic Feymann-Hibbs effective potential employed.");
        System.out.println("Non - additive = "+nonAdditive);
//        System.out.println("Reference diagram: B"+nPoints+" for hard spheres with diameter " + sigmaHSRef + " Angstroms");
        
//        System.out.println("B"+nPoints+"HS: "+HSB[nPoints]);
        
        if (steps%1000 != 0) {
            throw new RuntimeException("steps should be a multiple of 1000");
        }
        System.out.println(steps+" steps (1000 IntegratorOverlap steps of "+(steps/1000)+")");
        
        final Space space = Space3D.getInstance();
        // make ref and tar clusters
        MayerHardSphere fRef = new MayerHardSphere(sigmaHSRef);
        ClusterAbstract refCluster = null;        
        refCluster = new ClusterWheatleyHS(nPoints, fRef);            
        
        ClusterAbstract tarCluster = null;
        
        final P2NitrogenHellmann p2N2 = new P2NitrogenHellmann(space);
        
        if (p2N2HellmannA) p2N2.parametersB = false;
        final IPotentialAtomic p2 = (pLevel == level.classical ? p2N2 : p2N2.makeQFH(temperature));        
        PotentialMolecularMonatomic p2N2Molecular = new PotentialMolecularMonatomic(space, p2);        
        MayerGeneral f2Tar = new MayerGeneral(p2N2Molecular);
        tarCluster = new ClusterWheatleySoft(nPoints, f2Tar, 1e-12);        

        final double refIntegralF = HSB[nPoints];
        System.out.println("nPoints: "+nPoints);
//        System.out.println("Ref Integral: HSB[2]");
        
        if (nPoints == 3 && nonAdditive) {
            final P3NitrogenHellmannNonAdditive p3N2NonAdditive = new P3NitrogenHellmannNonAdditive(space);
            if (p3N2HellmannA) p3N2NonAdditive.parametersB = false;
            final IPotentialAtomic p3 = p3N2NonAdditive;
            PotentialMolecularMonatomic p3N2Molecular = new PotentialMolecularMonatomic(space, p3);
            MayerFunctionMolecularThreeBody f3Tar = new MayerFunctionMolecularThreeBody(p3N2Molecular);            
            MayerFunctionNonAdditive [] m1 = new MayerFunctionNonAdditive[]{null,null,null,f3Tar};
            tarCluster = new ClusterWheatleyMultibody(nPoints, f2Tar, m1);
        }
        refCluster.setTemperature(temperature);
        tarCluster.setTemperature(temperature);
        
        // make species
        final SpeciesSpheresRotating speciesUranium = new SpeciesSpheresRotating(space,new ElementSimple("U",238.02891));
        
        // make simulation
//        final SimulationVirialOverlapBob sim = new SimulationVirialOverlapBob(space, speciesUranium, temperature, refCluster, tarCluster);
        final SimulationVirialOverlap2 sim = new SimulationVirialOverlap2(space, speciesUranium, temperature, refCluster, tarCluster);
//        sim.init();
        sim.integratorOS.setNumSubSteps(1000);
        steps /= 1000;
        

        // add additional moves here, simulation already has translation and rotation moves        

        
        System.out.println();
        String refFileName = null;
        if (isCommandLine) {
            String tempString = ""+temperatureK;
            if (temperatureK == (int)temperatureK) {
                // temperature is an integer, use "200" instead of "200.0"<commit_msg>deleted unwanted lines that were causing problems<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package etomica.virial.simulations;

import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;

import org.json.simple.JSONObject;

import etomica.api.IAtomList;
import etomica.api.IPotentialAtomic;
import etomica.api.IVectorMutable;
import etomica.chem.elements.ElementSimple;
import etomica.data.IData;
import etomica.data.types.DataGroup;
import etomica.integrator.mcmove.MCMove;
import etomica.potential.P2NitrogenHellmann;
import etomica.potential.P3NitrogenHellmannNonAdditive;
import etomica.potential.PotentialMolecularMonatomic;
import etomica.space.Space;
import etomica.space3d.Space3D;
import etomica.species.SpeciesSpheresRotating;
import etomica.units.Kelvin;
import etomica.units.Mole;
import etomica.util.ParameterBase;
import etomica.util.ParseArgs;
import etomica.virial.ClusterAbstract;
import etomica.virial.ClusterWheatleyHS;
import etomica.virial.ClusterWheatleyMultibody;
import etomica.virial.ClusterWheatleySoft;
import etomica.virial.MayerFunctionMolecularThreeBody;
import etomica.virial.MayerFunctionNonAdditive;
import etomica.virial.MayerGeneral;
import etomica.virial.MayerHardSphere;
import etomica.virial.cluster.Standard;

public class VirialN2 {
    public static void main(String[] args) {
        VirialN2Param params = new VirialN2Param();
        boolean isCommandLine = args.length > 0;
        if (isCommandLine) {
            ParseArgs parseArgs = new ParseArgs(params);
            parseArgs.parseArgs(args, true);
        }
        else {
            // default options - choose these before committing to CVS
            params.potentialLevel = level.classical;
            params.temperatureK = 500;
            params.numSteps = (long)1E6;            

            // runtime options - make changes in these and not the default options above
//            params.nPoints = 3;
//            params.potentialLevel = level.semiClassical;
//            params.temperatureK = 700;
//            params.numSteps = (long)1E6;
//            params.nonAdditive = false;            
        }
        final int nPoints = params.nPoints;
        final double temperatureK = params.temperatureK;
        final double temperature = Kelvin.UNIT.toSim(temperatureK);
        final boolean pairOnly = params.pairOnly;
        long steps = params.numSteps;
        double sigmaHSRef = params.sigmaHSRef;
        double refFrac = params.refFrac;
        final boolean p2N2HellmannA = params.p2N2HellmannA;
        final boolean p3N2HellmannA = params.p3N2HellmannA;
        final boolean nonAdditive = params.nonAdditive;
        final level pLevel = params.potentialLevel;
        final int nT = params.nTimes;
        final boolean printInConvertedUnits = params.printInConvertedUnits;
        final double[] HSB = new double[8];

        HSB[2] = Standard.B2HS(sigmaHSRef);
        HSB[3] = Standard.B3HS(sigmaHSRef);
        HSB[4] = Standard.B4HS(sigmaHSRef);
        HSB[5] = Standard.B5HS(sigmaHSRef);
        HSB[6] = Standard.B6HS(sigmaHSRef);
        HSB[7] = Standard.B7HS(sigmaHSRef);
        
        System.out.println("Overlap sampling for N2 potential of Hellmann (2013) at " + temperatureK + " K");
        if (pLevel == level.semiClassical) System.out.println("Quadratic Feymann-Hibbs effective potential employed.");
        System.out.println("Non - additive = "+nonAdditive);
        
        if (steps%1000 != 0) {
            throw new RuntimeException("steps should be a multiple of 1000");
        }
        System.out.println(steps+" steps (1000 IntegratorOverlap steps of "+(steps/1000)+")");
        
        final Space space = Space3D.getInstance();
        // make ref and tar clusters
        MayerHardSphere fRef = new MayerHardSphere(sigmaHSRef);
        ClusterAbstract refCluster = null;        
        refCluster = new ClusterWheatleyHS(nPoints, fRef);            
        
        ClusterAbstract tarCluster = null;
        
        final P2NitrogenHellmann p2N2 = new P2NitrogenHellmann(space);
        
        if (p2N2HellmannA) p2N2.parametersB = false;
        final IPotentialAtomic p2 = (pLevel == level.classical ? p2N2 : p2N2.makeQFH(temperature));        
        PotentialMolecularMonatomic p2N2Molecular = new PotentialMolecularMonatomic(space, p2);        
        MayerGeneral f2Tar = new MayerGeneral(p2N2Molecular);
        tarCluster = new ClusterWheatleySoft(nPoints, f2Tar, 1e-12);        

        final double refIntegralF = HSB[nPoints];
        System.out.println("nPoints: "+nPoints);
//        System.out.println("Ref Integral: HSB[2]");
        
        if (nPoints == 3 && nonAdditive) {
            final P3NitrogenHellmannNonAdditive p3N2NonAdditive = new P3NitrogenHellmannNonAdditive(space);
            if (p3N2HellmannA) p3N2NonAdditive.parametersB = false;
            final IPotentialAtomic p3 = p3N2NonAdditive;
            PotentialMolecularMonatomic p3N2Molecular = new PotentialMolecularMonatomic(space, p3);
            MayerFunctionMolecularThreeBody f3Tar = new MayerFunctionMolecularThreeBody(p3N2Molecular);            
            MayerFunctionNonAdditive [] m1 = new MayerFunctionNonAdditive[]{null,null,null,f3Tar};
            tarCluster = new ClusterWheatleyMultibody(nPoints, f2Tar, m1);
        }
        refCluster.setTemperature(temperature);
        tarCluster.setTemperature(temperature);
        
        // make species
        final SpeciesSpheresRotating speciesUranium = new SpeciesSpheresRotating(space,new ElementSimple("U",238.02891));
        
        // make simulation
        final SimulationVirialOverlap2 sim = new SimulationVirialOverlap2(space, speciesUranium, temperature, refCluster, tarCluster);
        // sim.init();
        sim.integratorOS.setNumSubSteps(1000);
        steps /= 1000;
        

        // add additional moves here, simulation already has translation and rotation moves
        
        System.out.println();
        String refFileName = null;
        if (isCommandLine) {
            String tempString = ""+temperatureK;
            if (temperatureK == (int)temperatureK) {
                // temperature is an integer, use "200" instead of "200.0"
{'fraction_non_alphanumeric': 0.08813334316690022, 'fraction_numerical': 0.020355483442731765, 'mean_word_length': 2.9327146171693736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3866793', 'n_tokens_mistral': 4261, 'n_tokens_neox': 4004, 'n_words': 888}