DEMutilities. data_over_time

In order to be able to use this module import it like this:

import DEMutilities.data_over_time
#or assign it to a shorter name
import DEMutilities.data_over_time as dat
DEMutilities.data_over_time.TimeGetter(state)

Gets the time from a state. Be sure to set the time per outputstep: state.set_time_per_output( time_per_output ) (for old vtp files only)

DEMutilities.data_over_time.get_data_over_time(state_it, getters_dict, startstep=None, endstep='end', increment=1, log=False, verbose=False)

return a dict with keys as in getters_dict and values are lists of the things that the getter returns over time.

Parameters:

-state_it an iterator over the state of a simulations, typically vtp_read.VTP_State(0).
-getters_dict dictionary of names and unary functions operating on a state
-startstep step with which to start iterating
-endstep one beyond the last step that is taken into account
-increment step-width
-log if True (not default), approximates the next step as step*increment.

Example using lambdas and assuming you have a particle-container called cells_triangles:

from pyDEMeter.io.vtp_read import VTP_State
from DEMutilities.data_over_time import get_data_over_time, TimeGetter
ana_d = { 't'  : TimeGetter,
          'contact_area'  : lambda s: np.sum( s.get( 'cells_triangles', 'contact_area', 'point' ) ) ,
          'surface_area'  : lambda s: np.sum( s.get( 'cells_triangles', 'area', 'point' ) ),
          'centre_of_mass': lambda s: np.mean( s.get( 'cells_triangles','x','point' ) )
}
data = get_data_over_time( VTP_State( 0 ), ana_d )