Exemple #1
0
    def test_purelb(self):
        global runSteps

        self.integrator.run(runSteps)

        # variables to hold average density and mass flux
        av_den = 0.
        av_j = Real3D(0.)

        # lattice variables. halo is hard coded
        halo = 1
        myNi = self.lb.getMyNi
        area_yz = (myNi[1] - 2 * halo) * (myNi[2] - 2 * halo)

        for i in range(halo, myNi[0] - halo):
            for j in range(halo, myNi[1] - halo):
                for k in range(halo, myNi[2] - halo):
                    av_den += self.lb.getLBMom(Int3D(i, j, k), 0)

                    jx = self.lb.getLBMom(Int3D(i, j, k), 1)
                    jy = self.lb.getLBMom(Int3D(i, j, k), 2)
                    jz = self.lb.getLBMom(Int3D(i, j, k), 3)
                    av_j += Real3D(jx, jy, jz)
            av_den /= area_yz
            av_j /= area_yz

            print av_den, av_j

            self.assertAlmostEqual(av_den, initDen, places=2)
            self.assertAlmostEqual(av_j[0], initVel, places=2)
            self.assertAlmostEqual(av_j[1], initVel, places=2)
            self.assertAlmostEqual(av_j[2], initVel, places=2)

            av_den = 0.
            av_j = Real3D(0.)
Exemple #2
0
    def setUp(self):
        # set up system
        system = espressopp.System()
        system.rng = espressopp.esutil.RNG()
        system.bc = espressopp.bc.OrthorhombicBC(system.rng, size)
        system.skin = skin

        comm = MPI.COMM_WORLD

        nodeGrid = Int3D(1, 1, comm.size)
        cellGrid = Int3D(calcNumberCells(size[0], nodeGrid[0], cutoff),
                         calcNumberCells(size[1], nodeGrid[1], cutoff),
                         calcNumberCells(size[2], nodeGrid[2], cutoff))
        system.storage = espressopp.storage.DomainDecomposition(
            system, nodeGrid, cellGrid)

        pid = 0

        system.storage.addParticle(
            0, Real3D(6.1162456968, 3.9088541374, 9.4409851324))
        system.storage.addParticle(
            1, Real3D(5.9516473019, 4.2535440563, 9.4778266528))
        system.storage.addParticle(
            2, Real3D(5.8160837525, 4.1043280354, 9.8101428319))
        system.storage.addParticle(
            3, Real3D(6.0145256344, 4.0133146160, 9.4982604364))

        system.storage.decompose()
        self.system = system
Exemple #3
0
    def run_average(self, _vz):
        # variables to hold average density and mass flux
        av_den = 0.
        av_j = Real3D(0.)

        # lattice variables. halo is hard coded
        halo = 1
        myNi = self.lb.getMyNi
        volume_xyz = (myNi[0] - 2 * halo) * (myNi[1] - 2 * halo) * (myNi[2] -
                                                                    2 * halo)

        for i in range(halo, myNi[0] - halo):
            for j in range(halo, myNi[1] - halo):
                for k in range(halo, myNi[2] - halo):
                    av_den += self.lb.getLBMom(Int3D(i, j, k), 0)

                    jx = self.lb.getLBMom(Int3D(i, j, k), 1)
                    jy = self.lb.getLBMom(Int3D(i, j, k), 2)
                    jz = self.lb.getLBMom(Int3D(i, j, k), 3)
                    av_j += Real3D(jx, jy, jz)
        av_den /= volume_xyz
        av_j /= volume_xyz

        print av_den, av_j

        self.assertAlmostEqual(av_den, initDen, places=2)
        self.assertAlmostEqual(av_j[0], initVel, places=2)
        self.assertAlmostEqual(av_j[1], initVel, places=2)
        self.assertAlmostEqual(av_j[2], _vz, places=2)
Exemple #4
0
def cellGrid(box_size, node_grid, rc, skin, halfCellInt=1):
    rc_skin = rc + skin
    if rc_skin == 0:
        raise Error("interaction range (cutoff + skin) must be larger than 0")
    if (node_grid[0] <= 0 or node_grid[1] <= 0 or node_grid[2] <= 0):
        raise Error("invalid node grid %s" % str(node_grid))
    ix = (box_size[0] * halfCellInt) / (rc_skin * node_grid[0])

    if ix < 1:
        raise Error(
            "local box size in direction 0 (=%6f) is smaller than interaction range (cutoff + skin = %6f).\n \
                 hint: number of CPUs maybe too high or is prime, perhaps you could also try with Halfcells."
            % (ix, rc_skin))
    iy = (box_size[1] * halfCellInt) / (rc_skin * node_grid[1])
    if iy < 1:
        raise Error(
            "local box size in direction 1 (=%6f) is smaller than interaction range (cutoff + skin = %6f).\n \
                 hint: number of CPUs maybe too high or is prime, perhaps you could also try with Halfcells."
            % (iy, rc_skin))
    iz = (box_size[2] * halfCellInt) / (rc_skin * node_grid[2])
    if iz < 1:
        raise Error(
            "local box size in direction 2 (=%6f) is smaller than interaction range (cutoff + skin = %6f).\n \
                 hint: number of CPUs maybe too high or is prime, perhaps you could also try with Halfcells."
            % (iz, rc_skin))

    return Int3D(ix, iy, iz)
 def __init__(self, system,
              nodeGrid='auto',
              cellGrid='auto',
              halfCellInt = 'auto',
              nocheck=False):
     # do sanity checks for the system first
     if nocheck:
         self.next_id = 0
         self.pmiinit(system, nodeGrid, cellGrid, halfCellInt)
     else:
         if check.System(system, 'bc'):
             if nodeGrid == 'auto':
                 nodeGrid = decomp.nodeGridSimple(system.comm.rank)
             else:
                 nodeGrid = toInt3DFromVector(nodeGrid)
             if cellGrid == 'auto':
                 cellGrid = Int3D(2,2,2)
             else:
                 cellGrid = toInt3DFromVector(cellGrid)
             if halfCellInt == 'auto':
                 halfCellInt = 1
             # minimum image convention check:
             for k in range(3):
                 if nodeGrid[k]*cellGrid[k] == 1 :
                     print(("Warning! cellGrid[{}] has been "
                            "adjusted to 2 (was={})".format(k, cellGrid[k])))
                     cellGrid[k] = 2
             self.next_id = 0
             self.pmiinit(system, nodeGrid, cellGrid, halfCellInt)
         else:
             print('Error: could not create DomainDecomposition object')
        def __init__(self,
                     system,
                     nodeGrid='auto',
                     cellGrid='auto',
                     neiListx='auto',
                     neiListy='auto',
                     neiListz='auto'):
            if nodeGrid == 'auto':
                nodeGrid = Int3D(system.comm.rank, 1, 1)
            else:
                nodeGrid = toInt3DFromVector(nodeGrid)

            if cellGrid == 'auto':
                # TODO: Implement
                raise 'Automatic cell size calculation not yet implemented'
            else:
                cellGrid = toInt3DFromVector(cellGrid)
            if neiListx == 'auto':
                neiListx = 0
            else:
                neiListx = neiListx
            if neiListy == 'auto':
                neiListy = 0
            else:
                neiListy = neiListy
            if neiListz == 'auto':
                neiListz = 0
            else:
                neiListz = neiListz
            self.next_id = 0
            self.pmiinit(system, nodeGrid, cellGrid, neiListx, neiListy,
                         neiListz)
