def test_setMass(self): masses = {"U235": 5.0, "U238": 3.0} self.obj.setMasses(masses) self.assertAlmostEqual(self.obj.getMass("U235"), 5.0) self.assertAlmostEqual(self.obj.getMass("U238"), 3.0) self.assertAlmostEqual(self.obj.getMass(), 8.0) self.obj.addMasses(masses) self.assertAlmostEqual(self.obj.getMass("U238"), 6.0) # make sure it works with groups of groups group = composites.Composite("group") group.add(self.obj) group.add(loadTestBlock()) group.setMass("U235", 5) self.assertAlmostEqual(group.getMass("U235"), 5)
def construct(self, blueprint, matMods): """Construct a component or group""" runLog.debug("Constructing component {}".format(self.name)) kwargs = self._conformKwargs(blueprint, matMods) shape = self.shape.lower().strip() if shape == COMPONENT_GROUP_SHAPE: group = blueprint.componentGroups[self.name] constructedObject = composites.Composite(self.name) for groupedComponent in group: componentDesign = blueprint.componentDesigns[ groupedComponent.name] component = componentDesign.construct(blueprint, matMods=dict()) # override free component multiplicity if it's set based on the group definition component.setDimension("mult", groupedComponent.mult) _setComponentFlags(component, self.flags, blueprint) insertDepletableNuclideKeys(component, blueprint) constructedObject.add(component) else: constructedObject = components.factory(shape, [], kwargs) _setComponentFlags(constructedObject, self.flags, blueprint) insertDepletableNuclideKeys(constructedObject, blueprint) return constructedObject
def makeComp(name): c = composites.Composite(name) c.p = MockSyncPC() return c