def InitSystem(Natoms):
    NeighborsList = hoomd.md.nlist.cell()
    mypot = "KAshort" if Natoms < 500 else "KA"
    potential = pot.LJ(NeighborsList, type=mypot)
    analyzer = hoomd.analyze.log(filename=None,
                                 quantities=[
                                     'temperature', 'potential_energy',
                                     'kinetic_energy', 'momentum'
                                 ],
                                 period=None,
                                 header_prefix='#',
                                 overwrite=True,
                                 phase=0)
    return potential, analyzer
Ejemplo n.º 2
0
def CalculateRidge(snapT1, snapT2, Eis1, Eis2, L):
	''' Calculates energy at the ridge between two snapshots '''
	print("--- Calculate Ridge ---\n- Eis1:",Eis1,' Eis2:',Eis2)

	dmax=0.0001 #0.004 is about the typical distance between confs at subsequent time steps with dt=0.0025
	nsteps=1
	niter=10000
	snapT1.particles.velocity[:]=np.zeros((Natoms, 3))
	snapT2.particles.velocity[:]=np.zeros((Natoms, 3))

	#snapis are not inherent structures, but the gradually approach them
	snapis1,snapis2,snapis12,Eis1,Eis2,Eis12,dist12=ConfBisect(snapT1, snapT2, Eis1, Eis2, L, dmax=dmax)

	print("- Eis1=%.8f;\tEis2= %.8f (after ConfBisect)"%(Eis1,Eis2))

	context1 = hoomd.context.SimulationContext();
	with context1:
		system1 = hoomd.init.read_snapshot(snapis1)
		modeFire1=md.integrate.mode_minimize_fire(dt=dtFIRE, alpha_start=alphaFIRE, ftol=ftolFIRE, Etol=EtolFIRE, wtol=wtolFIRE)
		integrator1 = md.integrate.nve(group=hoomd.group.all())
		analyzerFire1=SetupAnalyzer(logname=None, period='None')
		md.update.zero_momentum(phase=2, period=10)
		pair=pot.LJ(md.nlist.cell(),type="KAshort")

	context2 = hoomd.context.SimulationContext();
	with context2:
		system2 = hoomd.init.read_snapshot(snapis2)
		modeFire2=md.integrate.mode_minimize_fire(dt=dtFIRE, alpha_start=alphaFIRE, ftol=ftolFIRE, Etol=EtolFIRE, wtol=wtolFIRE)
		integrator2 = md.integrate.nve(group=hoomd.group.all())
		analyzerFire2=SetupAnalyzer(logname=None, period='None')
		md.update.zero_momentum(phase=2, period=10)
		pair=pot.LJ(md.nlist.cell(),type="KAshort")

	modeFire1.reset()
	modeFire2.reset()


	for iter in range(niter):
		with context1:
			system1.restore_snapshot(snapis1)
			hoomd.run(nsteps)
			eis1=analyzerFire1.query('potential_energy')
			snapis1=system1.take_snapshot(dtype='double')
		with context2:
			system2.restore_snapshot(snapis2)
			hoomd.run(nsteps)
			eis2=analyzerFire2.query('potential_energy')
			snapis2=system2.take_snapshot(dtype='double')

		dist12=med.PeriodicDistance(snapis1.particles.position, snapis2.particles.position, L).sum()/Natoms

		print("iter: ",iter," dist12=",dist12,"eis1: %.14f"%eis1," eis2: %.14f"%eis2)

		if dist12>dmax:
			'''
			With the linear interpolations the found barrier is occasionally lower than one of the ISs, because of nonlinearities in the path.
			# snapRidge=LinearConfInterpolation(snapis1_old, snapis2_old, L)
			# Eridge=potential.CalculateEnergySlower(snapRidge)
			For this reason, I just take the energy of one of the two confs at the previous step.
			'''
			if eis1>eis2: 
				Eridge=ConsistentRidge(eis1_old,Eis1,Eis2,args.deltaE)
				snapRidge=snapis1_old
			else : 
				Eridge=ConsistentRidge(eis2_old,Eis1,Eis2,args.deltaE)
				snapRidge=snapis2_old
			print("Eridge = ",Eridge)
			break

		snapis1_old=snapis1
		snapis2_old=snapis2
		eis1_old=eis1
		eis2_old=eis2

	if iter==niter-1: sys.exit('CalculateRidge did not converge after '+str(niter)+' steps')
	return Eridge,snapRidge
