increment user variable

Submitted by mschramm on Mon, 03/06/2017 - 22:27

Hello,
I am trying to increment a user variable every thermo output.
Some background, I am trying to get a soil bed to a certain void ratio. I am doing this by stepping 5000 and then checking what my void ratio is. If it is my tolerance, I continue the simulation. If not, I step another 5000 and check again.
What I would like to have though is a continuous simulation time in my thermo output. I was doing this using

variable sim_time equal dt*elapsed

but every time I would reuse the "run 5000" command, elapsed. I then tried the following

variable sim_time equal 0.0 # At the start of my code

variable old_time equal ${sim_time}
variable sim_time equal v_old_time+5000*dt

This set sim_time to 5000*dt.

Does anyone know of a way to get a continuous simulation time while using multiple run commands?

Thank you!

Laure's picture

Laure | Tue, 03/07/2017 - 09:25

I never used 'elapsed', I prefer 'step' which is used across outputs (in particular to write restarts). Here's my solution, which lets time track time as I change timestep:

variable mydt equal 8e-8
variable mystep equal step
variable nbdt0 equal ${mystep}
variable t0 equal ${mystep}*${mydt}
variable mytime equal (step-v_nbdt0)*v_mydt+v_t0

# run for a while, then change timestep
variable mydt equal 1e-6
timestep ${mydt}
variable nbdt0 equal ${mystep}
variable t0 equal ${mytime}
# variable 'mytime' keeps returning the correct time

Best,
Laure Lemrich