<commit_before>package etomica.osmoticvirial;

import etomica.action.activity.ActivityIntegrate;
import etomica.action.activity.Controller;
import etomica.atom.AtomType;
import etomica.atom.DiameterHashByType;
import etomica.box.Box;
import etomica.config.ConfigurationLattice;
import etomica.data.AccumulatorAverage;
import etomica.data.AccumulatorAverageFixed;
import etomica.data.DataPumpListener;
import etomica.data.IData;
import etomica.data.meter.MeterWidomInsertion;
import etomica.graphics.SimulationGraphic;
import etomica.integrator.IntegratorMC;
import etomica.integrator.mcmove.MCMoveAtom;
import etomica.integrator.mcmove.MCMoveInsertDelete;
import etomica.lattice.LatticeCubicFcc;
import etomica.nbr.cell.PotentialMasterCell;
import etomica.potential.P2HardSphere;
import etomica.potential.Potential2;
import etomica.simulation.Simulation;
import etomica.space.BoundaryRectangularPeriodic;
import etomica.space3d.Space3D;
import etomica.species.SpeciesSpheresMono;
import etomica.util.ParameterBase;
import etomica.util.ParseArgs;

/**
 * Calculate osmotic virial coefficients for Hard-Sphere potential in Grand Canonical ensemble for solvent
 * from Free-Energy Perturbation Approach utilizing Widom's Insertion.
 */
public class GCWidomInsertHS extends Simulation {

    protected IntegratorMC integrator;
    protected MCMoveAtom mcMoveAtom;
    protected MCMoveInsertDelete mcMoveInsertDelete ;
    protected MCMoveGeometricCluster mcMoveGeometricCluster;
    protected SpeciesSpheresMono species1;
    protected SpeciesSpheresMono species2;
    protected Box box;
    protected P2HardSphere potential1, potential12;
    protected Potential2 potential2;
    protected Controller controller;
    protected ActivityIntegrate activityIntegrate;

