public synchronized void setTemperature(double temperature) {
		if (numberOfAtoms == 0)
			return;
		if (temperature < ZERO)
			temperature = 0.0;
		boolean electricFieldOn = false;
		synchronized (fields) {
			for (int n = 0, m = fields.size(); n < m; n++) {
				if (fields.elementAt(n) instanceof ElectricField) {
					electricFieldOn = true;
					break;
				}
			}
		}
		if (electricFieldOn && hasCoulomb && interCoulomb) {
			List[] list = splitParticlesByCharges();
			for (List l : list)
				setTemperature(l, temperature);
		} else if (isSteeringOn()) {
			List[] list = splitParticlesBySteering();
			for (List l : list)
				setTemperature(l, temperature);
		} else {
			double temp1 = getKE() * UNIT_EV_OVER_KB;
			if (temp1 < ZERO && temperature > ZERO) {
				assignTemperature(temperature);
				temp1 = getKE() * UNIT_EV_OVER_KB;
			}
			if (temp1 > ZERO)
				rescaleVelocities(Math.sqrt(temperature / temp1));
		}
		setElectronTemperature(temperature);
	}