|
9 | 9 | from csg2csg.OpenMCSurface import SurfaceCard,surface_from_attribute, write_openmc_surface |
10 | 10 | from csg2csg.OpenMCCell import cell_from_attribute, write_openmc_cell |
11 | 11 | from csg2csg.OpenMCMaterial import material_from_attribute, write_openmc_material |
| 12 | +from csg2csg.OpenMCLattice import lattice_from_attribute, write_openmc_lattice |
| 13 | + |
12 | 14 | ''' |
13 | 15 | copy and paste from http://effbot.org/zone/element-lib.htm#prettyprint |
14 | 16 | it basically walks your tree and adds spaces and newlines so the tree is |
@@ -69,13 +71,21 @@ def process(self): |
69 | 71 |
|
70 | 72 | # process the geometry |
71 | 73 | def __process_geometry(self): |
| 74 | + |
72 | 75 | for child in self.xml_geom: |
73 | 76 | if child.tag == "surface": |
74 | 77 | surface = surface_from_attribute(child.attrib) |
75 | 78 | InputDeck.surface_list.append(surface) |
76 | 79 | elif child.tag == "cell": |
77 | 80 | cell = cell_from_attribute(child.attrib) |
78 | 81 | InputDeck.cell_list.append(cell) |
| 82 | + elif child.tag == "lattice": |
| 83 | + lattice = lattice_from_attribute('lattice', child.attrib, child.getchildren()) |
| 84 | + InputDeck.lattice_list.append(lattice) |
| 85 | + elif child.tag == "hex_lattice": |
| 86 | + lattice = lattice_from_attribute('hex_latice', child.attrib, child.getchildren()) |
| 87 | + InputDeck.lattice_list.append(lattice) |
| 88 | + |
79 | 89 |
|
80 | 90 | # loop over the cells and set the material |
81 | 91 | # density for each cell |
@@ -114,7 +124,13 @@ def __write_openmc_surfaces(self, geometry_tree): |
114 | 124 | def __write_openmc_cells(self, geometry_tree): |
115 | 125 | for cell in self.cell_list: |
116 | 126 | write_openmc_cell(cell, geometry_tree) |
117 | | - |
| 127 | + |
| 128 | + # write the collection of OpenMC lattice definitions |
| 129 | + def __write_openmc_lattices(self, geometry_tree): |
| 130 | + for lattice in self.lattice_list: |
| 131 | + write_openmc_lattice(lattice, geometry_tree) |
| 132 | + |
| 133 | + |
118 | 134 | # write the collection of Material |
119 | 135 | def __write_openmc_materials(self, material_tree): |
120 | 136 | for mat in self.material_list: |
@@ -167,6 +183,7 @@ def write_openmc(self, filename, flat = True): |
167 | 183 |
|
168 | 184 | self.__write_openmc_surfaces(geometry) |
169 | 185 | self.__write_openmc_cells(geometry) |
| 186 | + self.__write_openmc_lattices(geometry) |
170 | 187 | self.__check_unused_universes(geometry) |
171 | 188 |
|
172 | 189 | tree = ET.ElementTree(geometry) |
|
0 commit comments