how to use setOrientation() during simulation

Asked by Jiadun Liu

Dear all,

What are the parameters for setOrientation(...)?

How to use setOrientation(...) during simulation?

Best,
Jiadun

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
Launchpad Janitor (janitor) said :
#1

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 :
#2

Dear All,

I tried the following methods, but I still don't know how to use setQuaternion().

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
Traceback (most recent call last):
  File "move_two_particles.py", line 130, in <module>
    pp.setOrientation(1.0,0.0,0.0,0.0)
Boost.Python.ArgumentError: Python argument types in
    RotSphere.setOrientation(RotSphere, float, float, float, float)
did not match C++ signature:
    setOrientation(esys::lsm::RotParticlePy {lvalue}, esys::lsm::QuaternionPy)
^Cmpirun: killing job...

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
Traceback (most recent call last):
  File "move_two_particles.py", line 130, in <module>
    pp.setOrientation(1.0,Vec3(0.0,0.0,0.0))
Boost.Python.ArgumentError: Python argument types in
    RotSphere.setOrientation(RotSphere, float, Vec3)
did not match C++ signature:
    setOrientation(esys::lsm::RotParticlePy {lvalue}, esys::lsm::QuaternionPy)
^Cmpirun: killing job...

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
Traceback (most recent call last):
  File "move_two_particles.py", line 130, in <module>
    pp.setOrientation(Quaternion(1.0,Vec3(0.0,0.0,0.0)))
NameError: name 'Quaternion' is not defined
^Cmpirun: killing job...

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
Traceback (most recent call last):
  File "move_two_particles.py", line 130, in <module>
    pp.setOrientation(Quaternion(1.0,0.0,0.0,0.0))
NameError: name 'Quaternion' is not defined
^Cmpirun: killing job...

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
Traceback (most recent call last):
  File "move_two_particles.py", line 130, in <module>
    pp.setOrientation(Quat(1.0,0.0,0.0,0.0))
NameError: name 'Quat' is not defined
^Cmpirun: killing job...

### the scripts
#import the appropriate ESyS-Particle modules:
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)
   #sim.setParticleNonTranslational(1)
   pp.setOrientation(Quat(1.0,0.0,0.0,0.0))

 sim.setParticleNonDynamic(2)
 sim.runTimeStep()

 n += 1

#exit simulation
sim.exit()

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

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 :
#4

Dear All,

I still need a reply.

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.

Best regards,
Jiadun

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

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