Ejemplo n.º 3
0
#
################################################################
system = hoomd.init.read_gsd(filename=filename)
snapT_old=system.take_snapshot()
snapT_old.particles.position[:]=posizioni[0]
snapT_old.particles.velocity[:] = np.zeros((Natoms,3))
snapT=system.take_snapshot()
snapT.particles.velocity[:] = np.zeros((Natoms,3))

################################################################
# 
# Set potential and analyzer
#
################################################################
NeighborsList = md.nlist.cell()
potential=pot.LJ(NeighborsList,type="KAshort")
analyzer_quantities = ['temperature', 'pressure', 'potential_energy', 'kinetic_energy', 'momentum'] #, 'volume', 'num_particles']
analyzer = hoomd.analyze.log(filename=None, quantities=analyzer_quantities, period=None)


################################################################
# 
# Functions
#
################################################################

def Minimize(snap):
	system.restore_snapshot(snap)
	fire.cpp_integrator.reset()
	if not integrator_fire.enabled: integrator_fire.enable()
	while not(fire.has_converged()):
Ejemplo n.º 4
0
#If it's the first chunk, there is no list of energies.
#Otherwise, we open it and make sure that the time step is consistent.
if(ichunk>0):
	elist_old=np.loadtxt('elistIS.txt',skiprows=skiprows)
	assert(int(elist_old[len(elist_old)-1][0])==t0-1)

################################################################
# 
# Set potential
#
################################################################
NeighborsListLJ = md.nlist.cell()
print(" *** KApotentialShort *** ")

potential=pot.LJ(NeighborsListLJ,type="KAshort") #myLJpair is now an attribute of potential. To call it: potential.GetLJpair()


################################################################
# 
# Set analyzer
#
################################################################
print("\n\n\nSET UP ANALYZER\n")

analyzer_quantities = ['temperature', 'pressure', 'potential_energy', 'kinetic_energy', 'momentum'] #, 'volume', 'num_particles']
analyzer = hoomd.analyze.log(filename=None, quantities=analyzer_quantities, period=1)

################################################################
# 
# Function declaration
	F[t]=np.array(snap.particles.acceleration[:],dtype=np.float64)
	return



################################################################
# OBSERVABLES
################################################################
P=np.ndarray( (args.Ntraj, Natoms, 3), dtype=np.float64)
F=np.ndarray( (args.Ntraj, Natoms, 3), dtype=np.float64)

################################################################
# INTEGRATE
################################################################
NeighborsList = md.nlist.cell()
potential=pot.LJ(NeighborsList,type="LJmono")

modeT=md.integrate.mode_standard(dt=args.dt)
md.update.zero_momentum(phase=0, period=int(1./args.dt))

#Thermalize
extraThermalizing=False
if extraThermalizing:
	print('Thermalizing with NVT')
	integratorNVT = md.integrate.nvt(group=hoomd.group.all(), kT=args.temperature, tau=args.tauT)
	hoomd.run(int(10./args.dt), quiet=False)
	hoomd.dump.gsd(filename='./sample-states/rotenberg.gsd', overwrite=True, truncate=True, period=None, time_step=0, group=hoomd.group.all())
	integratorNVT.disable()

#The trajectory
print('Measurement trajectory')
Ejemplo n.º 6
0
system = hoomd.init.read_gsd(filename=filename,
                             restart=backupname,
                             frame=iframe)
assert (Natoms == len(system.particles))
iniStep = hoomd.get_step()
print("iframe: ", iframe)
print("Initial step: ", iniStep)

################################################################
#
# SET UP POTENTIAL
#
################################################################
NeighborsList = md.nlist.cell()
if Natoms < 500:
    myLjPair = pot.LJ(NeighborsList, type="KAshort")
else:
    myLjPair = pot.LJ(NeighborsList, type="KA")

################################################################
#
# SET UP ANALYZER
#
################################################################
print("\n\n\nSET UP ANALYZER\n")

#Name of the log
logname = label + ".txt"