Exemple #7
0
    def modifyParticle(self, pid, property, value):
        if not (pmi._PMIComm and pmi._PMIComm.isActive()
                ) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():

            if (self.particleExists(pid)):
                #try:
                #if not particle.isGhost:
                particle = self.getParticle(pid)
                self.logger.info("particle pid=%i rank=%i" % (pid, pmi.rank))
                if property.lower() == "id":
                    raise "particles pid cannot be modified !"
                elif property.lower(
                ) == "pos":  # alway assume unfolded coordinates
                    particle.pos = value
                    particle.imageBox = Int3D(0, 0, 0)
                elif property.lower() == "modepos":
                    particle.modepos = value
                elif property.lower() == "img":
                    particle.imageBox = value
                elif property.lower() == "type":
                    particle.type = value
                elif property.lower() == "pib":
                    particle.pib = value
                elif property.lower() == "mass":
                    particle.mass = value
                elif property.lower() == "varmass":
                    particle.varmass = value
                elif property.lower() == "v":
                    particle.v = value
                elif property.lower() == "modemom":
                    particle.modemom = value
                elif property.lower() == "f":
                    particle.f = value
                elif property.lower() == "q":
                    particle.q = value
                elif property.lower() == "radius":
                    particle.radius = value
                elif property.lower() == "fradius":
                    particle.fradius = value
                elif property.lower() == "vradius":
                    particle.vradius = value
                elif property.lower() == "lambda_adr":
                    particle.lambda_adr = value
                elif property.lower() == "lambda_adrd":
                    particle.lambda_adrd = value
                elif property.lower() == "state":
                    particle.state = value
                else:
                    raise SyntaxError(
                        'unknown particle property: %s' % property
                    )  # UnknownParticleProperty exception is not implemented
Exemple #8
0
def nodeGridSimple(n):
    ijkmax = 3 * n * n + 1
    d1 = 1
    d2 = 1
    d3 = 1
    for i in xrange(1, n + 1):
        for j in xrange(i, n + 1):
            for k in xrange(j, n + 1):
                if (i * j * k == n) and (i * i + j * j + k * k < ijkmax):
                    d1 = k
                    d2 = j
                    d3 = i
                    ijkmax = i * i + j * j + k * k
    return Int3D(d1, d2, d3)
Exemple #9
0
def nodeGridSimple(n):  # Mainly used for Lattice-Boltzmann and cubic geometries
    ijkmax = 3 * n * n + 1
    d1 = 1
    d2 = 1
    d3 = 1
    for i in range(1, n + 1):
        for j in range(i, n + 1):
            for k in range(j, n + 1):
                if (i * j * k == n) and (i * i + j * j + k * k < ijkmax):
                    d1 = k
                    d2 = j
                    d3 = i
                    ijkmax = i * i + j * j + k * k
    print("nodeGrid reads as follows: ",d1, d2, d3,".... BTW, You are not using HeSpaDDA")
    return Int3D(d1, d2, d3)
 def __init__(self, system, nodeGrid, cellGrid, neiListx, neiListy,
              neiListz):
     if not (pmi._PMIComm and pmi._PMIComm.isActive()
             ) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():
         p1 = pmi._MPIcomm.rank % nodeGrid[0]
         aux1 = pmi._MPIcomm.rank / nodeGrid[
             0]  # HDD comment: Getting the order of processors
         p2 = aux1 % nodeGrid[1]
         aux2 = aux1 / nodeGrid[1]
         p3 = aux2  # HDD comment: Obtaining the processors per axes (x,y,z)
         cellGrid = Int3D(neiListx[p1 + 1] - neiListx[p1],
                          neiListy[p2 + 1] - neiListy[p2],
                          neiListz[p3 + 1] - neiListz[p3])
         cxxinit(self, storage_DomainDecompositionNonBlocking, system,
                 nodeGrid, cellGrid, neiListx, neiListy, neiListz)
