public double getEnergyForDOF(int dof){
        double E = constTerm;

        for(int t=0; t<terms.length; t++){
            
            if(dof!=-1){//if not total energy, only take terms involving this DOF
                if(!termHasDOF[t][dof])
                    continue;
            }
            
            ContETerm term  = terms[t];
            
            if(term!=null){
                DoubleMatrix1D termDOFVals = getTermDOFVals(DOFVals,term.DOFNums,term);
                double termVal = term.evaluate(termDOFVals,includeMinE,useSharedMolec);
                
                                
                if(termCoeffs==null){
                    E += termVal;
                }
                else{
                    E += termVal*termCoeffs[t];
                }
                
                
                if(Double.isNaN(E)){
                    System.err.println("ERROR: CETEnergyFunction returning NaN.  Writing ContETerm to badTerm.dat");
                    System.err.println("termVal: "+termVal+"  termDOFVals: "+termDOFVals);
                    System.err.println("DOFVals: "+DOFVals+" DOFNums: ");
                    for(int DOFNum : DOFNums)
                        System.err.println(DOFNum);
                    KSParser.outputObject(term, "badTerm.dat");
                    System.exit(0);
                }   
            }
        }

        return E;
    }