Esempio n. 1
0
from sscapi import PySSC
import matplotlib.pyplot as plot

# setup data structures
ssc = PySSC()
dat = ssc.data_create()
# required inputs
ssc.data_set_string(dat, "file_name", "daggett.tm2")
ssc.data_set_number(dat, "system_size", 4)
ssc.data_set_number(dat, "derate", 0.77)
ssc.data_set_number(dat, "track_mode", 2)
ssc.data_set_number(dat, "azimuth", 180)
ssc.data_set_number(dat, "tilt_eq_lat", 1)
# default inputs exposed
ssc.data_set_number(dat, 'rotlim', 45.0)
ssc.data_set_number(dat, 't_noct', 45.0)
ssc.data_set_number(dat, 't_ref', 25.0)
ssc.data_set_number(dat, 'gamma', -0.5)
ssc.data_set_number(dat, 'inv_eff', 0.92)
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
Esempio n. 2
0
from sscapi import PySSC

# setup inputs
ssc = PySSC()
dat = ssc.data_create()
ssc.data_set_string(dat, "file_name", "daggett.tm2")
ssc.data_set_number(dat, "system_size", 4)
ssc.data_set_number(dat, "derate", 0.77)
ssc.data_set_number(dat, "track_mode", 0)
ssc.data_set_number(dat, "azimuth", 180)
ssc.data_set_number(dat, "tilt_eq_lat", 1)
ssc.data_set_matrix(dat, "shading_mxh",
                    [[
                        0, 0, 0, 0, 0, 0, 0, 0, 0.475, 0.95, 1, 1, 0.7875,
                        0.2375, 0.25, 0.3625, 0, 0, 0, 0, 0, 0, 0, 0
                    ],
                     [
                         0, 0, 0, 0, 0, 0, 0, 0, 0.4875, 1, 1, 1, 0.925,
                         0.6375, 0.6625, 0.225, 0, 0, 0, 0, 0, 0, 0, 0
                     ],
                     [
                         0, 0, 0, 0, 0, 0, 0, 0.15, 0.925, 1, 1, 1, 1, 1, 0.75,
                         0.2, 0, 0, 0, 0, 0, 0, 0, 0
                     ],
                     [
                         0, 0, 0, 0, 0, 0, 0, 0.45, 0.9125, 1, 1, 1, 1, 1,
                         0.625, 0.375, 0, 0, 0, 0, 0, 0, 0, 0
                     ],
                     [
                         0, 0, 0, 0, 0, 0.075, 0.05, 0.7875, 1, 1, 1, 1, 1, 1,
                         0.625, 0.4875, 0.025, 0, 0, 0, 0, 0, 0, 0
Esempio n. 3
0
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