Example 1

Import libraries

[1]:
import numpy as np
import hyveopt as h2

# Set np.random seed for reproducibility
np.random.seed(0)

Create system components templates

[2]:
plant_template = h2.PlantTemplate(
    name="myplant",
    location=("22°10'17.66\"S", "70° 5'23.50\"W") # ~ Tocopilla, Chile.
)

electrolizer_efficiency = h2.Gain(
    breakpoints = [0.0, 0.1, 0.4, 0.7, 1],
    slopes = [0.,2., 0.5, 0.2],
    intercepts = [0.0, -0.1, 0.5, 0.8]
)

plant_template.add(h2.TemplateElectrolizer(
    name="electrolizer",
    pnom_kW=h2.Range(0., 200.),
    gain=electrolizer_efficiency,
    inv_cost_per_kw=1300.
    )
)

plant_template.add(h2.TemplateESS(
    name="battery",
    pnom_kW=h2.Range(0., 200.),
    soc_nom_kWh=h2.Range(0., 100.),
    inv_cost_per_kw=200.,
    bat_kw_to_kwh=3.
))

plant_template.add(h2.TemplatePVSystem(
    name="pv_system",
    snom_KVA=h2.Range(0., 200.),
    solar_irradiance=h2.TSParameter(tsname="si_pv_system", default=0.0),
    inv_cost_per_kw=1100.
))

[2]:
0

Planning horizon definition and time series data generation

[3]:

time_config = h2.PlanningTimeConfig( planning_horizon_start='2025-01-01', planning_horizon_end='2065-12-31', scenarios_per_year=2, scenario_resolution='1D', scenario_subsampling='1h' # Sampling frequency for simulation purposes. ) tsdata = h2.SingleBusDesignData.generate_tsdata(plant_template, time_config)

Create and solve sizing model

[4]:

pdata = h2.SingleBusDesignData( budget_inv_M=10., plant_template=plant_template, time_config=time_config, tsdata=tsdata ) model = h2.SingleBusDesignModel(pdata) model.solve()
feasible solution found by trivial heuristic after 0.1 seconds, objective value 0.000000e+00
presolving:
(round 1, fast)       996 del vars, 996 del conss, 0 add conss, 9843 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
   (0.2s) dualsparsify: 996 nonzeros canceled
(round 2, exhaustive) 996 del vars, 996 del conss, 0 add conss, 9844 chg bounds, 0 chg sides, 2988 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 3, fast)       1992 del vars, 1992 del conss, 0 add conss, 11836 chg bounds, 0 chg sides, 2988 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 4, fast)       2988 del vars, 2988 del conss, 0 add conss, 11836 chg bounds, 0 chg sides, 2988 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
   (0.3s) symmetry computation started: requiring (bin +, int +, cont +), (fixed: bin -, int -, cont -)
   (0.4s) symmetry computation finished: 21 generators found (max: 1500, log10 of symmetry group size: 0.0) (symcode time: 0.01)
dynamic symmetry handling statistics:
   orbitopal reduction:        2 components: 75x3, 81x4
   orbital reduction:         no components
   lexicographic reduction:   16 permutations with support sizes 174, 186, 162, 174, 186, 186, 150, 162, 162, 186, 150, 150, 174, 186, 162, 150
handled 18 out of 18 symmetry components
presolving (5 rounds: 5 fast, 2 medium, 2 exhaustive):
 2988 deleted vars, 2988 deleted constraints, 0 added constraints, 11836 tightened bounds, 0 added holes, 0 changed sides, 2988 changed coefficients
 0 implications, 0 cliques
presolved problem has 6856 variables (0 bin, 0 int, 0 impl, 6856 cont) and 10790 constraints
  10790 constraints of type <linear>
Presolving Time: 0.34
transformed 1/1 original solutions to the transformed problem space

 time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.
* 4.2s|     1 |     0 | 12213 |     - |    LP  |   0 |6856 |  10k|  10k|   0 |  0 |   0 |   0 | 3.620433e+07 | 3.620433e+07 |   0.00%| unknown
  4.2s|     1 |     0 | 12213 |     - |   112M |   0 |6856 |  10k|  10k|   0 |  0 |   0 |   0 | 3.620433e+07 | 3.620433e+07 |   0.00%| unknown

SCIP Status        : problem is solved [optimal solution found]
Solving Time (sec) : 4.16
Solving Nodes      : 1
Primal Bound       : +3.62043337104110e+07 (2 solutions)
Dual Bound         : +3.62043337104110e+07
Gap                : 0.00 %

Report solution

[5]:
model.report()
*************************
Solution Report
*************************
SIZING:
Electrolyzer size: 1920.86 kW
PV size: 5923.50 kW
Battery size: 4.94 MW, 14.81 MWh


FINANCIALS:
NPV: 36204333.71 USD