question about setParticleNonDynamic

Asked by Jiadun Liu

Dear All,

In the following code, there are two particles which have a overlap of 10% relative to the radius.

PROBLEM is: If one particle is moved, and the other one is fixed by the command setParticleNonDynamic(), then the fixed particle could not rotate.

So, I guess that the setParticleNonDynamic() fix both translational and rotational DOFs.

However, I checked the thread https://answers.launchpad.net/esys-particle/+question/226731, in which it was said that setParticleNonDynamic() only fixes the translational DOFs.

To make this question more clear, the code was attached.

 #import the appropriate ESyS-Particle module
from esys.lsm import *
from esys.lsm.util import Vec3, BoundingBox
from POVsnaps import POVsnaps
from esys.escript import *
from math import *
from numpy import *

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

TotalTimeSteps = 10
SaveTimeIncr = 1

#specify the number of timesteps and timestep increment:
sim.setNumTimeSteps(TotalTimeSteps)
sim.setTimeStepSize(1.0000e-02)

#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=RotSphere(id=0, posn=Vec3(0.0,0.0,0.0), radius=1.0, mass=2.0)
particle.setTag(1)
#particle.setOrientation(0.5,0.5,0.5,0.5)
sim.createParticle(particle)

#add the second particle to the domain:
particle=RotSphere(id=1, posn=Vec3(0.0,1.9,0.0),radius=1.0, mass=2.0)
particle.setTag(2)
sim.createParticle(particle)

sim.createInteractionGroup (
 RotFrictionPrms(
  name = "friction",
  normalK = 1.0, #if set youngsModulus a large value such as 100000.0, the repel is more obvious
  dynamicMu = 0.4,
  staticMu = 0.6,
  shearK = 0.2,
  scaling = False,
  rigid=True
 )
)

#create a FieldSaver to contact force and particle positions
friction_contact_force_saver = InteractionVectorFieldSaverPrms (
   interactionName = "friction",
   fieldName = "force",
   fileName = "friction_contactForces",
   fileFormat = "RAW_WITH_POS_ID",
   beginTimeStep = 0,
   endTimeStep = TotalTimeSteps,
   timeStepIncr = SaveTimeIncr
)
sim.createFieldSaver(friction_contact_force_saver)

#create a FieldSaver to store the total kinetic energy of the particles:
sim.createFieldSaver (
 ParticleScalarFieldSaverPrms(
  fieldName="e_kin",
  fileName="ekin.dat",
  fileFormat="SUM",
  beginTimeStep=0,
  endTimeStep=TotalTimeSteps,
  timeStepIncr=SaveTimeIncr
 )
)

#create a FieldSaver to store potential energy stored in bonds:
sim.createFieldSaver (
 InteractionScalarFieldSaverPrms(
  interactionName="friction",
  fieldName="potential_energy",
  fileName="epot.dat",
  fileFormat="SUM",
  beginTimeStep=1,
  endTimeStep=TotalTimeSteps,
  timeStepIncr=SaveTimeIncr
 )
)

#create CheckPointer
sim.createCheckPointer (
 CheckPointPrms (
  fileNamePrefix = "snapshot",
  beginTimeStep = 1,
  endTimeStep = TotalTimeSteps,
  timeStepIncr = SaveTimeIncr
 )
)

povcam = POVsnaps(sim=sim, interval=SaveTimeIncr)
povcam.configure(lookAt=Vec3(0.0,0.0,0.0), camPosn=Vec3(0.0,0.0,10.0),zoomFactor = 0.1)
sim.addPostTimeStepRunnable(povcam)

#execute the simulation:
N_max = sim.getNumTimeSteps()+1
n = 1
particleNum = 2
delt_u = Vec3(0.055,0.0,0.0)
while (n < N_max):

 ParticleList = sim.getParticleList()

 for pp in ParticleList:
  if pp.getTag() == 1:

   Posnparticle = pp.getInitialPosition() + Vec3(n*delt_u[0],delt_u[1],delt_u[2])

   #print "positon After deformation: ",Posnparticle[0],Posnparticle[1],Posnparticle[2]
   sim.moveParticleTo(pp.getId(),Posnparticle)
   # Choose one of the following restrictions, otherwise, the particles will be repelled away from each other

   ## Restrict the Translational degree of freedom
   #sim.setParticleNonDynamic(1) ### if this command is used, then the particle of Tag 1 can not rotate.

 sim.setParticleNonDynamic(2)
 sim.runTimeStep()

 n += 1

#exit simulation
sim.exit()

Question information

Language:
English Edit question
Status:
Solved
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Solved by:
Jiadun Liu
Solved:
Last query:
Last reply:
Revision history for this message
Dion Weatherley (d-weatherley) said :
#1

Hi Jiadun,

I checked the source code and you are correct: setParticleNonDynamic will prevent both translation and rotation of RotSphere particles.

