def linearization(self, ele_capacity=2):
        # define a converter and then conduct piecewise linearization on its power_in-power_out curve ---------
        con = converter.converter(ele_capacity)
        x = np.append(np.linspace(0, 0.1 * ele_capacity, 20),
                      np.linspace(0.11 * ele_capacity, ele_capacity, 50))
        y = np.array([i * con.eta(i) for i in x])

        con_pwlf = pwlf.PiecewiseLinFit(x, y)
        con_breaks = con_pwlf.fit(
            3)  # The number indicates how many pieces are generated.
        y1 = con_pwlf.predict(x)
        # fig, ax = plt.subplots()
        # ax.plot(x, y)
        # ax.plot(x, y1)
        # plt.show()
        self.con_breaks = con_breaks
        self.con_f_breaks = np.array([i * con.eta(i) for i in con_breaks])
        self.k1_c, self.k2_c, self.k3_c = con_pwlf.slopes[0], con_pwlf.slopes[
            1], con_pwlf.slopes[2]
        self.b1_c, self.b2_c, self.b3_c = con_pwlf.intercepts[
            0], con_pwlf.intercepts[1], con_pwlf.intercepts[2]
        # ---------------------------------------End linearization of converter-------------------------------

        # do the same to electrolyser
        ele = electrolyser.electrolyser_group(I_min=0)
        y = []
        for i in x:
            electrolyser.set_power_group(ele, i)
            y.append(ele.m_H2() * 3600)
        y = np.array(y)
        # fig,ax = plt.subplots()
        # ax.plot(x,y)
        # plt.show()
        ele_pwlf = pwlf.PiecewiseLinFit(x, y)
        ele_breaks = ele_pwlf.fit(3)

        self.ele_breaks = ele_breaks

        ele_f_breaks = []
        for i in ele_breaks:
            electrolyser.set_power_group(ele, i)
            ele_f_breaks.append(ele.m_H2() * 3600)

        self.ele_f_breaks = np.array(ele_f_breaks)
        self.k1_e, self.k2_e, self.k3_e = ele_pwlf.slopes[0], ele_pwlf.slopes[
            1], ele_pwlf.slopes[2]
        self.b1_e, self.b2_e, self.b3_e = ele_pwlf.intercepts[
            0], ele_pwlf.intercepts[1], ele_pwlf.intercepts[2]
        # ---------------------------------------End linearization of electrolyser-----------------------------
        '''
Exemple #2
0
OandM_cost = (54 * 2e6 * 0.02 + 26.8 * 3e6 * 0.02) / (54 + 26.8) / (365 * 24)
hourly_cost = economic.capital_recovery_factor(Annual_real_rate) * (
    54 * 2e6 + 26.8 * 3e6) / 365 / 24 / (54 + 26.8)
res_av_cost = OandM_cost + hourly_cost

# Build the wind turbines
WT_gls = [wind_turbine.wind_turbine(r=40, height=40)] * 13

# Build the photovoltaics
PV_gls = [pv.pv()] * 6

# Build the battery
Battery_gls = battery.battery_bank(soc_min=0.1)

# Build the electrolyser
Electrolyser_gls = electrolyser.electrolyser_group()

# Build the hydrogen tank
Hydrogen_tank_gls = hydrogen_tank.hydrogen_tank(
    Volume_tank=60)  # Given the fact that trailers carry 1000kg H2

# Build the load
load_data_p_mw = [
    0.98,  # Quantfuel, 2020), start up tests currently. It also consumes H2,CH4 and plastic waster
    2.5,  # Biogas
    0.8,  # Danish Marine Protein
    0.15,  # Ever Fuel, fillinig typical four hours. 200bar to 400bar, 900+kg Hydrogen
    3.25,  # GLS_use_case facility
    0.7,  # Methanol facility
    2,  # GreenSkive college
    0,  # Electrolyser, which is considered in storage