Exemple #11
0
    def setUp(self):
        # set up system
        system = espressopp.System()
        system.rng = espressopp.esutil.RNG()
        system.bc = espressopp.bc.OrthorhombicBC(system.rng, size)
        system.skin = skin

        comm = MPI.COMM_WORLD

        nodeGrid = Int3D(1, 1, comm.size)
        cellGrid = Int3D(calcNumberCells(size[0], nodeGrid[0], cutoff),
                         calcNumberCells(size[1], nodeGrid[1], cutoff),
                         calcNumberCells(size[2], nodeGrid[2], cutoff))
        system.storage = espressopp.storage.DomainDecomposition(
            system, nodeGrid, cellGrid)

        pid = 0

        system.storage.addParticle(0, Real3D(0.15, 0.1, 0))
        system.storage.addParticle(1, Real3D(0.4, 0.1, 0))

        system.storage.decompose()

        # integrator
        integrator = espressopp.integrator.VelocityVerlet(system)
        integrator.dt = 0.001

        # now build Verlet List
        # ATTENTION: you must not add the skin explicitly here
        logging.getLogger("Interpolation").setLevel(logging.INFO)
        vl = espressopp.VerletList(system, cutoff=cutoff)

        scaling_cv = 1.5
        alpha = 0.1

        # ATTENTION: auto shift was enabled
        # bonds
        writeTabFile(tabBonds[0], k=100000, x0=0.26, N=500, low=0.01, high=0.6)
        writeTabFile(tabBonds[1], k=50000, x0=0.24, N=500, low=0.01, high=0.6)

        fpl = espressopp.FixedPairList(system.storage)
        fpl.addBonds([(0, 1)])
        potBond = espressopp.interaction.TabulatedSubEns()
        potBond.addInteraction(
            1, tabBonds[0],
            espressopp.RealND([0.262, 0., 0., scaling_cv * 0.424, 0., 0.]))
        potBond.addInteraction(1, tabBonds[1],
                               espressopp.RealND([0., 0., 0., 0., 0., 0.]))
        potBond.alpha_set(alpha)
        cv_bl = espressopp.FixedPairList(system.storage)
        cv_bl.addBonds([])
        potBond.colVarBondList = cv_bl
        cv_al = espressopp.FixedTripleList(system.storage)
        cv_al.addTriples([])
        potBond.colVarAngleList = cv_al

        # Renormalize the CVs
        potBond.colVarSd_set(0, 0.0119)

        # Target probabilities
        potBond.targetProb_set(0, tgt_probs[0])
        potBond.targetProb_set(1, tgt_probs[1])

        interBond = espressopp.interaction.FixedPairListTabulatedSubEns(
            system, fpl, potBond)
        system.addInteraction(interBond)

        temp = espressopp.analysis.Temperature(system)

        temperature = temp.compute()
        Ek = 0.5 * temperature * (2 * numParticles)
        Ep = interBond.computeEnergy()

        # langevin thermostat
        langevin = espressopp.integrator.LangevinThermostat(system)
        integrator.addExtension(langevin)
        langevin.gamma = 1.0
        langevin.temperature = 2.479  # in kJ/mol

        # sock = espressopp.tools.vmd.connect(system)

        configurations = espressopp.analysis.Configurations(system)
        self.configuration = configurations
        self.system = system
        self.temp = temp
        self.integrator = integrator
        self.interBond = interBond
        self.potBond = potBond
