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

Additions to to unit conversions

Add in a tolerance on a diff check as well

4709
parent 839ed8a4
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -1616,7 +1616,7 @@ class Model:
                customPower = True
        if len(powers) > 0:
            avePow = np.average(powers, weights=mult)
            if customPower and not np.isclose(avePow, 1.0):
            if customPower and not np.isclose(avePow, 1.0, atol=1e-3):
                raise RuntimeError(
                    "A user-specified power distribution was supplied but it does not normalize to unity: " + str(avePow))
            elif not customPower and not np.isclose(avePow, 1.0):
@@ -1771,10 +1771,17 @@ class Model:

        # If the inlet mass flow rate distribution was non-uniform, the initial absolute mass flow rate
        # must be defined in CTF, mass flux set to zero, and inlet mass flow rate set to zero
        if me._inletMassflowsSpecified():
           if me._uniformInletMassFlux():
               me.nonuniformInletMdot = False
           else:
               me.nonuniformInletMdot = True
        else:
            # No inlet mass flow rates were defined for individual channels, so a uniform inlet mass flow
            # rate will have been specified for the model if possible and if not possible, the code will
            # have failed
            me.nonuniformInletMdot = False


        # Determine the start/end axial locations of the sections
        z = 0.0
@@ -1853,6 +1860,15 @@ class Model:

        me._gapChecks()

    def _inletMassflowsSpecified(me):
        """ Returns True if any mass flow rates were specified for the inlet"""
        for chID in me.sections[1].channels.keys():
            ch = me.sections[1].channels[chID]
            for idx, j in enumerate(ch.bcLevels):
                if j == 1 and BoundaryCondition.isMassFlowBC(ch.bcs[idx]):
                    return True
        return False

    def _uniformInletMassFlux(me):
        """ Returns True if the inlet mass flux in all Section 1 channels are the same and False otherwise.
        If no inlet mdot values are applied, this returns False.  If only some of the channels have inlet mass
+12 −0
Original line number Diff line number Diff line
@@ -10,9 +10,15 @@ t_cm_m = 0.01 # cm/m
t_m_cm = 1 / t_cm_m
t_mm_m = t_cm_m / 10
t_m_mm = 1 / t_mm_m
t_cm_mm = 10.0
t_mm_cm = 1/t_cm_mm
t_in_m = t_in_cm * t_cm_m
t_m_in = 1.0 / t_in_m
t_J_kJ = 0.001  # J/kJ
t_MJ_J = 1e6
t_J_MJ = 1/t_MJ_J
t_MJ_kJ = 1e3
t_kJ_MJ = 1/t_MJ_kJ
t_BTU_J = 1055.06
t_J_BTU = 1.0 / t_BTU_J
t_MBTU_J = t_BTU_J * 1e6
@@ -21,6 +27,10 @@ t_BTU_kJ = t_BTU_J * t_J_kJ
t_kJ_BTU = 1.0 / t_BTU_kJ
t_MBTU_kJ = t_MBTU_J * t_J_kJ
t_kJ_MBTU = 1.0 / t_MBTU_kJ
t_MW_kW = t_MJ_kJ
t_kW_MW = t_kJ_MJ
t_MW_W = t_MJ_J
t_W_MW = t_J_MJ
t_gal_L = 3.78541  # gal/L
t_L_gal = 1.0 / t_gal_L
t_L_m3 = 1e-3  # L/m**3
@@ -41,6 +51,8 @@ t_MPa_Pa = 1e6
t_Pa_MPa = 1 / t_MPa_Pa
t_bar_Pa = t_bar_MPa * t_MPa_Pa
t_Pa_bar = 1 / t_bar_Pa
t_bar_MPa = t_bar_Pa*t_Pa_MPa
t_MPa_bar = 1/t_bar_MPa
t_K_F = 1.8
t_bar_psi = 14.5038