mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Tested geometry cloning with examples and fixed a few bugs
This commit is contained in:
parent
06a918c1b5
commit
45af8a2937
6 changed files with 36 additions and 26 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from collections import OrderedDict, Iterable
|
||||
from copy import deepcopy
|
||||
from math import cos, sin, pi
|
||||
from numbers import Real, Integral
|
||||
from xml.etree import ElementTree as ET
|
||||
|
|
@ -508,7 +509,7 @@ class Cell(object):
|
|||
"""Create a copy of this cell with a new unique ID, and clones
|
||||
the cell's region and fill."""
|
||||
|
||||
clone = copy.deepcopy(self)
|
||||
clone = deepcopy(self)
|
||||
clone.id = None
|
||||
|
||||
if self.region is not None:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import division
|
|||
|
||||
from abc import ABCMeta
|
||||
from collections import OrderedDict, Iterable
|
||||
from copy import deepcopy
|
||||
from math import sqrt, floor
|
||||
from numbers import Real, Integral
|
||||
from xml.etree import ElementTree as ET
|
||||
|
|
@ -418,7 +419,7 @@ class Lattice(object):
|
|||
"""Create a copy of this lattice with a new unique ID, and clones
|
||||
all universes within this lattice."""
|
||||
|
||||
clone = copy.deepcopy(self)
|
||||
clone = deepcopy(self)
|
||||
clone.id = None
|
||||
|
||||
# Clone all unique universes in the lattice
|
||||
|
|
@ -427,9 +428,17 @@ class Lattice(object):
|
|||
univ_clones[univ_id] = univ_clones[univ_id].clone()
|
||||
|
||||
# Assign universe clones to the lattice clone
|
||||
for index in self.indices:
|
||||
univ_id = self.universe[index].id
|
||||
clone.universes[index] = univ_clones[univ_id]
|
||||
for i in self.indices:
|
||||
if isinstance(self, RectLattice):
|
||||
univ_id = self.universes[i].id
|
||||
clone.universes[i] = univ_clones[univ_id]
|
||||
else:
|
||||
if self.ndim == 2:
|
||||
univ_id = self.universes[i[0]][i[1]].id
|
||||
clone.universes[i[0]][i[1]] = univ_clones[univ_id]
|
||||
else:
|
||||
univ_id = self.universes[i[0]][i[1]][i[2]].id
|
||||
clone.universes[i[0]][i[1]][i[2]] = univ_clones[univ_id]
|
||||
|
||||
return clone
|
||||
|
||||
|
|
|
|||
|
|
@ -799,6 +799,13 @@ class Material(object):
|
|||
|
||||
return nuclides
|
||||
|
||||
def clone(self):
|
||||
"""Create a copy of this material with a new unique ID."""
|
||||
|
||||
clone = deepcopy(self)
|
||||
clone.id = None
|
||||
return clone
|
||||
|
||||
def _get_nuclide_xml(self, nuclide, distrib=False):
|
||||
xml_element = ET.Element("nuclide")
|
||||
xml_element.set("name", nuclide[0].name)
|
||||
|
|
@ -1100,13 +1107,6 @@ class Materials(cv.CheckedList):
|
|||
for material in self:
|
||||
material.make_isotropic_in_lab()
|
||||
|
||||
def clone(self):
|
||||
"""Create a copy of this material with a new unique ID."""
|
||||
|
||||
clone = copy.deepcopy(self)
|
||||
clone.id = None
|
||||
return clone
|
||||
|
||||
def _create_material_subelements(self, root_element):
|
||||
for material in self:
|
||||
root_element.append(material.to_xml_element(self.cross_sections))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from abc import ABCMeta, abstractmethod
|
||||
from collections import Iterable, OrderedDict
|
||||
from copy import deepcopy
|
||||
|
||||
from six import add_metaclass
|
||||
import numpy as np
|
||||
|
|
@ -306,12 +307,11 @@ class Intersection(Region):
|
|||
check_type('nodes', nodes, Iterable, Region)
|
||||
self._nodes = nodes
|
||||
|
||||
@abstractmethod
|
||||
def clone(self):
|
||||
"""Create a copy of this region - each of the surfaces in the
|
||||
intersection's nodes will be cloned and will have new unique IDs."""
|
||||
|
||||
clone = copy.deepcopy(self)
|
||||
clone = deepcopy(self)
|
||||
clone.nodes = [n.clone() for n in self.nodes]
|
||||
return clone
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from abc import ABCMeta
|
||||
from collections import Iterable, OrderedDict
|
||||
from copy import deepcopy
|
||||
from numbers import Real, Integral
|
||||
from xml.etree import ElementTree as ET
|
||||
from math import sqrt
|
||||
|
|
@ -174,7 +175,7 @@ class Surface(object):
|
|||
def clone(self):
|
||||
"""Create a copy of this surface with a new unique ID."""
|
||||
|
||||
clone = copy.deepcopy(self)
|
||||
clone = deepcopy(self)
|
||||
clone.id = None
|
||||
return clone
|
||||
|
||||
|
|
@ -1828,15 +1829,6 @@ class Halfspace(Region):
|
|||
def __init__(self, surface, side):
|
||||
self.surface = surface
|
||||
self.side = side
|
||||
|
||||
@abstractmethod
|
||||
def clone(self):
|
||||
"""Create a copy of this halfspace, with a cloned surface with a
|
||||
unique ID."""
|
||||
|
||||
clone = copy.deepcopy(self)
|
||||
clone.surface = self.surface.clone()
|
||||
return clone
|
||||
|
||||
def __and__(self, other):
|
||||
if isinstance(other, Intersection):
|
||||
|
|
@ -1918,6 +1910,14 @@ class Halfspace(Region):
|
|||
surfaces[self.surface.id] = self.surface
|
||||
return surfaces
|
||||
|
||||
def clone(self):
|
||||
"""Create a copy of this halfspace, with a cloned surface with a
|
||||
unique ID."""
|
||||
|
||||
clone = deepcopy(self)
|
||||
clone.surface = self.surface.clone()
|
||||
return clone
|
||||
|
||||
|
||||
def get_rectangular_prism(width, height, axis='z', origin=(0., 0.),
|
||||
boundary_type='transmission'):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import division
|
||||
from copy import copy
|
||||
from collections import OrderedDict, Iterable
|
||||
from copy import copy, deepcopy
|
||||
from numbers import Integral, Real
|
||||
import random
|
||||
import sys
|
||||
|
|
@ -521,7 +521,7 @@ class Universe(object):
|
|||
"""Create a copy of this universe with a new unique ID, and clones
|
||||
all cells within this universe."""
|
||||
|
||||
clone = copy.deepcopy(self)
|
||||
clone = deepcopy(self)
|
||||
clone.id = None
|
||||
|
||||
# Clone all cells for the universe clone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue