Skip to content

Commit

Permalink
update modelchains to run with frames and omegas; change cellLevelMod…
Browse files Browse the repository at this point in the history
…uleParamsDict to cellModuleDict in load.py
  • Loading branch information
cdeline committed Sep 25, 2024
1 parent a2b76d9 commit 9db0930
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 28 deletions.
60 changes: 37 additions & 23 deletions bifacial_radiance/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def boolConvert(d):

if simulationParamsDict['selectTimes']:
if config.has_section("timeControlParamsDict"):
timeControlParamsDict = boolConvert(confdict['timeControlParamsDict'])
timeControlParamsDict = confdict['timeControlParamsDict']

if simulationParamsDict['getEPW']:
try:
Expand Down Expand Up @@ -588,16 +588,16 @@ def boolConvert(d):
moduleParamsDict['glassEdge'] = moduleParamsDict2['glassEdge']
if simulationParamsDict['cellLevelModule']:
if config.has_section("cellLevelModuleParamsDict"):
cellLevelModuleParamsDict = confdict['cellLevelModuleParamsDict']
cellModuleDict = confdict['cellLevelModuleParamsDict']
try: # being lazy so just validating the whole dictionary as a whole. #TODO: validate individually maybe.
cellLevelModuleParamsDict['numcellsx'] = int(cellLevelModuleParamsDict['numcellsx'])
cellLevelModuleParamsDict['numcellsy'] = int(cellLevelModuleParamsDict['numcellsy'])
cellLevelModuleParamsDict['xcell'] = round(float(cellLevelModuleParamsDict['xcell']),3)
cellLevelModuleParamsDict['xcellgap'] = round(float(cellLevelModuleParamsDict['xcellgap']),3)
cellLevelModuleParamsDict['ycell'] = round(float(cellLevelModuleParamsDict['ycell']),3)
cellLevelModuleParamsDict['ycellgap'] = round(float(cellLevelModuleParamsDict['ycellgap']),3)
if 'centerJB' in cellLevelModuleParamsDict:
cellLevelModuleParamsDict['centerJB'] = round(float(cellLevelModuleParamsDict['centerJB']),3)
cellModuleDict['numcellsx'] = int(cellModuleDict['numcellsx'])
cellModuleDict['numcellsy'] = int(cellModuleDict['numcellsy'])
cellModuleDict['xcell'] = round(float(cellModuleDict['xcell']),3)
cellModuleDict['xcellgap'] = round(float(cellModuleDict['xcellgap']),3)
cellModuleDict['ycell'] = round(float(cellModuleDict['ycell']),3)
cellModuleDict['ycellgap'] = round(float(cellModuleDict['ycellgap']),3)
if 'centerJB' in cellModuleDict:
cellModuleDict['centerJB'] = round(float(cellModuleDict['centerJB']),3)
except:
print("Load Warning: celllevelModule set to True,",\
"but celllevelModule parameters are missing/not numbers.")
Expand All @@ -612,12 +612,12 @@ def boolConvert(d):
except:
print("Attempted to load x and y instead of celllevelModule parameters,",\
"Failed, so default values for cellLevelModule will be passed")
cellLevelModuleParamsDict['numcellsx'] = 12
cellLevelModuleParamsDict['numcellsy'] = 6
cellLevelModuleParamsDict['xcell'] = 0.15
cellLevelModuleParamsDict['xcellgap'] = 0.1
cellLevelModuleParamsDict['ycell'] = 0.15
cellLevelModuleParamsDict['ycellgap'] = 0.1
cellModuleDict['numcellsx'] = 12
cellModuleDict['numcellsy'] = 6
cellModuleDict['xcell'] = 0.15
cellModuleDict['xcellgap'] = 0.1
cellModuleDict['ycell'] = 0.15
cellModuleDict['ycellgap'] = 0.1
else: # no cellleveldictionary passed
print("Load Warning: celllevelmodule selected, but no dictionary was passed in input file.",\
"attempting to proceed with regular custom module and setting celllevelmodule to false")
Expand Down Expand Up @@ -783,15 +783,21 @@ def boolConvert(d):
try: analysisParamsDict
except: analysisParamsDict = None

try: cellLevelModuleParamsDict
except: cellLevelModuleParamsDict = None
try: cellModuleDict
except: cellModuleDict = None

#returnParams = Params(simulationParamsDict, sceneParamsDict, timeControlParamsDict, moduleParamsDict, trackingParamsDict, torquetubeParamsDict, analysisParamsDict, cellLevelModuleParamsDict)
#returnParams = Params(simulationParamsDict, sceneParamsDict, timeControlParamsDict, moduleParamsDict, trackingParamsDict, torquetubeParamsDict, analysisParamsDict, cellModuleDict)
#return returnParams
return simulationParamsDict, sceneParamsDict, timeControlParamsDict, moduleParamsDict, trackingParamsDict, torquetubeParamsDict, analysisParamsDict, cellLevelModuleParamsDict, frameParamsDict, omegaParamsDict
return (simulationParamsDict, sceneParamsDict, timeControlParamsDict,
moduleParamsDict, trackingParamsDict, torquetubeParamsDict,
analysisParamsDict, cellModuleDict, frameParamsDict, omegaParamsDict)


