Ejemplo n.º 1
0
    def printConnections(self, fd=sys.stdout):
        #
        # Sort the keys
        #
        v = pObject()
        retstr = pObject.getXMLpreamble(
            v,
            "RECURRENT",
            xslsheet='/peasd/ssd/husainkb/template/recurrent.xsl')

        skeys = self.allDates.keys()
        skeys.sort()
        for sk in skeys:
            dte = self.allDates[sk]
            retstr += '<DATE value="%s">\n' % dte.getDate()
            retstr += dte.getXMLcontent()
            for collectionType in dte.collections.keys():
                retstr += '<COLLECTION type="%s" >\n' % collectionType
                collection = dte.collections[collectionType]
                for ck in collection.keys():
                    retstr += '<%s name="%s">\n' % (collectionType, ck)
                    items = collection[ck]
                    items.sort()
                    for item in items:
                        retstr += '<item type="%s" name="%s"/>\n' % (
                            collectionType, item)
                    retstr += '</%s>\n' % collectionType
                retstr += '</COLLECTION>\n'
            retstr += "</DATE>\n"

        retstr += pObject.getXMLpostamble(v, "RECURRENT")
        fd.write(retstr)
Ejemplo n.º 2
0
    def writeXMLFiles(self, modelname, xmldir):
        """
		modelname cannot have extensions, etc. I will add them myself.
		"""
        if xmldir == None: return
        if not os.path.isdir(xmldir):
            try:
                os.mkdir(xmldir)
            except:
                print "Exception ..."
                return

        # print self.m_internalBlocks.keys()
        # useThese = ['PVT-WATER', 'SAT-OIL-WATER', 'COMPARATOR', 'SIMULATOR', \
        # 'LGRPARMS', 'FLOW', 'SAT-GAS-OIL', 'GRID', 'MIGRATION', 'PVT-OIL',
        # 'PVT-GAS', 'ROCKFLUID', 'EQUILIBRIUM']
        # use These  'COMPARATOR' ??

        co = pObject()
        retstr = co.getXMLpreamble('MASTER', xmldir, 'master.xsl')
        retstr += '<MODULES>\n'

        useThese = ['LGRPARMS','GRID', 'SECTOR_EXTRACT', 'PVT-WATER','PVT-GAS','PVT-OIL', 'SAT-GAS-OIL','SAT-OIL-WATER',\
         'SIMULATOR','ROCKFLUID','FLOW', 'MIGRATION', 'EQUILIBRIUM']

        useThese.sort()
        for nm in useThese:
            fname = xmldir + os.sep + nm.lower() + '.xml'
            print "Creating ...", fname
            fd = open(fname, 'w')
            blk = self.m_internalBlocks[nm]
            blk.writeXMLfile(fd, nm, xmldir)
            fd.close()
            retstr += '<REFERENCE name="%s" file="%s" />\n' % (nm, fname)
        retstr += '</MODULES>\n'
        retstr += co.getXMLpostamble('MASTER')

        if modelname[0] <> '/':
            mastername = xmldir + os.sep + modelname + '.model.xml'
        else:
            mname = os.path.basename(modelname)
            mastername = xmldir + os.sep + mname + '.xml'
        fd = open(mastername, 'w')
        fd.write(retstr)
        fd.close()
