-
Notifications
You must be signed in to change notification settings - Fork 32
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
Changes in users initialization #102
Changes from all commits
76ef697
9b3180b
f7720bb
2463ece
3cd60ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/python | ||
|
||
# Path to GEOUNED Package | ||
|
||
|
||
# only if modules are not in the PYTHONPATH or directly installed in the python distribution used | ||
import sys | ||
|
||
geo_path="C:\\Users\\Patrick\\Documents\\GitHub\\GEOUNED\\src" | ||
sys.path.append(geo_path) | ||
sys.path.append('C:\\Program Files\\FreeCAD 0.19\\bin...') | ||
|
||
from geouned import CadToCsg | ||
|
||
stepFileName = 'placa.stp' | ||
|
||
GEO = CadToCsg('Conversion Example') | ||
|
||
GEO.set('stepFile', stepFileName) | ||
GEO.set('geometryName','Placa') | ||
GEO.set('outFormat', ('mcnp', 'openMC_XML')) | ||
GEO.set('planeDistance', 0.05) | ||
GEO.set('quadricPY', True) | ||
GEO.set('P_abc', '12f') | ||
GEO.set('P_d', '12f') | ||
GEO.Start() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
class Options: | ||
pass | ||
from .optionsDefault import defaultValues, typeDict | ||
@classmethod | ||
def setDefaultAttribute(cls): | ||
for key,value in cls.defaultValues.items(): | ||
setattr(cls, key, value) | ||
|
||
@classmethod | ||
def setAttribute(cls,key,value): | ||
if key in cls.defaultValues.keys(): | ||
setattr(cls, key, value) | ||
|
||
class McnpNumericFormat: | ||
pass | ||
class Tolerances: | ||
from .tolerancesDefault import defaultValues, typeDict, KwrdEquiv | ||
|
||
@classmethod | ||
def setDefaultAttribute(cls): | ||
for key,value in cls.defaultValues.items(): | ||
setattr(cls, key, value) | ||
Comment on lines
+13
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can set all the defaults in the Class init with default args let me make a PR into this PR to show what I mean |
||
|
||
class Tolerances: | ||
pass | ||
@classmethod | ||
def setAttribute(cls,key,value): | ||
if key in cls.defaultValues.keys(): | ||
setattr(cls, key, value) | ||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. classes allow attributes to be set if we set them in the regular python manner without the need for a custom Attribute setter, so I don't think we need this |
||
|
||
|
||
class McnpNumericFormat: | ||
from .mcnpNumericDefault import defaultValues | ||
|
||
@classmethod | ||
def setDefaultAttribute(cls): | ||
for key,value in cls.defaultValues.items(): | ||
setattr(cls, key, value) | ||
|
||
@classmethod | ||
def setAttribute(cls,key,value): | ||
if key in cls.defaultValues.keys(): | ||
setattr(cls, key, value) | ||
Comment on lines
+28
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments as above for the class Options |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +0,0 @@ | ||
from .Classes import McnpNumericFormat, Options, Tolerances | ||
|
||
# default options values | ||
forceCylinder = True # Force using cylinders instead cones for auxillary surfaces of torus surface definition | ||
newSplitPlane = True # Use new module for planes splitting in decomposition module | ||
delLastNumber = False # Deleting the last word in the comment if it is a number | ||
verbose = False # Display information during conversion process | ||
enlargeBox = 2 # Enlarge box Boundary when evaluating Ctable (dimension in mm) | ||
nPlaneReverse = 0 # numbers of plane thresold whether cut of parallel planes are made fisrt with lowest or highest number | ||
splitTolerance = 0 # First try for fuzzy tolerance used in BOPTOOL Split function. If BOPTSplit crash try lower value for tolerance | ||
scaleUp = True # Scale up Fuzzy tolerance once get below 1e-12 | ||
quadricPY = False # use quadric form of cones and cylinder not aligned with X,Y,Z axis when write openMC script file | ||
Facets = False # use alternative conversion module when geometry is defined by cells compound by only triangular plane faces | ||
prnt3PPlane = ( | ||
False # print 3 point plane definition in MCNP output as 3 points coordinates | ||
) | ||
forceNoOverlap = False # force no overlaping cell definition. Adjacent cell definition are rested from current cell definition | ||
|
||
tolValueDict = { | ||
"relativeTol": False, | ||
"relativePrecision": 1.0e-6, # relative precision | ||
"value": 1.0e-6, # Tolerance in single value comparison | ||
"distance": 1.0e-4, # General Distance Tolerance | ||
"angle": 1.0e-4, # General Angle Tolerance | ||
"pln_distance": 1.0e-4, # distance between planes equal planes if distance between parallel planes < 1e-4 cm | ||
"pln_angle": 1.0e-4, # angle between axis. 1e-4 : planes separate each other 0.1mm each 1m | ||
"cyl_distance": 1.0e-4, # distance between radius/center | ||
"cyl_angle": 1.0e-4, # angle between axis | ||
"sph_distance": 1.0e-4, # distance between radius/center | ||
"kne_distance": 1.0e-4, # distance between apex | ||
"kne_angle": 1.0e-4, # angle between semiangles/axis | ||
"tor_distance": 1.0e-4, # distance between Major/Minor radii/center | ||
"tor_angle": 1.0e-4, # angle between axis | ||
"min_area": 1.0e-2, | ||
} # minimun face area to consider in cell definition | ||
|
||
|
||
numValueDict = { | ||
"P_abc": "14.7e", # Plane general a,b,c params | ||
"P_d": "14.7e", # Plane general d params | ||
"P_xyz": "14.7e", # PX/PY/PZ params | ||
"S_r": "14.7e", # SO/SX/SY/SZ/S radius | ||
"S_xyz": "14.7e", # SO/SX/SY/SZ/S center | ||
"C_r": "12f", # Cylinder radius | ||
"C_xyz": "12f", # Cylinder center | ||
"K_xyz": "13.6e", # Cone apex | ||
"K_tan2": "12f", # Cone tan^2 value | ||
"T_r": "14.7e", # Torus radii | ||
"T_xyz": "14.7e", # Torus center | ||
"GQ_1to6": "18.15f", # GQ 1 to 6 coefficients (order 2 x2,y2,z2,xy,...) | ||
"GQ_7to9": "18.15f", # GQ 7 to 9 coefficients (order 1 x,y,z) | ||
"GQ_10": "18.15f", | ||
} # GQ 10 coefficient (order 0) | ||
|
||
|
||
# Set default attributes to Options class | ||
setattr(Options, "forceCylinder", forceCylinder) | ||
setattr(Options, "newSplitPlane", newSplitPlane) | ||
setattr(Options, "enlargeBox", enlargeBox) | ||
setattr(Options, "delLastNumber", delLastNumber) | ||
setattr(Options, "verbose", verbose) | ||
setattr(Options, "nPlaneReverse", nPlaneReverse) | ||
setattr(Options, "splitTolerance", splitTolerance) | ||
setattr(Options, "scaleUp", scaleUp) | ||
setattr(Options, "quadricPY", quadricPY) | ||
setattr(Options, "Facets", Facets) | ||
setattr(Options, "prnt3PPlane", prnt3PPlane) | ||
setattr(Options, "forceNoOverlap", forceNoOverlap) | ||
|
||
# Set default attributes to Tolerances class | ||
for key in tolValueDict.keys(): | ||
setattr(Tolerances, key, tolValueDict[key]) | ||
|
||
|
||
# Set default attributes to MCNP number format class | ||
for key in numValueDict.keys(): | ||
setattr(McnpNumericFormat, key, numValueDict[key]) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defaultValues = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be done in the class on creation |
||
"P_abc": "14.7e", # Plane general a,b,c params | ||
"P_d": "14.7e", # Plane general d params | ||
"P_xyz": "14.7e", # PX/PY/PZ params | ||
"S_r": "14.7e", # SO/SX/SY/SZ/S radius | ||
"S_xyz": "14.7e", # SO/SX/SY/SZ/S center | ||
"C_r": "12f", # Cylinder radius | ||
"C_xyz": "12f", # Cylinder center | ||
"K_xyz": "13.6e", # Cone apex | ||
"K_tan2": "12f", # Cone tan^2 value | ||
"T_r": "14.7e", # Torus radii | ||
"T_xyz": "14.7e", # Torus center | ||
"GQ_1to6": "18.15f", # GQ 1 to 6 coefficients (order 2 x2,y2,z2,xy,...) | ||
"GQ_7to9": "18.15f", # GQ 7 to 9 coefficients (order 1 x,y,z) | ||
"GQ_10": "18.15f", # GQ 10 coefficient (order 0) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# default options values | ||
defaultValues = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above, can be moved into the class. Then users know the default values that are being used as the class tells them in the doc strings and with hover text in IDEs |
||
"forceCylinder" : False, # Force using cylinders instead cones for auxillary surfaces of torus surface definition | ||
"newSplitPlane" : True, # Use new module for planes splitting in decomposition module | ||
"delLastNumber" : False, # Deleting the last word in the comment if it is a number | ||
"verbose" : False, # Display information during conversion process | ||
"enlargeBox" : 2, # Enlarge box Boundary when evaluating Ctable (dimension in mm) | ||
"nPlaneReverse" : 0, # numbers of plane thresold whether cut of parallel planes are made fisrt with lowest or highest number | ||
"splitTolerance" : 0, # First try for fuzzy tolerance used in BOPTOOL Split function. If BOPTSplit crash try lower value for tolerance | ||
"scaleUp" : True, # Scale up Fuzzy tolerance once get below 1e-12 | ||
"quadricPY" : False, # use quadric form of cones and cylinder not aligned with X,Y,Z axis when write openMC script file | ||
"Facets" : False, # use alternative conversion module when geometry is defined by cells compound by only triangular plane faces | ||
"prnt3PPlane" : False, # print 3 point plane definition in MCNP output as 3 points coordinates | ||
"forceNoOverlap" : False, # force no overlaping cell definition. Adjacent cell definition are rested from current cell definition | ||
} | ||
|
||
typeDict = { | ||
"forceCylinder" : bool, # Force using cylinders instead cones for auxillary surfaces of torus surface definition | ||
"newSplitPlane" : bool, # Use new module for planes splitting in decomposition module | ||
"delLastNumber" : bool, # Deleting the last word in the comment if it is a number | ||
"verbose" : bool, # Display information during conversion process | ||
"enlargeBox" : float, # Enlarge box Boundary when evaluating Ctable (dimension in mm) | ||
"nPlaneReverse" : int, # numbers of plane thresold whether cut of parallel planes are made fisrt with lowest or highest number | ||
"splitTolerance" : int, # First try for fuzzy tolerance used in BOPTOOL Split function. If BOPTSplit crash try lower value for tolerance | ||
"scaleUp" : bool, # Scale up Fuzzy tolerance once get below 1e-12 | ||
"quadricPY" : bool, # use quadric form of cones and cylinder not aligned with X,Y,Z axis when write openMC script file | ||
"Facets" : bool, # use alternative conversion module when geometry is defined by cells compound by only triangular plane faces | ||
"prnt3PPlane" : bool, # print 3 point plane definition in MCNP output as 3 points coordinates | ||
"forceNoOverlap" : bool, # force no overlaping cell definition. Adjacent cell definition are rested from current cell definition | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
defaultValues = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above, we can move this to the class |
||
"relativeTol": False, | ||
"relativePrecision": 1.0e-6, # relative precision | ||
"value": 1.0e-6, # Tolerance in single value comparison | ||
"distance": 1.0e-4, # General Distance Tolerance | ||
"angle": 1.0e-4, # General Angle Tolerance | ||
"pln_distance": 1.0e-4, # distance between planes equal planes if distance between parallel planes < 1e-4 cm | ||
"pln_angle": 1.0e-4, # angle between axis. 1e-4 : planes separate each other 0.1mm each 1m | ||
"cyl_distance": 1.0e-4, # distance between radius/center | ||
"cyl_angle": 1.0e-4, # angle between axis | ||
"sph_distance": 1.0e-4, # distance between radius/center | ||
"kne_distance": 1.0e-4, # distance between apex | ||
"kne_angle": 1.0e-4, # angle between semiangles/axis | ||
"tor_distance": 1.0e-4, # distance between Major/Minor radii/center | ||
"tor_angle": 1.0e-4, # angle between axis | ||
"min_area": 1.0e-2, # minimun face area to consider in cell definition | ||
} | ||
|
||
typeDict = { | ||
"relativeTol": bool, | ||
"relativePrecision": float, # relative precision | ||
"value": float, # Tolerance in single value comparison | ||
"distance": float, # General Distance Tolerance | ||
"angle": float, # General Angle Tolerance | ||
"pln_distance": float, # distance between planes equal planes if distance between parallel planes < 1e-4 cm | ||
"pln_angle": float, # angle between axis. 1e-4 : planes separate each other 0.1mm each 1m | ||
"cyl_distance": float, # distance between radius/center | ||
"cyl_angle": float, # angle between axis | ||
"sph_distance": float, # distance between radius/center | ||
"kne_distance": float, # distance between apex | ||
"kne_angle": float, # angle between semiangles/axis | ||
"tor_distance": float, # distance between Major/Minor radii/center | ||
"tor_angle": float, # angle between axis | ||
"min_area": float, # minimun face area to consider in cell definition | ||
} | ||
|
||
KwrdEquiv = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw this in the original init file and it would be really great if we just have one set of names and don't need an equivalence dictionary |
||
"relativeTolerance": "relativeTol", | ||
"relativePrecision": "relativePrecision", | ||
"singleValue": "value", | ||
"generalDistance": "distance", | ||
"generalAngle": "angle", | ||
"planeDistance": "pln_distance", | ||
"planeAngle": "pln_angle", | ||
"cylinderDistance": "cyl_distance", | ||
"cylinderAngle": "cyl_angle", | ||
"sphereDistance": "sph_distance", | ||
"coneDistance": "kne_distance", | ||
"coneAngle": "kne_angle", | ||
"torusDistance": "tor_distance", | ||
"torusAngle": "tor_angle", | ||
"minArea": "min_area", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be the normal way to set class attributes that python users would be familiar with
Ideally this would work for options and tolerances as well