Exemple #12
0
def neiListAdress(node_grid, cell_grid,rc,skin,eh_size,adrCenter,ratioMS,idealGasFlag=True,sphereAdr=False,slabMSDims=[1,0,0]):
    # dataStructure Initialization
    print "HDD message: Current heterogeneous NodeGrid (X,Y,Z) -> powered by HeSpaDDA:",node_grid
    rc_skin=rc+skin
    #define Neighbor vectors
    neiListx=[0]*(node_grid[0]+1)
    neiListy=[0]*(node_grid[1]+1)
    neiListz=[0]*(node_grid[2]+1)
    # Check adress regions
    adrCenter=[adrCenter[0],adrCenter[1],adrCenter[2]]
    # Midle point DD
    cursor=[adrCenter[0]*2,adrCenter[1]*2,adrCenter[2]*2]
    #cg_sizeR=adrCenter[0]+eh_size 	# for further devs
    #cg_sizeL=adrCenter[0]-eh_size	# for further devs
    cellsX=round(cursor[0]/ rc_skin-0.5)#round(cg_sizeL/rc_skin-0.5)+round((cursor[0]-cg_sizeR)/ rc_skin-0.5)+round((cg_sizeR-cg_sizeL)/rc_skin-0.5) # old implementation rounded # Cells too much!
    cellsY=round(cursor[1] / rc_skin-0.5)
    cellsZ=round(cursor[2] / rc_skin-0.5)
    print "HDD message: Current heterogeneous CellGrid (X,Y,Z) -> powered by HeSpaDDA:",cellsX,cellsY,cellsZ
    # This condition checks if the Sys is a Slab or a Sphere. It should work for any middle based Sys 
    if not sphereAdr:
	if slabMSDims[0]==1:
		halfneilListx=halfDecomp(adrCenter[0],rc_skin,eh_size,int(round(node_grid[0]/2.-0.5)),cellsX,ratioMS,cursor[0],idealGasFlag)
		print "HDD message: My halfneilListx called a half decomposition of the first half of the sim box as (algorithm S.1)...,",halfneilListx
		# Next instruction is doubling(by unfolding halfDecomp) the halfspace based DD 
		neiListxin=addHsymmetry(halfneilListx,eh_size,rc_skin,node_grid[0],cellsX,ratioMS,cursor[0],idealGasFlag)
		print "HDD message: My neiListxin if it make sense your heterogenous system can be splitted in 2 equal parts (algorithm S.2)...,",neiListxin         
	else:
	        neiListxin=reDistCellsHom(node_grid[0],cursor[0],rc_skin)
        neiListx=adaptNeiList(neiListxin)	#Contains cores Neighbor List in full format for X
	if slabMSDims[1]==1:
		halfneilListy=halfDecomp(adrCenter[1],rc_skin,eh_size,int(round(node_grid[1]/2.-0.5)),cellsY,ratioMS,cursor[1],idealGasFlag)
		print "HDD message: My halfneilListx called a half decomposition of the first half of the sim box as (algorithm S.1)...,",halfneilListy
		# Next instruction is doubling(by unfolding halfDecomp) the halfspace based DD 
		neiListyin=addHsymmetry(halfneilListy,eh_size,rc_skin,node_grid[1],cellsY,ratioMS,cursor[1],idealGasFlag)
		print "HDD message: My neiListxin if it make sense your heterogenous system can be splitted in 2 equal parts (algorithm S.2)...,",neiListyin         
	else:
	        neiListyin=reDistCellsHom(node_grid[1],cursor[1],rc_skin)
        neiListy=adaptNeiList(neiListyin)	#Contains the homogeneously decomp cores Neighbor List in full format for Y
	if slabMSDims[2]==1:
		halfneilListz=halfDecomp(adrCenter[2],rc_skin,eh_size,int(round(node_grid[2]/2.-0.5)),cellsZ,ratioMS,cursor[2],idealGasFlag)
		print "HDD message: My halfneilListx called a half decomposition of the first half of the sim box as (algorithm S.1)...,",halfneilListz
		# Next instruction is doubling(by unfolding halfDecomp) the halfspace based DD 
		neiListzin=addHsymmetry(halfneilListz,eh_size,rc_skin,node_grid[2],cellsZ,ratioMS,cursor[2],idealGasFlag)
		print "HDD message: My neiListxin if it make sense your heterogenous system can be splitted in 2 equal parts (algorithm S.2)...,",neiListzin         
	else:
	        neiListzin=reDistCellsHom(node_grid[2],cursor[2],rc_skin)
        neiListz=adaptNeiList(neiListzin)	#Contains the homogeneously decomp cores Neighbor List in full format for Z
	# NOTE that additional DD options for slabs can be furhter added
    elif sphereAdr:
        flx,fly,flz=nodeGridSizeCheck(node_grid[0],node_grid[1],node_grid[2])
        print "HDD message: Is it worthy to use an advanced DD? Flags for it in each dir X,Y,Z (0 means OK for heterogenoeus DD)...,",flx,fly,flz
        #on X-axis
        if flx==0:
            halfneilListx=halfDecomp(adrCenter[0],rc_skin,eh_size,int(round(node_grid[0]/2.-0.5)),cellsX,ratioMS,cursor[0],idealGasFlag)
            print "HDD message: My halfneilListx called a half decomposition of the first half of the sim box as (algorithm S.1)...,",halfneilListx
            neiListxin=addHsymmetry(halfneilListx,eh_size,rc_skin,node_grid[0],cellsX,ratioMS,cursor[0],idealGasFlag)  
            print "HDD message: My neiListxin if it make sense your heterogenous system can be splitted in 2 equal parts (algorithm S.2)...,",neiListxin         
        elif flx>1:
            neiListxin=reDistCellsHom(node_grid[0],cursor[0],rc_skin)
        neiListx=adaptNeiList(neiListxin)
        #on Y-axis
        if fly==0:            
            halfneilListy=halfDecomp(adrCenter[1],rc_skin,eh_size,int(round(node_grid[1]/2.-0.5)),cellsY,ratioMS,cursor[1],idealGasFlag)
            print "HDD message: My halfneilListx called a half decomposition of the first half of the sim box as (algorithm S.1)...,",halfneilListy
            neiListyin=addHsymmetry(halfneilListy,eh_size,rc_skin,node_grid[1],cellsY,ratioMS,cursor[1],idealGasFlag)
            print "HDD message: My neiListxin if it make sense your heterogenous system can be splitted in 2 equal parts (algorithm S.2)...,",neiListyin
        elif fly>1:
            neiListyin=reDistCellsHom(node_grid[1],cursor[1],rc_skin)
        neiListy=adaptNeiList(neiListyin)            
        #on Z-axis
        if flz==0:                        
            halfneilListz=halfDecomp(adrCenter[2],rc_skin,eh_size,int(round(node_grid[2]/2.-0.5)),cellsZ,ratioMS,cursor[2],idealGasFlag)
            print "HDD message: My halfneilListx called a half decomposition of the first half of the sim box as (algorithm S.1)...,",halfneilListz
            neiListzin=addHsymmetry(halfneilListz,eh_size,rc_skin,node_grid[2],cellsZ,ratioMS,cursor[2],idealGasFlag)
            print "HDD message: My neiListxin if it make sense your heterogenous system can be splitted in 2 equal parts (algorithm S.2)...,",neiListzin         
        elif flz>1:
            neiListzin=reDistCellsHom(node_grid[2],cursor[2],rc_skin)
        neiListz=adaptNeiList(neiListzin)
    print "HDD message: neiListX:",map(int,neiListx),"\n neiListY",map(int,neiListy),"\n neiListZ",map(int,neiListz)                                   
    return Int3D(cellsX,cellsY,cellsZ),map(int,neiListx),map(int,neiListy),map(int,neiListz)
