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

Add ability to write VUQ files from SubKit

Description:
Adds blocks to the input schema for vuq_mult and vuq_param inputs.
The names are the same as in the CTF input file.
Modified an existing test to add all supported multipliers/parameters.
Also fix the documentation published to Readthedocs.

CASL Ticket # - N/A
parent 5d1a2458
Loading
Loading
Loading
Loading

.readthedocs.yml

0 → 100644
+24 −0
Original line number Diff line number Diff line
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
  configuration: doc/conf.py

# Build documentation with MkDocs
#mkdocs:
#  configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
##formats:
##  - pdf

# Optionally set the version of Python and requirements required to build your docs
python:
  version: 2.7
  install:
    - requirements: requirements.txt
+10 −0
Original line number Diff line number Diff line
@@ -118,6 +118,16 @@ class InpBuilder(object):
                me.model.addRodsToDomain(domain=domainID, rods=me.inp.getParallelDomainSolids(domainID), owners=me.inp.getParallelDomainSolidOwners(domainID))
                me.model.addChannelsToDomain(domain=domainID, channels=me.inp.getParallelDomainChannels(domainID))

        #VUQ input
        vuq_mult = me.inp.getVUQMultDict()
        if vuq_mult:
           for key in vuq_mult.keys():
              me.model.addVUQMult(key, vuq_mult[key])
        vuq_param = me.inp.getVUQParamDict()
        if vuq_param:
           for key in vuq_param.keys():
              me.model.addVUQParam(key, vuq_param[key])

        me.model.setAveragePower(qprime = me.inp.getInitialQprime())
        me.model.generateModel(me.getOutputFilename())

+24 −0
Original line number Diff line number Diff line
@@ -748,3 +748,27 @@ class InpParse(object):
            return domain['chans']['value']
        else:
            return InputError("Domain->"+str(domainID)+"->ch not defined")

    def _processDict(me, raw):
        """ Processes the dictionary read off of the input file so it is in key/value form"""
        processed = {}
        for key in raw.keys():
           processed[key] = raw[key]['value']
        return processed

    def getVUQMultDict(me):
        """ Returns a dictionary of VUQ multipliers for the model """
        vuq = me.inpDict.get('vuq')
        if vuq:
           raw = vuq.get('mult')
           if raw:
              return me._processDict(raw)

    def getVUQParamDict(me):
        """ Returns a dictionary of VUQ parameters for the model """
        vuq = me.inpDict.get('vuq')
        if vuq:
           raw = vuq.get('param')
           if raw:
              return me._processDict(raw)
+32 −0
Original line number Diff line number Diff line
@@ -139,6 +139,12 @@ class Model:
      me.setInitialConditionsCalled = False
      me.setInitialConditionsMassFluxCalled = False

      # Takes a VUQ multiplier/adder name and returns its value
      me.vuq_mult = {}

      # Takes a VUQ parameter name and returns its value
      me.vuq_param = {}

      # Single-phase turbulent mixing coefficient
      me.beta = 0.037

@@ -191,6 +197,32 @@ class Model:
      assert(fluidprops in validEntries)
      me.fluidProperties = fluidprops

   def addVUQMult(me, name, value):
      """ Adds a VUQ multiplier/adder to apply to this model

      Valid names can be found in the SubKit input documentation.  If the multiplier/adder has already
      been added, its existing value will be overwritten.

      Args:
         name (string): The name of the multiplier/adder
         value (float): The value of the multiplier/adder
      """
      assert isinstance(value, float)
      me.vuq_mult[name] = value

   def addVUQParam(me, name, value):
      """ Adds a VUQ parameter to apply to this model

      Valid names can be found in the SubKit input documentation.  If the parameter has already
      been added, its existing value will be overwritten.

      Args:
         name (string): The name of the parameter
         value (float): The value of the parameter
      """
      assert isinstance(value, float)
      me.vuq_param[name] = value

   def setInitialConditions(me, mdotInit, tempInit, pressureInit):
      """Set model initial conditions.

+12 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ class keyMap:
def writeDeck(model, filename):
   """ Creates a CTF input file

   Will also write the vuq_mult.txt and vuq_param.txt files if necessary.

   Args:
      model (Model): The subchannel model object that describes the model
      filename (str): The name to be given to the input file
@@ -819,6 +821,16 @@ def writeDeck(model, filename):
      outFile.write(l)
   outFile.close()

   if len(model.vuq_mult)>0:
      with open('vuq_mult.txt', 'w') as vuq:
         for key in model.vuq_mult.keys():
            vuq.write('{:s} = {:e}\n'.format(key, model.vuq_mult[key]))

   if len(model.vuq_param)>0:
      with open('vuq_param.txt', 'w') as vuq:
         for key in model.vuq_param.keys():
            vuq.write('{:s} = {:e}\n'.format(key, model.vuq_param[key]))

class test_genDeck(unittest.TestCase):
   def test_keyMap(me):
      keys = ['one', 'two', 7, -1, 2.2]
Loading