Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev into main #67

Merged
merged 30 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3d4ad1f
update Fuzzy write function
psauvan Mar 20, 2024
d123e67
several stp file update
psauvan Mar 23, 2024
f7cdf77
script to color CAD document following material label
psauvan Apr 9, 2024
db451b8
fix rounding error of z value acos(z) evaluation
psauvan Apr 9, 2024
f106652
Add a bug report template and .gitignore (#44)
AlvaroCubi Apr 9, 2024
4db7ce2
Removed unused imports and variables (#35)
repositony Apr 9, 2024
2d6e263
raise value error instead of exit (#41)
shimwell Apr 10, 2024
fdcd29d
Update to testing path (#40)
shimwell Apr 10, 2024
f14702d
Update bug_report.md
psauvan Apr 10, 2024
59731d8
raising catchable error instead of exit (#47)
shimwell Apr 16, 2024
377156b
added try for freecad import (#48)
shimwell Apr 16, 2024
dcb2c66
Solve SyntaxtError producing a bug (#49)
AlvaroCubi Apr 16, 2024
b132266
fixed error units in OpenMC output
psauvan Apr 16, 2024
b0742fd
GEOUNED training presentation added (#53)
akolsek Apr 18, 2024
9173938
Adding minimal ci to check cad converts (#52)
shimwell Apr 18, 2024
7a81367
Update pyproject.toml
psauvan Apr 18, 2024
6ed02e9
typo correction to test if CI is working (#54)
shimwell Apr 18, 2024
4cbd230
fix small bug with torus (bad identification of closed mozaic faces)
psauvan Apr 19, 2024
6e7f883
Adding minimal volume checking CI comparing CAD and CSG volumes (#56)
shimwell Apr 19, 2024
1a46bcd
Added mkdocs (#57)
shimwell Apr 19, 2024
d57bf81
Reverting mkdocs PR 57 (#58)
shimwell Apr 20, 2024
44ee8fa
Adding minimal particle transport tests on resulting csg files (#59)
shimwell Apr 20, 2024
a96e19d
Add the name to the cells in OpenMC to improve identification (#61)
ecasglez Apr 23, 2024
a4cc2cd
converting with no simplification = more geometry works (#62)
shimwell Apr 23, 2024
f741417
reduced number of skiped geoms (#63)
shimwell Apr 23, 2024
8e0e465
[skip ci] corrected bade to main branch (#64)
shimwell Apr 23, 2024
af70963
Improved import statements (#65)
shimwell Apr 23, 2024
6160952
Add bug report and .gitignore to main (#45) (#66)
shimwell Apr 23, 2024
90daab6
Merge branch 'main' into dev
AlvaroCubi Apr 23, 2024
213cb35
added standard gitignore for python project (#68)
shimwell Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI testing

on:
pull_request:
branches:
- dev
- main
push:
branches:
- main

jobs:
testing:
name: CI (Python=${{ matrix.python-version }}, OS=${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.11"]

include:
- python-version: "3.8"
os: "ubuntu-latest"
- python-version: "3.9"
os: "ubuntu-latest"
- python-version: "3.10"
os: "ubuntu-latest"
steps:
- name: checkout actions
uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge

- name: install dependencies
run: conda install -c conda-forge freecad -y

- name: install package
run: |
python -m pip install --upgrade pip
python -m pip install .
python -c 'import GEOUNED'
python -c 'from GEOReverse import reverse'
python -m pip install .[tests]

- name: testing GEOUNED functionality
run: python -m pytest -v tests/test_convert.py

- name: install openmc
if: ${{ matrix.os == 'ubuntu-latest'}}
run: conda install -c conda-forge openmc -y

- name: testing with OpenMC
if: ${{ matrix.os == 'ubuntu-latest'}}
run: |
python -m pytest -v tests/test_volumes.py
python -m pytest -v tests/test_transport.py
172 changes: 168 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,174 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# openmc output files
*.h5
*.xml

# testing folder
tests_outputs/

.vscode
**/__pycache__
.coverage
htmlcov/*
docs/source/_build/**
docs/build/**
docs/source/_autosummary/*
docs/jupyter_execute
.pytest_cache/**
build/
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![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)

# GEOUNED
A tool to convert from CAD to CSG & CSG to CAD for Monte Carlo transport codes (MCNP & OpenMC).
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).
Expand Down Expand Up @@ -27,7 +29,7 @@ In that case you can install directly de module using:
C:\Program Files\FreeCAD 0.XX\bin\python.exe -m pip install git+https://github.com/GEOUNED-code/GEOUNED.git
```
using this option you have directly access to both FreeCAD and GEOUNED python modules.
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).
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).

## How to use

Expand Down
Binary file added docs/Training_on_GEOUNED_tool.pdf
Binary file not shown.
13 changes: 9 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "GEOUNED"
version = "1.0.0"
version = "1.0.1"
authors = [
{ name="Juan-Pablo Catalan", email="[email protected]" },
{ name="Patrick Sauvan", email="[email protected]" },
Expand All @@ -22,6 +22,11 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/GEOUNED-code"
Repository = "https://github.com/GEOUNED-code/GEOUNED"
Documentation = "https://github.com/GEOUNED-code/GEOUNED/docs"
Homepage = "https://github.com/GEOUNED-org"
Repository = "https://github.com/GEOUNED-org/GEOUNED"
Documentation = "https://github.com/GEOUNED-org/GEOUNED/docs"

[project.optional-dependencies]
tests = [
"pytest",
]
50 changes: 50 additions & 0 deletions scripts/colorCADmat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import re
import sys

sys.path.append('/usr/lib64/freecad/lib64/')
import ImportGui

bd = 255
gd = 255*255
rd = 255* 255* 255
matNumber=re.compile(r"Material_(?P<matnum>\d+)")

def getColor(num,vmin=0,vmax=rd):
colRange = rd
dnum = vmax - vmin
dx = num - vmin
scale = colRange/dnum
snum = dx * scale + 1

red = snum//gd
r = snum - red * gd
green = r // bd
blue = r - green * bd
return (red/255,green/255,blue/255)

def setColorMaterial(documents):
featureObj = []
matMin = 999999999
matMax = 0
for obj in documents.Objects:
if obj.TypeId == 'Part::Feature' :
for o in obj.InListRecursive:
m = matNumber.search(o.Label)
if m :
mat = int(m.group('matnum'))
matMin = min(matMin,mat)
matMax = max(matMax,mat)
featureObj.append((obj,mat))

for obj,mat in featureObj:
obj.ViewObject.ShapeColor = getColor(mat,matMin,matMax)


# color solids in a Freecad document with respect to the material number
doc = App.ActiveDocument
setColorMaterial(doc)
name = doc.Label
outname = name+'_color'
ImportGui.export(doc.RootObjects,outname+'.stp')
doc.saveAs(outname+'.FCStd')

6 changes: 2 additions & 4 deletions scripts/geouned
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ elif len(sys.argv) == 3:
runReverse = True
inifile = sys.argv[1]
else:
print('Bad option')
exit()
raise ValueError('Bad option')
else:
print('Too many input arguments')
exit()
raise ValueError('Too many input arguments')


if not runReverse :
Expand Down
8 changes: 3 additions & 5 deletions scripts/geouned.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
runReverse = True
inifile = sys.argv[1]
else:
print('Bad option')
exit()
else:
print('Too many input arguments')
exit()
raise ValueError('Bad option')

else:
raise ValueError('Too many input arguments')

if not runReverse :
GEO = GEOUNED.GEOUNED(inifile)
Expand Down
16 changes: 8 additions & 8 deletions src/GEOReverse/Modules/MCNPinput.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import math
import os
import sys
import re

import FreeCAD
from GEOReverse.Modules.Parser import parser as mp
from GEOReverse.Modules.remh import cell_card_string, remove_hash
from GEOReverse.Modules.Objects import *
import math
import numpy as np
from numpy import linalg as LA

from .Objects import *
from .Parser import parser as mp
from .remh import cell_card_string, remove_hash


class MCNPinput:
def __init__(self,name):
if not os.path.isfile(name):
print("File %s does not exist" %name)
sys.exit()
return
raise FileNotFoundError (f"File {name} does not exist")
self.__inputcards__ = list(mp.get_cards(name))
self.Transformations = self.__getTransList__()
return
Expand Down
Loading