How to obtain timestep increment

Asked by Perchero

Hi, I'm writing a new interaction and I have the need to get the timestep increment value.
In my Python's script I did something like this:

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

Now I would like to know if it's possible to invoke the simulation object that holds the second value, from my source code (written in C++).
I need something like this: <object>.getTimeStepSize();

Thanks a lot.
Perchero.

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:

This question was reopened

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

Hi Perchero,

In your python script you can return the timestep increment and the total number of timesteps with:

dt = sim.getTimeStepSize()
#and
numT = sim.getTimeStep()

I don't really understand what you mean by "invoke the simulation object that holds the second value, from my source code (written in C++)". The commands above will work in a python script but I'm not sure how your c++ source code interacts with the ESyS-Particle code or its python interface.

Incidentally, it is technical still possible to run an ESyS-Particle simulation directly from C++ without the python interface. The c++ interface is not documented but the python interface is really just a thin wrapper on C++ calls. One of these days I'd like to try to run a pure C++ ESyS simulation but it's not a high priority for me ;)

Cheers,

Dion.

Revision history for this message
Perchero (toblipa) said :
#2

Hi Dion,

Thanks for your response, but that's not what I'm asking for.
As I said before, I'm writing a new interaction for ESyS, following this tutorial: https://twiki.esscc.uq.edu.au/pub/ESSCC/DocumentationAndPresentations/HowToAddInteraction.pdf

I'm writing a .cpp in /Model folder from ESyS source code. I hope you know what I mean now.

So, the problem in this new interaction for ESyS is how to get the timestep increment, whose value was set in Python's script.

Thanks a lot.
Perchero.

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

Hi Perchero,

Sorry I misunderstood your question. To pass the timestep increment to an interaction group you need to do so via the associated interaction group parameters class, as though it is another interaction parameter (like m_E and m_nu in the tutorial). An example of an interaction class that does this is CDampingIGP in Model/DampingIGP.* The parameter dt is used to pass the timestep increment from the Master process to the worker processes when the interaction group is created. I suggest you follow the implementation of the Damping interaction to see where and how to correctly pass the timestep increment to the interaction class.

In case it is not obvious in the tutorial, interaction groups are created by each worker process on receipt of a message from the master process instructing them to create that particular interaction group. The message itself contains the values for each of the parameters in the associated interaction group parameters class. In essence, the interaction group parameters classes are simply containers for the minimum amount of information required to create a particular type of interaction.

I hope this helps.

Cheers,

Dion.

Revision history for this message
Perchero (toblipa) said :
#4

Hi Dion,

Thanks a lot. I'm going to do it, that way.

Best Regards.
Perchero.

Revision history for this message
Perchero (toblipa) said :
#5

Thanks Dion Weatherley, that solved my question.

Revision history for this message
Perchero (toblipa) said :
#6

Hi Dion, I'm reopening this because I still can't get timestep increment. I writing a new interaction (following the Damping model) and I need the timestep increment value, I add it as a parameter in my interaction but when I run the simulation I get a 0 as a value in my dt parameter.

In my python script:
...
#set the number of timesteps and timestep increment:
sim.setNumTimeSteps(500000)
sim.setTimeStepSize(0.00001)
...

After a deep search through the source code I was able to find the origin of my problem (If I'm not wrong).
In my LsmMpiPy.cpp I added:

void LsmMpiPy::createHertzianViscoElasticFrictionIG(
      const HertzianViscoElasticFrictionPrmsPy &prms
    )
    {
      HertzianViscoElasticFrictionPrmsPy p = prms;

      p.setTimeStepSize(getTimeStepSize());
      getNameTypeMap()[p.getName()] = p.getTypeString();
      getLatticeMaster().addPairIG(p);
    }

However when I print getTimeStepSize() I found that is returning 0. I'm really lost with this because I don't understand why I'm getting this value (I'm expecting 0.00001).

If you want me to provide more source code or want me to print some value please let me know.

Thanks.
Perchero.

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

Hi Perchero,

There are possibly two things that are going wrong here.

Firstly, you need to ensure that in your python script, the call to sim.setTimeStepSize(..) is made *before* the call to create your interaction group. If not, then the default timestep increment (dt=0) will be passed into your interaction group parameters object, not your desired value of dt=0.00001.

The second possible problem is in LsmMpiPy.cpp. When you call getTimeStepSize() it might be better to replace that call with getLatticeMaster().getTimeStepSize(). The getLatticeMaster() subroutine will return a pointer direct to the C++ LatticeMaster object that stores the actual value of the time step increment.

Let me know whether either or both of these suggestions solve your problem.

Cheers,

Dion.

Revision history for this message
Perchero (toblipa) said :
#8

Thanks Dion Weatherley, that solved my question.

Revision history for this message
Perchero (toblipa) said :
#9

Hi Dion,

You were right with your first suggestion, I put sim.setTimeStepSize() before the creation of my interaction group and it work!!!

Thanks once again.
Perchero.