예제 #1
0
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()
def getPotential(system, cgtype, fftype):
	if cgtype == 'AA': cgtype = 'LD'
	if cgtype == 'LD': pType = '%s_AA' % fftype.upper()
	else: pType = 'SP'
	filePrefix = os.path.join(data_dir_potentials[system], '%s_%s_%s' % (system, fftype, cgtype))
	logfile, histfile, sumfile = pp.parseFileNames(filePrefix)
	r, pot = pp.parseLog(sumfile)[pType]
	r = np.append(r, np.linspace(r[-1], r[-1]*5.0, 20))
	pot = np.append(pot, np.zeros(20))
	return r, pot
예제 #3
0
import setup
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
예제 #4
0
#!/usr/bin/env python
import os, sys
import matplotlib
import matplotlib.pyplot as plt

# Build dependencies
sys.path.append('../')
import setup
import parse_potential as pp
matplotlib.rcParams.update(setup.params)

# data paths
prefix = '/home/tanmoy/projects/paper1_plots/data/FORCEFIELDS/cgff_methane25_newrc_50LDKnots/methane25_wca_SPLD'
logfile, histfile, sumfile = pp.parseFileNames(prefix)
rho, pot = pp.parseLog(sumfile)['LD']
rholist = rho.tolist()

# start potential from zero
pot-= pot[0]
start = [rholist.index(x) for x in rholist if rholist.__contains__(x) and x >=1.][0]

# normalized f(rho)
fig1 = plt.figure(figsize = (setup.set_width('single'),2.8))	
ax1 = fig1.add_subplot(1,1,1)
ax1.plot(rho, pot, 'r-')

# normalized f(rho)/rho
fig2 = plt.figure(figsize = (setup.set_width('single'),2.8))
ax2 = fig2.add_subplot(1,1,1)
ax2.plot(rho, pot/rho, 'r-')
import parse_potential as pp

import setup
matplotlib.rcParams.update(setup.params)
data_dir = os.path.join(setup.data_dir, 'TIP4P')

rhos = [1020, 1100, 1170, 1250]
temp = 300
cgtype = 'SP'
styles = ['r-', 'g-', 'b-', 'k-']
		
fig = plt.figure(figsize = (4,3))
ax= fig.add_subplot(1,1,1)
for j, rho in enumerate(rhos):
        prefix = os.path.join(data_dir, 'R%dT%d_%s' % (rho, temp, cgtype))
        sumfile = pp.parseFileNames(prefix)[2]
        r, potential = pp.parseLog(sumfile)['SP']
        ax.plot(r, potential, styles[j], label = r'$\rho = $' + str(rho) + r'$(kg/m^3)$')
       
	# design
	ax.set_xlabel(r'$r (\AA)$'); ax.set_ylabel('potential '+ r'$(kcal/mol)$')
	ax.set_xlim([2, 4.5]); ax.set_ylim([-1.5, 5])
	ax.set_xticks(np.arange(2,4.5, 10)); ax.set_yticks(np.arange(-1.5, 5, 10))
	setup.prune(ax)
	leg = ax.legend()
				
# annotation
ax.annotate('300 K', xy =  (3.5, 1))

# save figure					
fig.savefig('TIP4P_cg_potential.%s' % setup.params['savefig.format'])
units = setup.units_dict
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':