h2integrate.finances.numpy_financial_npv#

Classes

NumpyFinancialNPV(**kwargs)

OpenMDAO component for calculating Net Present Value (NPV) using the NumPy Financial.

NumpyFinancialNPVFinanceConfig(*, ...[, ...])

Configuration for NumpyFinancialNPVFinance.

class h2integrate.finances.numpy_financial_npv.NumpyFinancialNPVFinanceConfig(*, plant_life, discount_rate, commodity_sell_price=0.0, save_cost_breakdown=False, save_npv_breakdown=False, cost_breakdown_file_description='default')#

Configuration for NumpyFinancialNPVFinance.

Parameters:
  • plant_life (int)

  • discount_rate (float)

  • commodity_sell_price (int | float)

  • save_cost_breakdown (bool)

  • save_npv_breakdown (bool)

  • cost_breakdown_file_description (str)

plant_life#

operating life of plant in years

Type:

int

discount_rate#

discount rate, expressed as a fraction between 0 and 1.

Type:

float

commodity_sell_price#

sell price of commodity in USD/unit of commodity. Defaults to 0.0

Type:

int | float, optional

save_cost_breakdown#

whether to save the cost breakdown per year. Defaults to False.

Type:

bool, optional

save_npv_breakdown#

whether to save the npv breakdown per technology. Defaults to False.

Type:

bool, optional

cost_breakdown_file_description#

description to include in filename of cost breakdown file or npv breakdown file if either save_cost_breakdown or save_npv_breakdown is True. Defaults to 'default'.

Type:

str, optional

plant_life: int#
discount_rate: float#
commodity_sell_price: int | float#
save_cost_breakdown: bool#
save_npv_breakdown: bool#
cost_breakdown_file_description: str#
class h2integrate.finances.numpy_financial_npv.NumpyFinancialNPV(**kwargs)#

OpenMDAO component for calculating Net Present Value (NPV) using the NumPy Financial.

This component computes the NPV of a given commodity-producing plant over its operational lifetime, accounting for capital expenditures (CAPEX), operating expenditures (OPEX), refurbishment/replacement costs, and commodity revenues.

NPV is calculated using the discount rate and plant life defined in the plant_config. By convention, investments (CAPEX, OPEX, refurbishment) are treated as negative cash flows, while revenues from commodity sales are positive. This follows the NumPy Financial convention:

Reference:

NumpPy Financial NPV documentation: https://numpy.org/numpy-financial/latest/npv.html#numpy_financial.npv

By convention:
  • Investments or "deposits" are negative.

  • Income or "withdrawals" are positive.

  • Values typically start with the initial investment, so values[0] is often negative.

NPV_str#

The dynamically generated name of the NPV output variable, based on commodity_type and optional description.

Type:

str

tech_config#

Technology-specific configuration dictionary.

Type:

dict

config#

Parsed financial configuration parameters (e.g., discount rate, plant life, save options).

Type:

NumpyFinancialNPVConfig

initialize()#

Perform any one-time initialization run at instantiation.

setup()#

Declare inputs and outputs.

Available attributes:

name pathname comm options

compute(inputs, outputs)#

Compute the Net Present Value (NPV).

Calculates discounted cash flows over the plant lifetime, accounting for:
  • Revenue from annual commodity production and sale.

  • CAPEX and OPEX for all technologies.

  • Replacement or refurbishment costs if provided.

Optionally saves cost breakdowns and NPV breakdowns to CSV files if enabled in configuration.

NPV that is positive indicates a profitable investment, while negative NPV indicates a loss.

Parameters:
  • inputs (dict-like) -- Dictionary of input values, including production, CAPEX, OPEX, and optional replacement periods.

  • outputs (dict-like) -- Dictionary for storing computed outputs, including the NPV result.

Produces:
  • outputs[self.NPV_str]: The total NPV in USD.

Side Effects:
  • Writes annual cost breakdown and NPV breakdown CSVs to the configured output directory if save_cost_breakdown or save_npv_breakdown is enabled.

Raises:
  • FileNotFoundError -- If the specified output directory cannot be created.

  • ValueError -- If refurbishment schedules cannot be derived from inputs.

_save_cost_breakdown_files(cost_breakdown, npv_cost_breakdown, total_npv)#

Save cost breakdown and/or NPV breakdown to CSV files.

Creates CSV files containing detailed breakdowns of costs and NPV calculations for post-processing analysis and reporting.

Parameters:
  • cost_breakdown (dict) -- Dictionary mapping cost categories to annual cost arrays. Keys are category names (e.g., "wind: capital cost"), values are numpy arrays of costs per year (length = plant_life + 1).

  • npv_cost_breakdown (dict) -- Dictionary mapping cost categories to their NPV values. Keys are category names, values are floats representing discounted present value.

  • total_npv (float) -- The total NPV summed across all categories in USD.

File Formats:

NPV breakdown CSV: Single column with cost category as index and NPV as value. Cost breakdown CSV: Rows are cost categories, columns are years (Year 0, Year 1, etc.).