Package: t4_geom_convert
t4_geom_convertThis repository contains the development version oft4_geom_convert, a Python
tool to convertMCNPgeometries into theTRIPOLI-4®format.FeaturesHere is a list of features of the MCNP modelling engine that are
at least partially supported and converted byt4_geom_convert:All surface typesBoolean cell operatorsLIKE n BUTsyntaxAffine transformations on surfaces and on cells (see theCurrent
limitationssection though)Boundary conditions (reflection, white surfaces)Isotopic compositions and cell densitiesUniverses and fills, even nested, possibly with affine transformationsLatticesInstallationt4_geom_convertis available onPyPI. The suggested way to install it
is to usethepip/pip3package managerandthevenvmodule. Ifpip3andvenvare not available on your machine, you can
use your package manager to install them:# sudo apt install python3-pip python3-venv  # on Debian/Ubuntu
# sudo yum install python3-pip python3-libs  # on Fedora/CentOSYou can then create a virtual Python environment and install the latest stable
version oft4_geom_convertthere with$ python3 -m venv /path/to/some/folder
$ source /path/to/some/folder/bin/activate
$ pip3 install -U pip setuptools
$ pip3 install t4_geom_convertThis will install thet4_geom_convertexecutable in/path/to/some/folder/bin/t4_geom_convert. Sourcing/path/to/some/folder/bin/activatewill putt4_geom_convertin yourPATH.You can also install the latest development version with$ pip3 install git+https://github.com/arekfu/t4_geom_convert.git@nextYou can find more information aboutpip3andvenvon the
web.DependenciesThe MCNP input file is parsed byMIP. We use a slightly modified version of
MIP, which is shipped along witht4_geom_convert. MIP depends onTatSu.t4_geom_convertalso depends onNumPy.UsageThe basic usage is simply$ t4_geom_convert <mcnp_input>This will create a TRIPOLI-4 output file called<mcnp_input>.t4containing
the converted geometry.  You can also choose a different name for the output
file using the-ooption.Use the-hoption for a list of all available options.Lattice conversiont4_geom_convertis capable of handling the conversion of repeated structures
(lattices). Hexahedral lattices (LAT=1) and hexagonal (LAT=2) are
supported.The cell declared asLAT=1orLAT=2represents the unit cell of the
lattice, which is assumed to repeat in all directions up to the boundaries of
the enclosing cell. Due to limitations of the TRIPOLI-4 representation of
lattices, we have chosen to represent lattices using a purely surface-based
approach.  This means thatt4_geom_convertwill actually emit separate cell
definitions for each cell of the lattice that is visible through the enclosing
cell. The ranges of cell definitions to be emitted must be specified by the
user via the--latticecommand-line option. For instance, consider the
following MCNP input:A lattice example
1 0  -2 1 -4 3 IMP:N=1 U=2 LAT=1
10 1 -1. -10 IMP:N=1 FILL=2
1000 0 10 IMP:N=0

1 PX -1.5
2 PX 1.5
3 PY -0.5
4 PY 0.5
10 SO 4

m1 13027 1.Here the unit cell is two-dimensional. The lattice fills a sphere of radius
4.  Assuming the unit cell is indexed as (0,0), the visible lattice cells are(-1, -4) to (-1, 4)(0, -4) to (0, 4)(1, -4) to (1, 4)This can be confirmed by visual inspection of the MCNP geometry or by
geometrical considerations. Once the index bounds are determined, the--latticeoption must be specified as$ t4_geom_convert --lattice 1,-1:1,-4:4 <mcnp_input>
                            ↑  ↑ ↑  ↑ ↑
             cell number ───┘  │ │  │ └ j-range upper bound
        i-range lower bound ───┘ │  └─── j-range lower bound
          i-range upper bound ───┘This results in the following TRIPOLI-4 geometry (X-Y cut), where a few cell
