Пример #1
0
def autocreate_model(basexml, weather, randomxml='random.xml', schedule=None):
    randompath = os.path.split(os.path.abspath(randomxml))[0]
    found = False
    while not found:
        random_model(basexml, randomxml)
        randomxmlstr = None
        with open(randomxml) as randomxmlfile:
            randomxmlstr = randomxmlfile.read()
        idf = idfxml.xml_to_idf(randomxmlstr)
        idfname = '{}.idf'.format(randomxml)
        with open(idfname, 'w') as idffile:
            idffile.write(str(idf))
        if schedule is not None:
            schedule = [(schedule, os.split(schedule)[1])]
        runner = eplus.EnergyPlus()
        results = runner.run(idfname, weather, 
                             supplemental_files=schedule, 
                             working_directory=randompath)
        if results is not None:
            found = True
            try:
                os.remove(idfname)
            except:
                pass
            return results
Пример #2
0
def autocreate_model(basexml, weather, randomxml='random.xml', schedule=None):
    randompath = os.path.split(os.path.abspath(randomxml))[0]
    found = False
    while not found:
        random_model(basexml, randomxml)
        randomxmlstr = None
        with open(randomxml) as randomxmlfile:
            randomxmlstr = randomxmlfile.read()
        idf = idfxml.xml_to_idf(randomxmlstr)
        idfname = '{}.idf'.format(randomxml)
        with open(idfname, 'w') as idffile:
            idffile.write(str(idf))
        if schedule is not None:
            schedule = [(schedule, os.split(schedule)[1])]
        runner = eplus.EnergyPlus()
        results = runner.run(idfname,
                             weather,
                             supplemental_files=schedule,
                             working_directory=randompath)
        if results is not None:
            found = True
            try:
                os.remove(idfname)
            except:
                pass
            return results
Пример #3
0
def random_model(basexml, randomxml):
    basexmlstr = None
    with open(basexml) as basexmlfile:
        basexmlstr = basexmlfile.read()
    varset = idfxml.xml_to_variables(basexmlstr)
    candidate = eplus.EPlusCandidate(varset)
    randcand = candidate.permutation()
    baseidf = idfxml.xml_to_idf(basexmlstr)
    randidf = randcand.values_to_idf(baseidf)
    randomxmlstr = idfxml.idf_to_xml(randidf)
    randomxmlstr = idfxml.variables_to_xml(varset, randomxmlstr)
    with open(randomxml, 'w') as randfile:
        randfile.write(randomxmlstr)
Пример #4
0
def random_model(basexml, randomxml):
    basexmlstr = None
    with open(basexml) as basexmlfile:
        basexmlstr = basexmlfile.read()
    varset = idfxml.xml_to_variables(basexmlstr)
    candidate = eplus.EPlusCandidate(varset)
    randcand = candidate.permutation()
    baseidf = idfxml.xml_to_idf(basexmlstr)
    randidf = randcand.values_to_idf(baseidf)
    randomxmlstr = idfxml.idf_to_xml(randidf)
    randomxmlstr = idfxml.variables_to_xml(varset, randomxmlstr)
    with open(randomxml, 'w') as randfile:
        randfile.write(randomxmlstr)