Ejemplo n.º 1
0
    def collectGlobalEnergy(self):
        eLocal = np.zeros(2)
        eSum = np.zeros(2)

        eLocal[0] = self.eKineticLocal
        eLocal[1] = self.ePotLocal

        parallel.addParallel(eLocal, eSum)

        self._eKinetic = eSum[0]
        self._ePot = eSum[1]

        self.globalEnergyGood = True
Ejemplo n.º 2
0
def computeVcm(sim):
    vcm = np.zeros(3)
    vcmGlobal = np.zeros(3)
    totalMass = 0.0
    # for i in range(sim.atoms.nAtoms):
    for iBox in range(sim.boxes.nLocalBoxes):
        iOff = sim.boxes.MAXATOMS * iBox
        for ii in range(sim.boxes.nAtoms[iBox]):
            vcm += sim.atoms.p[iOff, :]
            iSpecies = sim.atoms.species[iOff]
            totalMass += sim.species[iSpecies].mass
            iOff += 1

    parallel.addParallel(vcm, vcmGlobal)

    vcm = vcmGlobal / totalMass
    return vcm
Ejemplo n.º 3
0
def createFccLattice(nx, ny, nz, lat, atoms, boxes, domain):
    """Create atom positions on a face centered cubic (FCC) lattice
       with nx * ny * nz unit cells and lattice constance 'lat'
    """
    nb = 4  # number of atoms in this basis

    basis = [(0.25, 0.25, 0.25), (0.25, 0.75, 0.75), (0.75, 0.25, 0.75), (0.75, 0.75, 0.25)]

    begin = [int(x) for x in np.floor(domain.localMin / lat)]
    end = [int(x) for x in np.ceil(domain.localMax / lat)]

    idx = 0
    for ix in range(begin[0], end[0]):
        for iy in range(begin[1], end[1]):
            for iz in range(begin[2], end[2]):
                for ib in range(nb):
                    rx = (ix + basis[ib][0]) * lat
                    ry = (iy + basis[ib][1]) * lat
                    rz = (iz + basis[ib][2]) * lat
                    if rx < domain.localMin[0] or rx >= domain.localMax[0]:
                        continue
                    if ry < domain.localMin[1] or ry >= domain.localMax[1]:
                        continue
                    if rz < domain.localMin[2] or rz >= domain.localMax[2]:
                        continue

                    gid = ib + nb * (iz + nz * (iy + ny * ix))
                    boxes.putAtomInBox(atoms, gid, 0, rx, ry, rz)
                    idx += 1

    nlocal = np.zeros(1, dtype=np.int)
    nglobal = np.zeros(1, dtype=np.int)
    nlocal[0] = idx

    parallel.addParallel(nlocal, nglobal)

    atoms.nGlobal = nglobal[0]
    if atoms.nGlobal != nb * nx * ny * nz:
        print "nGlobal = ", atoms.nGlobal
        print "nb,nx,ny,nz,product", nb, nx, ny, nz, nb * nx * ny * nz
    assert atoms.nGlobal == nb * nx * ny * nz