Ejemplo n.º 3
0
    def __init__(self, useTheseDates=None):
        cParserObject.__init__(self)
        self.filename = None
        self.fd = None
        self.resword = Str("group", "injector", "producer")
        self.keywords = {}
        self.collectionType = ''
        self.collectionName = ''
        self.collectionOption = ''

        ##################################### LEX ######################################
        self.lexicon = Lexicon([(name, 'ident'), (number, 'number'),
                                (math, TEXT), (eob, TEXT), (name, TEXT),
                                (self.resword, 'Kamran'), (closebrace, TEXT),
                                (openbrace, TEXT), (closelist, TEXT),
                                (openlist, TEXT), (space | quote, IGNORE),
                                (comment_begin, Begin('comment')),
                                State('comment', [(comment_char, IGNORE),
                                                  (comment_end, Begin(''))])])

        self.ST_IDLE = 0
        self.ST_IN_DATE = 1
        self.ST_IN_PSEUDO = 2
        self.ST_IN_WELLS = 3
        self.ST_IN_CONNECTIONS = 4
        self.ST_IN_GROUPRULES = 5
        self.ST_ONEWELL = 6
        self.ST_PERFS = 7
        self.ST_IN_GROUP = 8
        self.ST_IN_PRODUCER = 9
        self.ST_IN_INJECTOR = 10

        self.lastWell = None
        self.lastDate = None
        self.state = self.ST_IDLE
        self.previousState = self.state
        self.lastToken = ''

        self.userDates = {}  # Always do this.
        self.allDates = {}  #
        if useTheseDates <> None:
            self.allDates = useTheseDates
            self.userDates = useTheseDates
        #
        # The keywordHolder object is used to store the keywords which are at a global level
        #
        self.keywordHolder = pObject()
        self.keywordHolder.addKeyword('DT_MIN', '0.0001')
        self.keywordHolder.addKeyword('DT_MAX', '1.0 91.0')  #
        self.keywordHolder.addKeyword('DT_INIT', '0.00001')  #
        self.keywordHolder.addKeyword('END_OF_SIMULATION_DATE', 'None')  #
        self.keywordHolder.addKeyword('FRACTURE_MAX_DS_ITER', '0.3')  #
        self.keywordHolder.addKeyword('GAS_RESIDUAL_RELTOL', '0.01')  #
        self.keywordHolder.addKeyword('HYDROCARBON_RESIDUAL_RELTOL', '0.01')  #
        self.keywordHolder.addKeyword('LINEAR_MAXIMUM_ITERATIONS', '120')  #
        self.keywordHolder.addKeyword('LINEAR_SOLUTION_OPTION', 'ORTHOMIN',
                                      ('ORTHOMIN', 'REDUCED_SYSTEM_SERIES'))  #
        self.keywordHolder.addKeyword('LINEAR_TOLERANCE', '0.05')  #
        self.keywordHolder.addKeyword('MAX_DBPP_ITER', '100')  #
        self.keywordHolder.addKeyword('MAX_DBPP_TOL', '100')  #
        self.keywordHolder.addKeyword('MAX_DP_TIMESTEP', '2000.0')  #
        self.keywordHolder.addKeyword('MAX_DP_ITER', '100')  #
        self.keywordHolder.addKeyword('MAX_DP_TOL', '0.50')  #
        self.keywordHolder.addKeyword('MAX_DS_ITER', '0.15')  #
        self.keywordHolder.addKeyword('MAX_DS_TOL', '0.005')  #
        self.keywordHolder.addKeyword('MAX_DS_TIMESTEP', '0.1')  #
        self.keywordHolder.addKeyword('MAX_DT_INCREASE_FACTOR', '5.0')  #
        self.keywordHolder.addKeyword('MAX_TIMESTEP', '2000')  #
        self.keywordHolder.addKeyword('MAX_TIMESTEP_REPEAT', '2000')  #
        self.keywordHolder.addKeyword('MATBAL_OUTPUT', 'FREQ 1 MONTH')
        self.keywordHolder.addKeyword('MATRIX_SCALE_OPTION', 'TRUE',
                                      ('TRUE', 'FALSE'))
        self.keywordHolder.addKeyword('MAX_MGRID_ITERATIONS', '0.1')  #
        self.keywordHolder.addKeyword('MIN_PORE_VOL_TIMESTEP', '700.0')  #
        self.keywordHolder.addKeyword('NON_LINEAR_MAXIMUM_ITERATIONS', '6')  #
        self.keywordHolder.addKeyword('NON_LINEAR_MINIMUM_ITERATIONS', '5')  #
        self.keywordHolder.addKeyword('NON_LINEAR_TOLERANCE', '.0001')  #
        self.keywordHolder.addKeyword('NUM_OF_ORTHOGONAL_DIRECTIONS', '10')  #
        self.keywordHolder.addKeyword('OIL_RESIDUAL_RELTOL', '1.E-2')  #
        self.keywordHolder.addKeyword('PRE_CONDITIONER_OPTION',
                                      'RED_BLACK_Z_LINE')
        self.keywordHolder.addKeyword('START_OF_SIMULATION_DATE', 'None')
        self.keywordHolder.addKeyword('RESTART_OUTPUT', 'FREQ   1 MONTH')
        self.keywordHolder.addKeyword('WELL_OUTPUT', 'FREQ 1 MONTH')
        self.keywordHolder.addKeyword('WATER_RESIDUAL_RELTOL', '1.E-2')
        self.aAllowedKeywords = self.keywordHolder.aKeywords.keys()

        self.multipleValueList = {}
        self.multipleValueList['MAPS_OUTPUT'] = 3
        self.multipleValueList['MATBAL_OUTPUT'] = 3
        self.multipleValueList['RESTART_OUTPUT'] = 3
        self.multipleValueList['START_OF_PREDICTION'] = 0

        self.collections = {
            'GROUP': self.ST_IN_GROUP,
            'PRODUCER': self.ST_IN_PRODUCER,
            'INJECTOR': self.ST_IN_INJECTOR
        }
