コード例 #1
0
ファイル: unit_tests.py プロジェクト: tanmoy7989/c25ld
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()
コード例 #2
0
matplotlib.rcParams.update(setup.params)
data_dir = os.path.join(setup.data_dir, 'TIP4P')

temp = 300
rhos = [1020, 1100, 1170]

fig = plt.figure(figsize=(4, 3))
ax = fig.add_subplot(1, 1, 1)
styles = {'AA': 'ro', 'SP': 'b-', 'SPLD': 'k-'}
cgtypes = ['SP', 'SPLD']

for i, rho in enumerate(rhos):
    for j, cgtype in enumerate(cgtypes):
        prefix = os.path.join(data_dir, 'R%dT%d_%s' % (rho, temp, cgtype))
        histfile = pp.parseFileNames(prefix)[1]
        hist = pp.parseHist(histfile)['LD']
        r_t = hist[0]
        h_t = hist[1]
        r_m = hist[2]
        h_m = hist[3]
        if j == 0: ax.plot(r_t + 20 * i, h_t, styles['AA'], label='AA')
        ax.plot(r_m + 20 * i, h_m, styles[cgtype], label=cgtype)
        if i == 0: leg = ax.legend()

# design
ax.set_xlabel(r'$r(\AA)$')
ax.set_ylabel('local density')
setup.prune(ax)

# annotation
ax.annotate('300K', xy=(40, 0.30))
コード例 #3
0
if LDCut == 6.5 and system == 'c25': data_dir = 'cgff_c25_oldrc'
if LDCut == 6.5 and system == 'methane25': data_dir = 'cgff_methane25_oldrc'
if LDCut == 7.8 and system == 'c25': data_dir = 'cgff_c25_newrc'
if LDCut == 7.8 and system == 'methane25': data_dir = 'cgff_methane25_newrc_50LDKnots'
data_dir = os.path.join(setup.data_dir, 'FORCEFIELDS', data_dir)

if system == 'c25': prefix = os.path.join(data_dir, 'c25_%s_SPLD' % fftype)
else: prefix = os.path.join(data_dir, 'methane25_%s_SPLD' % fftype)
logfile, histfile, sumfile = pp.parseFileNames(prefix)
r, pot = pp.parseLog(sumfile)['LD']
# start potential from zero
if system == 'c25': pot -= pot.max()
if system == 'methane25': pot-= pot[0]

r_t, hist_t, r_m, hist_m = pp.parseHist(histfile)['LD']

fig = plt.figure(figsize = (setup.set_width('single'),2.3))	
axL = fig.add_subplot(1,1,1)
axR = axL.twinx()
p1 = axL.plot(r, pot, 'r-', label = 'potential')
p2 = axR.plot(r_t, hist_t, 'k-', label = 'all-atom')
p3 = axR.plot(r_m, hist_m, 'b--', label = 'coarse grained')
p = p1+p2+p3
labels = [this_p.get_label() for this_p in p]
if system == 'methane25': loc = 1
else: loc = 1
axL.legend(p, labels, loc = loc)

# Design
if system == 'c25': 
コード例 #4
0
matplotlib.rcParams.update(setup.params)

import parse_potential as pp
ffdir = os.path.expanduser('~/c25ld/data/cg_ff/feb15_runs_fsw')	
fig = plt.figure(figsize = (8,4))	
ax1= fig.add_subplot(1,2,1)
axL = fig.add_subplot(1,2,2)
ax2 = axL.twinx()

fftype = 'wca'
cgtypes = ['SP', 'SPLD', 'LD']
linest = ['r-', 'b-', 'g--', 'k:']
for i, cgtype in enumerate(cgtypes):
	prefix = os.path.join(ffdir, 'c25_%s_%s' % (fftype, cgtype))
	logname, histname = pp.parseFileNames(prefix)
	hist = pp.parseHist(histname, '', []) 
	hist = hist['LD']
	r_t = hist[0]; h_t = hist[1]; r_m = hist[2]; h_m = hist[3]
	if (i==0):
		ax1.plot(r_t, h_t, linest[0], markersize = 10, label = 'AA')
	ax1.plot(r_m, h_m, linest[i+1], label = cgtypes[i])
	

for cgtype in ['SPLD', 'LD']:
	prefix = os.path.join(ffdir, 'c25_%s_%s' % (fftype, cgtype))
	logname, histname = pp.parseFileNames(prefix)
	log = pp.parseLog(logname)
	log = log['LD']
	r = log[0]; pot = log[1]
	if cgtype == 'SPLD':
		pot_linest = 'g-'