etomica.potential
Class PotentialMaster

java.lang.Object
  extended by etomica.potential.PotentialMaster
All Implemented Interfaces:
IPotentialMaster, Serializable
Direct Known Subclasses:
PotentialMasterMonatomic, PotentialMasterNbr

public class PotentialMaster
extends Object
implements Serializable, IPotentialMaster

Manager of all potentials in simulation. Most calls to compute the energy or other potential calculations begin with the calculate method of this class. It then passes the calculation on to the contained potentials.

See Also:
Serialized Form

Nested Class Summary
static class PotentialMaster.AtomIterator0
           
static class PotentialMaster.PotentialLinker
           
 
Field Summary
protected  boolean enabled
           
protected  PotentialMaster.PotentialLinker first
           
protected  IteratorFactory iteratorFactory
           
protected  PotentialMaster.PotentialLinker last
           
protected  PotentialMasterLrc lrcMaster
           
 
Constructor Summary
PotentialMaster()
           
PotentialMaster(IteratorFactory iteratorFactory)
           
 
Method Summary
 void addModel(Model newModel)
          Add the given Model's intramolecular potentials to this PotentialMaster
 void addPotential(IPotentialAtomic potential, IAtomType[] atomTypes)
          Indicates to the PotentialMaster that the given potential should apply to the specified atom types.
 void addPotential(IPotentialMolecular potential, ISpecies[] species)
          Indicates to the PotentialMaster that the given potential should apply to the specified species.
 void addPotential(IPotentialMolecular potential, MoleculesetIteratorPDT iterator, ISpecies[] types)
           
 void calculate(IBox box, IteratorDirective id, PotentialCalculation pc)
          Performs the given PotentialCalculation on the atoms of the given Box.
 PotentialGroup getPotential(ISpecies[] types)
          Returns the potential that applies to the specified types, or null of no existing potential applies.
 IPotentialMolecular[] getPotentials()
          Returns an array containing all molecular Potentials.
 ISpecies[] getSpecies(IPotentialMolecular potential)
           
 boolean isEnabled()
           
 boolean isEnabled(IPotentialAtomic potential)
          Returns true if the potential is in this group and has not been disabled via a previous call to setEnabled; returns false otherwise.
 boolean isEnabled(IPotentialMolecular potential)
          Returns true if the potential is in this group and has not been disabled via a previous call to setEnabled; returns false otherwise.
 PotentialMasterLrc lrcMaster()
          Returns the object that oversees the long-range correction zero-body potentials.
 PotentialGroup makePotentialGroup(int nBody)
          Returns an nBody PotentialGroup appropriate for this type of PotentialMaster.
 void potentialAddedNotify(IPotentialAtomic subPotential, PotentialGroup pGroup)
          Notifies the PotentialMaster that the sub-potential has been added to the given PotentialGroup, which is associated (but not necessarily held by) this PotentialMaster.
 void removePotential(IPotentialAtomic potential)
          Removes given potential from the group.
 void removePotential(IPotentialMolecular potential)
          Removes given potential from the group.
 void setEnabled(boolean enabled)
          Permits enabling/disabling of all potentials.
 void setEnabled(IPotentialAtomic potential, boolean enabled)
          Indicates that the specified potential should not contribute to potential calculations.
 void setEnabled(IPotentialMolecular potential, boolean enabled)
          Indicates that the specified potential should not contribute to potential calculations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lrcMaster

protected PotentialMasterLrc lrcMaster

iteratorFactory

protected IteratorFactory iteratorFactory

first

protected PotentialMaster.PotentialLinker first

last

protected PotentialMaster.PotentialLinker last

enabled

protected boolean enabled
Constructor Detail

PotentialMaster

public PotentialMaster()

PotentialMaster

public PotentialMaster(IteratorFactory iteratorFactory)
Method Detail

lrcMaster

public PotentialMasterLrc lrcMaster()
Description copied from interface: IPotentialMaster
Returns the object that oversees the long-range correction zero-body potentials.

Specified by:
lrcMaster in interface IPotentialMaster

makePotentialGroup

public PotentialGroup makePotentialGroup(int nBody)
Description copied from interface: IPotentialMaster
Returns an nBody PotentialGroup appropriate for this type of PotentialMaster.

Specified by:
makePotentialGroup in interface IPotentialMaster

calculate

public void calculate(IBox box,
                      IteratorDirective id,
                      PotentialCalculation pc)
