def testSplineCoeff(): import parse_potential as pp prefix = '/home/cask0/home/tsanyal/c25ld/data/cg_ff/methane/methane_wca_SPLD' logfile, histfile, sumfile = pp.parseFileNames(prefix) paramstring = pp.parseParamString(sumfile) h = pp.parseHist(histfile)['LD'] rho_t = h[0]; rho_m = h[1] d = alg.makeSysData(isPolymer = False, hasLJ = True) Sys = alg.makeSys(LDCut = 6.5, SysData = d, Prefix = 'testsys', paramstring = paramstring, fftype = 'wca') (nknot, spdist, spc0, spc1, spc2, spc3) = alg.getLDSpline(Sys = Sys) rho = rho_t dfdrho = np.zeros(len(rho)) frho = np.zeros(len(rho)) for n in range(len(rho)): x = (rho[n] - min(rho)) * spdist[1] i = max(min(int(x), nknot-2), 0) t = max(min(x - float(i), 1.0), 0.0) frho[n] = spc0[i] + t * (spc1[i] + t*(spc2[i]+t*spc3[i])) dfdrho[n] = spdist[1] * (spc1[i] + t * (2.*spc2[i]+t*3.*spc3[i])) fig = plt.figure ax1 = plt.subplot(211) ; ax2 = plt.subplot(212) ax1.plot(rho, frho, linewidth = 3, label = r'$f(\rho)$'); ax1.legend() ax2.plot(rho, dfdrho, linewidth = 3, label = r'$\frac{df}{d\rho}$'); ax2.legend()
print '\n\nLDCut = %g\n' % LDCut #calculate coefficients (coeff, dcoeff) = alg.calcCoeff(LDCut = LDCut, Delta = 1.2) #get AA and CG trj Trj_CG = pickleTraj(base_fmt['cg_trj'] % (fftype, i)) #get Spline Coeffs for CG forcefield ffield_CG = base_fmt['cg_ff'] % (fftype, i) paramstring = parse_potential.parseParamString(ffield_CG) Sys = alg.makeSys(LDCut = LDCuts[i], Delta = Delta, BoxL = BoxL, fftype = fftype, Prefix = 'ldsplinecoeff', paramstring = paramstring, sample_trajtype = 'CG', eval_trajtype = 'CG', SysData = SysData) (nknot, spdist, spc0, spc1, spc2, spc3) = alg.getLDSpline(Sys = Sys) for key in TrjIter.keys(): if TrjIter[key][1] == -1: if key == 'AA': TrjIter[key][1] = len(Trj_AA) if key == 'CG': TrjIter[key][1] = len(Trj_CG) FrameRange_AA = range(TrjIter['AA'][0], TrjIter['AA'][1], TrjIter['AA'][2]) FrameRange_CG = range(TrjIter['CG'][0], TrjIter['CG'][1], TrjIter['CG'][2]) NFrames_AA = len(FrameRange_AA); NFrames_CG = len(FrameRange_CG) #frame stepping ####all-atom print '---> Calculating AA deriviative...\n' EneAA_deriv = 0 pb = sim.utility.ProgressBar(Text = 'Processing AA frames', Steps = NFrames_AA)