# import the esysparticle modules
from esys.lsm import *
from esys.lsm.util import *

#Create a simulation container:
sim = LsmMpi (
   numWorkerProcesses = 1,
   mpiDimList = [1,1,1]
)

#Initialise the neighbour search algorithm:
sim.initNeighbourSearch (
   particleType = "NRotSphere",
   gridSpacing = 1.25,
   verletDist = 0.1 
)

#Set the number of simulation timesteps and the timestep size:
sim.setNumTimeSteps (3000)
sim.setTimeStepSize (0.001)

#Define the spatial domain boundaries (min/max points):
domain = BoundingBox (
   minPt = Vec3 (-2,-2,-2),
   maxPt = Vec3 (2,2,2)  
)
sim.setSpatialDomain(domain)

# create the first particle:
particle1 = NRotSphere (
   id = 0,
   posn = Vec3 (-1, 0, 0),
   radius = 0.5,
   mass = 1.0
)
#Set the initial velocity of particle one:
particle1.setLinearVelocity ( Vec3 (1,0,0) )

#Insert the particle into the simulation container:
sim.createParticle (particle1)

#Create and insert a second particle:
particle2 = NRotSphere (id=1, posn=Vec3(1,0,0), radius=0.5, mass=2.0)
particle2.setLinearVelocity ( Vec3(-1,0,0) )
sim.createParticle(particle2)

#Specify linear elastic repulsion between particles:
sim.createInteractionGroup (
   NRotElasticPrms (
      name = "elastic_repulsion",
      normalK = 10000.0,
      scaling = True
   )
)

#Create a CheckPointer to store snapshots of simulation data for visualisation:
# (e.g. store snapshots every 100 timesteps between timestep numbers 0 and 3000)
sim.createCheckPointer (
   CheckPointPrms (
      fileNamePrefix = "snapshot",
      beginTimeStep = 0,
      endTimeStep = 3000,
      timeStepIncr = 100
   )
)

#Execute the simulation:
sim.run()

GlossyBlue theme adapted by David Gilbert
Powered by PmWiki
www.000webhost.com