dwind.valuation#

Provides the core value calculation methods.

Functions

calc_financial_performance(capex_usd_p_kw, ...)

Calculates the net present value (NPV) for a single agent.

calc_financial_performance_fom(...)

Calculates the post-tax net present value (NPV) for a single agent.

fetch_cambium_values(row, generation_hourly, ...)

Retrieves the Cambium values as an 8760 x 2 tuple of tuples.

find_breakeven(row, loan, batt_costs, ...[, ...])

Calculates the breakeven cost and parameters for a distributed wind turbine in the agent's location.

find_breakeven_fom(row, financial, ...[, ...])

Calculates the breakeven cost and parameters for a front-of-meter distributed wind turbine in the agent's location.

find_cf_from_rev_wind(rev_dir, ...[, year])

Calculate the reV capacity factor.

process_btm(row, tech, generation_hourly, ...)

Behind-the-meter calculation for a single agent.

process_fom(row, tech, generation_hourly, ...)

Front-of-meter calculation for a single agent.

process_tariff(utilityrate, row, ...)

Instantiate the utilityrate5 PySAM model and process the agent's rate information to conform with PySAM input formatting.

worker(row, config, sector)

Individual calculation process meant to be run in parallel.

Classes

ValueFunctions(scenario, inc_scenario, year, ...)

Primary model calculation engine responsible for the computation of individual agents.

class dwind.valuation.ValueFunctions(scenario, inc_scenario, year, configuration, return_format='totals')[source]#

Primary model calculation engine responsible for the computation of individual agents.

load()[source]#

Loads all the core data from CSVs for configuring PySAM.

run(agents, sector)[source]#

Run a multi-threaded PySAM analysis on each agent.

Parameters:
  • agents (pd.DataFrame) – The fully prepared agent DataFrame.

  • sector (dwind.config.Sector) – One of “fom” (front-of-meter) or “btm” (behind-the-meter).

Returns:

An updated version of agents with PySAM results data.

Return type:

pd.DataFrame

dwind.valuation.calc_financial_performance(capex_usd_p_kw, row, loan, batt_costs)[source]#

Calculates the net present value (NPV) for a single agent.

Parameters:
  • capex_usd_p_kw (float) – Capital expenditures per kilowatt in USD (CapEx $/kW).

  • row (pd.Series) – Single row of the agent DataFrame.

  • loan (PySAM.Cashloan) – Configured cashloan object.

  • batt_costs (float) – Battery costs.

Returns:

The NPV of the agent.

Return type:

float

dwind.valuation.calc_financial_performance_fom(capex_usd_p_kw, row, financial)[source]#

Calculates the post-tax net present value (NPV) for a single agent.

