Commit a287f64e authored by Salko Jr, Robert's avatar Salko Jr, Robert
Browse files

autopep

parent babd7b76
Loading
Loading
Loading
Loading
+37 −37
Original line number Diff line number Diff line
@@ -1478,12 +1478,12 @@ class Model:
            if type(value) is not type(me.conductorOptions[name]['value']):
                # Assume all entries must have the same type as the
                # default entry set in this class.
                raise TypeError(name + " must be " + str(type(me.conductorOptions[name]['value']))
                                + " but it was provided as " + str(type(value)))
                raise TypeError(name + " must be " + str(type(me.conductorOptions[name]['value'])) +
                                " but it was provided as " + str(type(value)))
            if value not in me.conductorOptions[name]['validEntries']:
                raise ValueError("The value provided for " + name + " (" + str(value) +
                                 ") is not one of the valid values: " +
                                 str(me.conductorOptions[name]['validEntries']))
                raise ValueError("The value provided for " + name + " (" + str(value)
                                 + ") is not one of the valid values: "
                                 + str(me.conductorOptions[name]['validEntries']))
            me.conductorOptions[name]['value'] = value
            me.conductorOptions[name]['set'] = True

@@ -1647,8 +1647,8 @@ class Model:
        sec1 = me.getSectionOfChannel(me.gaps[gapID].ii)
        sec2 = me.getSectionOfChannel(me.gaps[gapID].jj)
        if sec1 != sec2:
            raise RuntimeError("Gap {:d} connects Channels {:d} and {:d} which are in different sections " +
                               "{:d} and {:d}.  This is not allowed".format(gapID, me.gaps[gapID].ii, me.gaps[gapID].jj, sec1, sec2))
            raise RuntimeError("Gap {:d} connects Channels {:d} and {:d} which are in different sections "
                               + "{:d} and {:d}.  This is not allowed".format(gapID, me.gaps[gapID].ii, me.gaps[gapID].jj, sec1, sec2))
        return sec1

    def getSectionOfChannel(me, chID):
@@ -1773,8 +1773,8 @@ class Model:
        if me.channelsInDomain:
            # Make sure same number of domains were defined for rods
            if len(me.channelsInDomain) != len(me.rodsInDomain):
                raise RuntimeError("Number of domains defined for channels " + len(me.channelsInDomain) +
                                   " must equal number of domains defined for rods " + len(me.rodsInDomain))
                raise RuntimeError("Number of domains defined for channels " + len(me.channelsInDomain)
                                   + " must equal number of domains defined for rods " + len(me.rodsInDomain))
            rodDomains = sorted(me.rodsInDomain.keys())
            chanDomains = sorted(me.channelsInDomain.keys())
            # Domain numbering must start at 1 and increase sequentially
@@ -1853,8 +1853,8 @@ class Model:
                if obj.material:
                    # A material was defined for this solid type
                    if obj.material not in me.materials:
                        raise RuntimeError("The material: " + str(obj.material) +
                                           " defined for solid type " + str(key) + " was not defined in the model.")
                        raise RuntimeError("The material: " + str(obj.material)
                                           + " defined for solid type " + str(key) + " was not defined in the model.")

        # Set gap conductance to default value if not set by user
        for solidID in me.solidObjects.keys():
@@ -2038,8 +2038,8 @@ class Model:
        def getPressureBCOutlet(ch, topLev):
            """ Returns the pressure of the outlet BC if the channel has one"""
            for i, bc in enumerate(ch.bcLevels):
                if ch.bcLevels[i] == topLev and (isinstance(ch.bcs[i], BoundaryCondition.PressureTemperature) or
                                                 isinstance(ch.bcs[i], BoundaryCondition.PressureEnthalpy)):
                if ch.bcLevels[i] == topLev and (isinstance(ch.bcs[i], BoundaryCondition.PressureTemperature)
                                                 or isinstance(ch.bcs[i], BoundaryCondition.PressureEnthalpy)):
                    return ch.bcs[i].pressure
            return None, None

