import gridlabd gridlabd.command( 'model.glm') #change this to model.glm for full model implementation gridlabd.start('wait') quit()
import gridlabd gridlabd.command("test_house.glm") gridlabd.start("wait")
################# #write global file with settings from csv file: HH_global.py import global_functions global_functions.write_global(df_settings.loc[ind], ind, 'none') #re-write glm model for flexible devices - deactivate if no new file needs to be generated import glm_functions glm_functions.modify_model() # includes module and modifies output folders glm_functions.modify_config() #import pdb; pdb.set_trace() ################## # Run GridlabD ################# print('run Gridlabd') #gridlabd.command('IEEE123_BP_2bus_1min.glm') gridlabd.command('model.glm') gridlabd.command('-D') gridlabd.command('suppress_repeat_messages=FALSE') #gridlabd.command('--debug') #gridlabd.command('--verbose') gridlabd.command('--warn') gridlabd.start('wait') # Determine bills and token balances at the end of each month # Year-long balance
import sys assert(sys.version_info.major>2) import gridlabd # construct the command line (gridlabd hasn't started yet) gridlabd.command('example.glm') gridlabd.command('-D') gridlabd.command('suppress_repeat_messages=FALSE') #gridlabd.command('--debug') # start gridlabd and wait for it to complete gridlabd.start('wait') # send the final model state to a file gridlabd.save('done.json');
#!/usr/local/bin/python3 import sys assert(sys.version_info.major>2) import traceback import gridlabd def callstr(argv) : return ("%s(%s)" % (argv[0],",".join(argv[1:]))) for arg in sys.argv[1:] : gridlabd.command(arg) try : rc = (gridlabd.start('wait') & 255 ) if ( rc > 128 & rc < 255 ) : print("%s: signal %d caught" % (callstr(sys.argv),rc&127)) elif rc == 128 : print("%s: unknown signal caught" % callstr(sys.argv)) except: traceback.print_exc() rc = 255 print("%s -> exit %d" % (callstr(sys.argv),rc)) sys.exit(rc)
import gridlabd for i in range(5): print(i) gridlabd.command('pv_calibration.glm') gridlabd.command('-D') gridlabd.command('suppress_repeat_messages=FALSE') gridlabd.command('--warn') gridlabd.start('wait')
"""GridLAB-D Python validation routine This script runs a single gridlabd validate test. Syntax: python3 python_gridlabd.py <gridlabd-command-arguments> Example: host% python3 python_validate.py assert.glm """ import sys, gridlabd # construct the command line (gridlabd hasn't started yet) for cmd in sys.argv[1::]: gridlabd.command(cmd) # start gridlabd and wait for it to complete rc = gridlabd.start('wait') quit(rc)
fw_fixed = open("input/tariff/fixed.tariff", 'w') fw_fixed.write(year + '-01-01 00:00:00,' + fixed_winter) fw_fixed.write('\n' + year + '-05-01 00:00:00,' + fixed_summer) fw_fixed.write('\n' + year + '-11-01 00:00:00,' + fixed_winter) fw_fixed.close() elif tariff_type == 'TOU' or tariff_type == 'tou': if os.path.exists("input/tariff/tou.tariff"): os.remove("input/tariff/tou.tariff") fw_tou = open("input/tariff/tou.tariff", 'w') for s, delta in enumerate(delta_list): for i in range(delta.days + 1): day = '\n' + str(s_list[s] + timedelta(days=i)) if s == 1: #summer fw_tou.write(day + ' 00:00:00,' + str(TOU_summer)) fw_tou.write(day + ' ' + tou_start_s + ':00:00,' + str(TOU_summer * TOU_multiplier)) fw_tou.write(day + ' ' + tou_end_s + ':00:00,' + str(TOU_summer)) else: fw_tou.write(day + ' 00:00:00,' + str(TOU_winter)) fw_tou.write(day + ' ' + tou_start_w + ':00:00,' + str(TOU_winter * TOU_multiplier)) fw_tou.write(day + ' ' + tou_end_w + ':00:00,' + str(TOU_winter)) fw_tou.close() # # RUNNING GRIDLABD gridlabd.command(model_name + '/' + model_name + '.glm') gridlabd.start('wait') quit()
Part 2 generates a plot with the data generated and collected in Part 1. """ import sys assert (sys.version_info.major > 2) import numpy as np import matplotlib.pyplot as plt import gridlabd # # Part 1 - run the simulation # # construct the command line (gridlabd hasn't started yet) gridlabd.command('example.glm') # start gridlabd and wait for it to complete gridlabd.start('wait') # send the final model state to a file gridlabd.save('done.json') # # Part 2 - plot the results # # gather the results collected by on_term t = np.array(gridlabd.result["t"]) t = t - t[0] x = np.array(gridlabd.result["x"])
path = arg elif opt in ("-i", "--ifile"): modelinputfile = arg elif opt in ("-o", "--ofile"): outputfile = arg else: print( "ERROR: Incorrect argument set: python3 [file] -W [path] -i [modelinputfile] -o [outputfile]" ) if path: print("Setting path to folder: ", path) os.chdir(path) else: print("Setting path to current folder") gridlabd.command('--profile') gridlabd.command('--version') gridlabd.command('--relax') if compile_flag == 1: gridlabd.command('-C') gridlabd.command('--redirect') gridlabd.command('all') gridlabd.command(modelinputfile) if outputfile: gridlabd.command('-o') gridlabd.command(outputfile) gridlabd.start('wait') if os.stat('gridlabd.err').st_size == 0: print('No errors in file.') else: sys.stderr.write(
################## #Run GridlabD: DER, fixed price, no market ################# # gridlabd.command('IEEE123_BP_2bus_1min.glm') # gridlabd.command('-D') # gridlabd.command('suppress_repeat_messages=FALSE') # #gridlabd.command('--debug') # #gridlabd.command('--verbose') # gridlabd.command('--warn') # gridlabd.start('wait') ################## #Base case: DER, fixed price, no market ################# # import global_functions # global_functions.write_global(df_settings.loc[34],34,'noip_nomysql') #Some DER # import glm_functions # glm_functions.rewrite_glmfile(rewrite_houses=False,mode='DER_nomarket') ################## #Run GridlabD: DER, fixed price, no market ################# gridlabd.command('IEEE123_BP_2bus_1min.glm') gridlabd.command('-D') gridlabd.command('suppress_repeat_messages=FALSE') #gridlabd.command('--debug') #gridlabd.command('--verbose') gridlabd.command('--warn') gridlabd.start('wait')
import gridlabd import sys, getopt # import traceback import os try : gridlabd.command('--profile') gridlabd.command('--version') # gridlabd.command('--redirect') # gridlabd.command('all') gridlabd.command("virtual_islanding_model.glm") gridlabd.start('wait') print('\n') except Exception as e: sys.stderr.write(f'Unhandled Exception in run_gridlabd_main.py: {e}') sys.stderr.write(traceback.format_exc()) raise e
import gridlabd gridlabd.command('model_google_plymouth.glm') gridlabd.start('wait')
import gridlabd gridlabd.command('model.glm') gridlabd.start('wait')
""" gldcore/link/python/test_memory.py This module runs the 'test_memory.glm' module to verify that all the event handlers work and that there are no memory leaks. """ import sys assert (sys.version_info.major > 2) import gridlabd # construct the command line (gridlabd hasn't started yet) gridlabd.command('test_memory.glm') # start gridlabd and wait for it to complete gridlabd.start('wait') # send the final model state to a file gridlabd.save('done.json')
#meters = requests.get(db_address+'meters').json() #PV data = { 'home_hub_id': user_no, 'meter_id': user_no, 'q_rated': 4000, 'is_active': True } requests.post(db_address + 'pv', json=data, auth=(user_name, pw)) #pvs = requests.get(db_address+'pvs').json() #Meter interval #data = {'meter_id':1,'rate_id':1,'start_time':str(pd.Timestamp(2000,1,1,0,0)),'end_time':str(pd.Timestamp(2000,1,1,0,5)),'e':0.0,'qmtp':0.0,'p_bid':0.0,'q_bid':0,'is_bid':True} #requests.post(db_address+'meter_interval',json=data,auth=(user_name,pw)) #mis = requests.get(db_address+'meter_intervals').json() #Market interval #Get multiple bids #requests.get(db_address+'bids?is_supply=true&start_time=2019-01-01').json() #requests.get(db_address+'bids?is_supply=false&start_time=2019-01-01').json() # Adjust/Re-write # folders # interval (interval for markets should be identical with recorders) #Start simulation gridlabd.command('model_RT.glm') #gridlabd.command('-D') #gridlabd.command('run_realtime=TRUE') # CHECK - locks in clock with real-time
import sys assert (sys.version_info.major > 2) import gridlabd import time import pandas #import pdb; pdb.set_trace() ###USER input ind = 1 df_settings = pandas.read_csv('settings_final2.csv', index_col=[0]) ################## #Assemble correct glm files ################# #write global file with settings from csv file: HH_global.py #import global_functions #global_functions.write_global(df_settings.loc[ind],ind,'none') #re-write glm model for flexible devices - deactivate if no new file needs to be generated #import glm_functions #glm_functions.rewrite_glmfile(rewrite_houses=False) #Re-populates houses ################## #Run GridlabD ################# gridlabd.command('validate_thermal.glm') gridlabd.command('-D') gridlabd.command('suppress_repeat_messages=FALSE') #gridlabd.command('--debug') #gridlabd.command('--verbose') gridlabd.command('--warn') gridlabd.start('wait')