-
Notifications
You must be signed in to change notification settings - Fork 0
Jupyter Notebook
This Package can be used also in jupyter notebook.
First you have to import the basic functions initialize, simulate, load_mcvariables:
from mcpw.jupyter_functions import initialize, simulate, load_mcvariables
Next you have to initialize the local variables:
var = initialize(instrument='instrument.instr'[, working_dir='relative_or_absolute_path', mcstas='mcstas_path_or_link', output_dir='simulation_results', component_dir='relative_or_absolute_path', mpi=#cores])
The default for mcstas is 'mcstas' You will get a printout for your mcvariable class. copy the section into the next cell and execute it.
Now var and mcvar should be initialized and you can run a simulation with:
mcvar, res = simulate(var, mcvar, sim='bla'[,var_list=[], var_list_csv=PATH, recompile=False, verbose=False])
This function returns the used mcvariables and a list of result directory where the simulation results are saved. If the command is called a second time with the same value for dn, the mcvariables and result directorys for this dn will be loaded end returned. The var_list parameter expects an array in the form described above.
If you want to use the default mcstas plotter, you can import it:
from mcpw.mcstas_wrapper import mcplot
mcplot(var,mcvar)
###Functions explicit for jupyter notebook: Function returning mcvariables from simulation:
load_mcvariables(var, sim='')