Exemplo n.º 1
0
def testNCoord():
	
	rdfcut = 7.5

	ld = __prepLD()
	ld.LammpsTraj = os.path.expanduser('~/benwat/data/gromacs/NB250NW250/NB250NW250_prod.lammpstrj.gz')
	ld.LDDelta = 1e-3
	ld.LDCut = rdfcut

	ld.Prefix = 'NCoord'
	ld.genFileNames()
	
	ld.Normalize = True ; ld.makeRDF([1], [1])
	r,g,e1,x1 = pickle.load(open(ld.rdfpickle, 'r'))
	ind = np.where(abs(r-rdfcut) < 0.1)[0][0]
	rho_bulk = (ld.NCentAtoms + ld.NNeighAtoms) / (np.mean(ld.BoxL)**3.)
	N_rdf = 4 * np.pi * rho_bulk * np.trapz(y = r[:ind+1]**2. * g[:ind+1], x = r[:ind+1])

	ld.Normalize = True ; ld.makeLD(1,1)
	rho, h, e2, x2, y2 = pickle.load(open(ld.ldpickle, 'r'))
	N_ld = np.trapz(y = h * rho, x = rho)
	#N_ld = np.mean(np.mean(y2, axis = 0))

	print '\n\n'
	print 'N_RDF = ', N_rdf
	print 'N_LD = ', N_ld

	ax = plt.subplot(1,2,1) ; ax.plot(r,g, label = r'$g(r)$') ; ax.legend()
	ax = plt.subplot(1,2,2) ; ax.plot(rho, h, label = r'$h(\rho)$') ; ax.legend()
	plt.show()

	os.remove(ld.rdfpickle)
	os.remove(ld.ldpickle)
Exemplo n.º 2
0
def makeAllLD(LDCuts, LDDelta = 0.5):
	global Trj, BoxL, AtomNames, AtomTypes, NB, NW
	__prepHeadVars()

	LDPairs = {'BB': (1,1), 'BW' : (1,2), 'WB': (2,1), 'WW' : (2,2)}
	if not type(LDCuts) is dict:
		raise TypeError("LDCuts must be a dict of the form {'BB': <>, 'BW': <>, 'WB': <>, 'WW': <>}")

	if not NW: 
		LDPairs.pop('BW'); LDPairs.pop('WW'); LDPairs.pop('WB')
	
	if not NB:
		LDPairs.pop('BW'); LDPairs.pop('BB'); LDPairs.pop('WB')

	sc.LammpsTraj = Traj
	sc.Nbins = 100
	sc.TrjIter[2] = MeasureFreq
	sc.LDDelta = LDDelta
	sc.Normalize = Normalize
	sc.AtomNames2Types = AtomNames2Types

	sc.calcErrorBar = calcErrorBar
	sc.NBlocks = NBlocks

	for ext in LDPairs.keys():
		sc.LDCut = LDCuts[ext]
		sc.Prefix = Prefix + '_%s' % ext
		sc.genFileNames()
		if __isComputed(sc.ldpickle): continue
		sc.makeLD(LDPairs[ext][0], LDPairs[ext][1])
Exemplo n.º 3
0
def testInfCut():
	ld = __prepLD()
	ld.LammpsTraj = os.path.expanduser('~/benwat/data/gromacs/NB250NW250/NB250NW250_prod.lammpstrj.gz')
	ld.LDDelta = 1.0
	ld.LDCut = 1e3
	ld.Normalize = True

	ld.Prefix = 'infCut'
	ld.genFileNames()

	for i, ldtype in enumerate([(1,1), (2,2), (1,2), (2,1)]):
		print ldtype
		ld.makeLD(ldtype[0], ldtype[1])
		r,h,e,x,y  = pickle.load(open(ld.ldpickle, 'r'))
		ax = plt.subplot(2,2,i+1)
		ax.plot(r,h, label = 'C: %d, N: %d' % (ldtype[0], ldtype[1]))
		ax.legend()

	os.remove(ld.ldpickle)
	plt.show()
Exemplo n.º 4
0
#choices for LDCuts for NB250NW250
#BB: 1st shell = 7.66, quite good
#WW: 1st shell = 3.5, 2nd shell = 5.75, 3rd shell = 8
#BW: 1st shell = 3.8, 2nd shell = 6.25, 3rd shell = 9

LDTypes = ['BB', 'WW', 'BW', 'WB']
LDCuts = dict(BB = 7.66 , WW = 3.5 , BW = 17, WB = 9)
LDAtomTypes = dict(BB = (1,1), WW = (2,2), BW = (1,2), WB = (2,1))

ld.Normalize = True
ld.MeasureFreq = 50
ld.Normalize = True
ld.Nbins = 100
ld.AtomNames2Types = True
ld.LammpsTraj = os.path.expanduser('~/benwat/data/gromacs/NB250NW250/NB250NW250_prod.lammpstrj.gz')
ld.Prefix = 'NB250NW250_AA_%s' % LDType

ld.calcErrorBar = False

ld.LDCut = LDCuts[LDType]
ld.LDDelta = 1.0

ld.genFileNames()
ld.makeLD(LDAtomTypes[LDType][0], LDAtomTypes[LDType][1])

r,h,e,x,ld  = pickle.load(open(ld.ldpickle, 'r'))
plt.plot(r,h)
plt.show()