/* 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.simulation.prototypes;

import etomica.action.activity.ActivityIntegrate;
import etomica.atom.AtomType;
import etomica.box.Box;
import etomica.config.ConfigurationLattice;
import etomica.integrator.IntegratorHard;
import etomica.lattice.LatticeOrthorhombicHexagonal;
import etomica.nbr.list.PotentialMasterList;
import etomica.potential.P2HardSphere;
import etomica.potential.Potential2;
import etomica.simulation.Simulation;
import etomica.space2d.Space2D;
import etomica.species.SpeciesSpheresMono;

/**
 * Simple hard-sphere molecular dynamics simulation in 2D.
 *
 * @author David Kofke
 */

public class HSMD2D extends Simulation {

    private static final long serialVersionUID = 1L;
    public IntegratorHard integrator;
    public SpeciesSpheresMono species1, species2;
    public Box box;
    public Potential2 potential11;
    public Potential2 potential12;
    public Potential2 potential22;

    public HSMD2D() {
        super(Space2D.getInstance());
        PotentialMasterList potentialMaster = new PotentialMasterList(this, space);
//        super(space, new PotentialMaster(space));//,IteratorFactoryCell.instance));
        double sigma = 0.38;

        double neighborRangeFac = 1.6;
        potentialMaster.setRange(neighborRangeFac * sigma);

        integrator = new IntegratorHard(this, potentialMaster, space);
        integrator.setIsothermal(false);
        integrator.setTimeStep(0.01);

        potentialMaster.setRange(sigma * 1.6);

        ActivityIntegrate activityIntegrate = new ActivityIntegrate(integrator);
        activityIntegrate.setSleepPeriod(1);
        getController().addAction(activityIntegrate);
        species1 = new SpeciesSpheresMono(this, space);
        species1.setIsDynamic(true);
        species2 = new SpeciesSpheresMono(this, space);
        species2.setIsDynamic(true);
        AtomType leafType1 = species1.getLeafType();
        AtomType leafType2 = species2.getLeafType();
        addSpecies(species1);
        addSpecies(species2);
        potential11 = new P2HardSphere(space, sigma, false);
        potential12 = new P2HardSphere(space, sigma, false);
        potential22 = new P2HardSphere(space, sigma, false);

        potentialMaster.addPotential(potential11, new AtomType[]{leafType1, leafType1});

        potentialMaster.addPotential(potential12, new AtomType[]{leafType2, leafType2});

        potentialMaster.addPotential(potential22, new AtomType[]{leafType1, leafType2});

        box = new Box(space);
        addBox(box);
        box.setNMolecules(species1, 512);
        box.setNMolecules(species2, 5);
        integrator.getEventManager().addListener(potentialMaster.getNeighborManager(box));
        new ConfigurationLattice(new LatticeOrthorhombicHexagonal(space), space).initializeCoordinates(box);
        integrator.setBox(box);
    }

    /**
     * Demonstrates how this class is implemented.
     */
    public static void main(String[] args) {
        HSMD2D sim = new HSMD2D();
        sim.getController().actionPerformed();
    }

}

@@ -239,16 +239,50 @@
 types;%0A%0A
+import etomica.action.BoxInflate;%0A
 import e
@@ -319,24 +319,24 @@
 yIntegrate;%0A
-
 import etomi
@@ -377,16 +377,60 @@
 ox.Box;%0A
+import etomica.chem.elements.ElementSimple;%0A
 import e
@@ -465,16 +465,59 @@
 attice;%0A
+import etomica.graphics.SimulationGraphic;%0A
 import e
@@ -849,16 +849,9 @@
 %0A * 
-Simple h
+H
 ard-
@@ -891,14 +891,139 @@
 ion 
-in 2D.
+of two species in 2D.%0A * %3Cp%3E%0A * Atoms of each species have the same diameter but one has 10 times more mass than the other.%0A * %3C/p%3E
 %0A *%0A
@@ -1096,61 +1096,8 @@
  %7B%0A%0A
-    private static final long serialVersionUID = 1L;%0A
     
@@ -1454,94 +1454,8 @@
 e);%0A
-//        super(space, new PotentialMaster(space));//,IteratorFactoryCell.instance));%0A
     
@@ -1477,12 +1477,9 @@
 a = 
-0.38
+1
 ;%0A%0A 
@@ -2304,24 +2304,87 @@
 (species2);%0A
+        ((ElementSimple) leafType2.getElement()).setMass(10);%0A%0A
         pote
@@ -2957,16 +2957,133 @@
 es2, 5);
+%0A%0A        BoxInflate bi = new BoxInflate(box, space);%0A        bi.setTargetDensity(0.5);%0A        bi.actionPerformed();
 %0A       
@@ -3473,43 +3473,174 @@
     
-sim.getController().actionPerfor
+final SimulationGraphic simGraphic = new SimulationGraphic(sim, SimulationGraphic.TABBED_PANE, sim.space, sim.getController());%0A        simGraphic.makeAndDisplayFra
 me
-d
 ();%0A

Fix and clean up HSMD2D.