コード例 #1
0
ファイル: System.py プロジェクト: BackupTheBerlios/espressopp
 def scaleVolume(self, *args):
     'scale the Volume of the system, which means in detail: scale all particle coordinates, scale box length, scale cellgrid (if it exists)'
     if pmi.workerIsActive():
       if len(args) == 1:
         arg0 = args[0]
         if isinstance(arg0, Real3D):
           #print arg0," is a Real3D object"
           self.cxxclass.scaleVolume( arg0 )
         elif hasattr(arg0, '__iter__'):
           if len(arg0) == 3:
             #print args, " has iterator and length 3"
             self.cxxclass.scaleVolume(self, toReal3DFromVector(arg0) )
           elif len(arg0) == 1:
             #print args, " has iterator and length 1"
             self.cxxclass.scaleVolume(self, toReal3DFromVector(arg0[0], arg0[0], arg0[0]) )
           else:
             print args, " is invalid"
         else:
           #print args, " is scalar"
           self.cxxclass.scaleVolume(self, toReal3DFromVector( [arg0, arg0, arg0] ) )
       elif len(args) == 3:          
         #print args, " is 3 numbers"
         self.cxxclass.scaleVolume(self, toReal3DFromVector(*args) )
       else:
         print args, " is invalid"
コード例 #2
0
ファイル: BC.py プロジェクト: BackupTheBerlios/espressopp
 def getFoldedPosition(self, pos, imageBox=None):
     if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup() or pmi.isController:
         if imageBox is None:
             return self.cxxclass.getFoldedPosition(self, toReal3DFromVector(pos))
         else:
             return self.cxxclass.getFoldedPosition(
                 self, toReal3DFromVector(pos), toInt3DFromVector(imageBox))
コード例 #3
0
 def computeForce(self, *args):
     if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():
         if len(args) == 1:
             arg0 = args[0]
             if isinstance(arg0, float) or isinstance(arg0, int):
                 newargs = [arg0, 0, 0]
                 return self.cxxclass.computeForce(self, toReal3DFromVector(*newargs))[0]
         return self.cxxclass.computeForce(self, toReal3DFromVector(*args))
コード例 #4
0
 def computeForce(self, *args):
     if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():
         if len(args) == 1: # in case theta is passed
            arg0 = args[0]
            if isinstance(arg0, float) or isinstance(arg0, int):
                return self.cxxclass.computeForce(self, arg0)
         return self.cxxclass.computeForce(self, toReal3DFromVector(*args))
コード例 #5
0
ファイル: BC.py プロジェクト: BackupTheBerlios/espressopp
 def getMinimumImageVector(self, pos1, pos2):
     if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup() or pmi.isController:
         return self.cxxclass.getMinimumImageVector(
             self, toReal3DFromVector(pos1), toReal3DFromVector(pos2))
コード例 #6
0
 def pos(self, val): self.__getTmp().pos = toReal3DFromVector(val)
 
 @property
コード例 #7
0
    def v(self, val): self.__getTmp().v = toReal3DFromVector(val)

    @property