Exemple #13
0
def nodeGrid(box_size,rc,skin,n,eh_size=0,ratioMS=0,idealGas=0,slabMSDims=[0,0,0]):
     ijkmax = 3*n*n+1
     boxList=[box_size[0],box_size[1],box_size[2]]
     ratioEH2CG=[(2.*eh_size)/(abs(box_size[0]-(2.*eh_size))),(2.*eh_size)/(abs(box_size[1]-(2.*eh_size))),(2.*eh_size)/(abs(box_size[2]-(2.*eh_size)))]
     ratioEHCG=min(ratioEH2CG)
     if idealGas==0:	# Non ideal Gas Simulation	
	     # This condition checks if the sys is AdResS, if afirmative it resizes box accordingly
	     if ratioMS>1:	# Spatially heterogeneous simulation
		 #print ratioEHCG
		 # This condition checks if the sys is slab based or cubic and resizes the box accordingly
                 if sum(slabMSDims)>0.1:
			 boxList=[slabMSDims[0]*(box_size[0]+(2.*eh_size)*(pow(ratioMS,0.3333)-1.)),slabMSDims[1]*(box_size[1]+(2.*eh_size)*(pow(ratioMS,0.3333)-1.)),slabMSDims[2]*(box_size[2]+(2.*eh_size)*(pow(ratioMS,0.3333)-1.))]
                         boxList=[(1-slabMSDims[0])*box_size[0]*(pow(ratioMS,0.3333))+boxList[0],(1-slabMSDims[1])*box_size[1]*(pow(ratioMS,0.3333))+boxList[1],(1-slabMSDims[2])*box_size[2]*(pow(ratioMS,0.3333))+boxList[2]] # Flag NOR

		 else:	
			 boxList=[box_size[0]+(2.*eh_size)*(ratioMS-1.),box_size[1]+(2.*eh_size)*(ratioMS-1.),box_size[2]+(2.*eh_size)*(ratioMS-1.)]
	     else:
		 print "HDD message: Non AdResS DD...entering Homogeneous DD...3, 2, 1 "
     # Ideal Gas HeSpaDDA (idealGas==1)	
     else:
	     if ratioMS>1:
	         # This condition checks if the sys is slab based or cubic and resizes the box accordingly
		 if sum(slabMSDims)>0:
			 if n<=round((2.*eh_size)/(rc+skin)-0.5+2.) and min(boxList)*ratioEHCG/(rc+skin)>=1.:
			 	boxList=[slabMSDims[0]*((2.*eh_size)+2.*(rc+skin)),slabMSDims[1]*((2.*eh_size)+2.*(rc+skin)),slabMSDims[2]*((2.*eh_size)+2.*(rc+skin))]
			        boxList=[(1-slabMSDims[0])*box_size[0]+boxList[0],(1-slabMSDims[1])*box_size[1]+boxList[1],(1-slabMSDims[2])*box_size[2]+boxList[2]]

			 elif n>round((2.*eh_size)/(rc+skin)-0.5+2.) and min(boxList)/(rc+skin)>=4. and round((2.*eh_size)/(rc+skin)-0.5+2.)>min(boxList)/(rc+skin):
				boxList=[slabMSDims[0]*((2.*eh_size)+2.*(rc+skin)),slabMSDims[1]*((2.*eh_size)+2.*(rc+skin)),slabMSDims[2]*((2.*eh_size)+2.*(rc+skin))]			
			        boxList=[(1-slabMSDims[0])*box_size[0]*(pow(ratioMS,0.3333))+boxList[0],(1-slabMSDims[1])*box_size[1]*(pow(ratioMS,0.3333))+boxList[1],(1-slabMSDims[2])*box_size[2]*(pow(ratioMS,0.3333))+boxList[2]]
			 	#boxList=[box_size[0],box_size[1],box_size[2]]	# UJ is here
				print "this option TWO"
			 elif n>round((2.*eh_size)/(rc+skin)-0.5+2.) and min(boxList)/(rc+skin)<4.:
				boxList=[slabMSDims[0]*((2.*eh_size)+2.*(rc+skin)),slabMSDims[1]*((2.*eh_size)+2.*(rc+skin)),slabMSDims[2]*((2.*eh_size)+2.*(rc+skin))]			
			        boxList=[(1-slabMSDims[0])*box_size[0]+boxList[0],(1-slabMSDims[1])*box_size[1]+boxList[1],(1-slabMSDims[2])*box_size[2]+boxList[2]]
			 	#boxList=[box_size[0],box_size[1],box_size[2]]	# UJ is here
				print "this option THREE"
			 else:
			 	print "HDD message: No more space for distributing Cores...look if you could use some HalfCells, or reduce the nr. of processors used and try again"
		 else:	
			 boxList=[(2.*eh_size)+2.*(rc+skin),(2.*eh_size)+2.*(rc+skin),(2.*eh_size)+2.*(rc+skin)] # IDEA: multiply here by the cells refina
	     else:
		 print "HDD message: Non AdResS DD!"
     	     
     # Here starts the new Dimensional aware HDD algorithm which. Dependencies: loadbal 	
     LoN_Avgmin=sum(boxList)
     # ima and imi sort values according to the box dimensions	
     ima=boxList.index(max(boxList))
     imi=boxList.index(min(boxList))	
     dN = [1,1,1]
     fdN=[0,0,0]
     for i in xrange(1,n+1):
         for j in xrange(i,n+1):
             for k in xrange(j,n+1):
                 if (i*j*k == n) and (i*i + j*j + k*k < ijkmax):
                     dN[0] = k
                     dN[1] = j
                     dN[2] = i
                     ijkmax = i*i + j*j + k*k
		     # This checks if the system's box is cubic if not add weighted averages
		     # NOTE: It could be further optimized on a system by system basis as f(deltaCellSize beteween cores) this corresponds to the general version.		
                     if qbicity(box_size,rc,skin)==False:
                         ndN=changeIndex(dN,ima,imi)[:]
                         LoN_norm=[boxList[0]/ndN[0],boxList[1]/ndN[1],boxList[2]/ndN[2]]
                         LoN_Avg=sum(LoN_norm)/3.0
                         if LoN_Avg<=LoN_Avgmin:
                             LoN_Avgmin=LoN_Avg
                             fdN=ndN[:]
                             ijkmax = fdN[0]*fdN[0]+fdN[1]*fdN[1]+fdN[2]*fdN[2]
                             print fdN
                         else:
                             ijkmax = fdN[0]*fdN[0]+fdN[1]*fdN[1]+fdN[2]*fdN[2]
                             print 'HDD message: No update of dN req ...'
                     else:
                         print 'qbicity check passed -> powered by HeSpaDDA'
                         fdN=[k,j,i]
     if abs(box_size[1]-box_size[2])<(2*(rc+skin)):
         if fdN[2]>fdN[1]:
             aux=fdN[2]
             fdN[2]=fdN[1]
             fdN[1]=aux
	     #print 'ordered fdN:',fdN[0],fdN[1],fdN[2]	
         else:
             print 'HDD message: Size Lenghts are eq. while ordering axis with preference on X, Y and Z!'
     else:
         print 'HDD message: Size Lenghts are different in Y and Z!'
     return Int3D(fdN[0],fdN[1],fdN[2])
Exemple #14
0
thermostat = espressopp.integrator.LangevinThermostat(system)
thermostat.gamma = 1.0
thermostat.temperature = 1.0
integrator.addExtension(thermostat)
#integrator.dt = 0.000001
#integrator.run(10000)
#print "Finished with warming up"
#integrator.dt = 0.005
thermostat.disconnect()

# define a LB grid
nodeGrid = espressopp.tools.decomp.nodeGrid(espressopp.MPI.COMM_WORLD.size)
lb = espressopp.integrator.LatticeBoltzmann(system,
                                            nodeGrid,
                                            Ni=Int3D(20, 20, 20))
# add extension to the integrator
integrator.addExtension(lb)
initPop = espressopp.integrator.LBInitPopUniform(system, lb)
#initPop = espressopp.integrator.LBInitPopWave(system,lb)
initPop.createDenVel(1.0, Real3D(0., 0., 0.))
#initPop.createDenVel(1.0, Real3D(0.,0.,0.001))

