Skip to content

Commit

Permalink
Dev (#21)
Browse files Browse the repository at this point in the history
* fix undefined variables issue#14 by repositony

* fixed bug multiple output format

* Update README.md

* Update README.md

* Added link to paper and bibtex to README (#18)

* Update pyproject.toml (#13)

* Update CodeVersion.py

* Update CodeVersion.py

---------

Co-authored-by: mxmws <59613435+mxmws@users.noreply.github.com>
Co-authored-by: jpcatalanUNED <112404276+jpcatalanUNED@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 25, 2024
1 parent 87fb0e1 commit 695a30c
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/GEOUNED/Write/Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,10 @@ def MCNPSurface(id,Type,surf):
MCNP_def='{:<6d} P {:{abc}} {:{abc}} {:{abc}} {:{d}}'.format(id,A,B,C,D/10.0,abc=nf.P_abc,d=nf.P_d)

elif (Type == 'Cylinder'):
Pos = FreeCAD.Vector(surf.Center)
Pos.multiply(0.1)
Dir = FreeCAD.Vector(surf.Axis)
Dir.normalize()
rad = surf.Radius/10.0
Pos = surf.Center*0.1
rad = surf.Radius*0.1
if (isParallel(Dir,FreeCAD.Vector(1,0,0),tol.angle)):
if (Pos.y == 0.0 and Pos.z == 0.0):
MCNP_def='{:<6d} CX {:{r}}'.format(id,rad,r=nf.C_r)
Expand Down Expand Up @@ -252,10 +251,8 @@ def MCNPSurface(id,Type,surf):
# MCNP_def='%i RCC %13.7E %13.7E %13.7E %13.7E\n %13.7E %13.7E %13.7E' %(id,Vx,Vy,Vz,Hx,Hy,Hz,rad)

elif (Type == 'Cone'):
Apex = FreeCAD.Vector(surf.Apex)
Apex.multiply(0.1)
Dir = FreeCAD.Vector(surf.Axis)
Dir.multiply(0.1)
Apex = surf.Apex*0.1
Dir = surf.Axis*0.1
tan = math.tan(surf.SemiAngle)
X_dir=FreeCAD.Vector(1,0,0)
Y_dir=FreeCAD.Vector(0,1,0)
Expand Down Expand Up @@ -291,20 +288,19 @@ def MCNPSurface(id,Type,surf):

elif (Type == 'Sphere'):
# corresponding logic
rad = surf.Radius/10.0
pnt = surf.Center.multiply(0.1)
rad = surf.Radius*0.1
pnt = surf.Center*0.1
if pnt.isEqual(FreeCAD.Vector(0,0,0),tol.sph_distance):
MCNP_def='{:<6d} SO {:{r}}'.format(id,rad,r=nf.S_r)
else:
MCNP_def='{:<6d} S {:{xyz}} {:{xyz}} {:{xyz}} {:{r}}'.format(id,pnt.x,pnt.y,pnt.z,rad,xyz=nf.S_xyz,r=nf.S_r)

elif (Type == 'Torus'):
Pos = FreeCAD.Vector(surf.Center)
Pos.multiply(0.1)
Dir = FreeCAD.Vector(surf.Axis)
Dir.normalize()
radMaj = surf.MajorRadius/10.0
radMin = surf.MinorRadius/10.0
Pos = surf.Center*0.1
radMaj = surf.MajorRadius*0.1
radMin = surf.MinorRadius*0.1
if (isParallel(Dir,FreeCAD.Vector(1,0,0),tol.angle)):
MCNP_def='''\
{:<6d} TX {:{xyz}} {:{xyz}} {:{xyz}}
Expand Down Expand Up @@ -518,9 +514,10 @@ def SerpentSurface(id, Type, surf):
Serpent_def = f"surf {id} plane {A:{nf.P_d}} {B:{nf.P_d}} {C:{nf.P_d}} {D/10:{nf.P_d}}"

elif Type == 'Cylinder':
Pos = surf.Center.multiply(0.1)
Dir = surf.Axis.normalize()
rad = surf.Radius / 10.0
Dir = surf.Axis
Dir.normalize()
Pos = surf.Center*0.1
rad = surf.Radius*0.1
if isParallel(Dir, FreeCAD.Vector(1, 0, 0), tol.angle):
Serpent_def = f"surf {id} cylx {Pos.y:{nf.C_xyz}} {Pos.z:{nf.C_xyz}} {rad:{nf.C_r}}"
elif isParallel(Dir, FreeCAD.Vector(0, 1, 0), tol.angle):
Expand All @@ -537,8 +534,8 @@ def SerpentSurface(id, Type, surf):
{v[9]:{j}} '''.format(id,v=Q,aTof=nf.GQ_1to6,gToi=nf.GQ_7to9,j=nf.GQ_10)

elif Type == 'Cone':
Apex = surf.Apex.multiply(0.1)
Dir = surf.Axis.multiply(0.1)
Apex = surf.Apex*0.1
Dir = surf.Axis*0.1
tan = math.tan(surf.SemiAngle)
X_dir = FreeCAD.Vector(1, 0, 0)
Y_dir = FreeCAD.Vector(0, 1, 0)
Expand Down Expand Up @@ -569,16 +566,17 @@ def SerpentSurface(id, Type, surf):


elif Type == 'Sphere':
rad = surf.Radius / 10.0
pnt = surf.Center.multiply(0.1)
rad = surf.Radius*0.1
pnt = surf.Center*0.1
# Serpent has only explicit spheres at the origin
Serpent_def = f"surf {id} sph {pnt.x:{nf.S_xyz}} {pnt.y:{nf.S_xyz}} {pnt.z:{nf.S_xyz}} {rad:{nf.S_r}}"

elif Type == 'Torus':
Pos = surf.Center.multiply(0.1)
Dir = surf.Axis.normalize()
radMaj = surf.MajorRadius / 10.0
radMin = surf.MinorRadius / 10.0
Dir = surf.Axis
Dir.normalize()
Pos = surf.Center*0.1
radMaj = surf.MajorRadius*0.1
radMin = surf.MinorRadius*0.1
if (isParallel(Dir, FreeCAD.Vector(1, 0, 0), tol.angle)):
Serpent_def = f"surf {id} torx {Pos.x:{nf.T_xyz}} {Pos.y:{nf.T_xyz}} {Pos.z:{nf.T_xyz}}\n"
Serpent_def += f" {radMaj:{nf.T_r}} {radMin:{nf.T_r}} {radMin:{nf.T_r}}"
Expand Down

0 comments on commit 695a30c

Please # to comment.