DEMutilities. multisim_layout

Support for generating the directory and file structure lay-out for multi-simulation (multisim) collections

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

import DEMutilities.multisim_layout
#or assign it to a shorter name
import DEMutilities.multisim_layout as mul
DEMutilities.multisim_layout.add_cps_rec(cps, ds, basename='')
DEMutilities.multisim_layout.create_sample_groups(dirs, file_pattern='*.h5', lstrip='sample_', split_pattern='-', prefix='grouped_')
DEMutilities.multisim_layout.generate_layout(ds_samples, path='.', paramsName='params.pickle', copyfiles=[], linkfiles=[])

Generate the directory structure as specified in the provided data section in the specified path. File names will be the data entry names one level below ds_samples and any sub-level will be interpreted as varying parameters which will be saved for later loading in a .pickle file with given name.

  • ds_samples – section from a data set containing entries that specify individual samples.
  • path (str) – location where the directory structure should be generated
  • paramsName (str) – name of the .pickle file which will contain the specific parameters as varied in samples for each individual sample directory.
  • copyfiles (list) – List of filenames relative to ‘path’ that should be copied into the directory structure.
  • linkfiles (list) – List of filenames that will be symbolically linked in the directory structures. If your file system supports symlinking, this is often preferable to parameter ‘copyfiles’ as it saves disk space and changes along with the original file.

Example usage:

import DEMutilities.multisim_layout as ms
import DEMutilities.postprocessing.h5storage as h5s

storage = h5s.H5Storage('mysims.h5')
samples = storage.data_section( 'samples', overwrite=True )
sample1 = samples.data_section( 'test1' )
sample1.add_data( "params/g", -9.81, unit='m/s^2' )
sample1.add_data( "params/k", 1000,  unit='N/m'   )

sample2 = samples.data_section( 'test2' )
sample2.add_data( "params/g", -100, unit='m/s^2' )
sample2.add_data( "params/E", 1e6, unit='Pa')

ms.generate_layout( samples, './' )

Subsequently, any script can be run over the resulting directories from a shell:

$ mpacts-run-multiple SCRIPTNAME test1/ test2/


For more information on how to use mpacts-run-multiple, please see:

$ mpacts-run-multiple --help


In the example above, the samples are ‘manually’ generated, which gives full freedom in how they look like, yet can be quite cumbersome when specifying a large number of samples and/or parameters to vary. For actual parameter studies and multi-simulation experiments, the functionalities in doe_samples provide tools to automate the generation of these samples using a specific Design of Experiment strategy.

DEMutilities.multisim_layout.generate_single_sample_layout(sample, path='.', paramsName='params.pickle')