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

Check cell comment #55

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions csg2csg/MCNPCellCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,18 @@ def write_mcnp_cell(filestream, CellCard, print_importances=True):
if CellCard.cell_material_number != 0:
string += str(CellCard.cell_density) + " "

# string += " ( "
string += " ( "

# build the cell description
for item in CellCard.cell_interpreted:
string += mcnp_op_from_generic(item)

# TODO make string no longer than 60 chars
# string += " ) "
string += " ) "
string += "\n"

string = re.sub(" +", " ", string)

string = string.strip()

if CellCard.cell_universe != 0:
Expand All @@ -103,6 +104,7 @@ def write_mcnp_cell(filestream, CellCard, print_importances=True):
for i in range(9):
value = float(CellCard.cell_universe_rotation[i])
# value = math.cos(value/180.*math.pi)

string += str(value) + " "
string += ")"

Expand Down Expand Up @@ -291,6 +293,7 @@ def __interpret(self):

string = self.text_string
# look for mcnp cell specific keywords

string = self.__detect_keywords(mcnp_cell_keywords, string)

# this is to detect the presence of any importance
Expand Down
57 changes: 56 additions & 1 deletion csg2csg/MCNPInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ def explode_macrobody(self, Surface):

elif Surface.surface_type == SurfaceCard.SurfaceType["MACRO_RCC"]:
id = int(Surface.surface_id)

vector = [
Surface.surface_coefficients[3],
Surface.surface_coefficients[4],
Expand All @@ -786,6 +785,27 @@ def explode_macrobody(self, Surface):
elif Surface.surface_type == SurfaceCard.SurfaceType["MACRO_BOX"]:

id = int(Surface.surface_id)
origin = [
Surface.surface_coefficients[0],
Surface.surface_coefficients[1],
Surface.surface_coefficients[2],
]

vec1 = [
Surface.surface_coefficients[3],
Surface.surface_coefficients[4],
Surface.surface_coefficients[5],
]
vec2 = [
Surface.surface_coefficients[6],
Surface.surface_coefficients[7],
Surface.surface_coefficients[8],
]
vec3 = [
Surface.surface_coefficients[9],
Surface.surface_coefficients[10],
Surface.surface_coefficients[11],
]

origin = [
Surface.surface_coefficients[0],
Expand Down Expand Up @@ -832,6 +852,25 @@ def explode_macrobody(self, Surface):
+ vec3n[2] * (origin[2] + vec3[2])
)

d1 = vec1n[0] * origin[0] + vec1n[1] * origin[1] + vec1n[2] * origin[2]
d2 = (
vec1n[0] * (origin[0] + vec1[0])
+ vec1n[1] * (origin[1] + vec1[1])
+ vec1n[2] * (origin[2] + vec1[2])
)
d3 = vec2n[0] * origin[0] + vec2n[1] * origin[1] + vec2n[2] * origin[2]
d4 = (
vec2n[0] * (origin[0] + vec2[0])
+ vec2n[1] * (origin[1] + vec2[1])
+ vec2n[2] * (origin[2] + vec2[2])
)
d5 = vec3n[0] * origin[0] + vec3n[1] * origin[1] + vec3n[2] * origin[2]
d6 = (
vec3n[0] * (origin[0] + vec3[0])
+ vec3n[1] * (origin[1] + vec3[1])
+ vec3n[2] * (origin[2] + vec3[2])
)

# cannonical facet ordering is done such that the surfaces
# making up the macrobody all point inwards
p1 = self.__make_new_plane(vec1n, d2)
Expand Down Expand Up @@ -981,8 +1020,10 @@ def __split_nots(self, cell):
# because cell.OperationType is not iterable
for i in cell.cell_interpreted:
# if its not an operation

if not isinstance(i, cell.OperationType):
if "#" in i:

pos = count
break
count = count + 1
Expand Down Expand Up @@ -1039,6 +1080,7 @@ def __generate_bounding_coordinates(self):
self.bounding_coordinates[4] = box[4]
if box[5] > self.bounding_coordinates[5]:
self.bounding_coordinates[5] = box[5]

logging.debug(
"%s ",
"bounding box of geometry is "
Expand Down Expand Up @@ -1124,6 +1166,17 @@ def __get_cell_cards(self):
self.file_lines[jdx]
)
cell_line = self.file_lines[jdx]
pos_comment = cell_line.find("$")
cell_comment = ""
if pos_comment != -1:
cell_line = cell_line[:pos_comment]
cell_comment = self.file_lines[jdx][pos_comment:] # set the comment
self.file_lines[jdx] = cell_line # update the file data

# if first token is 'c', skip this line
if cell_line.split()[0] == "c":
idx += 1
continue

# mcnp continue line is indicated by 5 spaces
if cell_line.startswith(" ") and not cell_line.isspace():
Expand Down Expand Up @@ -1343,7 +1396,9 @@ def process(self):
self.__get_material_cards(idx)
# need to flatten first to get transformed surface in the
# correct place

self.__simplify_cones()

self.__flatten_macrobodies()
self.__explode_nots()

Expand Down