Skip to content

Commit 8bc7bd0

Browse files
AlvaroCubipsauvanrepositonyshimwellakolsek
authored
Merge dev into main (#67)
* update Fuzzy write function * several stp file update * script to color CAD document following material label * fix rounding error of z value acos(z) evaluation * Add a bug report template and .gitignore (#44) * Removed unused imports and variables (#35) * raise value error instead of exit (#41) * Update to testing path (#40) * changed hardcoded path to work for all users * path update * Update bug_report.md * raising catchable error instead of exit (#47) * raising catchable error instead of exit * added new line * added try for freecad import (#48) * Solve SyntaxtError producing a bug (#49) * Solve SyntaxtError producing a bug * Limit the amount of decimals printed in the enclosure comment * fixed error units in OpenMC output * GEOUNED training presentation added (#53) * Adding minimal ci to check cad converts (#52) * added minimal CI * all step files * added ci yml * removed freecadcmd arg * Update pyproject.toml Update url links to "GEOUNED-org" * typo correction to test if CI is working (#54) * typo correction * [skip ci] added ci status badge * opening up ci to all os systems * fix small bug with torus (bad identification of closed mozaic faces) * Adding minimal volume checking CI comparing CAD and CSG volumes (#56) * added volume test to ci * removed if os cond * added csg vs cad volume for **most** stp files * Added mkdocs (#57) * added example docs * added docs deps * Reverting mkdocs PR 57 (#58) * Revert "added example docs" This reverts commit bd1c67a. * Revert "added docs deps" This reverts commit f31d241. * Adding minimal particle transport tests on resulting csg files (#59) * added transport tests * removed files that break, raised issue * [skip ci] remove prints * added link to issue * Add the name to the cells in OpenMC to improve identification (#61) The name is the same that is used in MCNP inputs cell.Comments * converting with no simplification = more geometry works (#62) * reduced number of skiped geoms (#63) * [skip ci] corrected bade to main branch (#64) * Improved import statements (#65) * changed single file from package to relative imports * 2nd file converted to relative imports * converted more fiels to relative import * relative imports everywhere * isort on all imports * Add bug report and .gitignore to main (#45) (#66) Co-authored-by: AlvaroCubi <55387701+AlvaroCubi@users.noreply.github.com> * added standard gitignore for python project (#68) --------- Co-authored-by: psauvan <psauvan@ind.uned.es> Co-authored-by: Tony <63453741+repositony@users.noreply.github.com> Co-authored-by: Jonathan Shimwell <drshimwell@gmail.com> Co-authored-by: Aljaz Kolsek (F4E) <158494312+aljaz-kolsek@users.noreply.github.com> Co-authored-by: Emilio Castro <emilio.castro@upm.es>
1 parent c426387 commit 8bc7bd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+892
-302
lines changed

.github/workflows/ci.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI testing
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
testing:
14+
name: CI (Python=${{ matrix.python-version }}, OS=${{ matrix.os }})
15+
runs-on: ${{ matrix.os }}
16+
defaults:
17+
run:
18+
shell: bash -el {0}
19+
strategy:
20+
matrix:
21+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
22+
python-version: ["3.11"]
23+
24+
include:
25+
- python-version: "3.8"
26+
os: "ubuntu-latest"
27+
- python-version: "3.9"
28+
os: "ubuntu-latest"
29+
- python-version: "3.10"
30+
os: "ubuntu-latest"
31+
steps:
32+
- name: checkout actions
33+
uses: actions/checkout@v4
34+
- uses: conda-incubator/setup-miniconda@v3
35+
with:
36+
auto-update-conda: true
37+
python-version: ${{ matrix.python-version }}
38+
channels: conda-forge
39+
40+
- name: install dependencies
41+
run: conda install -c conda-forge freecad -y
42+
43+
- name: install package
44+
run: |
45+
python -m pip install --upgrade pip
46+
python -m pip install .
47+
python -c 'import GEOUNED'
48+
python -c 'from GEOReverse import reverse'
49+
python -m pip install .[tests]
50+
51+
- name: testing GEOUNED functionality
52+
run: python -m pytest -v tests/test_convert.py
53+
54+
- name: install openmc
55+
if: ${{ matrix.os == 'ubuntu-latest'}}
56+
run: conda install -c conda-forge openmc -y
57+
58+
- name: testing with OpenMC
59+
if: ${{ matrix.os == 'ubuntu-latest'}}
60+
run: |
61+
python -m pytest -v tests/test_volumes.py
62+
python -m pytest -v tests/test_transport.py

.gitignore

+168-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,174 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
#.idea/
161+
162+
# openmc output files
163+
*.h5
164+
*.xml
165+
166+
# testing folder
167+
tests_outputs/
168+
1169
.vscode
2170
**/__pycache__
3-
.coverage
4-
htmlcov/*
5171
docs/source/_build/**
6172
docs/build/**
7173
docs/source/_autosummary/*
8174
docs/jupyter_execute
9-
.pytest_cache/**
10-
build/

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![CI testing](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/ci.yml)
2+
13
# GEOUNED
24
A tool to convert from CAD to CSG & CSG to CAD for Monte Carlo transport codes (MCNP & OpenMC).
35
This repository contains the implementation of the algorithm presented in the paper [GEOUNED: A new conversion tool from CAD to Monte Carlo geometry](https://doi.org/10.1016/j.net.2024.01.052).
@@ -27,7 +29,7 @@ In that case you can install directly de module using:
2729
C:\Program Files\FreeCAD 0.XX\bin\python.exe -m pip install git+https://github.com/GEOUNED-code/GEOUNED.git
2830
```
2931
using this option you have directly access to both FreeCAD and GEOUNED python modules.
30-
Furthermore, using this python compabilities problems between different versions of python are avoided (some dynamic libraries of FreeCAD depends on the version of python used during the built process).
32+
Furthermore, using this python compatibilities problems between different versions of python are avoided (some dynamic libraries of FreeCAD depends on the version of python used during the built process).
3133

3234
## How to use
3335

docs/Training_on_GEOUNED_tool.pdf

896 KB
Binary file not shown.

pyproject.toml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "GEOUNED"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
authors = [
55
{ name="Juan-Pablo Catalan", email="jpcatalan@ind.uned.es" },
66
{ name="Patrick Sauvan", email="psauvan@ind.uned.es" },
@@ -22,6 +22,11 @@ classifiers = [
2222
]
2323

2424
[project.urls]
25-
Homepage = "https://github.com/GEOUNED-code"
26-
Repository = "https://github.com/GEOUNED-code/GEOUNED"
27-
Documentation = "https://github.com/GEOUNED-code/GEOUNED/docs"
25+
Homepage = "https://github.com/GEOUNED-org"
26+
Repository = "https://github.com/GEOUNED-org/GEOUNED"
27+
Documentation = "https://github.com/GEOUNED-org/GEOUNED/docs"
28+
29+
[project.optional-dependencies]
30+
tests = [
31+
"pytest",
32+
]

scripts/colorCADmat.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import re
2+
import sys
3+
4+
sys.path.append('/usr/lib64/freecad/lib64/')
5+
import ImportGui
6+
7+
bd = 255
8+
gd = 255*255
9+
rd = 255* 255* 255
10+
matNumber=re.compile(r"Material_(?P<matnum>\d+)")
11+
12+
def getColor(num,vmin=0,vmax=rd):
13+
colRange = rd
14+
dnum = vmax - vmin
15+
dx = num - vmin
16+
scale = colRange/dnum
17+
snum = dx * scale + 1
18+
19+
red = snum//gd
20+
r = snum - red * gd
21+
green = r // bd
22+
blue = r - green * bd
23+
return (red/255,green/255,blue/255)
24+
25+
def setColorMaterial(documents):
26+
featureObj = []
27+
matMin = 999999999
28+
matMax = 0
29+
for obj in documents.Objects:
30+
if obj.TypeId == 'Part::Feature' :
31+
for o in obj.InListRecursive:
32+
m = matNumber.search(o.Label)
33+
if m :
34+
mat = int(m.group('matnum'))
35+
matMin = min(matMin,mat)
36+
matMax = max(matMax,mat)
37+
featureObj.append((obj,mat))
38+
39+
for obj,mat in featureObj:
40+
obj.ViewObject.ShapeColor = getColor(mat,matMin,matMax)
41+
42+
43+
# color solids in a Freecad document with respect to the material number
44+
doc = App.ActiveDocument
45+
setColorMaterial(doc)
46+
name = doc.Label
47+
outname = name+'_color'
48+
ImportGui.export(doc.RootObjects,outname+'.stp')
49+
doc.saveAs(outname+'.FCStd')
50+

scripts/geouned

+2-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ elif len(sys.argv) == 3:
3232
runReverse = True
3333
inifile = sys.argv[1]
3434
else:
35-
print('Bad option')
36-
exit()
35+
raise ValueError('Bad option')
3736
else:
38-
print('Too many input arguments')
39-
exit()
37+
raise ValueError('Too many input arguments')
4038

4139

4240
if not runReverse :

scripts/geouned.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131
runReverse = True
3232
inifile = sys.argv[1]
3333
else:
34-
print('Bad option')
35-
exit()
36-
else:
37-
print('Too many input arguments')
38-
exit()
34+
raise ValueError('Bad option')
3935

36+
else:
37+
raise ValueError('Too many input arguments')
4038

4139
if not runReverse :
4240
GEO = GEOUNED.GEOUNED(inifile)

src/GEOReverse/Modules/MCNPinput.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
import math
12
import os
2-
import sys
33
import re
4+
45
import FreeCAD
5-
from GEOReverse.Modules.Parser import parser as mp
6-
from GEOReverse.Modules.remh import cell_card_string, remove_hash
7-
from GEOReverse.Modules.Objects import *
8-
import math
96
import numpy as np
107
from numpy import linalg as LA
118

9+
from .Objects import *
10+
from .Parser import parser as mp
11+
from .remh import cell_card_string, remove_hash
12+
13+
1214
class MCNPinput:
1315
def __init__(self,name):
1416
if not os.path.isfile(name):
15-
print("File %s does not exist" %name)
16-
sys.exit()
17-
return
17+
raise FileNotFoundError (f"File {name} does not exist")
1818
self.__inputcards__ = list(mp.get_cards(name))
1919
self.Transformations = self.__getTransList__()
2020
return

0 commit comments

Comments
 (0)