problem with forming bonds

Asked by Robert Sarracino

I've created a raft of particles ('by hand', so to speak) and am having trouble bonding them. My code segment is below

#instantiate a simulation object
#and initialise the neighbour search algorithm:
sim = LsmMpi(numWorkerProcesses=1, mpiDimList=[1,1,1])
sim.initNeighbourSearch(particleType="RotSphere",gridSpacing=2.5,verletDist=0.5)

# set values of simulation variables. Units are mks
numIceParticlesx = 60
numIceParticlesz = 6
particleRad = 0.5
particleRho = 900.0
particleMass = 4*pi*particleRad**3*particleRho/3.0
normalStiffness = 9000000.0 # reduced by a factor of 1000 to increase timestep
poisRatio = 0.25
shearStrength = 500 # reduced by a factor of 1000 to give correct displacement at bond breakage
tanPhi = 1
kinFriction = 0.4
statFriction = 0.6

numsteps = 50000 # 500000
# stepsize = 0.2*particleRad*sqrt(particleRho/normalStiffness)
timestep = 0.001

#set the number of timesteps and timestep increment:
sim.setNumTimeSteps(numsteps)
sim.setTimeStepSize(timestep)

#specify the spatial domain for the simulation:
domain = BoundingBox(Vec3(-120,-120,-120), Vec3(120,120,120))
sim.setSpatialDomain(domain)

# add the particles to the domain:
for countz in range(numIceParticlesz):
   zDist = -0.5*1.73205*countz
   for countx in range(numIceParticlesx):
      xDist = -1.0*countx +(2*(countz//2)-countz)*0.5
      yDist = 0.001*(5-random.randint(1,10))
      particle_number = countz*100 + countx
      particle=RotSphere(id=particle_number, posn=Vec3(xDist,yDist,zDist), radius=particleRad, mass=particleMass)
      particle.setLinearVelocity(Vec3(0.0,0.0,0.0))
      sim.createParticle(particle)

# create bonds between particles separated by less than the specified maxDist
sim.createConnections(ConnectionFinder(maxDist = 0.005, bondTag =1, pList =particle))

# create rotational elastic-brittle bonds between particles
pp_bonds = sim.createInteractionGroup(BrittleBeamPrms(name = "pp_bonds", youngsModulus=normalStiffness, poissonsRatio=poisRatio, cohesion=shearStrength, tanAngle=tanPhi, tag=1))

The problem appears to be that I'm not using the correct label for 'pList' when I call ConnectionFinder.

In general, where do I find the source code which gives the syntax for createConnections, ConnectionFinder and createInteractionGroup?

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
Dion Weatherley
Solved:
Last query:
Last reply:
Revision history for this message
Robert Sarracino (robert-sarracino) said :
#1

As a follow up to my question, when I run the code I get the error message

Traceback (most recent call last):
  File "icebeamstrength3d.py", line 70, in <module>
    sim.createConnections(ConnectionFinder(maxDist=0.005, bondTag=1, pList=particle))
AttributeError: 'RotSphere' object has no attribute '__iter__'

Revision history for this message
Robert Sarracino (robert-sarracino) said :
#2

I've gotten around the problem by using HexagBlock to generate the particles & then setParticleDensity to set the particle density.

However, I can anticipate wanting to add particles separately in future simulations, and would like to know how to create new bonds when I do.

Revision history for this message
Best Dion Weatherley (d-weatherley) said :
#3

Hi Robert,

The main issue with the code fragment you posted is that ConnectionFinder expects that pList is a list of SimpleSphere objects, rather than a single RotSphere object.

The following code should generate the bonds correctly:

# add the particles to the domain:
particleList = []
for countz in range(numIceParticlesz):
   zDist = -0.5*1.73205*countz
   for countx in range(numIceParticlesx):
      xDist = -1.0*countx +(2*(countz//2)-countz)*0.5
      yDist = 0.001*(5-random.randint(1,10))
      particle_number = countz*100 + countx
      particle=SimpleSphere(id=particle_number, posn=Vec3(xDist,yDist,zDist), radius=particleRad, mass=particleMass)
      #particle.setLinearVelocity(Vec3(0.0,0.0,0.0))
      sim.createParticle(particle)
      particleList.append(particle)

# create bonds between particles separated by less than the specified maxDist
sim.createConnections(ConnectionFinder(maxDist = 0.005, bondTag =1, pList =particleList))

Note that SimpleSphere objects have no velocity attributes so particle.setLinearVelocity(..) is an invalid call. If you need to set the velocity of particles, I suggest you use LsmMpi.setParticleVelocity(..) or LsmMpi.setTaggedParticleVelocity(..) subsequent to inserting the particles and creating the bonds.

Cheers,

Dion

Revision history for this message
Robert Sarracino (robert-sarracino) said :
#4

Thanks Dion Weatherley, that solved my question.

Revision history for this message
Robert Sarracino (robert-sarracino) said :
#5

Thanks, Dion.