    /**
     * @param vf reservoir volume fraction of solvent
     * @param q size of solvent divided by size of solute
     * @param computez2z1 whether to compute z2/z1
     * @param computez3z2 whether to compute z3/z2
     */
    public GCWidomInsertHS(double vf, double q, boolean computez2z1, boolean computez3z2){
        super(Space3D.getInstance());
        PotentialMasterCell potentialMaster = new PotentialMasterCell(this,space);

        integrator = new IntegratorMC(this, potentialMaster);
        activityIntegrate = new ActivityIntegrate(integrator);
        getController().addAction(activityIntegrate);
        mcMoveAtom = new MCMoveAtom(random, potentialMaster, space);
        mcMoveInsertDelete = new MCMoveInsertDelete(potentialMaster, random, space);
        integrator.getMoveManager().addMCMove(mcMoveAtom);
        integrator.getMoveManager().addMCMove(mcMoveInsertDelete);

        double sigma1 = 1.0; //solute
        double sigma2 = q * sigma1; //solvent
        double sigma12 = (sigma1+sigma2)/2;

        species1 = new SpeciesSpheresMono(this, space);
        species2 = new SpeciesSpheresMono(this, space);
        addSpecies(species1);
        addSpecies(species2);
        box = new Box(space);
        addBox(box);
        box.setBoundary(new BoundaryRectangularPeriodic(space, 4*sigma1));

        mcMoveInsertDelete.setSpecies(species2);
        double mu = (8*vf-9*vf*vf+3*vf*vf*vf) / Math.pow((1-vf),3)+Math.log(6*vf/(Math.PI*Math.pow(sigma2,3))); //Configurational chemical potential from Carnahan–Starling equation of state
        System.out.println("mu "+ mu+" muig "+Math.log(6*vf/(Math.PI*Math.pow(sigma2,3))));
        mcMoveInsertDelete.setMu(mu);

        if (computez2z1){box.setNMolecules(species1,1);}
        else if (computez3z2){box.setNMolecules(species1,2);}

        mcMoveGeometricCluster = new MCMoveGeometricCluster(potentialMaster, space, random, 1.5, integrator, null);
        integrator.getMoveManager().addMCMove(mcMoveGeometricCluster);

        potential1 = new P2HardSphere(space, sigma1, false);
//        potential2 = new P2Ideal(space);
//        System.out.println("AO");<commit_msg>Edit parameter in cluster move instance<commit_after>package etomica.osmoticvirial;

import etomica.action.activity.ActivityIntegrate;
import etomica.action.activity.Controller;
import etomica.atom.AtomType;
import etomica.atom.DiameterHashByType;
import etomica.box.Box;
import etomica.config.ConfigurationLattice;
import etomica.data.AccumulatorAverage;
import etomica.data.AccumulatorAverageFixed;
import etomica.data.DataPumpListener;
import etomica.data.IData;
import etomica.data.meter.MeterWidomInsertion;
import etomica.graphics.SimulationGraphic;
import etomica.integrator.IntegratorMC;
import etomica.integrator.mcmove.MCMoveAtom;
import etomica.integrator.mcmove.MCMoveInsertDelete;
import etomica.lattice.LatticeCubicFcc;
import etomica.nbr.cell.PotentialMasterCell;
import etomica.potential.P2HardSphere;
import etomica.potential.Potential2;
import etomica.simulation.Simulation;
import etomica.space.BoundaryRectangularPeriodic;
import etomica.space3d.Space3D;
import etomica.species.SpeciesSpheresMono;
import etomica.util.ParameterBase;
import etomica.util.ParseArgs;

/**
 * Calculate osmotic virial coefficients for Hard-Sphere potential in Grand Canonical ensemble for solvent
 * from Free-Energy Perturbation Approach utilizing Widom's Insertion.
 */
public class GCWidomInsertHS extends Simulation {

    protected IntegratorMC integrator;
    protected MCMoveAtom mcMoveAtom;
    protected MCMoveInsertDelete mcMoveInsertDelete ;
    protected MCMoveGeometricCluster mcMoveGeometricCluster;
    protected SpeciesSpheresMono species1;
    protected SpeciesSpheresMono species2;
    protected Box box;
    protected P2HardSphere potential1, potential12;
    protected Potential2 potential2;
    protected Controller controller;
    protected ActivityIntegrate activityIntegrate;

    /**
     * @param vf reservoir volume fraction of solvent
     * @param q size of solvent divided by size of solute
     * @param computez2z1 whether to compute z2/z1
     * @param computez3z2 whether to compute z3/z2
     */
    public GCWidomInsertHS(double vf, double q, boolean computez2z1, boolean computez3z2){
        super(Space3D.getInstance());
        PotentialMasterCell potentialMaster = new PotentialMasterCell(this,space);

        integrator = new IntegratorMC(this, potentialMaster);
        activityIntegrate = new ActivityIntegrate(integrator);
        getController().addAction(activityIntegrate);
        mcMoveAtom = new MCMoveAtom(random, potentialMaster, space);
        mcMoveInsertDelete = new MCMoveInsertDelete(potentialMaster, random, space);
        integrator.getMoveManager().addMCMove(mcMoveAtom);
        integrator.getMoveManager().addMCMove(mcMoveInsertDelete);

        double sigma1 = 1.0; //solute
        double sigma2 = q * sigma1; //solvent
        double sigma12 = (sigma1+sigma2)/2;

        species1 = new SpeciesSpheresMono(this, space);
        species2 = new SpeciesSpheresMono(this, space);
        addSpecies(species1);
        addSpecies(species2);
        box = new Box(space);
        addBox(box);
        box.setBoundary(new BoundaryRectangularPeriodic(space, 4*sigma1));

        mcMoveInsertDelete.setSpecies(species2);
        double mu = (8*vf-9*vf*vf+3*vf*vf*vf) / Math.pow((1-vf),3)+Math.log(6*vf/(Math.PI*Math.pow(sigma2,3))); //Configurational chemical potential from Carnahan–Starling equation of state
        System.out.println("mu "+ mu+" muig "+Math.log(6*vf/(Math.PI*Math.pow(sigma2,3))));
        mcMoveInsertDelete.setMu(mu);

        if (computez2z1){box.setNMolecules(species1,1);}
        else if (computez3z2){box.setNMolecules(species1,2);}

        mcMoveGeometricCluster = new MCMoveGeometricCluster(potentialMaster, space, random, integrator, null);
        integrator.getMoveManager().addMCMove(mcMoveGeometricCluster);

        potential1 = new P2HardSphere(space, sigma1, false);
//        potential2 = new P2Ideal(space);
//        System.out.println("AO");
{'fraction_non_alphanumeric': 0.09027336300063572, 'fraction_numerical': 0.017037507946598855, 'mean_word_length': 4.508403361344538, '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': '4442352', 'n_tokens_mistral': 2501, 'n_tokens_neox': 2391, 'n_words': 491}