How to create a fieldsaver to store contact forces among particles

Asked by ceguo

Hello again,

I am running a simulation of packing a series of particles. According to an answered question, I generated a particle aggregation with specified size distribution using algorithmic technique proposed by Dion. After all the particles(RotSphere) reach an equilibrium, why there are a lot of particles missing? How to create a fieldsaver to store contact forces among the final static particles? My script is like this(with no error or warning but also no file output)

force_saver = InteractionVectorFieldSaverPrms (
   interactionName = "ppcontact",
   fieldName = "force",
   fileName = "out_force.dat",
   fileFormat = "RAW_SERIES",
   beginTimeStep = 50000,
   endTimeStep = 50000,
   timeStepIncr = 1
)
sim.createFieldSaver(force_saver)

Besides, can the different contacting forces be visualized using lines with different width or colors like PFC does?

Best regards!
Ning

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
Best Dion Weatherley (d-weatherley) said :
#1

Hi Ning,

I assume my answer to which you refer is this one:
https://answers.launchpad.net/esys-particle/+question/79956

There are a couple of reasons why particles might be missing after the settling stage. The first is because your timestep increment is too large and the simulation is unstable. You should make sure that your timestep increment (dt) satisfies the following relationship:

dt < 0.1 * sqrt (M_min/K_max)

where M_min is the mass of the lightest particle and K_max is the maximum elastic stiffness used in your simulations.

The second reason is that your viscosity coefficient is too small. If particles initially overlap by a large amount they will experience very high accelerations (particularly the smallest/lightest particles) so you will need to use a high viscosity to prevent particles escaping the model. It may also be necessary to run a series of simulations one after another with gradually decreasing values of the viscosity coefficient. As I said in the related post, "It can be difficult at times to perfect a simulation to achieve a desirable packing" so be prepared to experiment quite a bit with your simulation scripts.

Regarding your force field saver, try changing your fileFormat from "RAW_SERIES" to "RAW2". InteractionVectorFieldSavers currently do not support the RAW_SERIES output format. One of my colleagues (Vince Boros) is currently working on a table for the Tutorial with a complete list of the supported output formats for each type of FieldSaver. Vince has already produced some tables identifying the fields available for saving for different types of particles and interactions. These are available online at:
https://twiki.esscc.uq.edu.au/bin/twiki/view/ESSCC/DocumentationAndPresentations

Finally, ESyS-Particle currently does not have stable, generic tool for visualising force chains in the manner of PFC and other DEM packages but some colleagues have written their own programs for doing this by reading either CheckPoint files or the output from FieldSavers.

I hope this helps.

Cheers,

Dion.

Revision history for this message
ceguo (hhh-guo) said :
#2

Hi Dion,

Thanks for your kind reply. The result is better off after I modified the timestepsize and viscosity. I also get the output file containing contact forces between neighbor particles.

Revision history for this message
ceguo (hhh-guo) said :
#3

Thanks Dion Weatherley, that solved my question.

Revision history for this message
Jessica (jescarish) said :
#4

Hello!!!

Is there a fieldsaver for elastic interactions??? Because I'm trying to plot the total energy.

Thanks!!

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

Hi Jessica,

Can you be more specific about the type of elastic interactions and what you mean by 'total energy'? Which interaction groups are you using (RotBondedPrms, RotFrictionPrms etc.)? Do you wish to output total potential energy or another measure of energy?

Vince has produced a couple of tables that summarise some of the fields that can be saved using FieldSavers. The tables are here:
https://twiki.esscc.uq.edu.au/bin/twiki/view/ESSCC/DocumentationAndPresentations

These tables are still a work in progress but hopefully they will help you determine what information can be stored using FieldSavers.

Cheers,

Dion.

Revision history for this message
Jessica (jescarish) said :
#6

Good day Sir Dion!!

I'm using RotFrictionPrms interaction group and I wish to calculate the total energy of interacting particles which is just the sum of total kinetic energy of the particles and the total elastic energy stored in the contacts. So my problem is that the translational and rotational kinetic energies were already available on the fieldsavers except the elastic contact energy. So I was asking if there is a fieldsaver for the elastic energy for contacts.

Jesica

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

Hi Jessica,

OK, now I understand what you wish to output. Yes, you can output the total potential energy for interaction groups using an InteractionScalarFieldSaver. The following code fragment shows how to do that:

