def MakeAtoms(elem1, elem2=None): if elem2 is None: elem2 = elem1 a1 = reference_states[elem1]['a'] a2 = reference_states[elem2]['a'] a0 = (0.5 * a1**3 + 0.5 * a2**3)**(1.0/3.0) * 1.03 if ismaster: # 50*50*50 would be big enough, but some vacancies are nice. print "Z1 = %i, Z2 = %i, a0 = %.5f" % (elem1, elem2, a0) atoms = FaceCenteredCubic(symbol='Cu', size=(51,51,51)) nremove = len(atoms) - 500000 assert nremove > 0 remove = np.random.choice(len(atoms), nremove, replace=False) del atoms[remove] if isparallel: atoms = atoms.repeat(cpuLayout) if elem1 != elem2: z = atoms.get_atomic_numbers() z[np.random.choice(len(atoms), len(atoms)/2, replace=False)] = elem2 atoms.set_atomic_numbers(z) else: atoms = None if isparallel: atoms = MakeParallelAtoms(atoms, cpuLayout) MaxwellBoltzmannDistribution(atoms, T * units.kB) return atoms
def MakeAtoms(elem1, elem2=None): if elem2 is None: elem2 = elem1 a1 = reference_states[elem1]['a'] a2 = reference_states[elem2]['a'] a0 = (0.5 * a1**3 + 0.5 * a2**3)**(1.0 / 3.0) * 1.03 if ismaster: print "Z1 = %i, Z2 = %i, a0 = %.5f" % (elem1, elem2, a0) # 50*50*50 would be big enough, but some vacancies are nice. atoms = FaceCenteredCubic(symbol='Cu', size=(51, 51, 51)) nremove = len(atoms) - 500000 assert nremove > 0 remove = np.random.choice(len(atoms), nremove, replace=False) del atoms[remove] if elem1 != elem2: z = atoms.get_atomic_numbers() z[np.random.choice(len(atoms), len(atoms) / 2, replace=False)] = elem2 atoms.set_atomic_numbers(z) if isparallel: # Move this contribution into position uc = atoms.get_cell() x = mpi.world.rank % cpuLayout[0] y = (mpi.world.rank // cpuLayout[0]) % cpuLayout[1] z = mpi.world.rank // (cpuLayout[0] * cpuLayout[1]) assert (0 <= x < cpuLayout[0]) assert (0 <= y < cpuLayout[1]) assert (0 <= z < cpuLayout[2]) offset = x * uc[0] + y * uc[1] + z * uc[2] new_uc = cpuLayout[0] * uc[0] + cpuLayout[1] * uc[1] + cpuLayout[ 2] * uc[2] atoms.set_cell(new_uc, scale_atoms=False) atoms.set_positions(atoms.get_positions() + offset) # Distribute atoms. Maybe they are all on the wrong cpu, but that will # be taken care of. atoms = MakeParallelAtoms(atoms, cpuLayout) MaxwellBoltzmannDistribution(atoms, T * units.kB) return atoms
def MakeAtoms(elem1, elem2=None): if elem2 is None: elem2 = elem1 a1 = reference_states[elem1]['a'] a2 = reference_states[elem2]['a'] a0 = (0.5 * a1**3 + 0.5 * a2**3)**(1.0/3.0) * 1.03 if ismaster: print "Z1 = %i, Z2 = %i, a0 = %.5f" % (elem1, elem2, a0) # 50*50*50 would be big enough, but some vacancies are nice. atoms = FaceCenteredCubic(symbol='Cu', size=(51,51,51)) nremove = len(atoms) - 500000 assert nremove > 0 remove = np.random.choice(len(atoms), nremove, replace=False) del atoms[remove] if elem1 != elem2: z = atoms.get_atomic_numbers() z[np.random.choice(len(atoms), len(atoms)/2, replace=False)] = elem2 atoms.set_atomic_numbers(z) if isparallel: # Move this contribution into position uc = atoms.get_cell() x = mpi.world.rank % cpuLayout[0] y = (mpi.world.rank // cpuLayout[0]) % cpuLayout[1] z = mpi.world.rank // (cpuLayout[0] * cpuLayout[1]) assert(0 <= x < cpuLayout[0]) assert(0 <= y < cpuLayout[1]) assert(0 <= z < cpuLayout[2]) offset = x * uc[0] + y * uc[1] + z * uc[2] new_uc = cpuLayout[0] * uc[0] + cpuLayout[1] * uc[1] + cpuLayout[2] * uc[2] atoms.set_cell(new_uc, scale_atoms=False) atoms.set_positions(atoms.get_positions() + offset) # Distribute atoms. Maybe they are all on the wrong cpu, but that will # be taken care of. atoms = MakeParallelAtoms(atoms, cpuLayout) MaxwellBoltzmannDistribution(atoms, T * units.kB) return atoms
pbc = tuple(random.randint(0, 2, 3)) print "Periodic boundaries:", pbc #Verbose(1) atoms = FaceCenteredCubic(directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], size=(10, 10, 10), symbol=element, pbc=pbc) atoms2 = atoms.copy() atoms = MonteCarloAtoms(atoms) print "Number of atoms:", len(atoms) # Replace 10% of the atoms with element2 newz = where(greater(random.random((len(atoms), )), 0.9), element2number, elementnumber) atoms.set_atomic_numbers(newz) atoms2.set_atomic_numbers(newz) atoms.set_calculator(MonteCarloEMT()) atoms2.set_calculator(EMT()) atoms.get_potential_energy() for e in ((element, elementnumber), (element2, element2number)): print("Number of %s atoms (Z=%d): %d" % (e[0], e[1], sum(equal(atoms.get_atomic_numbers(), e[1])))) print print "Testing perturbations of single atoms" magnarr = array((0.0, 0.01, 0.1, 1.0, 3.0, 10.0)) numarr = array((1, 3, 10, len(atoms) / 2, -3))
natoms * shellpop[n], 0) n += 1 else: ReportTest(("Between shells (%d)" % (i, )), globalrdf[i], 0, 0) latconst, maxrdf, nbins, withemt = 3.6, 6.001, 100, False atoms = FaceCenteredCubic(directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], symbol="Cu", size=(10, 10, 10), latticeconstant=latconst, debug=0) natoms = len(atoms) z = atoms.get_atomic_numbers() z[100] = 47 atoms.set_atomic_numbers(z) ReportTest("Number of atoms", natoms, 4000, 0) if withemt: atoms.set_calculator(EMT()) print atoms.get_potential_energy() result = _asap.RawRDF(atoms, maxrdf, nbins, zeros(len(atoms), int32), 1, ListOfElements(atoms)) globalrdf, rdfdict, countdict = result print globalrdf print rdfdict print countdict
break ReportTest(("Shell %d (%d)" % (n+1, i)), globalrdf[i], natoms*shellpop[n], 0) n += 1 else: ReportTest(("Between shells (%d)" % (i,)), globalrdf[i], 0, 0) latconst, maxrdf, nbins, withemt = 3.6, 6.001, 100, False atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]], symbol="Cu", size=(10,10,10), latticeconstant=latconst, debug=0) natoms = len(atoms) z = atoms.get_atomic_numbers() z[100] = 47 atoms.set_atomic_numbers(z) ReportTest("Number of atoms", natoms, 4000, 0) if withemt: atoms.set_calculator(EMT()) print atoms.get_potential_energy() result = _asap.RawRDF(atoms, maxrdf, nbins, zeros(len(atoms), int32), 1, ListOfElements(atoms)) globalrdf, rdfdict, countdict = result print globalrdf print rdfdict print countdict