package etomica.modules.dcvgcmd;

import etomica.AtomTreeNodeGroup;
import etomica.EtomicaElement;
import etomica.EtomicaInfo;
import etomica.Phase;
import etomica.Species;
import etomica.SpeciesAgent;
import etomica.atom.AtomList;
import etomica.data.meter.MeterKineticEnergy;
import etomica.data.meter.MeterScalar;
import etomica.units.Dimension;

/**
 * Meter for measurement of the temperature based on kinetic-energy
 * equipartition
 */

/*
 * History of changes 7/03/02 (DAK) Changes to tie in with function of
 * kinetic-energy meter.
 */

public final class MeterTemperature extends MeterScalar implements
		EtomicaElement {

	public MeterTemperature(Species species) {
		super();
		this.species = species;
		setLabel("Temperature");
		meterKE = new MeterKineticEnergy();
	}

	public static EtomicaInfo getEtomicaInfo() {
		EtomicaInfo info = new EtomicaInfo(
				"Records temperature as given via kinetic energy");
		return info;
	}

	public double getDataAsScalar(Phase phase) {
		SpeciesAgent agent = phase.getAgent(species);
		AtomList list = ((AtomTreeNodeGroup)agent.node).childList;
		int size = list.size();
		int natoms = 0;
		if(size > 0){
			natoms = size * ((AtomTreeNodeGroup)list.getFirst().node).childList.size();
		}
		return (2. / (double) ((phase.atomCount()- natoms) * phase.boundary().dimensions().D()))
				* meterKE.getDataAsScalar(phase);
	}

	public Dimension getDimension() {
		return Dimension.TEMPERATURE;
	}

	private final MeterKineticEnergy meterKE;
	private final Species species;
}
@@ -87,65 +87,12 @@
 mica
-Element;%0Aimport etomica.EtomicaInfo;%0Aimport etomica.Phase
+Info
 ;%0Aim
@@ -176,93 +176,8 @@
 st;%0A
-import etomica.data.meter.MeterKineticEnergy;%0Aimport etomica.data.meter.MeterScalar;%0A
 impo
@@ -451,47 +451,43 @@
 nds 
-M
 et
-erScalar implements%0A%09%09EtomicaElement
+omica.data.meter.MeterTemperature
  %7B%0A%0A
@@ -571,73 +571,8 @@
 es;%0A
-%09%09setLabel(%22Temperature%22);%0A%09%09meterKE = new MeterKineticEnergy();%0A
 %09%7D%0A%0A
@@ -765,19 +765,8 @@
 lar(
-Phase phase
 ) %7B%0A
@@ -932,16 +932,17 @@
 ize %3E 0)
+ 
 %7B%0A%09%09%09nat
@@ -1139,21 +1139,16 @@
 sScalar(
-phase
 );%0A%09%7D%0A%0A%09
@@ -1221,51 +1221,8 @@
 %09%7D%0A%0A
-%09private final MeterKineticEnergy meterKE;%0A
 %09pri

extend standard MeterTemperature so IntegratorMD likes us