sim.createFieldSaver (
   InteractionScalarFieldSaverPrms(
      interactionName="pp_friction",
      fieldName="potential_energy",
      fileName="PotentialEnergy.dat",
      fileFormat="SUM",
      beginTimeStep=0,
      endTimeStep=10000,
      timeStepIncr=1
   )
)

You will need to replace "pp_friction" with the name you provided when you created your RotFrictionPrms interaction group in your script. You probably will also need to change at least the endTimeStep to be equal to the number of timesteps in your simulation. The code will create a file called PotentialEnergy.dat containing the total potential energy stored in frictional bonds each timestep.

I hope this helps. Have fun!

Dion.

Revision history for this message
Jessica (jescarish) said :
#8

Thanks a lot sir Dion!! I never thought that the elastic energy for contact is just the potential energy..what a shame!! hehe..

God Bless you always!!

Jessica

Revision history for this message
Jessica (jescarish) said :
#9

Hello again sir Dion!!

Got an error with the script again. I did try the fieldsaver you provide but it says that it's an invalid syntax. What's wrong with the fieldname? I have already check the spelling and the orders.

jessica

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

Hi Jessica,

Can you please copy and paste the whole of the syntax error message into your reply? Also, please copy the part of your script where you create the RotFrictionPrms interaction group and the potential energy FieldSaver?

The fragment I posted earlier was almost a direct copy-paste from one of my simulation scripts so I'm surprised you had problems with it.

Cheers,

Dion.

Revision history for this message
Jessica (jescarish) said :
#11

Jessica suggests this article as an answer to your question:
FAQ #711: “Where can I obtain the latest development version of ESyS-Particle?”.

Revision history for this message
Jessica (jescarish) said :
#12

Oh!!! Sorry for the last comment about the fact being link. Anyway, here's the whole syntax error:

[jessica@localhost hopper files]$ mpiexec -machinefile hosts.txt -np 5 mpipython FunnelFlow.py
CSubLatticeControler::initMPI()
CSubLatticeControler::initMPI()
CSubLatticeControler::initMPI()
CSubLatticeControler::initMPI()
  File "FunnelFlow.py", line 118
    fieldName="potential_energy",
            ^
SyntaxError: invalid syntax

And here's the part where I declare the RotFrictionPrms and the Potential energy Fieldsaver:

   sim.createInteractionGroup (
      RotFrictionPrms (
         name = "pp_friction",
         normalK = elasticContactModulus,
         dynamicMu = frictionCoefficient,
         staticMu = frictionCoefficient,
         shearK = 0.4*elasticContactModulus,
         scaling = True
      )
   )

   sim.createFieldSaver (
      InteractionScalarFieldSaverPrms (
         InteractionName="pp_friction"
         fieldName="potential_energy",
         fileName="PotentialEnergy.dat",
  fileFormat="SUM",
  beginTimeStep=0,
  endTimeStep=100000,
  timeStepIncr=100
      )
   )