indices have been annotated:The syntax for one-dimensional lattices is--lattice <cell>,<i-from>:<i-to>and for three-dimensional lattices it is--lattice <cell>,<i-from>:<i-to>,<j-from>:<j-to>,<k-from>:<k-to>Note that theijkaxes are not necessarily the same as the coordinate axes.
The orientation of the lattice axes is specified by MCNP (see theLattice
indexingparagraph in the User's Manual) and it is determined by the order in
which the surfaces of the unit cell appear specified. In our example, the first
surface appearing in the definition of the unit cell is surface2; therefore,
surface2separates the unit cell (0, 0) from cell (1, 0); the next surface
(1) separates the unit cell from cell (-1, 0); the following surfaces,4and3, separate the unit cell from cells (0, 1) and (0, -1), respectively.For hexagonal lattices,t4_geom_convertfollows the convention described in
the MCNP manual. The lattice axes are defined by the first and the third plane
appearing in the definition of the base cell. The positive direction of the
third axis (if present) is defined by the normal to the seventh plane appearing
in the definition.A lattice unit cell may appear as a fill pattern in several enclosing cells. It
is currently not possible to specify different fill ranges for each of them.Fully-specified latticesMCNP provides a syntax for the specification of lattice with heterogeneous
cells. An example isA lattice example
c cells
2 0  -21 u=2 imp:n=1
21 0  21 u=2 imp:n=1
3 0  -31 u=3 imp:n=1
31 0  31 u=3 imp:n=1
10 0  -2 1 3 -4  lat=1 u=20 IMP:N=1
        FILL=-1:1 -4:4
c       i=-1   i=0   i=1
        2      3     2   $ j=-4
        2      3     2   $ j=-3
        2      3     2   $ j=-2
        2      3     2   $ j=-1
        2      3     2   $ j=0
        3      3     2   $ j=1
        3      3     2   $ j=2
        3      3     2   $ j=3
        3      3     2   $ j=4
100 1 -1. -10 IMP:N=1 FILL=20
1000 0 10 IMP:N=0

1 PX -1.5
2 PX 1.5
3 PY -0.5
4 PY 0.5
10 SO 4
21 SO 0.4
31 SO 0.1

m1 13027 1.TheFILL=-1:1 -4:4option indicates the range of indices where cells will be
specified. The universes filling the cells are detailed in the table below,
which by convention loops over the leftmost (i) axis first. This syntax is
supported byt4_geom_convertand doesnotrequire a--latticeoption. One
restriction applies: none of the subcells may be filled with the universe of
the lattice cell itself. This syntax indicates to MCNP that the cell should be
filled with the material of the lattice cell. Using0as a universe number
for the subcells is supported and results in no subcell being generated.Here is how the example above is converted and rendered in TRIPOLI-4:Current limitationsHere is a list of some things thatt4_geom_convertcannot currently do, but
may be able to do in the future (in roughly decreasing order of likelihood):Import the title of the MCNP input file (tracked inissue
#5)Handle affine transformations withm=-1(the last parameter of the
affine transformation) (tracked inissue
#12)Optimize fills with negative universes (do not intersect with the
enclosing cell) (tracked inissue
#13)Warn about isotopes that are missing from the TRIPOLI-4 dictionary
(currently you need to edit the converted file by hand and remove the
occurrences of the missing isotopes)Convert cell temperaturesImport comments describing the MCNP cells/surfaces (tracked inissue
#9)Provide a way to specify lattice fill ranges per enclosing cell(s) (this
needs to be specified in such a way that it works with nested lattices, too)Deduplicate repeated cell definitions (this is a bit harder than
deduplicating surfaces)Produce a TRIPOLI-4 connectivity map for as many cells as possible
(mostly lattices)Recognize and automatically suppress empty cells (they may be generated
by lattice development or fill development)Use a linear programming solver for cells bounded by planes?Use a SAT solver in the general case?Convert (some) MCNP source definitionsConvert (some) MCNP tally definitionsYour help is welcome! Feel free to open an issue if you would like to implement
a new feature or contribute to the project in any way.The full changelog ishere.TestingThe correctness oft4_geom_convertis tested usinga specific test
oracle, which is included in this repository.Reporting bugsPlease report any bug/feature request onthe GitHub issues page.Licence and acknowledgmentsThe development oft4_geom_convertwas partially financed by theEUROfusionconsortium.t4_geom_convertis released under the terms of theGNU General
Public Licence, version 3.