#These are the observables we want to log
analyzerManyVariables_quantities = [
Ejemplo n.º 7
0
	snap=system.take_snapshot()
	P[t]=np.array(snap.particles.velocity[:],dtype=np.float64)
	F[t]=np.array(snap.particles.acceleration[:],dtype=np.float64)
	return

################################################################
# OBSERVABLES
################################################################
P=np.ndarray( (args.Ntraj, Natoms, 3), dtype=np.float64)
F=np.ndarray( (args.Ntraj, Natoms, 3), dtype=np.float64)

################################################################
# INTEGRATE
################################################################
NeighborsList = md.nlist.cell()
potential=pot.LJ(NeighborsList,type="KA") if Natoms > 500 else pot.LJ(NeighborsList,type="KAshort")


modeT=md.integrate.mode_standard(dt=args.dt)
md.update.zero_momentum(phase=0, period=int(1./args.dt))

#Thermalize
if args.extraThermalizing:
	print('Thermalizing with NVT')
	integratorNVT = md.integrate.nvt(group=hoomd.group.all(), kT=args.temperature, tau=args.tauT)
	hoomd.run(int(10./args.dt), quiet=False)
	hoomd.dump.gsd(filename='./sample-states/rotenbergKA_T'+str(args.temperature)+'_N'+str(Natoms)+'.gsd', overwrite=True, truncate=True, period=None, time_step=0, group=hoomd.group.all())
	integratorNVT.disable()

#The trajectory
print('Measurement trajectory')
        'The two configurations do not have the same particle indices')
#Same space dimensionality
if snap.box.dimensions != s2.configuration.dimensions:
    raise ValueError(
        'The two configurations live in different spatial dimensions (%d and %d)'
        % (snap.box.dimensions, s2.configuration.dimensions))
#Same box size
if L == s2.configuration.box[0] == False:
    raise ValueError(
        'Either the two boxes are different (Lx1=%g and Lx2=%g), or you should make a decent floating point comparison'
        % (snap.box.Lx, s2.configuration.box[0]))

#Neighborlist, Potential and Analyzer
NeighborsList = md.nlist.cell()
mypot = "KAshort" if Natoms < 500 else "KA"
potential = pot.LJ(NeighborsList, type=mypot)
analyzer = hoomd.analyze.log(filename=None,
                             quantities=[
                                 'temperature', 'potential_energy',
                                 'kinetic_energy', 'momentum'
                             ],
                             period=None,
                             header_prefix='#',
                             overwrite=True,
                             phase=0)


def Minimize(snap):
    system.restore_snapshot(snap)
    fire.cpp_integrator.reset()
    while not (fire.has_converged()):
Ejemplo n.º 9
0
    return snap1, snap2, snap12, eis1, eis2, eis12, dist12


################################################################
#
# INITIALIZE
#
################################################################
backupname = label + "_backup.gsd"
simT = hoomd.context.SimulationContext()
simIS = hoomd.context.SimulationContext()

with simT:
    systemT = hoomd.init.read_gsd(filename=filename, restart=None)
    assert (Natoms == len(systemT.particles))
    myLjPair = pot.LJ(md.nlist.cell(), type="KAshort")
    analyzerStandard = SetupAnalyzer(logname=None, period=None)
    modeStandard = md.integrate.mode_standard(dt=dt)
    md.update.zero_momentum(phase=2, period=10)
    integrator = md.integrate.nvt(group=hoomd.group.all(),
                                  kT=temperature,
                                  tau=tauT)
    hoomd.run(5 / dt)
    snapT = systemT.take_snapshot(dtype='double')
    boxParamsT = snapT.box

with simIS:
    systemIS = hoomd.init.read_gsd(filename=filename, restart=None)
    assert (Natoms == len(systemIS.particles))
    myLjPair = pot.LJ(md.nlist.cell(), type="KAshort")
    analyzerFire = SetupAnalyzer(logname=None, period='None')
Ejemplo n.º 10
0
	def InitPotential(self):
		self.NeighborsList = md.nlist.cell()
		if self.params.Natoms<500: assert(self.params.potential=='KAshort')
		self.pair=pot.LJ(self.NeighborsList, type=self.params.potential)
		return
Ejemplo n.º 11
0
context = hoomd.context.initialize()

#PARAMETERS
T = 2.0
Natoms = 1080
maindir = '../../OUTPUT/T' + str(T) + '/N' + str(Natoms) + '/'
samples = range(10)
nsamples = len(samples)
EPS = 1e-8

#READ THERMALIZED SYSTEM (for copying particle types and creating snapshots) AND POTENTIAL
sam = 0
system = hoomd.init.read_gsd(filename=maindir + '/S' + str(sam) +
                             '/thermalized.gsd')
L = system.box.Lx
pair = pot.LJ(md.nlist.cell(), type='KAshort')

#READ HEAVY TRAJECTORY

#Make sure that L and dt are consistent
for isam in range(nsamples):
    sam = samples[isam]
    name = maindir + '/S' + str(sam) + '/heavyTraj/L.txt'
    f = open(name, 'rt')
    Ltemp = np.float64(f.readline())
    if 0 == isam:
        dt = np.float64(f.readline())
    else:
        dttemp = np.float64(f.readline())
        if np.abs(dt - dttemp) > EPS:
            raise ValueError(