mcstasscript.helper.managed_mcrun.ManagedMcrun#
- class mcstasscript.helper.managed_mcrun.ManagedMcrun(instr_name, **kwargs)#
A class for performing a mcstas simulation and organizing the data into python objects
ManagedMcrun is usually called by the instrument class of McStasScript but can be used independently. It runs the mcrun command using the system command, and if this is not in the path, the absolute path can be given in a keyword argument executable_path.
- name_of_instrumentfile#
Name of instrument file to be executed
- Type:
str
- data_folder_name#
Name of datafolder mcrun writes to disk
- Type:
str
- ncount#
Number of rays to simulate
- Type:
int
- mpi#
Number of mpi threads to run
- Type:
int
- parameters#
Dictionary of parameter names and values for this simulation
- Type:
dict
- custom_flags#
Custom flags that are passed to the mcrun command
- Type:
string
- executable_path#
Path to the mcrun command (can be empty if already in path)
- Type:
string
- run_simulation()#
Runs simulation, returns list of McStasData instances
- __init__(instr_name, **kwargs)#
Performs call to McStas with given options
Uses subprocess to call mcrun / mxrun to perform simulation of given instrument file.
- Parameters:
instr_name (str) – Name of instrument file to be simulated
kwargs (keyword arguments) –
- output_pathstr, required
Sets data_folder_name
- ncountint, default 1E6
Sets ncount
- mpiint, default None
Sets thread count, None to disable mpi
- gravitybool, default False
Enables gravity if True
- parametersdict
Sets parameters
- custom_flagsstr, default “”
Sets custom_flags passed to mcrun
- executable_pathstr
Path to mcrun command, “” if already in path
- increment_folder_namebool, default True
If True, automatically appends output_path to make it unique
- force_compilebool, default True
If True, forces compile. If False no new instrument is written
- run_folderstr
Path to folder in which to run McStas
- openaccbool, default False
If True, adds the –openacc flag to mcrun call
- NeXusbool, default False
If True, adds the –format=NeXus to mcrun call
Methods
__init__(instr_name, **kwargs)Performs call to McStas with given options
Loads component data if file exists and the simulation has been performed
load_results(*args)Method for loading data from a mcstas simulation
Runs McStas simulation described by initializing the object
- load_component_data()#
Loads component data if file exists and the simulation has been performed
Avoids reloading the data if it already has been loaded successfully
- load_results(*args)#
Method for loading data from a mcstas simulation
Loads data on all monitors in a McStas data folder, and returns these as a list of McStasData objects.
- Parameters:
argument (optional first) – path to folder from which data should be loaded
- run_simulation()#
Runs McStas simulation described by initializing the object