I believe this was changed in response to the former question you mentioned. At that time the developers agreed to add two additional function calls:
1) LsmMpi.setParticleNonRotational(tag), and
2) LsmMpi.setParticleNonTranslational(tag)

The intent was to ensure users could specifically decide which degrees of freedom to suppress. Unfortunately it appears that the python wrapper for the second function was not implemented. I have corrected that and commited it to the latest revision of ESyS-Particle (rev. 1156).

To use this functionality you will need to uninstall your current version and install the latest version. Instructions on how to do so are available here:
https://answers.launchpad.net/esys-particle/+faq/1613

Thanks for identifying this bug and have fun!

Cheers,

Dion

Revision history for this message
Jiadun Liu (liujiadun) said :
#2

Hi Dion,

How to uninstall my current version?

I tried by using "sudo rm -r -f esys-particle" and then followed the steps

6) Obtain a copy of the latest development version of ESyS-Particle and change to the top-level ESyS-Particle directory:
bzr branch lp:esys-particle
cd esys-particle

7) Compile and install ESyS-Particle:
sh autogen.sh
./configure CC=mpicc CXX=mpic++ --disable-dependency-tracking (https://answers.launchpad.net/esys-particle/+question/250726)
make
sudo make install
cd

However, after trying the code I posted in the above thread, the setParticleNonDynamic still fixes the rotational DOFs.

I guess that I did not uninstall the eys-particle by using "sudo rm -r -f esys-particle".

Then I tried "make uninstall".
jiadun@jiadun-Lenovo-IdeaPad-Z500:~/esys-particle$ make uninstall
Making uninstall in libltdl
make[1]: Entering directory `/home/jiadun/esys-particle/libltdl'
make[1]: Leaving directory `/home/jiadun/esys-particle/libltdl'
Making uninstall in Foundation
make[1]: Entering directory `/home/jiadun/esys-particle/Foundation'
 /bin/bash ../libtool --mode=uninstall rm -f '/usr/local/lib/libFoundation.la'
libtool: uninstall: rm -f /usr/local/lib/libFoundation.la /usr/local/lib/libFoundation-2.3.so /usr/local/lib/libFoundation-2.3.so /usr/local/lib/libFoundation.so /usr/local/lib/libFoundation.a
rm: cannot remove '/usr/local/lib/libFoundation.la': Permission denied
rm: cannot remove '/usr/local/lib/libFoundation-2.3.so': Permission denied
rm: cannot remove '/usr/local/lib/libFoundation-2.3.so': Permission denied
rm: cannot remove '/usr/local/lib/libFoundation.so': Permission denied
rm: cannot remove '/usr/local/lib/libFoundation.a': Permission denied
make[1]: *** [uninstall-libLTLIBRARIES] Error 1
make[1]: Leaving directory `/home/jiadun/esys-particle/Foundation'
make: *** [uninstall-recursive] Error 1

Best regards,
Jiadun

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

Hi Jaidun,

The usual method to uninstall ESyS-Particle is to return to the folder from which you installed the software (containing the source code) and type "sudo make uninstall". The various 'Permission denied' errors you received were because of the missing 'sudo'.

Given that you have removed the original source code ("sudo rm -r -f esys-particle") you may need to manually remove the installed binary packages. This FAQ describes how to do that:
https://answers.launchpad.net/esys-particle/+faq/947

> However, after trying the code I posted in the above thread, the setParticleNonDynamic still fixes the rotational DOFs.

When you successfully install the new version of ESyS-Particle, you will need to modify your script, replacing 'setParticleNonDynamic' with 'setParticleNonTranslational' in order to not constrain/fix the rotational DOFs.

Cheers,

Dion

Revision history for this message
Jiadun Liu (liujiadun) said :
#4

Hi Dion,

 After deleting the installed binary packages and installing the new version, I tried t my script with setParticleNonTranslational(tag) used, then I got nothing. No outputs in folder which contains the script and no outputs in terminal.

jiadun@jiadun-Lenovo-IdeaPad-Z500:~/esys-test/move_twoparticles$ mpirun -np 2 `which esysparticle` move_two_particles.py
CSubLatticeControler::initMPI()
slave started at local/global rank 0 / 1
constructing FieldMaster for field force
constructing FieldMaster for field e_kin
constructing FieldMaster for field potential_energy

Best regards,
Jiadun

Revision history for this message
Launchpad Janitor (janitor) said :
#5

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Jiadun Liu (liujiadun) said :
#6

Dear All,

I still need an Answer.

Thank you very much.

Best regards,

Jiadun

Revision history for this message
Launchpad Janitor (janitor) said :
#7

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Jiadun Liu (liujiadun) said :
#8

Dear All,

I still need an answer.

Best regards,
Jiadun

Revision history for this message
Jiadun Liu (liujiadun) said :
#9

Dear All,

This question was solved by my friend.

The solution could be found in
https://answers.launchpad.net/esys-particle/+question/254274

Best regards,
Jiadun