This paper develops and applies a techno-economic optimization framework for sizing photovoltaic (PV) and battery energy storage systems (BESSs) in grid-connected energy communities. An in-house developed modeling platform featuring custom MATLAB (R2025a) code implements a mixed-integer linear programming (MILP) model that minimizes differential net present value (NPV) over a 25-year lifetime, integrating capital expenditures, operating cash flows, and carbon taxation. The formulation captures temperature-dependent PV efficiency, battery round-trip efficiency, and time-varying electricity prices, and is validated on a real campus energy community with hourly demand, irradiance, and tariff data. Two design scenarios are examined: the optimal unconstrained case and a budget-constrained configuration (CAPEX ≤ 2.0 M€). Results show the unconstrained system installs 3.19 MWp PV and 12.3 MWh storage, achieving 78.9% self-sufficiency and a 78.9% emissions reduction. The constrained case installs 0.99 MWp and 1.68 MWh, achieves 32.0% self-sufficiency, and delivers a 4.46 M€ NPV with payback in 3.9 years. Under current costs and tariffs, PV-dominated configurations provide the highest value, with limited battery benefit except under generous budgets or higher carbon prices. A dedicated CAPEX sensitivity analysis explores PV and battery cost variability and its impact on optimal sizing and economic outcomes. The core methodological contribution is a master-planning formulation that solves design decision variables and optimal dispatch concurrently within a single MILP. The flexible platform enables future reassessment as technology, tariff, and policy landscapes evolve.
Mazzoni et al. (Tue,) studied this question.