#import the appropriate ESyS-Particle modules: from esys.lsm import * from esys.lsm.util import Vec3, BoundingBox #instantiate a simulation object #and initialise the neighbour search algorithm: sim = LsmMpi(numWorkerProcesses=1, mpiDimList=[1,1,1]) sim.initNeighbourSearch( particleType="NRotSphere", gridSpacing=2.5, verletDist=0.5 ) #set the number of timesteps and timestep increment: sim.setNumTimeSteps(10000) sim.setTimeStepSize(0.001) #specify the spatial domain for the simulation: domain = BoundingBox(Vec3(-20,-20,-20), Vec3(20,20,20)) sim.setSpatialDomain(domain) #add the first particle to the domain: particle=NRotSphere(id=0, posn=Vec3(-5,5,-5), radius=1.0, mass=1.0) particle.setLinearVelocity(Vec3(1.0,-1.0,1.0)) sim.createParticle(particle) #add the second particle to the domain: particle=NRotSphere(id=1, posn=Vec3(5,5,5), radius=1.5, mass=2.0) particle.setLinearVelocity(Vec3(-1.0,-1.0,-1.0)) sim.createParticle(particle) #specify the type of interactions between colliding particles: sim.createInteractionGroup( NRotElasticPrms( name = "elastic_repulsion", normalK = 10000.0, scaling = True
sim.initNeighbourSearch( particleType="NRotSphere", gridSpacing=0.2, verletDist=0.1 ) # set the number of timesteps and timestep increment: sim.setNumTimeSteps(5000000) sim.setTimeStepSize(0.0001) L = 10 Ld = L + 1 kT = 0.1 a = sqrt(kT) # specify the spatial domain for the simulation: domain = BoundingBox(Vec3(-Ld, -Ld, -Ld), Vec3(Ld, Ld, Ld)) sim.setSpatialDomain( bBox=domain, circDimList=[False, False, False]) # add a cube of particles to the domain: #cube = CubicBlock(dimCount=[20, 20, 20], radius=0.05) #sim.createParticles(cube) N = 100 seed(1234) for n in range(N): p = NRotSphere(id=n, posn=uniform(), radius=0.05, mass=1.0) sim.createParticle(p) for n in range(sim.getNumParticles()): sim.setParticleVelocity( id=n, Velocity=Vec3(a*randn(), a*randn(), a*randn()))