def savedictionariestoConfigurationIniFile(simulationParamsDict, sceneParamsDict, timeControlParamsDict=None, moduleParamsDict=None, trackingParamsDict=None, torquetubeParamsDict=None, analysisParamsDict=None, cellLevelModuleParamsDict=None, inifilename=None):
def savedictionariestoConfigurationIniFile(simulationParamsDict, sceneParamsDict,
timeControlParamsDict=None, moduleParamsDict=None,
trackingParamsDict=None, torquetubeParamsDict=None,
analysisParamsDict=None, cellModuleDict=None,
frameParamsDict=None, omegaParamsDict=None, inifilename=None):
"""
Saves dictionaries from working memory into a Configuration File
with extension format .ini.
Expand All @@ -810,7 +816,7 @@ def savedictionariestoConfigurationIniFile(simulationParamsDict, sceneParamsDict
Default None
analysisParamsDict
Default None,
cellLevelModuleParamsDict
cellModuleDict
Default None
Returns
Expand Down Expand Up @@ -841,9 +847,17 @@ def savedictionariestoConfigurationIniFile(simulationParamsDict, sceneParamsDict
try: config['analysisParamsDict'] = analysisParamsDict
except: pass

try: config['cellLevelModuleParamsDict'] = cellLevelModuleParamsDict
try: config['cellLevelModuleParamsDict'] = cellModuleDict
except: pass

if frameParamsDict:
try: config['frameParamsDict'] = frameParamsDict
except: pass

if omegaParamsDict:
try: config['omegaParamsDict'] = omegaParamsDict
except: pass

if inifilename is None:
inifilename = 'example.ini'

Expand Down
15 changes: 10 additions & 5 deletions bifacial_radiance/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def _append_dicts(x, y):

def runModelChain(simulationParamsDict, sceneParamsDict, timeControlParamsDict=None,
moduleParamsDict=None, trackingParamsDict=None, torquetubeParamsDict=None,
analysisParamsDict=None, cellModuleDict=None):
analysisParamsDict=None, cellModuleDict=None, frameParamsDict=None,
omegaParamsDict=None):
"""
This calls config.py values, which are arranged into dictionaries,
and runs all the respective processes based on the variables in the config.py.
Expand Down Expand Up @@ -55,16 +56,19 @@ def runModelChain(simulationParamsDict, sceneParamsDict, timeControlParamsDict=N
demo = bifacial_radiance.RadianceObj(
simulationParamsDict['simulationname'], path=testfolder) # Create a RadianceObj 'object'


# Save INIFILE in folder
inifilename = os.path.join(
simulationParamsDict['testfolder'], 'simulation.ini')
bifacial_radiance.load.savedictionariestoConfigurationIniFile(simulationParamsDict, sceneParamsDict, timeControlParamsDict,
moduleParamsDict, trackingParamsDict, torquetubeParamsDict, analysisParamsDict, cellModuleDict, inifilename)
moduleParamsDict, trackingParamsDict, torquetubeParamsDict,
analysisParamsDict, cellModuleDict, frameParamsDict, omegaParamsDict,
inifilename)

# re-load configuration file to make sure all booleans are converted
(simulationParamsDict, sceneParamsDict, timeControlParamsDict,
moduleParamsDict, trackingParamsDict,torquetubeParamsDict,
analysisParamsDict,cellModuleDict) = \
analysisParamsDict, cellModuleDict, frameParamsDict, omegaParamsDict) = \
bifacial_radiance.load.readconfigurationinputfile(inifilename)

# Load weatherfile
Expand Down Expand Up @@ -121,14 +125,15 @@ def runModelChain(simulationParamsDict, sceneParamsDict, timeControlParamsDict=N

module = demo.makeModule(name=simulationParamsDict['moduletype'],
tubeParams=torquetubeParamsDict,
cellModule=cellModule, **kwargs)
cellModule=cellModule, **kwargs)

print("\nUsing Pre-determined Module Type: %s " %
simulationParamsDict['moduletype'])
else:
module = demo.makeModule(name=simulationParamsDict['moduletype'],
tubeParams=torquetubeParamsDict,
cellModule=cellModule, **kwargs)
cellModule=cellModule, frameParams=frameParamsDict,
omegaParams=omegaParamsDict, **kwargs)


if 'gcr' not in sceneParamsDict: # didn't get gcr passed - need to calculate it
Expand Down

0 comments on commit 9db0930

Please sign in to comment.