Description copied from interface: IPotentialMaster
Performs the given PotentialCalculation on the atoms of the given Box. Sets the box for all molecule iterators and potentials, sets target and direction for iterators as specified by given IteratorDirective, and applies doCalculation of given PotentialCalculation with the iterators and potentials.

Specified by:
calculate in interface IPotentialMaster

addModel

public void addModel(Model newModel)
Description copied from interface: IPotentialMaster
Add the given Model's intramolecular potentials to this PotentialMaster

Specified by:
addModel in interface IPotentialMaster

addPotential

public void addPotential(IPotentialMolecular potential,
                         ISpecies[] species)
Description copied from interface: IPotentialMaster
Indicates to the PotentialMaster that the given potential should apply to the specified species. Exception is thrown if the potential.nBody() value is different from the length of the species array. Thus, for example, if giving a 2-body potential, then the array should contain exactly two species; the species may refer to the same instance (appropriate for an intra-species potential, defining the iteractions between molecules of the same species).

Specified by:
addPotential in interface IPotentialMaster

addPotential

public void addPotential(IPotentialAtomic potential,
                         IAtomType[] atomTypes)
Description copied from interface: IPotentialMaster
Indicates to the PotentialMaster that the given potential should apply to the specified atom types. The potential is assumed to be intermolecular. The given types should not include any type which is the descendent of another. Potential group hierarchy will be constructed as needed above the level of the given atom types.

The order of the elements in the atomTypes array is not relevant, and is subject to rearrangement by the method -- the array is sorted (using the compareTo method of AtomType) before doing anything else.

Specified by:
addPotential in interface IPotentialMaster

potentialAddedNotify

public void potentialAddedNotify(IPotentialAtomic subPotential,
                                 PotentialGroup pGroup)
Description copied from interface: IPotentialMaster
Notifies the PotentialMaster that the sub-potential has been added to the given PotentialGroup, which is associated (but not necessarily held by) this PotentialMaster. This method is called by PotentialGroup and should not be called in other circumstances.

Specified by:
potentialAddedNotify in interface IPotentialMaster

getPotential

public PotentialGroup getPotential(ISpecies[] types)
Description copied from interface: IPotentialMaster
Returns the potential that applies to the specified types, or null of no existing potential applies.

Specified by:
getPotential in interface IPotentialMaster

getSpecies

public ISpecies[] getSpecies(IPotentialMolecular potential)

addPotential

public void addPotential(IPotentialMolecular potential,
                         MoleculesetIteratorPDT iterator,
                         ISpecies[] types)

removePotential

public void removePotential(IPotentialMolecular potential)
Description copied from interface: IPotentialMaster
Removes given potential from the group. No error is generated if potential is not in group.

Specified by:
removePotential in interface IPotentialMaster

removePotential

public void removePotential(IPotentialAtomic potential)
Description copied from interface: IPotentialMaster
Removes given potential from the group. No error is generated if potential is not in group.

Specified by:
removePotential in interface IPotentialMaster

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface IPotentialMaster
Returns:
Returns enabled flag.

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: IPotentialMaster
Permits enabling/disabling of all potentials. Default is enabled (true).

Specified by:
setEnabled in interface IPotentialMaster
Parameters:
enabled - flags if potentials are enabled.

setEnabled

public void setEnabled(IPotentialMolecular potential,
                       boolean enabled)
Description copied from interface: IPotentialMaster
Indicates that the specified potential should not contribute to potential calculations. If potential is not in this group, no action is taken.

Specified by:
setEnabled in interface IPotentialMaster

setEnabled

public void setEnabled(IPotentialAtomic potential,
                       boolean enabled)
Description copied from interface: IPotentialMaster
Indicates that the specified potential should not contribute to potential calculations. If potential is not in this group, no action is taken.

Specified by:
setEnabled in interface IPotentialMaster

isEnabled

public boolean isEnabled(IPotentialAtomic potential)
Description copied from interface: IPotentialMaster
Returns true if the potential is in this group and has not been disabled via a previous call to setEnabled; returns false otherwise.

Specified by:
isEnabled in interface IPotentialMaster

isEnabled

public boolean isEnabled(IPotentialMolecular potential)
Description copied from interface: IPotentialMaster
Returns true if the potential is in this group and has not been disabled via a previous call to setEnabled; returns false otherwise.

Specified by:
isEnabled in interface IPotentialMaster

getPotentials

public IPotentialMolecular[] getPotentials()
Description copied from interface: IPotentialMaster
Returns an array containing all molecular Potentials.

Specified by:
getPotentials in interface IPotentialMaster