void init(Molecule molec, EnergyFunction ef, double cutoff, DoubleMatrix1D dv,
            ContSCObjFunction of, DoubleMatrix1D[] samples){
        //Take the VDW interactions with distances below distCutoff
        //if of and samples aren't null then count distances below distCutoff in any of the samples
        //(from the DOFs of of)
        //if they are null then just check distances in the current geometry
        
        DOFVals = dv;
        m = molec;
        distCutoff = cutoff;
        
        double VDWMultiplier = ef.getAmber96ext().vdwMultiplier;
        V6 = VDWMultiplier*VDWMultiplier;//square then cube
        V6=V6*V6*V6;
        V12 = V6*V6;
        
        if(includeElec){
            Amber96ext a96ff = ef.getAmber96ext();//to get general parameters
            distDepDielec = a96ff.distDepDielect;
            coulombFactor = a96ff.constCoulomb / a96ff.dielectric;
        }
        
                
        //now traverse ef to get all VDW terms with specified distance, and their coefficients in ef
        HashMap<Integer,double[]> terms = new HashMap<Integer,double[]>();
        //will record pair of molecule atom numbers (as (lower number)*m.numberOfAtoms+(higherNumber) )
        //mapped to the pair (coefficient for r^-12, coefficient for r^-6)
        
        if(of==null){
            getTerms(ef,terms,1);
        }
        else{
            for(DoubleMatrix1D samp : samples){
                of.setDOFs(samp);
                HashMap<Integer,double[]> sampTerms = new HashMap<Integer,double[]>();
                getTerms(ef,sampTerms,1);
                //merge sampTerms into terms
                for( int pair : sampTerms.keySet() ){
                    terms.put(pair, sampTerms.get(pair));
                    //coefficients will be the same for each of the samples
                    //since these come from the energy function, not geometry
                }
            }
        }
        
        //now fill in atomNums and coeffs accordingly
        numTerms = terms.size();
        atomNums = new int[2*numTerms];
        coeffs = new double[2*numTerms];
        
        resNums = new int[2*numTerms];
        
        //resAtomNums = new int[2*numTerms];
        atomNames = new String[2*numTerms];
        
        if(includeElec)
            elecCoeffs = new double[numTerms];
            
        int count = 0;
        for( int index : terms.keySet() ){
            int atom1 = index / m.numberOfAtoms;
            int atom2 = index % m.numberOfAtoms;
            double termCoeffs[] = terms.get(index);
            
            atomNums[2*count] = atom1;
            atomNums[2*count+1] = atom2;
            coeffs[2*count] = termCoeffs[0];
            coeffs[2*count+1] = termCoeffs[1];
            
            if(includeElec)
                elecCoeffs[count] = termCoeffs[2];
            
            getResBasedNums(2*count);
            getResBasedNums(2*count+1);
            
            count++;
        }
        
        System.out.println("Created SVE with "+numTerms+" terms");
    }