lboutputScreen = espressopp.analysis.LBOutputScreen(system, lb)
OUT3 = espressopp.integrator.ExtAnalyze(lboutputScreen, 200)
integrator.addExtension(OUT3)
# declare gammas responsible for viscosities (if they differ from 0)
lb.gamma_b = 0.5
lb.gamma_s = 0.5

# specify desired temperature (set the fluctuations if any)
Exemple #15
0
# run simulation for all interpolation types
for spline in range(1, len(splinetypes) + 1):

    print('\nSpline interpolation (%0d/%0d): %0s' %
          (spline, len(splinetypes), splinetypes[spline - 1]))

    # set up system
    system = espressopp.System()
    system.rng = espressopp.esutil.RNG()
    system.bc = espressopp.bc.OrthorhombicBC(system.rng, size)
    system.skin = skin

    comm = MPI.COMM_WORLD

    nodeGrid = Int3D(1, 1, comm.size)
    cellGrid = Int3D(calcNumberCells(size[0], nodeGrid[0], cutoff),
                     calcNumberCells(size[1], nodeGrid[1], cutoff),
                     calcNumberCells(size[2], nodeGrid[2], cutoff))
    system.storage = espressopp.storage.DomainDecomposition(
        system, nodeGrid, cellGrid)

    pid = 0

    for i in range(int(N)):
        for j in range(int(N)):
            for k in range(int(N)):
                m = (i + 2 * j + 3 * k) % 11
                r = 0.45 + m * 0.01
                x = (i + r) / N * size[0]
                y = (j + r) / N * size[1]
