0, 0, 0, 0, 0, 0, 0, 0.6625, 0.9625, 1, 1, 1, 1, 1, 0.6125, 0.4, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0.2, 0.9125, 1, 1, 1, 1, 1, 0.7375, 0.2125, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0.0625, 0.7, 1, 1, 1, 0.9375, 0.8, 0.7, 0.1875, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0.45, 0.95, 1, 1, 0.8125, 0.3625, 0.3625, 0.375, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0.0125, 0.525, 0.95, 1, 0.9875, 0.75, 0.175, 0.2125, 0.275, 0, 0, 0, 0, 0, 0, 0, 0 ]]) # run PV system simulation mod = ssc.module_create("pvwattsv1") ssc.module_exec(mod, dat) # print results ann = 0 ac = ssc.data_get_array(dat, "ac") for i in range(len(ac)): ac[i] = ac[i] / 1000 ann += ac[i] print "PVWatts V1 Simulation ok, e_net (annual kW)=", ann
ssc.data_set_number(dat, 'fd', 1.0) ssc.data_set_number(dat, 'i_ref', 1000) ssc.data_set_number(dat, 'poa_cutin', 0) ssc.data_set_number(dat, 'w_stow', 0) # complicated optional inputs # ssc.data_set_array(dat, 'shading_hourly', ...) Hourly beam shading factors # ssc.data_set_matrix(dat, 'shading_mxh', ...) Month x Hour beam shading factors # ssc.data_set_matrix(dat, 'shading_azal', ...) Azimuth x altitude beam shading factors # ssc.data_set_number(dat, 'shading_diff', ...) Diffuse shading factor # ssc.data_set_number(dat, 'enable_user_poa', ...) Enable user-defined POA irradiance input = 0 or 1 # ssc.data_set_array(dat, 'user_poa', ...) User-defined POA irradiance in W/m2 # run PV system simulation mod = ssc.module_create("pvwattsv1") ssc.module_exec(mod, dat) # OLD print results # ac = ssc.data_get_array(dat, "ac") # ann = sum([x/1000 for x in ac]) # print "PVWatts V1 Simulation ok, e_net (annual kW)=", ann # Extract data. # Geodata. city = ssc.data_get_string(dat, 'city') state = ssc.data_get_string(dat, 'state') lat = ssc.data_get_number(dat, 'lat') lon = ssc.data_get_number(dat, 'lon') elev = ssc.data_get_number(dat, 'elev') # Weather irrad = ssc.data_get_array(dat, 'dn')
def sam_simulation(nsrdb_data, meta=None, verbose=False, **kwargs): """SAM solar PV simulation Perform a PVWATTS5 simulation using some input information about the solar plant. Parameters ---------- weather (pd.DataFrame): Solar radiation dataframe meta (pd.DataFrame): NSRDB metadata kwargs (dictionary): Dictionary containing simulation parameters Returns ---------- CF (float): Capacity factor Generation (float): Generation over the year of simulation meto_data (pd.DataFrame): Dataframe with hourly generation """ params = { "lat": kwargs["lat"], "lng": kwargs["lon"], "system_capacity": kwargs["system_capacity"], "dc_ac_ratio": kwargs["dc_ac_ratio"], "inv_eff": kwargs["inv_eff"], "losses": kwargs["losses"], "tilt": kwargs["tilt"], "gcr": kwargs["gcr"], "azimuth": kwargs["azimuth"], "interval": kwargs["interval"], } if verbose: print({key: value for key, value in params.items()}) # Start sscapi module ssc = PySSC() weather_data = ssc.data_create() valid_keys = [ "lat", "lon", "tz", "elev", ] for key, value in kwargs.items(): bytestr = key.encode() # Convert string to byte to read it on C if key in valid_keys: ssc.data_set_number(weather_data, bytestr, value) # Set tilt of system in degrees ssc.data_set_array(weather_data, b"year", nsrdb_data.index.year) ssc.data_set_array(weather_data, b"month", nsrdb_data.index.month) ssc.data_set_array(weather_data, b"day", nsrdb_data.index.day) ssc.data_set_array(weather_data, b"hour", nsrdb_data.index.hour) ssc.data_set_array(weather_data, b"minute", nsrdb_data.index.minute) ssc.data_set_array(weather_data, b"dn", nsrdb_data["DNI"]) ssc.data_set_array(weather_data, b"df", nsrdb_data["DHI"]) ssc.data_set_array(weather_data, b"wspd", nsrdb_data["Wind Speed"]) ssc.data_set_array(weather_data, b"tdry", nsrdb_data["Temperature"]) # Create SAM compliant object sam_data = ssc.data_create() ssc.data_set_table(sam_data, b"solar_resource_data", weather_data) ssc.data_free(weather_data) valid_keys = [ "system_capacity", # kW "dc_ac_ratio", "array_type", "inv_eff", "losses", "gcr", "tilt", "azimuth", "interval", "adjust:constant", ] for key, value in kwargs.items(): bytestr = key.encode() # Convert string to byte to read it on C if key in valid_keys: ssc.data_set_number(sam_data, bytestr, value) if kwargs["model"] == "pvwattsv7" and "module_type" in kwargs: ssc.data_set_number(sam_data, b"module_type", kwargs.get("module_type", 0)) mod = ssc.module_create(kwargs.get("model").encode()) ssc.module_exec(mod, sam_data) nsrdb_data["ac_generation_W"] = np.array( ssc.data_get_array(sam_data, b"ac")) nsrdb_data["dc_generation_W"] = np.array( ssc.data_get_array(sam_data, b"dc")) nsrdb_data["dc_capacity_factor"] = (nsrdb_data["dc_generation_W"] * 1e3) / kwargs["system_capacity"] nsrdb_data["POA"] = np.array(ssc.data_get_array(sam_data, b"poa")) # Module temperature in ºC nsrdb_data["TCell"] = np.array(ssc.data_get_array(sam_data, b"tcell")) # free the memory ssc.data_free(sam_data) ssc.module_free(mod) return nsrdb_data
ssc.data_set_number(dat, 'inverter_model', 1) ssc.data_set_number(dat, 'inv_snl_c0', inv_snl_c0) ssc.data_set_number(dat, 'inv_snl_c1', inv_snl_c1) ssc.data_set_number(dat, 'inv_snl_c2', inv_snl_c2) ssc.data_set_number(dat, 'inv_snl_c3', inv_snl_c3) ssc.data_set_number(dat, 'inv_snl_paco', inv_snl_paco) ssc.data_set_number(dat, 'inv_snl_pdco', inv_snl_pdco) ssc.data_set_number(dat, 'inv_snl_pnt', inv_snl_pnt) ssc.data_set_number(dat, 'inv_snl_pso', inv_snl_pso) ssc.data_set_number(dat, 'inv_snl_vdco', inv_snl_vdco) ssc.data_set_number(dat, 'inv_snl_vdcmax', inv_snl_vdcmax) # all variables have been set up for pvsamv1. Run! mod = ssc.module_create('pvsamv1') returnStatus = ssc.module_exec(mod, dat) # process results # if ssc.module_exec(mod, dat) == 0: # print "pvsamv1 simulation error" # idx = 1 # msg = ssc.module_log(mod, 0) # while (msg != None): # print "\t: " + msg # msg = ssc.module_log(mod, idx) # idx = idx + 1 # else: # #return the relevant outputs desired # ac_hourly = var('hourly_ac_net'); # ac_monthly = var('monthly_ac_net');
ssc.data_set_number(dat, 'inverter_model', 1) ssc.data_set_number(dat, 'inv_snl_c0', inv_snl_c0) ssc.data_set_number(dat, 'inv_snl_c1', inv_snl_c1) ssc.data_set_number(dat, 'inv_snl_c2', inv_snl_c2) ssc.data_set_number(dat, 'inv_snl_c3', inv_snl_c3) ssc.data_set_number(dat, 'inv_snl_paco', inv_snl_paco) ssc.data_set_number(dat, 'inv_snl_pdco', inv_snl_pdco) ssc.data_set_number(dat, 'inv_snl_pnt', inv_snl_pnt) ssc.data_set_number(dat, 'inv_snl_pso', inv_snl_pso) ssc.data_set_number(dat, 'inv_snl_vdco', inv_snl_vdco) ssc.data_set_number(dat, 'inv_snl_vdcmax', inv_snl_vdcmax) # all variables have been set up for pvsamv1. Run! mod = ssc.module_create('pvsamv1') returnStatus = ssc.module_exec(mod, dat) # process results # if ssc.module_exec(mod, dat) == 0: # print "pvsamv1 simulation error" # idx = 1 # msg = ssc.module_log(mod, 0) # while (msg != None): # print "\t: " + msg # msg = ssc.module_log(mod, idx) # idx = idx + 1 # else: # #return the relevant outputs desired # ac_hourly = var('hourly_ac_net'); # ac_monthly = var('monthly_ac_net'); # ac_annual = var('annual_ac_net');