Skip to content

Commit

Permalink
migrate intramolecular bits to direct sampling from overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
ajschult committed May 13, 2024
1 parent 8d41ecc commit 7453184
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
import etomica.integrator.Integrator;
import etomica.integrator.IntegratorMC;
import etomica.integrator.mcmove.MCMoveBoxStep;
import etomica.potential.IPotential2;
import etomica.potential.PotentialMasterBonding;
import etomica.potential.compute.NeighborManagerIntra;
import etomica.potential.compute.PotentialCompute;
import etomica.potential.compute.PotentialComputeAggregate;
import etomica.potential.compute.PotentialComputePair;
import etomica.simulation.Simulation;
import etomica.space.Space;
import etomica.species.ISpecies;
Expand Down Expand Up @@ -50,6 +54,9 @@ public class SimulationVirial extends Simulation {
public int[] newSeeds;
public int[] numMolecules;
protected double boxLength;
protected PotentialMasterBonding.FullBondingInfo bondingInfo;
protected IPotential2[][] pairPotentials;
protected boolean initialized;

public SimulationVirial(Space space, ISpecies[] species, int[] nMolecules, double temperature, ClusterWeight aSampleCluster, ClusterAbstract refCluster, ClusterAbstract[] targetClusters) {
super(space);
Expand All @@ -74,7 +81,21 @@ public void setBoxLength(double length) {
boxLength = length;
}

public void setIntraPairPotentials(IPotential2[][] pairPotentials) {
if (initialized) throw new RuntimeException("too late");
this.pairPotentials = pairPotentials;
}

public void setBondingInfo(PotentialMasterBonding.FullBondingInfo bondingInfo) {
this.bondingInfo = bondingInfo;
}

public void init() {
if (initialized) throw new RuntimeException("you can only call me once");
// we aren't actually initialized yet, but we will be unless we crash.
// if we crash, we shouldn't get called again!
initialized = true;

if (seeds != null) {
setRandom(new RandomMersenneTwister(seeds));
}
Expand All @@ -89,8 +110,18 @@ public void init() {
box.setNMolecules(species[i], numMolecules[i]);
}

PotentialCompute pc = null;
pc = new PotentialComputeAggregate();
PotentialCompute pc;
if (pairPotentials != null) {
PotentialMasterBonding pmBonding = new PotentialMasterBonding(getSpeciesManager(), box, bondingInfo);
PotentialComputePair pcPair = new PotentialComputePair(getSpeciesManager(), box, new NeighborManagerIntra(box, bondingInfo), pairPotentials);
pc = new PotentialComputeAggregate(pmBonding, pcPair);
}
else if (bondingInfo != null){
pc = new PotentialMasterBonding(getSpeciesManager(), box, bondingInfo);
}
else {
pc = new PotentialComputeAggregate();
}

// temperature isn't going to mean anything here, but pass it anyway
integrator = new IntegratorMC(pc, random, temperature, box);
Expand Down

0 comments on commit 7453184

Please sign in to comment.