Revision history for this message
Anton Gladky (gladky-anton) said :
#13

  sim.createFieldSaver (
     InteractionScalarFieldSaverPrms (

> InteractionName="pp_friction"
> fieldName="potential_energy",
>

After "pp_friction" should be, probably, a coma, like
....
        InteractionName="pp_friction"*,*
______________________________

Anton Gladkyy

2010/2/9 Jessica <email address hidden>

> Question #82823 on ESyS-Particle changed:
> https://answers.launchpad.net/esys-particle/+question/82823
>
> Jessica posted a new comment:
> Oh!!! Sorry for the last comment about the fact being link. Anyway,
> here's the whole syntax error:
>
> [jessica@localhost hopper files]$ mpiexec -machinefile hosts.txt -np 5
> mpipython FunnelFlow.py
> CSubLatticeControler::initMPI()
> CSubLatticeControler::initMPI()
> CSubLatticeControler::initMPI()
> CSubLatticeControler::initMPI()
> File "FunnelFlow.py", line 118
> fieldName="potential_energy",
> ^
> SyntaxError: invalid syntax
>
> And here's the part where I declare the RotFrictionPrms and the
> Potential energy Fieldsaver:
>
> sim.createInteractionGroup (
> RotFrictionPrms (
> name = "pp_friction",
> normalK = elasticContactModulus,
> dynamicMu = frictionCoefficient,
> staticMu = frictionCoefficient,
> shearK = 0.4*elasticContactModulus,
> scaling = True
> )
> )
>
> sim.createFieldSaver (
> InteractionScalarFieldSaverPrms (
> InteractionName="pp_friction"
> fieldName="potential_energy",
> fileName="PotentialEnergy.dat",
> fileFormat="SUM",
> beginTimeStep=0,
> endTimeStep=100000,
> timeStepIncr=100
> )
> )
>
> --
> You received this question notification because you are an answer
> contact for ESyS-Particle.
>

Revision history for this message
Jessica (jescarish) said :
#14

Thanks a lot!!! Whew! I didn't saw that comma there. But a have another error encountered in the fieldsaver after a correct the script. Here's what it say:

Traceback (most recent call last):
  File "FunnelFlow.py", line 206, in <module>
    FunnelFlow()
  File "FunnelFlow.py", line 146, in FunnelFlow
    timeStepIncr=100
Boost.Python.ArgumentError: Python argument types in
    InteractionScalarFieldSaverPrms.__init__(InteractionScalarFieldSaverPrms)
did not match C++ signature:
    __init__(_object*, std::string interactionName, std::string fieldName, std::string fileName, std::string fileFormat, int beginTimeStep, int endTimeStep, int timeStepIncr)

Revision history for this message
Anton Gladky (gladky-anton) said :
#15

It is difficult to say something, no seeing the code:

 File "FunnelFlow.py", line 146, in FunnelFlow
   timeStepIncr=100

Please, paste your code around those lines.
______________________________

Anton Gladkyy

2010/2/9 Jessica <email address hidden>

> Question #82823 on ESyS-Particle changed:
> https://answers.launchpad.net/esys-particle/+question/82823
>
> Jessica posted a new comment:
> Thanks a lot!!! Whew! I didn't saw that comma there. But a have another
> error encountered in the fieldsaver after a correct the script. Here's
> what it say:
>
> Traceback (most recent call last):
> File "FunnelFlow.py", line 206, in <module>
> FunnelFlow()
> File "FunnelFlow.py", line 146, in FunnelFlow
> timeStepIncr=100
> Boost.Python.ArgumentError: Python argument types in
>
> InteractionScalarFieldSaverPrms.__init__(InteractionScalarFieldSaverPrms)
> did not match C++ signature:
> __init__(_object*, std::string interactionName, std::string fieldName,
> std::string fileName, std::string fileFormat, int beginTimeStep, int
> endTimeStep, int timeStepIncr)
>
> --
> You received this question notification because you are an answer
> contact for ESyS-Particle.
>

Revision history for this message
Jessica (jescarish) said :
#16

ok. I'll just put the corresponding line numbers.

137 #create a FieldSaver to store the potential energy of particles:
138 sim.createFieldSaver (
139 InteractionScalarFieldSaverPrms (
140 InteractionName="pp_friction",
141 fieldName="potential_energy",
142 fileName="PotentialEnergy.dat",
143 fileFormat="SUM",
144 beginTimeStep=0,
145 endTimeStep=100000,
146 timeStepIncr=100
147 )
148 )

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

Hi Jessica,

I think the problem is no one of indentation. Python expects that you indent all the arguments of InteractionScalarFieldSaverPrms by the same amount. Your FieldSaver code should look like this:

137 #create a FieldSaver to store the potential energy of particles:
138 sim.createFieldSaver (
139 InteractionScalarFieldSaverPrms (
140 InteractionName="pp_friction",
141 fieldName="potential_energy",
142 fileName="PotentialEnergy.dat",
143 fileFormat="SUM",
144 beginTimeStep=0,
145 endTimeStep=100000,
146 timeStepIncr=100
147 )
148 )

In the email I received containing your code, the'fileFormat', 'beginTimeStep' and 'endTimeStep' lines were not indented by the same amount as 'fileName' and 'timeStepIncr'.

Thanks to Anton for spotting the missing comma! You should have a working FieldSaver soon Jessica!

Cheers,

Dion.

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

Hi again Jessica,

It looks like Launchpad is doing something to remove indentation from the code fragments. Let me try again to post the correct syntax for the FieldSaver:

sim.createFieldSaver (
   InteractionScalarFieldSaverPrms(
      interactionName="pp_friction",
      fieldName="potential_energy",
      fileName="PotentialEnergy.dat",
      fileFormat="SUM",
      beginTimeStep=0,
      endTimeStep=10000,
      timeStepIncr=100
   )
)

Cheers,

Dion.

Revision history for this message
Jessica (jescarish) said :
#19

That solved my script. Everything now is ok. Thank a bunch to Sir Anton and Sir Dion!! =)