Exemple #16
0
def nodeGrid(n=None, box_size=None, rc=None, skin=None, eh_size=0, ratioMS=0, idealGas=0, slabMSDims=[0, 0, 0,]):
    if isinstance(n, numbers.Number) and box_size is None:
        return nodeGridSimple(n)
    else:
        if eh_size!=0:
            print("################################################# --> | HeSpaDDA: Domain Decomposition method | <-- #####################################################")
            ijkmax = 3 * n * n + 1
            boxList = [box_size[0], box_size[1], box_size[2]]
            ratioEH2CG = [(2. * eh_size) / (abs(box_size[0] - (2. * eh_size))), (2. * eh_size)/(abs(box_size[1] - (2. * eh_size))), (2. * eh_size) / (abs(box_size[2] - (2. * eh_size)))]
            ratioEHCG = min(ratioEH2CG)
            if not idealGas:  # Non ideal Gas Simulation
                # This condition checks if the sys is AdResS, if afirmative it resizes box accordingly
                if ratioMS > 1:  # Spatially heterogeneous simulation
                    # print ratioEHCG
                    # This condition checks if the sys is slab based or cubic and resizes the box accordingly
                    if sum(slabMSDims) > 0.1:
                        boxList = [slabMSDims[0] * (box_size[0] + (2. * eh_size) * (pow(ratioMS, 0.3333) - 1.)), slabMSDims[1] * (box_size[1] + (2. * eh_size) * (pow(ratioMS, 0.3333) - 1.)), slabMSDims[2] * (box_size[2] + (2. * eh_size) * (pow(ratioMS, 0.3333) - 1.))]
                        boxList = [(1 - slabMSDims[0]) * box_size[0] * (pow(ratioMS, 0.3333)) + boxList[0], (1 - slabMSDims[1]) * box_size[1] * (pow(ratioMS, 0.3333)) + boxList[1], (1 - slabMSDims[2]) * box_size[2] * (pow(ratioMS, 0.3333)) + boxList[2]]  # Flag NOR

                    else:
                        boxList = [box_size[0] + (2. * eh_size) * (ratioMS - 1.), box_size[1] + (
                            2. * eh_size) * (ratioMS - 1.), box_size[2] + (2. * eh_size) * (ratioMS - 1.)]
                else:
                    print("HeSpaDDA message: Non AdResS DD...entering Homogeneous DD...3, 2, 1 ")
            # Ideal Gas HeSpaDDA (idealGas==1)
            else:
                if ratioMS > 1:
                    # This condition checks if the sys is slab based or cubic and resizes the box accordingly
                    if sum(slabMSDims) > 0:
                        if n <= round((2. * eh_size) / (rc + skin) - 0.5 + 2.) and min(boxList) * ratioEHCG / (rc + skin) >= 1.:
                            boxList = [slabMSDims[0] * ((2. * eh_size) + 2. * (rc + skin)), slabMSDims[1] * ((2. * eh_size) + 2. * (rc + skin)), slabMSDims[2] * ((2. * eh_size) + 2. * (rc + skin))]
                            boxList = [(1 - slabMSDims[0]) * box_size[0] + boxList[0], (1 - slabMSDims[1])* box_size[1] + boxList[1], (1 - slabMSDims[2]) * box_size[2] + boxList[2]]
                            print("HeSpaDDA message: this option ONE of the ideal gas size box your low resolution region is small")
                        elif n > round((2. * eh_size) / (rc + skin) - 0.5 + 2.) and min(boxList) / (rc + skin) >= 4. and round((2. * eh_size) / (rc + skin) - 0.5 + 2.) > min(boxList) / (rc + skin):
                            boxList = [slabMSDims[0] * ((2. * eh_size) + 2. * (rc + skin)), slabMSDims[1] * ((2. * eh_size) + 2. * (rc + skin)), slabMSDims[2] * ((2. * eh_size) + 2. * (rc + skin))]
                            boxList = [(1 - slabMSDims[0]) * box_size[0] * (pow(ratioMS, 0.3333)) + boxList[0], (1 - slabMSDims[1]) * box_size[1] * (pow(ratioMS, 0.3333)) + boxList[1], (1 - slabMSDims[2]) * box_size[2] * (pow(ratioMS, 0.3333)) + boxList[2]]
                            # boxList=[box_size[0],box_size[1],box_size[2]]     # UJ is here
                            print("HeSpaDDA message: this option TWO of the ideal gas size box your low resolution region is big")
                        elif n > round((2. * eh_size) / (rc + skin) - 0.5 + 2.) and min(boxList) / (rc + skin) < 4.:
                            boxList = [slabMSDims[0] * ((2. * eh_size) + 2. * (rc + skin)), slabMSDims[1] * ((2. * eh_size) + 2. * (rc + skin)), slabMSDims[2] * ((2. * eh_size) + 2. * (rc + skin))]
                            boxList = [(1 - slabMSDims[0]) * box_size[0] + boxList[0], (1 - slabMSDims[1]) * box_size[1] + boxList[1], (1 - slabMSDims[2]) * box_size[2] + boxList[2]]
                            # boxList=[box_size[0],box_size[1],box_size[2]]     # UJ is here
                            print("HeSpaDDA message: this option THREE of the ideal gas size box your low resolution region is just sufficiently big")
                        else:
                            print("HeSpaDDA message: No more space for distributing Cores...look if you could use some HalfCells, or reduce the nr. of processors used and try again")
                    else:
                        boxList = [(2. * eh_size) + 2. * (rc + skin), (2. * eh_size) + 2. * (rc + skin), (2. * eh_size) + 2. * (rc + skin)]  # IDEA: multiply here by the cells refina
                else:
                    print("HeSpaDDA message: Non AdResS DD!")

            # Here starts the new Dimensional aware HDD algorithm which. Dependencies: loadbal
            LoN_Avgmin = sum(boxList)
            # ima and imi sort values according to the box dimensions
            ima = boxList.index(max(boxList))
            imi = boxList.index(min(boxList))
            dN = [1, 1, 1]
            fdN = [0, 0, 0]
            if ((abs(box_size[1] - box_size[2]) < (1.0* (rc + skin))) or (abs(box_size[0] - box_size[1]) < (1.0* (rc + skin))) or (abs(box_size[0] - box_size[2]) < (1* (rc + skin)))) and not ((abs(box_size[1] - box_size[2]) < (1.0* (rc + skin))) and (abs(box_size[0] - box_size[1]) < (1.0* (rc + skin)))):
                print('HeSpaDDA message: AdResS DD with 2 equal dimensions!')
                for i in range(1, n + 1):
                    for j in range(i, n + 1):
                        if (i * i * j == n) and (i * i + j * j + i * i < ijkmax):
                            dN[0] = j
                            dN[1] = i
                            dN[2] = i
                            ijkmax = i * i + j * j + i * i
                            # This checks if the system's box is cubic if not add weighted averages
                            # NOTE: It could be further optimized on a system by system basis as f(deltaCellSize beteween cores) this corresponds to the general version.
                            if qbicity(box_size, rc, skin) == False:
                                ndN = changeIndex(dN, ima, imi)[:]
                                redDi= [float(boxList[0]) / sum(boxList), float(boxList[1]) / sum(boxList), float(boxList[2]) / sum(boxList)]
                                LoN_norm = [boxList[0]*redDi[0] / ndN[0], boxList[1]*redDi[1] / ndN[1], boxList[2]*redDi[2] / ndN[2]]
                                LoN_Avg = sum(LoN_norm) / 3.0
                                if LoN_Avg <= LoN_Avgmin:
                                    LoN_Avgmin = LoN_Avg
                                    fdN = ndN[:]
                                    ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                    print(fdN)
                                else:
                                    ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                    print('HeSpaDDA message: No update of dN req ...')
                            else:
                                print('Cubicity check passed -> powered by HeSpaDDA')
                                fdN = [j, i, i]
            else:
                for i in range(1, n + 1):
                    for j in range(i, n + 1):
                        for k in range(j, n + 1):
                            if (i * j * k == n) and (i * i + j * j + k * k < ijkmax):
                                dN[0] = k
                                dN[1] = j
                                dN[2] = i
                                ijkmax = i * i + j * j + k * k
                                # This checks if the system's box is cubic if not add weighted averages
                                # NOTE: It could be further optimized on a system by system basis as f(deltaCellSize beteween cores) this corresponds to the general version.
                                if qbicity(box_size, rc, skin) == False:
                                    ndN = changeIndex(dN, ima, imi)[:]
                                    redDi= [float(boxList[0]) / sum(boxList), float(boxList[1]) / sum(boxList), float(boxList[2]) / sum(boxList)]
                                    LoN_norm = [boxList[0]*redDi[0] / ndN[0], boxList[1]*redDi[1] / ndN[1], boxList[2]*redDi[2] / ndN[2]]
                                    LoN_Avg = sum(LoN_norm) / 3.0
                                    if LoN_Avg <= LoN_Avgmin:
                                        LoN_Avgmin = LoN_Avg
                                        fdN = ndN[:]
                                        ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                        print(fdN)
                                    else:
                                        ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                        print('HeSpaDDA message: No update of dN req ...')
                                else:
                                    print('Cubicity check passed -> powered by HeSpaDDA')
                                    fdN = [k, j, i]
            if abs(box_size[1] - box_size[2]) < (2 * (rc + skin)):
                if fdN[2] > fdN[1]:
                    aux = fdN[2]
                    fdN[2] = fdN[1]
                    fdN[1] = aux
                else:
                    print('HeSpaDDA message: Size Lenghts are eq. while ordering axis with preference on X, Y and Z!')
            else:
                print('HeSpaDDA message: Size Lenghts are different in Y and Z!')
            return Int3D(fdN[0], fdN[1], fdN[2])
        elif eh_size==0:

            ijkmax = 3 * n * n + 1
            boxList = [box_size[0], box_size[1], box_size[2]]
            # Here starts the new Dimensional aware HDD algorithm which. Dependencies: loadbal
            LoN_Avgmin = sum(boxList)
            # ima and imi sort values according to the box dimensions
            ima = boxList.index(max(boxList))
            imi = boxList.index(min(boxList))
            dN = [1, 1, 1]
            fdN = [0, 0, 0]
            if ((abs(box_size[1] - box_size[2]) < (1.0* (rc + skin))) or (abs(box_size[0] - box_size[1]) < (1.0* (rc + skin))) or (abs(box_size[0] - box_size[2]) < (1* (rc + skin)))) and not ((abs(box_size[1] - box_size[2]) < (1.0* (rc + skin))) and (abs(box_size[0] - box_size[1]) < (1.0* (rc + skin)))):
                print('HeSpaDDA message: Non AdResS DD with 2 equal dimensions!')
                for i in range(1, n + 1):
                    for j in range(i, n + 1):
                        if (i * i * j == n) and (i * i + j * j + i * i < ijkmax):
                            dN[0] = j
                            dN[1] = i
                            dN[2] = i
                            ijkmax = i * i + j * j + i * i
                            # This checks if the system's box is cubic if not add weighted averages
                            # NOTE: It could be further optimized on a system by system basis as f(deltaCellSize beteween cores) this corresponds to the general version.
                            if qbicity(box_size, rc, skin) == False:
                                ndN = changeIndex(dN, ima, imi)[:]
                                redDi= [float(boxList[0]) / sum(boxList), float(boxList[1]) / sum(boxList), float(boxList[2]) / sum(boxList)]
                                LoN_norm = [boxList[0]*redDi[0] / ndN[0], boxList[1]*redDi[1] / ndN[1], boxList[2]*redDi[2] / ndN[2]]

                                LoN_Avg = sum(LoN_norm) / 3.0
                                if LoN_Avg <= LoN_Avgmin:
                                    LoN_Avgmin = LoN_Avg
                                    fdN = ndN[:]
                                    ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                    print(fdN)
                                else:
                                    ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                    print('HeSpaDDA message: No update of dN req ...')
                            else:
                                print('Cubicity check passed -> powered by HeSpaDDA')
                                fdN = [j, i, i]

            else:
                for i in range(1, n + 1):
                    for j in range(i, n + 1):
                        for k in range(j, n + 1):
                            if (i * j * k == n) and (i * i + j * j + k * k < ijkmax):
                                dN[0] = k
                                dN[1] = j
                                dN[2] = i
                                ijkmax = i * i + j * j + k * k
                                # This checks if the system's box is cubic if not add weighted averages
                                # NOTE: It could be further optimized on a system by system basis as f(deltaCellSize beteween cores) this corresponds to the general version.
                                if qbicity(box_size, rc, skin) == False:
                                    ndN = changeIndex(dN, ima, imi)[:]
                                    redDi= [float(boxList[0]) / sum(boxList), float(boxList[1]) / sum(boxList), float(boxList[2]) / sum(boxList)]
                                    LoN_norm = [boxList[0]*redDi[0] / ndN[0], boxList[1]*redDi[1] / ndN[1], boxList[2]*redDi[2] / ndN[2]]
                                    LoN_Avg = sum(LoN_norm) / 3.0
                                    if LoN_Avg <= LoN_Avgmin:
                                        LoN_Avgmin = LoN_Avg
                                        fdN = ndN[:]
                                        ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                        print(fdN)
                                    else:
                                        ijkmax = fdN[0] * fdN[0] + fdN[1] * fdN[1] + fdN[2] * fdN[2]
                                        print('HeSpaDDA message: No update of dN req ...')
                                else:
                                    print('Cubicity check passed -> powered by HeSpaDDA')
                                    fdN = [k, j, i]
    if abs(box_size[1] - box_size[2]) < (2 * (rc + skin)):
        if fdN[2] > fdN[1]:
            aux = fdN[2]
            fdN[2] = fdN[1]
            fdN[1] = aux
        else:
            print('HeSpaDDA message: Size Lenghts are eq. while ordering axis with preference on X, Y and Z!')
    else:
        print('HeSpaDDA message: Size Lenghts are different in Y and Z!')
    return Int3D(fdN[0], fdN[1], fdN[2])
