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

autopep

parent 45391341
Loading
Loading
Loading
Loading
+40 −40
Original line number Diff line number Diff line
@@ -1438,12 +1438,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

@@ -1607,8 +1607,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):
@@ -1733,8 +1733,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
@@ -1813,8 +1813,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():
@@ -1866,7 +1866,6 @@ class Model:
                raise RuntimeError(
                    "`setInitial` was not called and the channels do not all have inlet mass/temp and outlet pressure BCs with uniform values, so cannot infer the correct initial conditions")


        # Determine the start/end axial locations of the sections
        z = 0.0
        for secID in sorted(me.sections.keys()):
@@ -1999,8 +1998,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

@@ -2101,30 +2100,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"""
@@ -2169,8 +2168,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
@@ -2190,7 +2189,8 @@ class Model:
        ID = 1
        for key in sorted(me.axialGeoShape.keys()):
            if key != ID:
                raise RuntimeError("Axial geometry table IDs must be sequential starting at 1.")
                raise RuntimeError(
                    "Axial geometry table IDs must be sequential starting at 1.")
            ID = ID + 1
        for chID in me.channelGeoTables.keys():
            foundChannel = False
@@ -2198,8 +2198,8 @@ 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 " +
+16 −13
Original line number Diff line number Diff line
@@ -304,7 +304,8 @@ def writeDeck(model, filename):
        for key in model.axialGeoShape.keys():
            maxLen = max(maxLen, len(model.axialGeoShape[key]['axial']))
        group5Data.append("** NAFACT   NAXL\n")
        group5Data.append("{:9d}{:7d} 0 0 0 0 0 0 0 0 0 0 0 0\n".format(len(model.axialGeoShape.keys()), maxLen))
        group5Data.append("{:9d}{:7d} 0 0 0 0 0 0 0 0 0 0 0 0\n".format(
            len(model.axialGeoShape.keys()), maxLen))
        group5Data.append("**Card 5.2\n")
        for key in sorted(model.axialGeoShape.keys()):
            line = ""
@@ -319,22 +320,25 @@ def writeDeck(model, filename):
        group6Data.append("**NGR\n6\n")
        group6Data.append("*Card 6.1\n")
        group6Data.append("**   N1\n")
        group6Data.append("{:7d} 0 0 0 0 0 0 0 0 0 0 0 0 0\n".format(len(model.channelGeoTables.keys())+
            len(model.gapGeoTables.keys())))
        group6Data.append("{:7d} 0 0 0 0 0 0 0 0 0 0 0 0 0\n".format(len(model.channelGeoTables.keys())
                                                                     + len(model.gapGeoTables.keys())))
        group6Data.append("*Card 6.2\n")
        group6Data.append("** IACT   IAMT   IPWT   ICRG\n")

        def getMom(channelGeoTables):
            """ Takes the channelGeoTables entry for chID and returns the flag for IAMT in the CTF input deck."""
            for i, tableID in enumerate(channelGeoTables['tables']):
                if 'momentum' in channelGeoTables['aspects'][i]:
                    return tableID
            return 0

        def getScal(channelGeoTables):
            """ Takes the channelGeoTables entry for chID and returns the flag for IACT in the CTF input deck."""
            for i, tableID in enumerate(channelGeoTables['tables']):
                if 'scalar' in channelGeoTables['aspects'][i]:
                    return tableID
            return 0

        def getPw(channelGeoTables):
            """ Takes the channelGeoTables entry for chID and returns the flag for IPWT in the CTF input deck."""
            for i, tableID in enumerate(channelGeoTables['tables']):
@@ -348,7 +352,6 @@ def writeDeck(model, filename):
            group6Data.append("{:7d}{:7d}{:7d}{:7d} 0 0 0 0 0 0 0 0 0 0 0\n".format(-model.gapGeoTables[gapID], 0, 0,
                                                                                    gapID))


    group7Data = []
    group7Data.append("**NGR\n")
    group7Data.append("    7\n")
+9 −6
Original line number Diff line number Diff line
@@ -45,9 +45,12 @@ def main():
                         rodEdits=False, dnbEdits=False)

    # Add axial geo tables
    model.addAxialGeoShape(ID=1, axialLevels=[1, 5, 6, 20], multipliers=[1.0, 1.0, 0.5, 0.5])
    model.addAxialGeoShape(ID=2, axialLevels=[1, 14, 15, 21], multipliers=[1.0, 1.0, 0.5, 0.5])
    model.addAxialGeoShape(ID=3, axialLevels=[1, 18, 19, 20], multipliers=[1.0, 1.0, 0.5, 0.5])
    model.addAxialGeoShape(ID=1, axialLevels=[1, 5, 6, 20], multipliers=[
                           1.0, 1.0, 0.5, 0.5])
    model.addAxialGeoShape(ID=2, axialLevels=[1, 14, 15, 21], multipliers=[
                           1.0, 1.0, 0.5, 0.5])
    model.addAxialGeoShape(ID=3, axialLevels=[1, 18, 19, 20], multipliers=[
                           1.0, 1.0, 0.5, 0.5])

    model.assignTableToChannel(tableID=1, chID=1, applies=['scalar', 'pw'])
    model.assignTableToChannel(tableID=2, chID=1, applies='momentum')
+3 −3

File changed.

Contains only whitespace changes.