package etomica;

/**
 * Intramolecular potential in which bonded atoms interact with a hard tether
 * potential, and nonbonded atoms interact as hard spheres.
 *
 * @author David Kofke
 */
 
public class P1TetheredHardSpheres extends PotentialGroup implements Potential1.Intramolecular {
    
    public final P2HardSphere p2HardSphere;
    public final P2Tether p2Tether;
    
    public P1TetheredHardSpheres() {
        this(Simulation.getDefault().space);
    }
    
    public P1TetheredHardSpheres(Space space) {
        super(1, space);
        p2HardSphere = new P2HardSphere();
        p2Tether = new P2Tether();
        addPotential(p2Tether, new ApiInnerVariable(new AtomIteratorList(),
	            new AtomIteratorBonds()));
	    addPotential(p2HardSphere, new ApiInnerVariable(new AtomIteratorList(),
	            new AtomIteratorNonbonded(parent.simulation())));
    }
    
    public static EtomicaInfo getEtomicaInfo() {
        EtomicaInfo info = new EtomicaInfo("Bonded atoms tethered, nonbonded interact as hard spheres");
        return info;
    }

    public double energy(Atom a) {
        return 0.0;
    }

    /**
     * Demonstrates how this class is implemented.
     */
    public static void main(String[] args) {
        etomica.graphics.SimulationGraphic sim = new etomica.graphics.SimulationGraphic();
        Simulation.instance = sim;
	    IntegratorHard integratorHard = new IntegratorHard();
	    SpeciesSpheres speciesSpheres = new SpeciesSpheres(1, 3);
	    Phase phase = new Phase();
	    
	    PotentialGroup potential2 = new PotentialGroup(2);
	    Potential2 p2 = new P2HardSphere();
	    sim.potentialMaster.setSpecies(p2, new Species[]{speciesSpheres});
	    //XXX need to add p2 to potential2 with an iterator
	    
	    PotentialGroup p1 = new P1TetheredHardSpheres();
	    sim.potentialMaster.setSpecies(p1, new Species[]{speciesSpheres});
	    
	    Controller controller = new Controller();
	    etomica.graphics.DisplayPhase displayPhase = new etomica.graphics.DisplayPhase();
        integratorHard.setTimeStep(0.01);
        
        //this method call invokes the mediator to tie together all the assembled components.
		Simulation.instance.elementCoordinator.go();
		                                    
        sim.makeAndDisplayFrame();
        
     //   controller.start();
    }//end of main
    
}//end of P1TetheredHardSpheres
   

@@ -233,145 +233,22 @@
 ds P
-otentialGroup implements Potential1.Intramolecular %7B%0A    %0A    public final P2HardSphere p2HardSphere;%0A    public final P2Tether p2Tether;
+1IntraSimple %7B
 %0A   
@@ -408,349 +408,48 @@
 per(
-1, 
 space
-);%0A        p2HardSphere = new P2HardSphere();%0A        p2Tether = new P2Tether();%0A        addPotential(p2Tether, new ApiInnerVariable(new AtomIteratorList(),%0A%09            new AtomIteratorBonds()));%0A%09    addPotential(p2HardSphere, new ApiInnerVariable(new AtomIteratorList(),%0A%09            new AtomIteratorNonbonded(parent.simulation())
+, new P2HardSphere(), new P2Tether(
 ));%0A
@@ -645,70 +645,8 @@
  %7D%0A%0A
-    public double energy(Atom a) %7B%0A        return 0.0;%0A    %7D%0A%0A
     
@@ -708,16 +708,18 @@
      */%0A
+/*
     publ
@@ -751,24 +751,24 @@
 g%5B%5D args) %7B%0A
-
         etom
@@ -937,16 +937,35 @@
 torHard(
+sim.potentialMaster
 );%0A%09    
@@ -1051,16 +1051,25 @@
 w Phase(
+sim.space
 );%0A%09    
@@ -1868,24 +1868,24 @@
 er.start();%0A
-
     %7D//end o
@@ -1890,16 +1890,18 @@
  of main
+*/
 %0A    %0A%7D/

make P1TetheredHardSpheres just extend P1IntraSimple