public double cg(double delta) {
		int n = model.getNumberOfAtoms();
		if (n <= 1)
			return -1.0;
		if (congvxAtLastStep == null || congvyAtLastStep == null)
			initCongArrays();
		double potential = 0.0;
		double scalar = 1.0;
		double sumgrad = 0.0;
		double tempx = 0.0, tempy = 0.0;
		for (int i = 0; i < n; i++)
			sumgrad += model.atom[i].fx * model.atom[i].fx + model.atom[i].fy * model.atom[i].fy;
		scalar = -sumgrad / modeGradientAtLastStep;
		modeGradientAtLastStep = sumgrad;
		sumgrad = 0.0;
		for (int i = 0; i < n; i++) {
			tempx = scalar * congvxAtLastStep[i] + model.atom[i].fx;
			tempy = scalar * congvyAtLastStep[i] + model.atom[i].fy;
			congvxAtLastStep[i] = tempx;
			congvyAtLastStep[i] = tempy;
			sumgrad += congvxAtLastStep[i] * congvxAtLastStep[i] + congvyAtLastStep[i] * congvyAtLastStep[i];
		}
		model.putInBounds();
		sumgrad = Math.sqrt(sumgrad);
		for (int i = 0; i < n; i++) {
			if (!model.atom[i].isMovable())
				continue;
			congvxAtLastStep[i] /= sumgrad;
			congvyAtLastStep[i] /= sumgrad;
			model.atom[i].rx = model.atom[i].rx + congvxAtLastStep[i] * delta;
			model.atom[i].ry = model.atom[i].ry + congvyAtLastStep[i] * delta;
		}
		potential = model.computeForce(-1);
		return potential;
	}