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

Add support for specifying enthalpy as IC and BC

Allows the user to specify enthalpy for inlet/outlet boundary conditions
and/or initial conditions in addition to temperature.

Gitlab ticket - 4164
parent 6c047df9
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -47,12 +47,16 @@ class InpBuilder(object):
        mdotinit = me.inp.getInitialmdot()
        pressureinit = me.inp.getInitialPressure()
        temperatureinit = me.inp.getInitialTemperature()
        #enthalpyinit = me.inp.getInitialEnthalpy()
        enthalpyinit = me.inp.getInitialEnthalpy()

        if massfluxinit:
            mdotinit = massfluxinit * me.inp.getInFlowArea()
        me.model.setInitialConditions(
            mdotInit=mdotinit, tempInit=temperatureinit, pressureInit=pressureinit)
        if enthalpyinit is not None:
            temp_solid = temperatureinit
            temperatureinit = None
        else:
            temp_solid = None

        me.model.setInitial(mdot=mdotinit, massflux=massfluxinit, temp=temperatureinit,
                temp_solid=temp_solid, enthalpy=enthalpyinit, pressure=pressureinit)

        # Boundary Conditions
        for chID in me.inp.getChannelIDs():
+13 −3
Original line number Diff line number Diff line
@@ -195,6 +195,10 @@ class InpParse(object):
        if 'temp' in me.inpDict['initial']:
            return me.inpDict['initial']['temp']['value']

    def getInitialEnthalpy(me):
        if 'enth' in me.inpDict['initial']:
            return me.inpDict['initial']['enth']['value']

    def getSectionIDs(me):
        return me.secIDs

@@ -414,11 +418,17 @@ class InpParse(object):
            massflux = me.getInitialMassFlux()
            mdotin = me.getInitialmdot()
            temperature = me.getInitialTemperature()
            enthalpy = me.getInitialEnthalpy()
            pressure = me.getInitialPressure()
            if massflux:
                mdot = massflux * me.getChannelArea(chID)
            if mdotin:
                mdot = mdotin * me.getChannelArea(chID) / me.getInFlowArea()
            if enthalpy:
                BCs.append(BC.MassEnthalpy(mdot=mdot, h=enthalpy))
                BCs.append(BC.PressureEnthalpy(
                    pressure=pressure, h=enthalpy))
            else:
                BCs.append(BC.MassTemperature(mdot=mdot, T=temperature))
                BCs.append(BC.PressureTemperature(
                    pressure=pressure, T=temperature))
