Skip to content

Commit 9ed017e

Browse files
authored
Merge pull request #308 from GEOUNED-org/dev
Merge dev into main for new release
2 parents a5948c1 + a1d957f commit 9ed017e

File tree

4 files changed

+143
-0
lines changed

4 files changed

+143
-0
lines changed

docs/example_of_use.rst

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
Example of use
2+
==============
3+
4+
The following is an example of how to use GEOUNED to convert a CAD file to a CSG file
5+
for use in MCNP. It includes the methodology and rationale behind the process.
6+
7+
.. warning:: It is assumed that GEOUNED has been properly installed as described in the
8+
`Quick install guide <./quick_install_guide.html>`_.
9+
10+
1. `CAD simplification`_
11+
2. `Export as STEP`_
12+
3. `Conversion to CSG`_
13+
4. `Suspicious solids and debug`_
14+
5. `Void check verification`_
15+
16+
.. _CAD simplification:
17+
18+
CAD simplification
19+
~~~~~~~~~~~~~~~~~~
20+
21+
The CAD model of the system should undergo a process of simplification. In this process,
22+
features that do not affect the radiation transport should be removed. The level of
23+
detail is usually decreased. Surfaces that are not allowed like splines are substituted
24+
by simpler surfaces like planes or cylinders.
25+
26+
.. _Export as STEP:
27+
28+
Export as STEP
29+
~~~~~~~~~~~~~~
30+
31+
Once the CAD is simplified, it is exported as a STEP file to be used as input by
32+
GEOUNED.
33+
34+
.. _Conversion to CSG:
35+
36+
Conversion to CSG
37+
~~~~~~~~~~~~~~~~~
38+
39+
The below code is run in a Python environment with GEOUNED installed. In the comments
40+
of the code there is an explanation of the parameters used.
41+
42+
.. code-block:: python
43+
44+
import geouned
45+
46+
settings = geouned.Settings(
47+
debug=True, # This will create a folder with the CAD bodies and their decomposition
48+
startCell=12001, # The first cell id
49+
startSurf=12001, # The first surface id
50+
compSolids=False, # False so the different solids of a component
51+
# are not combined into a single MCNP cell
52+
voidGen=True, # Generate the void cells
53+
)
54+
55+
geo = geouned.CadToCsg(settings=settings)
56+
geo.load_step_file(filename=f"Geometry/model.stp") # Path to the STEP file
57+
geo.start()
58+
print("Start exporting")
59+
geo.export_csg(
60+
geometryName="My model", # Name of the model to appear in the MCNP file
61+
outFormat=("mcnp",), # The output format
62+
UCARD=50, # Makes the model a filler universe with filler id 50
63+
volCARD=True, # The volume card is included in the cell definition
64+
volSDEF=True, # Generate a SDEF card
65+
)
66+
print("Exporting finished")
67+
68+
.. _Suspicious solids and debug:
69+
70+
Suspicious solids and debug
71+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
72+
73+
Running the above code will generate a debug folder that contains each of the converted
74+
solids, both the original and the decomposed ones. Those bodies can be opened and
75+
examined in a CAD software to compare them to the original model. If the decomposed
76+
model doesn't look right, it is possible to manually decompose a specific solid and
77+
redo the conversion.
78+
79+
Also, it is possible that a folder called *Suspicious solids* is created. This folder
80+
contains the same solids as the debug folder but only the ones that have been flagged as
81+
potentially problematic. This can be useful to quickly identify the problematic solids.
82+
83+
After applying any fix necessary and exporting to STEP, the conversion can be run again.
84+
85+
.. _Void check verification:
86+
87+
Void check verification
88+
~~~~~~~~~~~~~~~~~~~~~~~
89+
90+
Once the conversion is finished, it is recommended to stocastically check the volume
91+
of the solids and to make some plots.
92+
93+
In this example, the *UCARD* was used to make the model a filler universe. For these
94+
initial checks the *U=50* cards should be commented out as we want to test the
95+
standalone model. Plots with the MCNP plotter should be done to check that the model
96+
looks as expected.
97+
98+
Also, a void check simulation should be run. The *volSDEF=True* card automatically
99+
generated a spherical inward-oriented source with the correct weight to calculate
100+
volumes stochastically. The tallies for the solid MCNP cells were also automatically
101+
generated. The user can run the simulation directly and the results of the tallies
102+
should all be close to 1.0. If a MCNP cell tally shows a result far from 1.0 it would
103+
mean that the volume of the solid is not correct.
104+
105+
.. warning:: The void check simulation should be run with a high number of particles to
106+
achieve an acceptable statistical error. An usually number is 1e9 particles. Always
107+
check that the statistical error of the tallies is below 0.1.

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Supported codes include OpenMC, PHITS, Serpent and MCNP.
1111
:maxdepth: 2
1212

1313
quick_install_guide
14+
example_of_use
1415
users_guide/index
1516
python_api
1617
developers_guide

docs/version_switcher.json

+5
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@
2323
"name": "1.4.0",
2424
"version": "1.4.0",
2525
"url": "https://geouned-org.github.io/GEOUNED/1.4.0"
26+
},
27+
{
28+
"name": "1.5.2",
29+
"version": "1.5.2",
30+
"url": "https://geouned-org.github.io/GEOUNED/1.5.2"
2631
}
2732
]

src/geouned/GEOReverse/Modules/MCNPinput.py

+30
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,34 @@ def getTransMatrix(trsf, unit="", scale=10.0):
389389
0,
390390
1,
391391
)
392+
elif len(trsf) == 9:
393+
if unit == "*":
394+
coeff = tuple(map(math.radians, trsf[3:9]))
395+
coeff = tuple(map(math.cos, coeff))
396+
else:
397+
coeff = trsf[3:9]
398+
399+
axis = FreeCAD.Vector(coeff[0:3]).cross(FreeCAD.Vector(coeff[3:6]))
400+
coeff = coeff + (axis.x, axis.y, axis.z)
401+
402+
trsfMat = FreeCAD.Matrix(
403+
coeff[0],
404+
coeff[3],
405+
coeff[6],
406+
trsf[0] * scale,
407+
coeff[1],
408+
coeff[4],
409+
coeff[7],
410+
trsf[1] * scale,
411+
coeff[2],
412+
coeff[5],
413+
coeff[8],
414+
trsf[2] * scale,
415+
0,
416+
0,
417+
0,
418+
1,
419+
)
392420
else:
393421
if unit == "*":
394422
coeff = tuple(map(math.radians, trsf[3:12]))
@@ -965,6 +993,7 @@ def points_to_coeffs(scf):
965993
# coeff [0:3] a,b,c plane parameters
966994
# coeff [3] d plane parameter
967995
# normalization is d set to one if origin is not in the plane
996+
return coeff
968997

969998

970999
def get_parabola_parameters(eVal, eVect, T, U):
@@ -1250,6 +1279,7 @@ def gq2params(x):
12501279

12511280
Dinv = np.where(abs(eVal) < 1e-8, eVal, 1 / eVal) # get inverse eigen value where eigen< 1e-8
12521281
zero = (abs(eVal) < 1e-8).nonzero() # index in eigen value vector where eigen < 1e-8
1282+
zero = zero[0] # nonzero return a tuple with array containing the nonzero indexes
12531283
TD = -XD * Dinv # Translation vector in diagonalized base
12541284

12551285
k = np.matmul(TD, XD) + x[9]

0 commit comments

Comments
 (0)