Exemple #17
0
interFENE = espressopp.interaction.FixedPairListFENE(system, bondlist, potFENE)
system.addInteraction(interFENE)

for k in range(5):
    espressopp.tools.analyse.info(system, integrator)
    cmvel = Real3D(0., 0., 0.)
    for i in range(1, num_particles + 1):
        particle = system.storage.getParticle(i)
        cmvel += particle.v
    print "centre of mass velocity is ", cmvel
    integrator.run(100)

#thermostat.disconnect() # disconnect md-thermostat as we want to run lb-md coupled system

# define a LB grid
lb = espressopp.integrator.LatticeBoltzmann(system, Ni=Int3D(16, 16, 16))
initPop = espressopp.integrator.LBInitPopUniform(system, lb)
initPop.createDenVel(1.0, Real3D(0., 0., 0.0))

# declare gammas responsible for viscosities (if they differ from 0)
lb.gamma_b = 0.5
lb.gamma_s = 0.5

# specify desired temperature (set the fluctuations if any)
lb.lbTemp = 0.000025
lb.fricCoeff = 20.

# add extension to the integrator
integrator.addExtension(lb)

print integrator.dt
Exemple #18
0
import espressopp
from espressopp import Int3D
from espressopp import Real3D
# create default Lennard Jones (WCA) system with 0 particles and cubic box (L=40)
system, integrator = espressopp.standard_system.LennardJones(100,
                                                             box=(s, s, s),
                                                             temperature=1.)
system.rng.seed = 123456
integrator = espressopp.integrator.VelocityVerlet(system)
integrator.dt = 0.01

# define a LB grid
nodeGrid = espressopp.tools.decomp.nodeGrid(espressopp.MPI.COMM_WORLD.size)
lb = espressopp.integrator.LatticeBoltzmann(system,
                                            nodeGrid,
                                            Ni=Int3D(s, s, s))
# add extension to the integrator
integrator.addExtension(lb)

lb.visc_b = 3.
lb.visc_s = 3.

lb.profStep = 5000

#initPop = espressopp.integrator.LBInitPopUniform(system,lb)
initPop = espressopp.integrator.LBInitPopWave(system, lb)
initPop.createDenVel(1.0, Real3D(0., 0., 0.))
#initPop.createDenVel(1.0, Real3D(0.,0.,0.001))

lboutputScreen = espressopp.analysis.LBOutputScreen(system, lb)
OUT3 = espressopp.integrator.ExtAnalyze(lboutputScreen, 5000)