+48 −20
Original line number Diff line number Diff line
@@ -424,39 +424,67 @@ class Model:
           mdot (float): Initial mass flow rate in the system
           massflux (float): Initial mass flux in the system
           temp (float): Initial temperature in the model
           temp_solid (float): Initial temperature of solids in the model
           enthalpy (float): Initial enthalpy in the model
           pressure (float): Initial (and reference) pressure in the system

        """
        if me.setInitialCalled:
            raise RuntimeError("`setInitial` already called")
        assert not ('mdot' in kwargs and 'massflux' in kwargs)
        assert 'mdot' in kwargs or 'massflux' in kwargs
        assert not ('temp' in kwargs and 'enthalpy' in kwargs)
        assert 'temp' in kwargs or 'enthalpy' in kwargs
        if 'enthalpy' in kwargs:
            assert 'temp_solid' in kwargs
        assert 'pressure' in kwargs

        if 'mdot' in kwargs:
            me.mdotInit = kwargs['mdot']
            mdot = kwargs['mdot']
        else:
            mdot = None
        if 'massflux' in kwargs:
            massflux = kwargs['massflux']
        else:
            massflux = None
        if 'temp' in kwargs:
            temp = kwargs['temp']
        else:
            temp = None
        if 'temp_solid' in kwargs:
            temp_solid = kwargs['temp_solid']
        else:
            temp_solid = None
        if 'enthalpy' in kwargs:
            enthalpy = kwargs['enthalpy']
        else:
            enthalpy = None
        if 'pressure' in kwargs:
            pressure = kwargs['pressure']
        else:
            pressure = None

        # Cannot have both mdot and massflux provided
        assert not ((mdot is not None) and (massflux is not None))
        # Cannot have both temp and enthalpy provided
        assert not ((temp is not None) and (enthalpy is not None))
        # Must specify at least temperature or enthalpy
        assert (temp is not None) or (enthalpy is not None)
        if enthalpy is not None:
            assert temp_solid is not None
        assert pressure is not None

        if mdot is not None:
            me.mdotInit = mdot
            me.massFluxInit = me.mdotInit / me.sections[1].getFlowArea()
            me.mdotInitialWasSpecified = True
        else:
            me.massFluxInit = kwargs['massflux']
            me.massFluxInit = massflux
            me.mdotInit = me.massFluxInit * me.sections[1].getFlowArea()

        if 'temp' in kwargs:
            me.tempInit = kwargs['temp']
        if temp is not None:
            me.tempInit = temp
        else:
            me.enthalpyInit = kwargs['enthalpy']
            me.enthalpyInit = enthalpy

        if 'temp_solid' in kwargs:
            me.solidTempInit = kwargs['temp_solid']
        if temp_solid is not None:
            me.solidTempInit = temp_solid
        else:
            me.solidTempInit = kwargs['temp']
            me.solidTempInit = temp

        me.pressureInit = kwargs['pressure']
        me.pressureInit = pressure

        me.setInitialCalled = True

+14 −0
Original line number Diff line number Diff line
@@ -694,6 +694,8 @@ ch{
      }
      # press and mdot/mflux cannot both be specified
      ChildAtMostOne=[press, mdot, mflux]
      # Cannot have both temp and enthalpy
      ChildExactlyOne=[enth, temp]
      mflux{
         Description="Mass flux for the specified channel bc."
         MinOccurs=0
@@ -730,6 +732,18 @@ ch{
            ValType=Real
         }
      }
      enth{
         Description="Enthalpy for the specified bc."
         MinOccurs=0
         MaxOccurs=1
         InputTmpl="value.flag"
         value{
            MinOccurs=1
            MaxOccurs=1
            ### Units="kJ/kg"
            ValType=Real
         }
      }
      press{
         Description="Fluid pressure for the specified bc."
         MinOccurs=0
+241 −0
Original line number Diff line number Diff line
***********************************************************************************************
*MAIN CONTROL DATA
***********************************************************************************************
*ICOBRA
      1
*INITIAL   DUMPF
       1       0
**    EPSO    OITMAX    IITMAX   COURANT
  1e-4             5       200  0.800000
*TITLE
ctf model
***********************************************************************************************
*GROUP 1 - Calculation Variables and Initial Conditions
***********************************************************************************************
**NGR
   1
**NGAS IRFC EDMD IMIX ISOL          GINIT NOTRN MESH MAPS IPRP MFLX IBTM PPV  NM14
     1    2    0    3    3    0.00000e+00     1    1    0    3    1    0   7     0
*Card 1.2
**         GTOT          AFLUX         DHFRAC      MASSFLUX
        0.00000       15.00000        0.00000     3500.00000
*Card 1.3
**         PREF            HIN           HGIN         VFRAC1         VFRAC2
      155.00000     1000.00000 288.4200000      1.0000000      0.9999000
*Card 1.4
**GTP(1)   VFRAC(3)  GTP(2) VFRAC(4)  GTP(3) VFRAC(5)  GTP(4) VFRAC(6)
     air     0.0001
***********************************************************************************************
*GROUP 2 - Channel Description
***********************************************************************************************
**NGR
    2
*Card 2.1
**  NCH NDM2 NDM3 NDM4 NDM5 NDM6 NDM7 NDM8 NDM9 NM10 NM11 NM12 NM13 NM14
   1    0    0    0    0    0    0    0    0    0    0    0    0    0
*Card 2.2
**   I          AN          PW ABOT ATOP NMGP           X           Y        XSIZ        YSIZ
     1  8.5368e-05  2.9845e-02  0.0  0.0    0  0.0000e+00  0.0000e+00  0.0000e+00  0.0000e+00
***********************************************************************************************
*GROUP 4 - Vertical Channel Connection Data
***********************************************************************************************
**NGR
    4
*Card 4.1
**NSEC NSIM IREB NDM4 NDM5 NDM6 NDM7 NDM8 NDM9 NM10 NM11 NM12 NM13 NM14
     1    1    0    0    0    0    0    0    0    0    0    0    0    0    0
*Card 4.2
**ISEC    NCHN  NONO         DXS     IVAR
     1         1    10  3.0000e-01        10
*Card 4.3
**JLEV      VARDX
     2  3.00000e-01
     3  3.00000e-01
     4  3.00000e-01
     5  3.00000e-01
     6  3.00000e-01
     7  3.00000e-01
     8  3.00000e-01
     9  3.00000e-01
    10  3.00000e-01
    11  3.00000e-01
*Card 4.4
**    I   NCHA  KCHA(:)    NCHB  KCHB(:)
      1      0
             0
*Card4.5
**  IWDE
       1
*Card 4.6
**  MSIM
      10
***********************************************************************************************
*GROUP 7 - Grid Loss Coefficient Data
***********************************************************************************************
**NGR
    7
*Card 7.1
**  NCD NGT  IFGQF IFSDRP  IFESPV  IFTPE  IGTEMP  NFBS  NDM9 NDM10 NDM11 NDM12 NDM13 NDM14
      0   0      0      0       0      0       0     0     0     0     0     0     0     0
*Card 7.2
**   CDL    J   CD1   CD2   CD3   CD4   CD5   CD6   CD7   CD8   CD9  CD10  CD11  CD12
***********************************************************************************************
*GROUP 8 - Rod and Unheated Conductor Data
***********************************************************************************************
**NGR
    8
*Card 8.1
** NRRD   NSRD    NC  NRTB  NRAD  NLTY  NSTA   NXF  NCAN  RADF    W3 IHTC  DNBCHK NDM14
      1      0     1     1     0     0     1     1     0     0    -1     1     1     0
*Card 8.2
**    N   IFTY   IAXP   NRND DAXMIN  RMULT         HGAP  ISECR       HTAMB        TAMB  SYMROD  HTCMAP TKEMAP NSUBAX NSUBAZ
*Card 8.3
**NSCH   PIE  NSCH   PIE  NSCH   PIE  NSCH   PIE  NSCH   PIE  NSCH   PIE  NSCH   PIE NSCH   PIE
      1      1      1      0       0  1.000  5.7000e+03      1  0.0000e+00  0.0000e+00    1.000      0      0      1      1
     1 1.000     0 0.000     0 0.000     0 0.000     0 0.000     0 0.000     0 0.000     0 0.000
*Card 8.5
**    N   ISTYP      HPERIM     HPERIMI       RMULS  NOSLCH  NSLCHC       HTAMBS        TAMBS
*Card 8.6
**    I   NRT1   NST1   NRX1
      1      1      0      2
*Card 8.7
**IRTB1  IRTB2  IRTB3  IRTB4  IRTB5  IRTB6  IRTB7  IRTB8  IRTB9 IRTB10 IRTB11 IRTB12
      1
*Card 8.8
**ISTB1  ISTB2  ISTB3  ISTB4  ISTB5  ISTB6  ISTB7  ISTB8  ISTB9 ISTB10 ISTB11 ISTB12
*Card 8.9
**    AXIALT      TRINIT
 0.00000e+00 3.00000e+02
 3.00000e+00 3.00000e+02
***********************************************************************************************
*GROUP 9 - Conductor Geometry Description
***********************************************************************************************
**NGR
    9
*Card 9.1
** NFLT IRLF ICNF IMWR ISWL IDNS IRLG CREEP NDM9 NM10 NM11 NM12 NM13 NM14
      1   -1   -1   -1   -1   -1   -1   -1    0    0    0    0    0    0
*Card 9.2
**  I FTYP       DROD       DFUL  NFUL IMTF IMTC IMOX DCRE        TCLD        FTDS IGPC IGFC IRDP  EPSO
    1 nucl  0.0095000  0.0085000    10    0    0    0    0 2.50000e-04 1.00000e+00    0    0    0   0.0
***********************************************************************************************
*GROUP 10 - Material Properties Tables
***********************************************************************************************
*NGRP
   10
*NMAT NDM2 NDM3 NDM4 NDM5 NDM6 NDM7 NDM8 NDM9 NM10 NM11 NM12 NM13 NM14
     0    0    0    0    0    0    0    0    0    0    0    0    0    0
*
***********************************************************************************************
*GROUP 11 - Core Power Distribution Information
***********************************************************************************************
*NGR group number
   11
**Card 11.1
* NQA  NAXP  MNXN    NQ NGPFF   NQR  NDM7  NDM8  NDM9 NDM10 NDM11 NDM12 NDM13 NDM14
    1     1     2     0     0     1     0     0     0     0     0     0     0     0
**Card 11.2
*           YQA
    0.00000e+00
**Card 11.3
*     I   NAXN
      1      2
**Card 11.4
*             Y         AXIALZ
    0.00000e+00    1.00000e+00
    3.00000e+00    1.00000e+00
**Radial power profile forcing function
**Card 11.7
*          YQR
    0.00000E+00
**Card 11.8
*    FQR1      FQR2      FQR3      FQR4      FQR5      FQR6      FQR7      FQR8
   1.00000
***********************************************************************************************
*GROUP 12 - Turbulent Mixing and Void Drift Data
***********************************************************************************************
**NGR
   12
*Card 12.2
**    AAAK      BETA     THETM
 0.140E+01 3.700e-02 0.500E+01
***********************************************************************************************
*GROUP 13 -  Boundary Condition Data
***********************************************************************************************
*NGR group number
   13
**Card 13.1
* NBND   NKBD NFUN NGBD VBC  NDM6 NDM7 NDM8 NDM9 NM10 NM11 NM12 NM13 NM14
     2      0    0    0  0    0    0    0    0    0    0    0    0    0
*Card 13.2
** NPTS
*Card 13.3
**Card 13.4
* IBD1   IBD2 ISPC N1FN N2FN N3FN     BCVALUE1     BCVALUE2     BCVALUE3 INITGAS
     1      1    2    0    0    0  2.98787e-01  1.00000e+03  0.00000e+00       1
     1     12    1    0    0    0  0.00000e+00  1.00000e+03  1.55000e+02       1
***********************************************************************************************
*GROUP 14 - Output Options
***********************************************************************************************
**NGR
  -14
**               KEY     VALUE
           rod_edits         0
             rod_vtk         0
         native_hdf5         1
           fluid_vtk         1
           dnb_edits         0
          chan_edits         1
                hdf5         0
         convergence         1
           gap_edits         0
end 14
***********************************************************************************************
*GROUP 15 - Time Domain Data
***********************************************************************************************
**NGR
   15
*Card 15.1
**        DTMIN          DTMAX           TEND          EDINT         DMPINT          RTWFP     MAXITS
    1.00000e-06    1.00000e-03     1.0000E-01  0.0000E+00  0.0000E+00     1.000000e+02      10000
***********************************************************************************************
*GROUP 19 - convergence Criteria for Steady State Solve
***********************************************************************************************
**NGR
   19
** Normalized l-infinity of checked solution terms must go below these tolerances for the case
** to be considered steady state.  The code converges if the following is true for each checked
** solution term:
**
**   abs((X-Xn))<=max(rtol*abs(Xn),atol)
**
** In this equation, 'X' is a vector of the checked solution terms from the current checkpoint
** and 'Xn' is the vector of the same solution terms, but from the previous checkpoint.  Checks
** are made every 0.05 seconds in the transient.  The relative tolerances are defined on Card
** 19.1 and the absolute tolerances are defined on Card 19.2.  This check is done for pressure,
** fluid temperature, solid temperature, and the three components of axial velocity.  There is
** also a check on void, but it does not invole the relative check because void is a
** dimensionless value; only the absolute check is done.
**
** The final check involves checking that the mass and energy balance over the system is below
** a tolerance as well.
** Balance of mass ((mass_in-mass_out)/mass_in) and balance of energy ((energy_in-energy_out)/
** energy_in) must go below tolerance values defined on Card 19.3 for case to be considered
** steady state.
*Card 19.1 - relative stopping criteria [unitless]
** LIPRESS   LITCOOL  LITSOLID      LIVL      LIVV      LIVD
 2.000e-03 4.000e-03 4.500e-03 2.500e-03 3.000e-03 3.500e-03
*Card 19.2 - absolute stopping criteria [pressure in psia|bar, velocity in ft/s|m/s,
** and temperature in F|C]
** LIAVOID  LIAPRESS  LIATCOOL LIATSOLID     LIAVL     LIAVV     LIAVD
 1.000e-04 1.000e-04 1.000e-04 1.000e-04 1.000e-04 1.000e-04 1.000e-04
*Card 19.2   [%]
** ENERGYBAL     MASSBAL
   1.000000e-01   1.000000e-01
*Card 19.4   [%]
** L2PRESS   L2TCOOL  L2TSOLID      L2VL      L2VV      L2VD
*Card 19.5 - absolute stopping criteria [pressure in psia|bar, velocity in ft/s|m/s,
 2.000e-04 4.000e-04 4.500e-04 2.500e-04 3.000e-04 3.500e-04
** and temperature in F|C]
** L2AVOID  L2APRESS  L2ATCOOL L2ATSOLID     L2AVL     L2AVV     L2AVD
 1.000e-04 1.000e-04 1.000e-04 1.000e-04 1.000e-04 1.000e-04 1.000e-04
Loading