Ejemplo n.º 4
0
    def printXMLoutput(self, fd=sys.stdout):
        #
        # Sort the keys
        #
        v = pObject()
        retstr = pObject.getXMLpreamble(
            v,
            "RECURRENT",
            xslsheet='/peasd/ssd/husainkb/template/recurrent.xsl')

        skeys = self.allDates.keys()
        skeys.sort()
        for sk in skeys:
            dte = self.allDates[sk]
            dte.setParentage()
            retstr += '<DATE value="%s">\n' % dte.getDate()
            retstr += dte.getXMLcontent()

            for ck in dte.pseudoItems.keys():
                pseudo = dte.pseudoItems[ck]
                retstr += '<PSEUDO name="%s">\n' % (ck)  # Start GROUP node
                retstr += pseudo.getXMLcontent()
                retstr += '</PSEUDO>\n'

            for ck in dte.Wells.keys():
                w = dte.Wells[ck]
                nm = w.getWellName()
                retstr += '<WELL name="%s">\n' % (nm)  # Start GROUP node
                retstr += w.getXMLcontent()
                retstr += '</WELL>\n'

            #
            # First get the groups in this date.
            #
            grpNames = dte.getCollectionNames('GROUP')
            injNames = dte.getCollectionNames('INJECTOR')
            proNames = dte.getCollectionNames('PRODUCER')
            groups = dte.collections['GROUP']
            for ck in groups.keys():
                pname = dte.parentage.get(ck, '')
                retstr += '<GROUP name="%s" parent="%s">\n' % (
                    ck, pname)  # Start GROUP node
                items = groups[ck]
                for k in items:  # For each item in the list of sub
                    if k in grpNames:  # If item is a group, mark it such.
                        retstr += '<item type="GROUP" name="%s"/>\n' % (k)
                    elif k in injNames:  # If item is a group, mark it such.
                        retstr += '<item type="INJECTOR" name="%s"/>\n' % (k)
                    elif k in proNames:  # If item is a group, mark it such.
                        retstr += '<item type="PRODUCER" name="%s"/>\n' % (k)
                retstr += '</GROUP>\n'

            for subName in dte.collections.keys():
                if subName == 'GROUP':
                    continue  # Since you have done that above.
                inj = dte.collections[subName]  # Get the list of injectors
                for ck in inj.keys():
                    pname = dte.parentage.get(ck, '')
                    retstr += '<%s name="%s" parent="%s">\n' % (
                        subName, ck, pname)  # Start GROUP node
                    items = inj[ck]
                    for k in items:  # For each item in the list of sub
                        pname = dte.parentage.get(k, '')
                        retstr += '<WELL parent="%s" name="%s"/>\n' % (pname,
                                                                       k)
                    retstr += '</%s>\n' % subName

            retstr += "</DATE>\n"
        retstr += pObject.getXMLpostamble(v, "RECURRENT")
        fd.write(retstr)