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 itscene
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’ formcnp5
, ‘x’ formcnpx
, or ‘polimi’ formcnpx-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 createdParameters: filename (str) – the base of the filename
-
set_comment
(comment)[source]¶ set_comment
writes the first line of themcnp
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 definedwig.geo
objects to an input deckParameters: geos (list) – the wig.geo
objects to be added to the input deck. Make sure this includes a universe
-
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 deckParameters: matls (list) – the materials to add to the input deck
-
phys
(phys=None)[source]¶ phys
adds allwig.phys
blocks to the modelParameters: phys (wig.phys) – the wig.phys
block to be added to the model.
-
tally
(tallies=None)[source]¶ tally
adds allwig.tally
b’ocks to the modelParameters: tallies (list) – the wig.tally
blocks to be added to the model.
-
source
(sources=None)[source]¶ source
adds thewig.source
object to the modelParameters: 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 awig.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 havemcnp
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 towrite
- remote (str) – The ip address of the remote system you want to
run this on, or
-
write
(**kwargs)[source]¶ write
writes the input deck and renders the input deckParameters: **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 topyb
, a simplified renderer that usesblender
as the backendParameters: - 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
. Seepyb
for options, such assamples
orres
.
- filename_suffix (str) – suffix to put after the filename when we
save the rendering. Default:
-
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 therefresh_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.