Skip to main content

No project description provided

Project description

McStas Python Wrapper (mcpw)

Requirements

A mcstas instrument with all components

The Define Section of your instrument must have following Format:

DEFINE INSTRUMENT 'instrument'
(
    double x = 1.0,     //comment

	//comment
    int i = 1,          //comment
    float f = 1.0,      //comment
)

empty lines will be ignored

Short Overview

This Package offers several functions to improve your workflow with Mcstas Simuations and Processing the simmulation results.

The Functionality is build around the two Classes variables and mcvariables.

class variables

variables are global variables that apply to any simulation and contains the location of the main working directory. it is automatically generated with the 'mcpw_setup' command and is saved in local_var.python_requires

class mcvariables

mcvariables contains all important variables to run a simulation. the mcpw_setup command will create it from the given instrument file and put it into instrument_name.py file.

the instrument.py file

the instrument.py file will be the main file you will work in. appart from the mcvariables class it will contain all your custom functions for analysing and datatreatment. here you import all necessary packages and all your functions you want to get executed you add into the analyse() function or the post_mcrun_funktions() function. the analyse and post_mcrun_funktions will be called by mcpw_manager and executed

First Setup

Requirements:

the mcpw_setup command creates all necessary files in order to use the mcpw_manager command.

cd to the directory where your mcstas instrument lies

then execute mcpw_setup:

mcpw_setup -I instrument.instr -d working_directory -m path_to_mcstas_executable -o output_directory -c component_directory

necessary is only the -I instrument.intr argument.

with the -d working_directory argument you can set a different directory than your current one as the main working directory

with the -m argument you can give the location of your mcstas installation. only needed if you did not install mcstas with a packages manager

with the -o argument you can specify the location of the output directory where the simulation results are put in. the default is 'simulation_results' in the main working directory

with the -c argument you can specify extra locations for mcstas components

if you have no errors and have two files: local_var.py and instrument.py in your working directory the setup stepp is compleated

First Use

with mcpw_manager you can execute your simulation and all relevant functions you added to the analyse and post_mcrun_funktions functions.

the minimal command to run a simmulation is:

mcpw_manager -p instrument.py local

Command Usage

Usage of mcpw_manager

usage: mcpw_manager [-h] -p PYTHON_FILE [-d RESULT_DIR] mode ...

Control command for automatic mcstas usage for the Reseda Instrument

optional arguments:
  -h, --help            show this help message and exit
  -p PYTHON_FILE, --python_file PYTHON_FILE
                        path (absolute or not) to the python file containing mcvariables and analyse functions
  -d RESULT_DIR, --result-dir RESULT_DIR
                        directory name for the simulationresults. If none is given or foulder name exists allrady, a increment Folder Name is generated

modes:
  Use 'manager mode --help' to view the help for any command.

  mode
    server              mcstas will be executed localy and the processed simulation results packed in a tarball
    remote              mcstas will be executed on a remote machine
    local               mcstas will be executed on localy
    full                mcstas will be executed on localy and the analyze function will be called after
    analyse             analyse function will be called

Usage of mcpw_setup

usage: mcpw_setup [-h] -I INSTRUMENT [-d WORKING_DIR] [-m MCSTAS] [-o OUTPUT_DIR] [-c COMPONENT_DIR] mode ...

Script to create a python file to control a McStas Instrument with MPW

optional arguments:
  -h, --help            show this help message and exit
  -I INSTRUMENT, --instrument INSTRUMENT
                        mcstas instrument you want to control with mpw
  -d WORKING_DIR, --working_dir WORKING_DIR
                        path to working directory (optional)
  -m MCSTAS, --mcstas MCSTAS
                        path to mcstas executable; default=mcstas
  -o OUTPUT_DIR, --output_dir OUTPUT_DIR
                        name in the simulation results directory; default=simulation_results
  -c COMPONENT_DIR, --component_dir COMPONENT_DIR
                        additional directory where mcstas will search for components; default=""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpw-0.2.2.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

mcpw-0.2.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file mcpw-0.2.2.tar.gz.

File metadata

  • Download URL: mcpw-0.2.2.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for mcpw-0.2.2.tar.gz
Algorithm Hash digest
SHA256 df8c4f8af617e10dba5e6a786776186ae4f2010b3b58f65a56462729b929cda7
MD5 c0dc6a11f8e74060b901c669f1162edb
BLAKE2b-256 fcaf8273a22adb84f67469545343c4fe3be21b38e224393c6d366fde47ae3dfd

See more details on using hashes here.

File details

Details for the file mcpw-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: mcpw-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for mcpw-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 441368699564325c8302ffcdf6510d2ab01c50e51dcbdf91400970335b8db544
MD5 8483c37a6d7c3b2a5c2186d6a1af5dac
BLAKE2b-256 e51a4ec26172b41dec0eec74c7f36de91f2065e07a7d71b7361d086df8b722c7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page