Exemplo n.º 1
0
def simple_lp(profile_dataframe):
    """Builds a simple LP with natural gas and solar.

    Args:
     profile_dataframe: A pandas dataframe with source and demand names
       in the column header.  Hour of year in indexed column-0.

    Returns:
      A LinearProgramContainer with natural gas and solar sources.
    """

    lp = gslp.LinearProgramContainer(profile_dataframe)

    # Must specify a demand to put proper load on the grid.  GridDemand
    # is linked to the corresponding profile:
    # lp.profiles[GridDemand.name]

    lp.add_demands(gslp.GridDemand("DEMAND"))

    # Nondispatchable sources are intermittent and have profiles which
    # describe their availability.  Building more capacity of these
    # sources scales the profile but cannot provide power when the
    # profile is 0. (e.g. Solar power in the middle of the night, Wind
    # power during a lull)).  A nondispatchable GridSource is linked to
    # its corresponding profile, profile[GridSource.name]

    lp.add_nondispatchable_sources(
        gslp.GridSource(
            name="SOLAR",  # Matches profile column name for nondispatch.
            nameplate_unit_cost=946000,  # Aggressive solar cost $/MW
            variable_unit_cost=0,  # No fuel cost.
            co2_per_electrical_energy=0,  # Clean energy.
            is_rps_source=True,
        ))  # In Renewable Portfolio Standard

    # Dispatchable sources can provide power at any-time.  The LP will
    # optimize generation from these sources on an as-needed basis
    # hour-by-hour.

    lp.add_dispatchable_sources(
        gslp.GridSource(
            name="NG",  # Dispatchable, so no name restriction.
            nameplate_unit_cost=1239031,  # Cost for a combined cycle plant. $/MW
            variable_unit_cost=17.5,  # Cheap fuel costs assumes fracking. $/MWh
            co2_per_electrical_energy=0.33,  # Tonnes CO2 / MWh
            is_rps_source=False,
        ))  # Not in Renewable Portfolio Standard.

    return lp
