-
Notifications
You must be signed in to change notification settings - Fork 3
Importing Modules
The first step in using PINSPEC is to import the modules that give access to PINSPEC functions as well as any other modules that the user may want to make use of. Importing can be done as needed, or done at the beginning of a file, but it must be done before the user can access anything contained in the module. PINSPEC has several modules of utility which will be discussed below, but other modules can be imported. Python has a large index of modules that users may find useful, particularly the math module, which contains mathematical constants and common functions.
##PINSPEC Modules
PINSPEC is a Python package with several modules of utility functions which can be used to construct a monte carlo spectral simulation. The main pinspec Python module contains wrappers to C++ classes such as Isotope, Material, Region, etc which the user can reference from within Python. These references can be imported into an interactive Python interpreter as follows:
>>> from pinspec import *
In addition, PINSPEC contains a log module to print formatted messages to the screen, a plotter module to plot nuclear data, tallies, etc, a process module for processing simulation output, and an slbw module to generate Single-Level Breit Wigner cross-sections from resonance paramaters. Each of these modules must be imported separately and a user can determine whether or not any, some or all of the modules are needed for a particular simulation. To import all of PINSPEC's modules into Python using the following commands in the interpreter:
>>> import pinspec.log as log
>>> import pinspec.slbw as slbw
>>> import pinspec.plotter as plotter
>>> import pinspec.process as process
After running the previous commands, you now have access to all of PINSPEC directly from within an interactive Python interpreter. Most users, however, will choose to write a static Python input script for a particular simulation. In this case, include the module import statements at the top of your script as follows:
from pinspec import *
from pinspec.log import *
import pinspec.slbw as slbw
import pinspec.plotter as plotter
import pinspec.process as process
Importing a module as another name allows the use of a different (usually shorter) handle when using any capability from that module. The functionality of each of these modules will be discussed in the following tutorials.