@@ -2140,30 +2140,30 @@ class Model:
                gapSectionBelow = me.getSectionOfGap(gapBelow)
                # Make sure the section of the gap below is actually the section below this gap's section
                if gapSectionBelow != gapSection - 1:
                    raise RuntimeError("Gap {:d} connects to Gap {:d} below, but Gap {:d} is in Section {:d} and " +
                                       "Gap {:d} is in Section {:d}, which are not correctly axially aligned".format(gapID,
                    raise RuntimeError("Gap {:d} connects to Gap {:d} below, but Gap {:d} is in Section {:d} and "
                                       + "Gap {:d} is in Section {:d}, which are not correctly axially aligned".format(gapID,
                                                                                                                     gapBelow, gapID, gapSection, gapBelow, gapSectionBelow))
                # If the gap below does not have gapAbove set to be consistent with this one, set it
                if me.gaps[gapBelow].gapAbove == 0:
                    me.gaps[gapBelow].gapAbove = gapID
                # If the gap below was set, but is not equal to this gapID, throw an error
                if me.gaps[gapBelow].gapAbove != gapID:
                    raise RuntimeError("Gap {:d} had gapAbove set to {:d}, but this is not consistent with what " +
                                       "gapBelow was set to for {:d}".format(gapBelow, me.gaps[gapBelow].gapAbove, gapID))
                    raise RuntimeError("Gap {:d} had gapAbove set to {:d}, but this is not consistent with what "
                                       + "gapBelow was set to for {:d}".format(gapBelow, me.gaps[gapBelow].gapAbove, gapID))
            gapAbove = me.gaps[gapID].gapAbove
            if gapAbove != 0:
                gapSectionAbove = me.getSectionOfGap(gapAbove)
                if gapSectionAbove != gapSection + 1:
                    raise RuntimeError("Gap {:d} connects to Gap {:d} above, but Gap {:d} is in Section {:d} and " +
                                       "Gap {:d} is in Section {:d}, which are not correctly axially aligned".format(gapID,
                    raise RuntimeError("Gap {:d} connects to Gap {:d} above, but Gap {:d} is in Section {:d} and "
                                       + "Gap {:d} is in Section {:d}, which are not correctly axially aligned".format(gapID,
                                                                                                                     gapAbove, gapID, gapSection, gapAbove, gapSectionAbove))
                # If the gap above does not have gapAbove set to be consistent with this one, set it
                if me.gaps[gapAbove].gapBelow == 0:
                    me.gaps[gapAbove].gapBelow = gapID
                # If the gap above was set, but is not equal to this gapID, throw an error
                if me.gaps[gapAbove].gapBelow != gapID:
                    raise RuntimeError("Gap {:d} had gapBelow set to {:d}, but this is not consistent with what " +
                                       "gapAbove was set to for {:d}".format(gapAbove, me.gaps[gapAbove].gapBelow, gapID))
                    raise RuntimeError("Gap {:d} had gapBelow set to {:d}, but this is not consistent with what "
                                       + "gapAbove was set to for {:d}".format(gapAbove, me.gaps[gapAbove].gapBelow, gapID))

    def _validateBoundaryConditions(me):
        """ Ensure boundary conditions were setup correctly"""
@@ -2208,8 +2208,8 @@ class Model:
                sections.append(me.getSectionOfChannel(ch))
            unique = list(set(sections))
            if len(innerChan) > 0 and len(unique) > 1:
                raise RuntimeError("For solidID: " + str(solidID) +
                                   " has internal connections and exists in multiple sections, which is not currently allowed.")
                raise RuntimeError("For solidID: " + str(solidID)
                                   + " has internal connections and exists in multiple sections, which is not currently allowed.")
            # Loop through each section connected to this rod
            for u in unique:
                # In each section, ensure that all percentages of connections add up to 1.0
@@ -2238,19 +2238,19 @@ class Model:
                if chID in me.sections[section].channels.keys():
                    foundChannel = True
            if not foundChannel:
                raise RuntimeError("Geometry table ID: " + str(me.channelGeoTables[chID]['tables'][0])
                                   + " assigned to non-existent channel:  " + str(chID))
                raise RuntimeError("Geometry table ID: " + str(me.channelGeoTables[chID]['tables'][0]) +
                                   " assigned to non-existent channel:  " + str(chID))
            for tableID in me.channelGeoTables[chID]['tables']:
                if tableID not in me.axialGeoShape:
                    raise RuntimeError("Geometry table ID: " + str(tableID) + " was not defined, but is trying " +
                                       "to be applied to channel:  " + str(chID))
                    raise RuntimeError("Geometry table ID: " + str(tableID) + " was not defined, but is trying "
                                       + "to be applied to channel:  " + str(chID))
        for gapID in me.gapGeoTables.keys():
            if gapID not in me.gaps:
                raise RuntimeError("Geometry table ID: " + str(me.gapGeoTables[gapID]) + " attempting to be applied" +
                                   " to non-existent gap:  " + str(gapID))
                raise RuntimeError("Geometry table ID: " + str(me.gapGeoTables[gapID]) + " attempting to be applied"
                                   + " to non-existent gap:  " + str(gapID))
            if tableID not in me.axialGeoShape:
                raise RuntimeError("Geometry table ID: " + str(tableID) + " was not defined, but is trying " +
                                   "to be applied to gap:  " + str(gapID))
                raise RuntimeError("Geometry table ID: " + str(tableID) + " was not defined, but is trying "
                                   + "to be applied to gap:  " + str(gapID))


class Gap(object):
+7 −4
Original line number Diff line number Diff line
@@ -162,14 +162,17 @@ def writeDeck(model, filename):
        group1Data.append("{{beta_htc}} {:15.3e}\n".format(model.betaHTC))

    if 'intDragModel' in model.optionalModels:
        group1Data.append("{{int_drag_model}} {:s}\n".format(model.optionalModels['intDragModel']))
        group1Data.append("{{int_drag_model}} {:s}\n".format(
            model.optionalModels['intDragModel']))
    if 'flowRegimeMap' in model.optionalModels:
        group1Data.append("{{flow_regime_map}} {:s}\n".format(model.optionalModels['flowRegimeMap']))
        group1Data.append("{{flow_regime_map}} {:s}\n".format(
            model.optionalModels['flowRegimeMap']))
    if 'subcooledBoilingModel' in model.optionalModels:
        if model.optionalModels['subcooledBoilingModel'] == 'saha':
            group1Data.append("{use_onb_model} .true.\n")
    if 'tpFrictionModel' in model.optionalModels:
        group1Data.append("{{tp_fric_model}} {:s}\n".format(model.optionalModels['tpFrictionModel']))
        group1Data.append("{{tp_fric_model}} {:s}\n".format(
            model.optionalModels['tpFrictionModel']))
    if 'maxOuterIterations' in model.numericalControls:
        group1Data.append("{enable_outer_iteration_loop} .true.\n")

+3 −2
Original line number Diff line number Diff line
@@ -61,7 +61,8 @@ def main():
    model.assignTableToGap(tableID=3, gapID=1)
    model.assignTableToChannel(tableID=2, chID=2, applies='scalar')

    model.solidQuickAdd(solidID=1, geoObj=skb.Tube(d_outer=1e-3, d_inner=0.8e-3))
    model.solidQuickAdd(solidID=1, geoObj=skb.Tube(
        d_outer=1e-3, d_inner=0.8e-3))
    model.addSolidOuterChan(solidID=1, chID=[1, 2], percent=[0.5, 0.5])

    model.setNumericalControls(maxOuterIterations=10)