atoms.center(vacuum=10.0, axis=2) atoms.set_momenta(np.zeros((len(atoms), 3))) # Select an atom to get a kick r = atoms.get_positions() uc = atoms.get_cell() x = r[:, 0] - 0.5 * uc[0, 0] y = r[:, 1] - 0.5 * uc[1, 1] z = r[:, 2] zprime = z - 0.01 * (x * x + y * y) n = np.argmax(zprime) #a = atoms[n] #dp = np.sqrt(2 * a.mass * 1000.0) #a.momentum = np.array([0, 0, dp]) t = np.zeros(len(atoms), int) t[n] = 1 atoms.set_tags(t) else: atoms = None atoms = MakeParallelAtoms(atoms, cpulayout) print len(atoms), atoms.get_number_of_atoms() atoms.set_calculator(EMT()) traj = PickleTrajectory("UnBalance.traj", "w", atoms) if fast: atoms.get_forces() traj.write() for i in range(50): print "\n\n\n\n*** STEP %i ***\n\n\n\n\n" % (i, ) r = atoms.get_positions() r += atoms.get_tags().reshape((-1, 1)) * np.array([ [0, 0, 20.0],
if world.size == 1: cpulayout = None elif world.size == 2: cpulayout = [2,1,1] elif world.size == 3: cpulayout = [1,3,1] elif world.size == 4: cpulayout = [2,1,2] if ismaster: init = FaceCenteredCubic(size=(10,10,10), symbol='Cu', pbc=False) z = init.get_positions()[:,2] fixedatoms = np.less(z, 0.501*z.max()) print len(init), sum(fixedatoms) MaxwellBoltzmannDistribution(init, 6000*units.kB) init.set_tags(fixedatoms) else: init = None print print "Running simulation with Filter" atoms1 = MakeParallelAtoms(init, cpulayout) atoms1.arrays['r_init'] = atoms1.get_positions() atoms1.set_calculator(EMT()) atoms1a = Filter(atoms1, mask=np.logical_not(atoms1.get_tags())) dyn = VelocityVerlet(atoms1a, 3*units.fs) dyn.run(100) print print "Running simulation with Asap's FixAtoms"
atoms.center(vacuum=10.0, axis=2) atoms.set_momenta(np.zeros((len(atoms),3))) # Select an atom to get a kick r = atoms.get_positions() uc = atoms.get_cell() x = r[:,0] - 0.5 * uc[0,0] y = r[:,1] - 0.5 * uc[1,1] z = r[:,2] zprime = z - 0.01 * (x * x + y * y) n = np.argmax(zprime) #a = atoms[n] #dp = np.sqrt(2 * a.mass * 1000.0) #a.momentum = np.array([0, 0, dp]) t = np.zeros(len(atoms), int) t[n] = 1 atoms.set_tags(t) else: atoms = None atoms = MakeParallelAtoms(atoms, cpulayout) print len(atoms), atoms.get_number_of_atoms() atoms.set_calculator(EMT()) traj = PickleTrajectory("UnBalance.traj", "w", atoms) if fast: atoms.get_forces() traj.write() for i in range(50): print "\n\n\n\n*** STEP %i ***\n\n\n\n\n" % (i,) r = atoms.get_positions() r += atoms.get_tags().reshape((-1,1)) * np.array([[0, 0, 20.0],]) atoms.set_positions(r)