Main object

wig.wig object

class wig.wig.wig(comment, filename, flavor=‘6’, render=True)[source]

The wig object is the base object for an MCNP setup.

The wig object is basically the scene in which we create our MCNP geometry, cells, materials, physics, tallies, and other data. I usually just call it scene and use it from there.

Parameters:
  • comment (str) – The comment that will be placed BELOW the first comment line of the MCNP deck.
  • filename (str) – The filename (duh) of the input deck. ‘.inp’ will be automatically appended. The full path to this file will be the first line of the input file (i.e., the full path will be the first comment line of the deck)
  • flavor (str) – ‘6’ for mcnp6, ‘5’ for mcnp5, ‘x’ for mcnpx, or ‘polimi’ for mcnpx-polimi. Make sure you alias the binaries to those commands or the runner wont work.
  • render (bool) – defines whether to render the scene using blender before running it
Returns:

the wig object.

set_filename(filename)[source]

set_filename sets the base of the filenames that will be created

Parameters:filename (str) – the base of the filename
set_comment(comment)[source]

set_comment writes the first line of the mcnp file, which is a comment describing the file. Be descriptive but not too long.

Parameters:comment (str) – the first line of the mcnp file - limit is 80 characters. wig manually strips newlines, so feel free to make this a triple quoted (''') string with as many returns as you like.
geo(geos=None)[source]

geo adds all defined wig.geo objects to an input deck

Parameters:geos (list) – the wig.geo objects to be added to the input deck. Make sure this includes a universe
add_geo(geos=None)[source]
cell(cells=None)[source]

cell adds all the ``wig.cell“s in a list to an input deck.

Parameters:cells (list) – the list of wig.cell``s to be added to the input deck.  If you don't have a cell named ``'universe', this method will make one for you, but you might night like it.
matl(matls=None)[source]

matl adds all the ``wig.matl“s to the input deck

Parameters:matls (list) – the materials to add to the input deck
add_matl(matls=None)[source]
phys(phys=None)[source]

phys adds all wig.phys blocks to the model

Parameters:phys (wig.phys) – the wig.phys block to be added to the model.
tally(tallies=None)[source]

tally adds all wig.tally b’ocks to the model

Parameters:tallies (list) – the wig.tally blocks to be added to the model.
source(sources=None)[source]

source adds the wig.source object to the model

Parameters:sources (list) – the wig.source blocks (defining sources and distributions) to be added to the model.
run(remote=’local’, sys=’linux’, blocking=False, clean=False, **kwargs)[source]

run (of course) runs the deck.

run first writes the input deck, including rendering with whatever additional keyword args you pass, and then opens an instance of a wig.runner, and passes commands to it.

Parameters:
  • remote (str) – The ip address of the remote system you want to run this on, or 'local' if on this system. The remote system must be set for passwordless ssh login and have mcnp on path (whatever flavor you’re using). Default: 'local'
  • sys (str) – The type of system that the remote runs on. Currently, this is useless, as I’ve only made it run on linux. Default: 'linux'
  • blocking (bool) – Whether to wait on the deck to finish running before continuing or not. Useful to block if you want to run many decks depending on the previous result (optimization), or if you only have a certain number of processors. Default: False
  • clean (bool) – Whether to clean up the running files in the ~/mcnp/active directory or not. Keep the files if storage isn’t a concern and you’re unsure if your deck will run correctly. Default: False
  • **kwargs (dict) –

    run passes the rest of the commands to write

write(**kwargs)[source]

write writes the input deck and renders the input deck

Parameters:**kwargs (dict) –

keyword arguments to pass to render

render(filename_suffix=”, render_target=None, camera_location=None, render=True, **kwargs)[source]

render passes the input deck to pyb, a simplified renderer that uses blender as the backend

Parameters:
  • filename_suffix (str) – suffix to put after the filename when we save the rendering. Default: ''
  • render_target (tuple) – a point for the camera to look at when rendering. Default: (0, 0, 0)
  • camera_location (tuple) – a point from which the camera looks. Default: based on the size of the scene, isotropic placement.
  • render (bool) – Whether or not to actually run the render. This method will always save a blender file, regardless of if we do a full render. Default: True
  • **kwargs (dict) –

    Other arguments to pass to pyb.render. See pyb for options, such as samples or res.

refresh_data()[source]

refresh_data resets the data block to nothing. Useful if you’re reusing a model and want to reset sources or materials or something.

refresh_geo()[source]

refresh_geo resets the geometry block to nothing. Useful if you’re changing geometry, although this probably shouldn’t be used without also refreshing the cells. But I don’t know you, live your life.

refresh_cell()[source]

refresh_cell resets the cell block to nothing. Again, useful for changing up cell definitions or materials.

refresh_phys()[source]

refresh_phys resets the physics block to nothing. This is a subset of the refresh_data method, so use whichever one is more useful.

refresh_tally()[source]

refresh_tally resets the tally block to nothing. This is probably not useful, unless you’re changing other things, too. If the model is still the name, just add the all the tallies in one input file and run it, it’s faster that way.

refresh_matl()[source]

refresh_matl resets the materials block to nothing. Super useful if you’re messing around with shielding, or reactions.

go_home()[source]

wig runs in the directory ~/mcnp/active. go_home goes to the directory in which the script started.

Input Deck Creation Submodules

wig.geo object

class wig.geo.geo[source]

some docstring

cell(matl)[source]

use geo.cell(matl) to return a cell of this geometry with material matl

Parameters:mcnpm.matl (matl) – The material to make this cell
Returns:mcnpce.cell object
rpp(c=None, l=None, x=None, y=None, z=None, id=None, name=None)[source]
box(v=None, a1=None, a2=None, a3=None, id=None)[source]
sph(c=None, r=None, id=None)[source]
rcc(c=None, l=None, r=None, id=None, lx=None, ly=None, lz=None)[source]
gq(A=None, B=None, C=None, D=None, E=None, F=None, G=None, H=None, J=None, K=None, coeffs=None, id=’gq’)[source]

gq creates a generalized quadratic surface.

gq creates a generalized quadratic surface defined by the equation

\[\begin{split}Ax^{2}+By^{2}+Cz^{2}+Dxy+Eyz\\+Fzx+Gx+Hy+Jz+K=0\end{split}\]

and takes inputs of either \(A\), \(B\), \(C\), \(D\), \(E\), \(F\), \(G\), \(H\), \(J\), \(K\), or an array coeffs which has the coefficients (all 10 of them) defined in alphabetical order.

Parameters:
  • A (float) – the coefficient \(A\)
  • B (float) – the coefficient \(B\)
  • C (float) – the coefficient \(C\)
  • D (float) – the coefficient \(D\)
  • E (float) – the coefficient \(E\)
  • F (float) – the coefficient \(F\)
  • G (float) – the coefficient \(G\)
  • H (float) – the coefficient \(H\)
  • J (float) – the coefficient \(J\)
  • K (float) – the coefficient \(K\)
  • coeffs (list) – a (10,) or (1,10) size array containing the coefficients \(A\) through \(K\), respectively
Returns:

the generalized quadratic surface object

cone(c=None, dir=’+z’, h=None, r=None, r1=0.0, r2=0.0, lx=0.0, ly=0.0, lz=0.0, id=0.0)[source]

wig.matl object

wig.cell object

wig.phys object

wig.source object

wig.tally object

Run and Runtime Submodules

wig.renderer object

class wig.wig.renderer(filename)[source]
run()[source]
add_geo(str)[source]
add_matl(str)[source]

wig.runner object

class wig.wig.runner(filename, command, remote=’local’, sys=’linux’, renderer=None, blocking=False, clean=False)[source]

wig.mcnpdaemon object

Post-processing Submodules

wig.analyze object

Convenience and internal submodules

wig.mcnp_string object