Parameters:
  • capex_usd_p_kw (float) – Capital expenditures per kilowatt in USD (CapEx $/kW).

  • row (pd.Series) – Single row of the agent DataFrame.

  • financial (PySAM.Merchantplant) – Configured PVWattsMerchantplant` or WindPowerMerchantplant.

Returns:

The post-taxs NPV of the agent.

Return type:

float

dwind.valuation.fetch_cambium_values(row, generation_hourly, cambium_dir, cambium_value, lower_thresh=0.01)[source]#

Retrieves the Cambium values as an 8760 x 2 tuple of tuples.

Parameters:
  • row (pd.Series) – An individual row of the agent DataFrame.

  • generation_hourly (np.ndarray) – Hourly generation data for a single year (length 8760).

  • cambium_dir (pathlib.Path) – Full file path for the Cambium data.

  • cambium_value (str) – Which Cambium value to retrieve.

  • lower_thresh (float, optional) – Lower threshold for the MerchantPlant calculations. Defaults to 0.01.

Returns:

Hourly, single year (8760) of the clipped generation, in MW,

and value, in $/MW.

Return type:

list[list[float, float], …]

dwind.valuation.find_breakeven(row, loan, batt_costs, pysam_outputs, method, *, pre_calc_bounds_and_tolerances=True, **kwargs)[source]#

Calculates the breakeven cost and parameters for a distributed wind turbine in the agent’s location.

Parameters:
  • row (pd.Series) – Single row of the agent DataFrame.

  • loan (PySAM.Cashloan) – Configured cashloan object.

  • batt_costs (float) – Battery costs.

  • pysam_outputs (list[str]) – List of PySAM output variables to return with the breakeven cost.

  • method (str) – Name of the optimization strategy. Must be one of “bisect”, “brentq”, “grid_search”, or “newton”.

  • pre_calc_bounds_and_tolerances (bool, optional) – Flag to pre-calculate the bounds for the bisect adn brentq optimization methods.

  • **kwargs (dict) – Inputs for each optimization strategy. For further parameterizations, see the documentation for the “brentq”, “bisect”, and “newton” methods on the scipy optimize API reference site

Raises:
  • ValueError – Raised if the optimization was unable to find a viable solution

  • ValueError – Raised for an unknown method.

Return type:

DataFrame | tuple[float, dict]

Returns:

Returns one of the following

  • pd.DataFrame: Returned when method is “grid_search”

  • tuple[float, dict]: Returns the breakeven cost and PySAM outputs specified in

    pysam_outputs when method is “brentq”, “bisect”, or “newton”.

dwind.valuation.find_breakeven_fom(row, financial, pysam_outputs, method, *, pre_calc_bounds_and_tolerances=True, **kwargs)[source]#

Calculates the breakeven cost and parameters for a front-of-meter distributed wind turbine in the agent’s location.

Parameters:
  • row (pd.Series) – Single row of the agent DataFrame.

  • financial (PySAM.Merchantplant) – Configured PVWattsMerchantPlant or PySAM.WindPowerMerchantplant object.

  • pysam_outputs (list[str]) – List of PySAM output variables to return with the breakeven cost.

  • method (str) – Name of the optimization strategy. Must be on of “bisect”, “brentq”, “grid_search”, or “newton”.

  • pre_calc_bounds_and_tolerances (bool, optional) – Flag to pre-calculate the bounds for the bisect adn brentq optimization methods.

  • **kwargs (dict) – Inputs for each optimization strategy. For further parameterizations, see the documentation for the “brentq”, “bisect”, and “newton” methods on the scipy optimize API reference site

Raises:
  • ValueError – Raised if the optimization was unable to find a viable solution

  • ValueError – Raised for an unknown method.

Return type:

DataFrame | tuple[float, dict]

Returns:

Returns one of the following

  • pd.DataFrame: Returned when method is “grid_search”

  • tuple[float, dict]: Returns the breakeven cost and PySAM outputs specified in

    pysam_outputs when method is “brentq”, “bisect”, or “newton”.

dwind.valuation.find_cf_from_rev_wind(rev_dir, generation_scale_offset, tech_config, rev_index, year=2018)[source]#

Calculate the reV capacity factor.

Parameters:
  • rev_dir (pathlib.Path) – Location of the pre-calculated reV results found at Configuration.project.rev.DIR

  • generation_scale_offset (float) – Generation scaling offset found in the model configuration at Configuration.project.settings.GENERATION_SCALE_OFFSET.wind.

  • tech_config (str) – Technology configuration string

  • rev_index (str) – The “rev_index_wind” column value for the agent.

  • year (int, optional) – reV generation year basis. Defaults to 2018.

Returns:

Array of capacity factors.

Return type:

np.ndarray

dwind.valuation.process_btm(row, tech, generation_hourly, consumption_hourly, pysam_outputs, batt_dispatch=None, *, en_batt=False)[source]#

Behind-the-meter calculation for a single agent.

TODO: list out the actual process

Parameters:
  • row (pandas.Series) – The row of the dataframe on which the function is performed.

  • tech (dwind.config.Technology) – Validated dwind.config.Technology object.

  • generation_hourly (np.ndarray) – Hourly generation for a single year (8760 hours).

  • consumption_hourly (np.ndarray) – Hourly consumption for a single year (8760 hours).

  • pysam_outputs (list[str]) – List of desired PySAM output data.

  • batt_dispatch (str, optional) – Battery dispatch strategy type.

  • en_batt (bool, optional) – Enable battery modeling if True. Defaults to False.

Returns:

Updated row with PySAM and breakeven cost results.

Return type:

pd.Series

dwind.valuation.process_fom(row, tech, generation_hourly, market_profile, pysam_outputs, batt_dispatch=None, *, en_batt=False)[source]#

Front-of-meter calculation for a single agent.

TODO: list out the actual process

Parameters:
  • row (pandas.Series) – The row of the dataframe on which the function is performed.

  • tech (dwind.config.Technology) – Validated dwind.config.Technology object.

  • generation_hourly (np.ndarray) – Hourly generation for a single year (8760 hours).

  • market_profile (list[list[float, float], ...]) – Hourly Cambium values for a single year.

  • pysam_outputs (list[str]) – List of desired PySAM output data.

  • batt_dispatch (str, optional) – Battery dispatch strategy type.

  • en_batt (bool, optional) – Enable battery modeling if True. Defaults to False.

Returns:

Updated row with PySAM and breakeven cost results.

Return type:

pd.Series

dwind.valuation.process_tariff(utilityrate, row, net_billing_sell_rate)[source]#

Instantiate the utilityrate5 PySAM model and process the agent’s rate information to conform with PySAM input formatting.

Parameters:
  • utilityrate (PySAM.Utilityrate5) – Utilityrate5 model to be configured based on the agent’s specifications.

  • row (pd.Series) – Individual agent row from the agent DataFrame.

  • net_billing_sell_rate (float) – Net billing sell rate.

Returns:

Configured Utilityrate5 model.

Return type:

PySAM.Utilityrate5

dwind.valuation.worker(row, config, sector)[source]#

Individual calculation process meant to be run in parallel.

Parameters:
  • row (pd.Series) – Individual row of from the agent DataFraem to analyze.

  • config (Configuration) – The overarching dwind configuration.

  • sector (Sector) – One of “fom” or “btm”.

Returns:

“gid” column of row and the dictionary of results for that agent.

Return type:

tuple[str, dict]