コード例 #8
0
    def addParticles(self, particleList, *properties):
        if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():

            index_id          = -1
            index_pos         = -1
            index_v           = -1
            index_f           = -1
            index_q           = -1
            index_radius      = -1
            index_fradius     = -1
            index_vradius     = -1
            index_type        = -1
            index_mass        = -1            
            index_adrAT       = -1 # adress AT particle if 1
            index_lambda_adr  = -1
            index_lambda_adrd = -1
            
            last_pos = toReal3DFromVector([-99,-99,-99])

            if properties == None:
                # default properities = (id, pos)
                index_id = 0
                index_pos = 1
                nindex = 2
            else:
                nindex = 0
                for val in properties:
                    if val.lower() == "id": index_id = nindex
                    elif val.lower() == "pos": index_pos = nindex
                    elif val.lower() == "type": index_type = nindex
                    elif val.lower() == "mass": index_mass = nindex
                    elif val.lower() == "v": index_v = nindex
                    elif val.lower() == "f": index_f = nindex
                    elif val.lower() == "q": index_q = nindex
                    elif val.lower() == "radius": index_radius = nindex
                    elif val.lower() == "fradius": index_fradius = nindex
                    elif val.lower() == "vradius": index_vradius = nindex
                    elif val.lower() == "adrat": index_adrAT = nindex
                    elif val.lower() == "lambda_adr": index_lambda_adr = nindex
                    elif val.lower() == "lambda_adrd": index_lambda_adrd = nindex
                    else: raise SyntaxError("unknown particle property: %s"%val)
                    nindex += 1

            if index_id < 0  : raise "particle property id is mandatory"
            if index_pos < 0 : raise "particle property pos is mandatory"

            # we should check at the begin whether all the particles do not exist.
            doWeAddParticles = True
            for particle in particleList:
              pid = particle[index_id]
              if( self.particleExists(pid) ):
                doWeAddParticles = False
                print "WARNING: Particle ", pid, " already exists"
                
            if(not doWeAddParticles):
              print 'WARNING: Some particles already exist. The list of particles was not added.'
              return
              
            for particle in particleList:

                # verify that each particle has enough entries, avoids index errors
                if len(particle) != nindex:
                    raise SyntaxError("particle has %d entries, but %d expected"%(len(particle), nindex))

                id = particle[index_id]
                pos = particle[index_pos]

                if index_adrAT >= 0:
                    if particle[index_adrAT] == 0:
                        #print "%d:  addParticle %d, last_pos=pos %f, %f, %f"%(pmi._MPIcomm.rank,id,pos[0], pos[1], pos[2])
                        storedParticle = self.cxxclass.addParticle(self, id, pos)
                        last_pos = pos
                    else:
                        #print "%d:  addAdrATparticle %d, pos %f, %f, %f, last_pos %f, %f, %f"%(pmi._MPIcomm.rank,id,pos[0],pos[1],pos[2],last_pos[0], last_pos[1], last_pos[2])
                        storedParticle = self.cxxclass.addAdrATParticle(self, id, pos, last_pos)
                else:
                    #print "%d:  addParticle %d, last_pos=pos %f, %f, %f"%(pmi._MPIcomm.rank,id,pos[0], pos[1], pos[2])
                    storedParticle = self.cxxclass.addParticle(self, id, pos)
                    
                if storedParticle != None:
                    self.logger.debug("Processor %d stores particle id = %d"%(pmi.rank, id))
                    self.logger.debug("particle property indexes: id=%i pos=%i type=%i mass=%i v=%i f=%i q=%i radius=%i lambda_adr=%i lambda_adrd=%i"%(index_id,index_pos,index_type,index_mass,index_v,index_f,index_q,index_radius,index_lambda_adr,index_lambda_adrd))

                    # only the owner processor writes other properties

                    if index_v >= 0:
                        storedParticle.v = particle[index_v]

                    if index_f >= 0:
                        storedParticle.f = particle[index_f] 

                    if index_q >= 0:
                        storedParticle.q = particle[index_q]

                    if index_radius >= 0:
                        storedParticle.radius = particle[index_radius]

                    if index_fradius >= 0:
                        storedParticle.fradius = particle[index_fradius]

                    if index_vradius >= 0:
                        storedParticle.vradius = particle[index_vradius]

                    if index_type >= 0:
                        storedParticle.type = particle[index_type]

                    if index_mass >= 0:
                        storedParticle.mass = particle[index_mass]
 
                    if index_lambda_adr >= 0:
                        storedParticle.lambda_adr = particle[index_lambda_adr]
                        
                    if index_lambda_adrd >= 0:
                        storedParticle.lambda_adrd = particle[index_lambda_adrd]
コード例 #9
0
 def addAdrATParticle(self, pid, *args):
     if not (pmi._PMIComm and pmi._PMIComm.isActive()) or pmi._MPIcomm.rank in pmi._PMIComm.getMPIcpugroup():
         self.cxxclass.addAdrATParticle(
             self, pid, toReal3DFromVector(*args)
             )