コード例 #1
0
    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)
コード例 #2
0
ファイル: componentBlueprint.py プロジェクト: ntouran/armi
    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
コード例 #3
0
def makeComp(name):
    c = composites.Composite(name)
    c.p = MockSyncPC()
    return c