Variable period specification
If, for any reason, a constant period for a command is not to your liking, you can make it any function you please! Just specify a function taking a single argument to the period parameter.Any analyze, update, or dump command in hoomd can be given such a variable period. dump.xml is used as an example here, but the same works with any update, dump, or analyze command
For example, lets say we want to dump xml files at time steps 1, 10, 100, 1000, ... The following command will do the job.
dump.xml(filename="dump", period = lambda n: 10**n)
It is that simple. Any mathematical expression that can be represented in python can be used in place of the 10**n.
More examples:
dump.xml(filename="dump", period = lambda n: n**2) dump.xml(filename="dump", period = lambda n: 2**n) dump.xml(filename="dump", period = lambda n: 1005 + 0.5 * 10**n)
The only requirement is that the object passed into period is callable, accepts one argument, and returns a floating point number or integer. The function also had better be monotonically increasing or the output might not make any sense.
How does it work, exactly?
- First, the current time step of the simulation is saved when the analyzer is created
- n is also set to 1 when the analyzer is created
- Every time the analyzer performs it's output, it evaluates the given function at the current value of n and records that as the next time to perform the analysis. n is then incremented by 1
Here is a final example of how variable periods behave in simulations where analyzers are not created on time step 0. The following
... initialize ... run(4000) dump.xml(filename="dump", period = lambda n: 2**n) run(513)
In other words, the function specified for the period starts counting at the time step when the analyzer is created. Consequently, any analyze, dump, or update command given a variable period becomes ill-defined if it is disabled and then re-enabled. If this is done, it will then re-enable with a constant period of 1000 as a default case.
Generated on Tue Mar 24 17:40:34 2009 for HOOMD by
1.5.7.1