Exemplo n.º 2
0
def configure_sources_and_storage(profile_directory,
                                  region,
                                  site,
                                  dc,
                                  lang,
                                  source_dataframe,
                                  storage_dataframe,
                                  source_dict_index,
                                  storage_names,
                                  rps_names,
                                  cross_region=None,
                                  hydrolimits=None):
    """Generates a LinearProgramContainer similar to the website.

  Args:
    profile_directory: String filepath where profile files of the form
      profile_<region>.csv exist.  Acceptable values of <region> are
      REGION_HUBS.keys().

    region: String name of the region to generate simulation for.
      Acceptable values are REGION_HUBS.keys().

    source_dataframe: A pandas dataframe with source names in indexed
      column-0.

      Index names match the source names in the website with a cost
      option index. (e.g. COAL_0, SOLAR_2, NUCLEAR_1).  Some sources
      only have one cost option associated with them.
      Source names are as follows.
        COAL, Coal fired plants.
        HYDROPOWER, Water turbines fed by a dammed reservoir.
        NGCC, Natural Gas Combined Cycle. A natural gas fired turbine
          whose exhaust heats a steam turbine for additional power.
        NGCT, Natural Gas Conventional Turbine. A natural gas turbine.
        NGCC_AMINE, NGCC + Carbon Capture and Sequestration via amine
          capture.
        NGCC_CRYO, NGCC + Carbon Capture and Sequestration from
          capturing the CO2 by freezing into dry-ice.
        NUCLEAR, Nuclear power.
        SOLAR, Solar power through utility scale photovoltaic panels.
        WIND, Wind power through modern conventional wind turbines.

      Column headers include
        CO2, Amount of CO2 emitted per generated energy. Units are
          Tonnes of CO2 Emitted per Megawatt-hour.
        fixed, Cost of building and maintaining a plant per
          nameplate-capacity of the plant.  Units are $ / Megawatt
      Source names are as follows.
        COAL, Coal fired plants.
        HYDROPOWER, Water turbines fed by a dammed reservoir.
        NGCC, Natural Gas Combined Cycle. A natural gas fired turbine
          whose exhaust heats a steam turbine for additional power.
        NGCT, Natural Gas Conventional Turbine. A natural gas turbine.
        NGCC_AMINE, NGCC + Carbon Capture and Sequestration via amine
          capture.
        NGCC_CRYO, NGCC + Carbon Capture and Sequestration from
          capturing the CO2 by freezing into dry-ice.
        NUCLEAR, Nuclear power.
        SOLAR, Solar power through utility scale photovoltaic panels.
        WIND, Wind power through modern conventional wind turbines.

      Column headers include
        CO2, Amount of CO2 emitted per generated energy. Units are
          Tonnes of CO2 Emitted per Megawatt-hour.
        fixed, Cost of building and maintaining a plant per
          nameplate-capacity of the plant.  Units are $ / Megawatt

        variable, Cost of running the plant based upon generation
          energy.  Units are $ / Megawatt-hour

    storage_dataframe: A pandas dataframe with storage names in indexed
      column-0.


        variable, Cost of running the plant based upon generation
          energy.  Units are $ / Megawatt-hour

    storage_dataframe: A pandas dataframe with storage names in indexed
      column-0.

      There are only two kinds of storage considered in this dataframe.
        HYDROGEN, Storage charges by generating and storing hydrogen.
          Storage discharges by buring hydrogen.
        ELECTROCHEMIC  # print(comp_lp(30, 'ru', save_csv=True))
  # print(comp_lp(30, 'fr', save_csv=True))
  # print(comp_lp(30, 'de', save_csv=True))
  # print(comp_lp(30, 'ja', save_csv=True))
  # print(comp_lp(30, 'es', save_csv=True))
  # print(comp_lp(30, 'zh', save_csv=True))AL, Storage charges and discharges through batteries.
  # print(comp_lp(30, 'ru', save_csv=True))
  # print(comp_lp(30, 'fr', save_csv=True))
  # print(comp_lp(30, 'de', save_csv=True))
  # print(comp_lp(30, 'ja', save_csv=True))
  # print(comp_lp(30, 'es', save_csv=True))
  # print(comp_lp(30, 'zh', save_csv=True))
      Index names mat  # print(comp_lp(30, 'ru', save_csv=True))
  # print(comp_lp(30, 'fr', save_csv=True))
  # print(comp_lp(30, 'de', save_csv=True))
  # print(comp_lp(30, 'ja', save_csv=True))
  # print(comp_lp(30, 'es', save_csv=True))
  # print(comp_lp(30, 'zh', save_csv=True))ch the storage names.

      Column headers include:
        fixed,
        charge_efficiency,
        discharge_efficiency,
        charge_capital,
        discharge_capital,

    source_dict_index: A dict keyed by source name with index values
      for cost.  Acceptable index values are either [0] for sources
      which only had one cost assumed in the webiste or [0,1,2] for
      sources which had 3 choices for cost assumption.

    storage_names: A list of storge names of storage type to add to
      the LP.  Must match names in the storage_dataframe index.

    rps_names: A list of source names which should be considered in
      the Renewable Portfolio Standard.

    hydrolimits: A dict with 'max_power' and 'max_energy' keys.  If
      specified, hydropower will be limited to this power and energy.

  Returns:
    A Configured LinearProgramContainer suitable for simulating.
  """
    #profiles_file = osp.join(profile_directory, 'profiles_dcnet.csv').get_dmd()

    #profiles_dataframe = pd.read_csv(profiles_file, index_col=0, parse_dates=True)

    profiles_dataframe = build_dc(region=region,
                                  site=site,
                                  with_dc=dc,
                                  lang=lang,
                                  traffic_file='train_2.csv')

    lp = gslp.LinearProgramContainer(profiles_dataframe)

    # Specify grid load or demand which has a profile in
    # profile_dataframe.<region>_DEMAND
    lp.add_demands(gslp.GridDemand('%s_DEMAND' % region.upper()))

    # Configure dispatchable and non-dispatchable sources.
    for source_name, source_index in source_dict_index.items():
        dataframe_row = source_dataframe.loc['%s_%d' %
                                             (source_name, source_index)]
        is_rps_source = source_name in rps_names

        # Adjust source_name by region to match profiles and to
        # differentiate it from sources from other regions.
        regional_source_name = '%s_%s' % (region.upper(), source_name)
        source = gslp.GridSource(
            name=regional_source_name,
            nameplate_unit_cost=dataframe_row['fixed'],
            variable_unit_cost=dataframe_row['variable'],
            co2_per_electrical_energy=dataframe_row['CO2'],
            is_rps_source=is_rps_source)

        # For energystrategies.org we assumed that the prime hydropower
        # sites have already been developed and built.  So for hydropower
        # sites, we make the capital cost 0.  Here we limit the LP to only
        # use as much power and energy as existing sites already provide.
        # Without this limitation and with capital cost of 0, the LP will
        # assume an infinite supply of cheap hydropower and fulfill demand
        # with 100% hydropower.

        if hydrolimits is not None:
            if source_name == 'HYDROPOWER':
                source.max_power = hydrolimits['max_power']
                source.max_energy = hydrolimits['max_energy']

        # Non-dispatchable sources have profiles associated with them.
        if regional_source_name in profiles_dataframe.columns:
            lp.add_nondispatchable_sources(source)
        else:
            lp.add_dispatchable_sources(source)

    # Add Solar and Wind from other regions.  Adjust by additional
    # transmission costs and efficiency losses for distance traveled if
    # Solar and Wind are in the simulation.  The website assumes Solar
    # and Wind are always present.

    if cross_region != None:
        for other_region in REGION_HUBS:
            if other_region != region:
                transmission_cost, efficiency = get_transmission_cost_efficiency(
                    REGION_HUBS[region], REGION_HUBS[other_region])

                for source in ['SOLAR', 'WIND']:
                    if source in source_dict_index:
                        cost_row = source_dataframe.loc[
                            '%s_%d' % (source, source_dict_index[source])]
                        lp.add_nondispatchable_sources(
                            gslp.GridSource(
                                name='%s_%s' % (other_region.upper(), source),
                                nameplate_unit_cost=cost_row['fixed'] +
                                transmission_cost,
                                variable_unit_cost=cost_row['variable'],
                                co2_per_electrical_energy=cost_row['CO2'],
                                is_rps_source=True,
                                power_coefficient=efficiency))
    if storage_names != None:
        for storage_name in storage_names:
            dataframe_row = storage_dataframe.loc[storage_name]
            storage = gslp.GridRecStorage(
                name=storage_name,
                storage_nameplate_cost=dataframe_row['fixed'],
                charge_nameplate_cost=dataframe_row['charge_capital'],
                discharge_nameplate_cost=dataframe_row['discharge_capital'],
                charge_efficiency=dataframe_row['charge_efficiency'],
                discharge_efficiency=dataframe_row['discharge_efficiency'])

            lp.add_storage(storage)

    return lp