Пример #1
0
    def set_results(self):
        """set optimization results in processes and commodities"""
        for process in self._processes:
            process.optimization_output = Dict({})
            process_code_name = process.name.lower().replace(" ", "_")
            for variable in process.core.variables:
                if variable.type is not PyomoVarType.NON_PYOMO:
                    variable_code_name = variable.name.lower().replace(
                        " ", "_")
                    unique_name = process_code_name + "__" + variable_code_name
                    result_list = list(
                        self._model.component(
                            unique_name).get_values().values())
                    # check for None values
                    process.optimization_output[variable.name] = List([
                        result for result in result_list if result is not None
                    ])

        # set commodity flow results
        for commodity in self._commodities:
            commodity.optimization_output = Dict({
                "input_processes": Dict({}),
                "output_processes": Dict({})
            })
            in_out_commodities = [
                str(process) for process in self._commodity_list[
                    commodity.name]["input_processes"] if process in
                self._commodity_list[commodity.name]["output_processes"]
            ]
            commodity_code_name = commodity.name.lower().replace(" ", "_")
            input_com = True
            for process_direction in ["input_processes", "output_processes"]:
                for process_name in self._commodity_list[
                        commodity.name][process_direction]:
                    process_code_name = process_name.lower().replace(" ", "_")
                    commodity_process_name = commodity_code_name
                    if process_name in in_out_commodities:
                        commodity_process_name += "_in" if input_com else "_out"
                    commodity_process_name += "__" + process_code_name
                    result_list = self._model.component(
                        commodity_process_name).get_values().values()
                    commodity.optimization_output[process_direction][process_name] = \
                        List([result for result in result_list if result is not None])
                # add balance to commodity flows
                if input_com:
                    commodity_process_name = "commodity_" + commodity_code_name + "_overflow_pos"
                    process_name = "Positive Balance"
                else:
                    commodity_process_name = "commodity_" + commodity_code_name + "_overflow_neg"
                    process_name = "Negative Balance"

                result_list = list(
                    self._model.component(
                        commodity_process_name).get_values().values())
                # check result_list for None values
                commodity.optimization_output[process_direction][
                    process_name] = List([
                        result for result in result_list if result is not None
                    ])
                input_com = False
Пример #2
0
    def scenarios():
        scenario_1 = Scenario("Base scenario", List())
        scenario_2 = Scenario("Extra long scenario name requiring a lot of space", List())
        scenario_3 = Scenario("Another scenario", List())
        scenario_4 = Scenario("Yet, another one", List())
        scenario_list = PropertyPopupMenu("Scenarios", List([scenario_1,
                                                             scenario_2,
                                                             scenario_3,
                                                             scenario_4]))

        return scenario_list
Пример #3
0
    def overview_properties():
        project_name = PropertyLineEdit(
            "Project Name",
            "Name")
        project_longitude = PropertyLineEdit("Longitude", "0.0", "")
        project_latitude = PropertyLineEdit("Latitude", "0.0", "")
        project_location = PropertyDialog(
            "Project Location",
            List([project_longitude, project_latitude]))
        project_area = PropertyLineEdit(
            "Project Area",
            "0.0",
            "ha")
        property_list = List([project_name, project_location, project_area])

        return property_list
Пример #4
0
    def __init__(self, process_dialog_model, process_dialog_controller):
        settings = Qt.Window | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
        super(ProcessDialogView, self).__init__(None, settings)
        self.setAttribute(Qt.WA_TranslucentBackground)

        self._model = process_dialog_model
        self._section_popup_model = PropertyPopupMenu(
            "Sections", List(list(OverviewSelection)[1:]))
        self._category_popup_model = PropertyPopupMenu(
            "Categories", List(list(ProcessCategory)))
        self._ctrl = process_dialog_controller
        self._ui = Ui_ProcessDialog()
        self._ui.setupUi(self)
        """connect widgets to controller"""
        self._ui.process_name.clicked.connect(self.gather_data)
        self._ui.button_add.clicked.connect(self.on_add_click)
        self._ui.button_icon.clicked.connect(self.open_icon_dialog)
        self._ui.variables_list.edit_add.connect(self._ctrl.change_variables)
        self._ui.data_list.edit_add.connect(self._ctrl.change_data)
        self._ui.properties_list.edit_add.connect(self._ctrl.change_properties)
        self._ui.inputs_list.edit_add.connect(self._ctrl.change_commodities)
        self._ui.outputs_list.edit_add.connect(self._ctrl.change_commodities)
        self._ui.cancel_button.clicked.connect(self.reject)
        self._ui.apply_button.clicked.connect(self.accept)
        self.accepted.connect(self.gather_data)
        """listen for model event signals"""
        self._model.value_changed.connect(self.on_process_change)
        self._section_popup_model.value_changed.connect(
            lambda: self._ui.section_value.setText(
                str(self._section_popup_model.value)))
        self._category_popup_model.value_changed.connect(
            lambda: self._ui.category_value.setText(
                str(self._category_popup_model.value)))
        """initialize view"""
        self._new_process = False
        self._ui.objective_value.setAttribute(Qt.WA_MacShowFocusRect, 0)
        self._ui.process_name.set_model(self._model)
        self._ui.process_name.setReadOnly(False)
        self._ui.section_value.set_model(self._section_popup_model)
        self._ui.category_value.set_model(self._category_popup_model)
        if not self._model.value:
            self._new_process = True
            self.init_content()
        else:
            self.load_content(self._model.value)
Пример #5
0
 def __init__(self, name="", choices=List(), value=None):
     if choices.list:
         if value:
             super().__init__(name, value)
         else:
             super().__init__(name, choices[0])
     else:
         super().__init__(name)
     self._choices = choices
Пример #6
0
 def commodities():
     return List([
         CommodityType("Energy"),
         CommodityType("Fuel"),
         CommodityType("Biogas"),
         CommodityType("Biowaste"),
         CommodityType("Water"),
         CommodityType("Food"),
         CommodityType("Land")
     ])
Пример #7
0
    def transfer_data(self, new_process, name, section, category, icon,
                      variables_data, data_data, properties_data, inputs_data,
                      outputs_data, objective, constraints):
        if new_process:
            # create new process, add to current list and set it as current
            new_process = ProcessCore()
            self._model.choices.add(new_process)
            self._model.value = new_process

        self._model.value.name = name
        self._model.value.section = OverviewSelection[section.upper()]
        self._model.value.category = ProcessCategory[category.upper()]
        self._model.value.icon = icon
        self._model.value.variables = List(variables_data)
        self._model.value.data = List(data_data)
        self._model.value.properties = List(properties_data)
        self._model.value.inputs = List(inputs_data)
        self._model.value.outputs = List(outputs_data)
        self._model.value.objective_function = objective
        self._model.value.constraints = constraints
Пример #8
0
    def transfer_data(self, new_dataset, name, unit, resolution,
                      dataset_values):
        if new_dataset:
            # create new dataset, add to current list and set it as current
            new_dataset = PropertyValueTimeSeries()
            self._model.choices.add(new_dataset)
            self._model.value = new_dataset

        self._model.value.name = name
        self._model.value.value = List(dataset_values)
        self._model.value.unit = unit
Пример #9
0
 def change_commodities(self, command, index, model):
     if command == "Add":
         dialog_model = PropertyDialog(command + " Commodity", [
             PropertyLineEdit("Name"),
             PropertyPopupMenu("Type", self._commodities),
             PropertyPopupMenu("Resolution", List(list(DatasetResolution)))
         ])
         if self.show_dialog(dialog_model):
             name = dialog_model.values[0].value
             commodity_type = dialog_model.values[1].value
             resolution = dialog_model.values[2].value
             item = Commodity(name, commodity_type, resolution)
             self.add_item(model, item)
     else:
         item = model.retrieve_data()[index]
         dialog_model = PropertyDialog(command + " Commodity", [
             PropertyPopupMenu("Type", self._commodities,
                               item.commodity_type),
             PropertyPopupMenu("Resolution", List(list(DatasetResolution)),
                               item.resolution)
         ])
         if self.show_dialog(dialog_model):
             item.commodity_type = dialog_model.values[0].value
             item.resolution = dialog_model.values[1].value
Пример #10
0
    def on_commodity_change(self, commodity_type):
        """commodity line in scene selected"""
        if commodity_type is not None:
            self._ui.title_graph.setText(str(commodity_type))
            commodities = list(
                filter(
                    lambda commodity: commodity.commodity_type is
                    commodity_type,
                    self._model.project_elements.commodity_list))
            commodity_model = PropertyPopupMenu("Commodities",
                                                List(commodities))
            commodity_model.value_changed.connect(
                lambda: self.on_commodity_choose(commodity_model.value))
            self._ui.commodity_select.set_model(commodity_model)
            self.on_commodity_choose(commodity_model.value)

            self._project_ctrl.change_page(PageType.GRAPH)
Пример #11
0
    def change_properties(self, command, _, model):
        # not allowed to edit properties
        if command == "Edit":
            return

        single_value = "Single Value"
        time_series = "Timeseries"
        dialog_model = PropertyDialog(command + " Property", [
            PropertyLineEdit("Name"),
            PropertyLineEdit("Unit"),
            PropertyPopupMenu("Type", List([single_value, time_series]))
        ])
        if self.show_dialog(dialog_model):
            name = dialog_model.values[0].value
            unit = dialog_model.values[1].value
            prop_type = dialog_model.values[2].value
            item = PropertyPopupMenu(name, self._time_series) if prop_type == time_series \
                else PropertyLineEdit(name, "", unit)
            self.add_item(model, item)
Пример #12
0
    def __init__(self, section, model, commodity_types, process_cores):
        super().__init__()
        self._grid_size = QSize(GRID_WIDTH, GRID_HEIGHT)
        self._drop_indicator = self.init_drop_indicator()
        self._process_items = QGraphicsItemGroup()
        self._commodity_items = List([])
        self._bounding_rect = BoundingRect(section, model.process_list,
                                           commodity_types)
        self._clicked_item = None
        self._item_mouse_offset = None
        self._connect_line = None
        self._items_border = QRect()
        self._grid_border = QRect()
        self._section = section
        self._model = model
        self._cores = process_cores

        self._edit_mode = SelectConnect.SELECT
        self._draft_mode = False

        self.init_scene()
Пример #13
0
 def on_draft_mode(self):
     """draft tool button clicked"""
     section_cores = list(
         filter(lambda core: core.section == self._model.current_section,
                self._model.process_cores))
     cores = List([
         list(
             filter(lambda core: core.category == ProcessCategory.SUPPLY,
                    section_cores)),
         list(
             filter(lambda core: core.category == ProcessCategory.PROCESS,
                    section_cores)),
         list(
             filter(lambda core: core.category == ProcessCategory.STORAGE,
                    section_cores)),
         list(
             filter(lambda core: core.category == ProcessCategory.DEMAND,
                    section_cores))
     ])
     self._ui.draftbar.load_data(cores, PageType.DRAFT)
     self._project_ctrl.change_page(PageType.DRAFT)
Пример #14
0
    def __init__(self, dataset_dialog_model, dataset_dialog_controller):
        settings = Qt.Window | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
        super(DatasetDialogView, self).__init__(None, settings)
        self.setAttribute(Qt.WA_TranslucentBackground)

        self._model = dataset_dialog_model
        self._unit_model = PropertyLineEdit("Unit")
        self._resolution_popup_model = PropertyPopupMenu(
            "Resolution", List(list(DatasetResolution)))
        self._table_view_model = DatasetModel([])
        self._ctrl = dataset_dialog_controller
        self._ui = Ui_DatasetDialog()
        self._ui.setupUi(self)
        """connect widgets to controller"""
        self._ui.dataset_name.clicked.connect(self.gather_data)
        self._ui.button_add.clicked.connect(self.on_add_click)
        self._ui.cancel_button.clicked.connect(self.reject)
        self._ui.apply_button.clicked.connect(self.accept)
        self.accepted.connect(self.gather_data)
        """listen for model event signals"""
        self._model.value_changed.connect(self.on_dataset_change)
        self._resolution_popup_model.value_changed.connect(
            self.on_resolution_change)
        """initialize view"""
        self._new_dataset = False
        self._ui.dataset_name.set_model(self._model)
        self._ui.dataset_name.setReadOnly(False)
        self._ui.unit_value.set_model(self._unit_model)
        self._ui.resolution_value.set_model(self._resolution_popup_model)
        self._ui.dataset_value.setModel(self._table_view_model)
        self._ui.dataset_graph.set_model(self._table_view_model)
        if not self._model.value:
            self._new_process = True
            self.init_content()
        else:
            self.load_content(self._model.value)
Пример #15
0
    def change_variables(self, command, index, model):
        if command == "Add":
            # create model for dialog
            dialog_model = PropertyDialog("Add Variable", [
                PropertyLineEdit("Name"),
                PropertyLineEdit("Unit"),
                PropertyPopupMenu("Resolution", List(list(DatasetResolution))),
                PropertyPopupMenu("Pyomo Type", List(list(PyomoVarType))),
                PropertyPopupMenu("Display Result", List(list(DisplayType)))
            ])
            if self.show_dialog(dialog_model):
                # retrieve data from dialog model
                name = dialog_model.values[0].value
                unit = dialog_model.values[1].value
                resolution = dialog_model.values[2].value
                pyomo_type = dialog_model.values[3].value
                display_result = dialog_model.values[4].value
                item = PropertyVariable(name, resolution, pyomo_type, unit,
                                        display_result)
                # set list view data
                self.add_item(model, item)

        else:
            # create model for dialog
            item = model.retrieve_data()[index]
            dialog_model = PropertyDialog("Edit Variable", [
                PropertyLineEdit("Unit", item.unit),
                PropertyPopupMenu("Resolution", List(list(DatasetResolution)),
                                  item.resolution),
                PropertyPopupMenu("Pyomo Type", List(list(PyomoVarType)),
                                  item.type),
                PropertyPopupMenu("Display Result", List(list(DisplayType)),
                                  item.display)
            ])
            if self.show_dialog(dialog_model):
                # retrieve data from dialog model
                item.unit = dialog_model.values[0].value
                item.resolution = dialog_model.values[1].value
                item.type = dialog_model.values[2].value
                item.display = dialog_model.values[3].value
Пример #16
0
 def time_series():
     return List([])
Пример #17
0
    def process_cores(commodity_types, time_series):
        pv_core = ProcessCore()
        pv_core.name = "PV"
        pv_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        pv_core.category = ProcessCategory.PROCESS
        pv_core.section = OverviewSelection.ENERGY
        pv_core.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS,
                             "", DisplayType.YES),
            PropertyVariable("Shunt", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS)
        ])
        pv_core.data = List([PropertyValue("WACC", "0.15")])
        pv_core.properties = List([
            PropertyPopupMenu("Irradiation", time_series),
            PropertyLineEdit("Rated Power", "0.25", "kW"),
            PropertyLineEdit("Life Time", "25", "a"),
            PropertyLineEdit("Investment Costs", "1676", "$/kW"),
            PropertyLineEdit("Fixed Costs", "81", "$/kW"),
            PropertyLineEdit("Variable Costs", "0", "$/kWh")
        ])
        pv_core.outputs = List([Commodity("Electricity", commodity_types[0], DatasetResolution.HOURLY)])
        pv_core.objective_function = "amount * rated_power * " \
                                     "(investment_costs * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc) " \
                                     "+ fixed_costs) ++ electricity * variable_costs"
        pv_core.constraints = "electricity + shunt == amount * rated_power * irradiation"

        diesel_core = ProcessCore()
        diesel_core.name = "Diesel Generator"
        diesel_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        diesel_core.category = ProcessCategory.PROCESS
        diesel_core.section = OverviewSelection.ENERGY
        diesel_core.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS,
                             "", DisplayType.YES)
        ])
        diesel_core.data = List([PropertyValue("WACC", "0.15"),
                                 PropertyValue("Energy Density", "10", "kWh/l"),])
        diesel_core.properties = List([
            PropertyLineEdit("Efficiency", "0.28", ""),
            PropertyLineEdit("Rated Power", "5", "kW"),
            PropertyLineEdit("Life Time", "23", "a"),
            PropertyLineEdit("Investment Costs", "324", "$/kW"),
            PropertyLineEdit("Fixed Costs", "26.9", "$/kW"),
            PropertyLineEdit("Variable Costs", "0.01", "$/kWh")
        ])
        diesel_core.inputs = List([Commodity("Diesel", commodity_types[1], DatasetResolution.HOURLY)])
        diesel_core.outputs = List([Commodity("Electricity", commodity_types[0], DatasetResolution.HOURLY)])
        diesel_core.objective_function = "amount * rated_power * " \
                                         "(investment_costs * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc) " \
                                         "+ fixed_costs) ++ electricity * variable_costs"
        diesel_core.constraints = """electricity <= amount * rated_power
        electricity == diesel * energy_density * efficiency"""

        diesel_market_core = ProcessCore()
        diesel_market_core.name = "Diesel Market"
        diesel_market_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        diesel_market_core.category = ProcessCategory.SUPPLY
        diesel_market_core.section = OverviewSelection.ENERGY
        diesel_market_core.properties = List([PropertyLineEdit("Diesel Price", "1.06", "$/l")])
        diesel_market_core.outputs = List([Commodity("Diesel", commodity_types[1], DatasetResolution.HOURLY)])
        diesel_market_core.objective_function = "diesel_price * diesel"

        biowaste_market_core = ProcessCore()
        biowaste_market_core.name = "Biowaste Market"
        biowaste_market_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        biowaste_market_core.category = ProcessCategory.SUPPLY
        biowaste_market_core.section = OverviewSelection.BUSINESS
        biowaste_market_core.properties = List([
            PropertyLineEdit("Maize Straw Price", "500", "$/kg"),
            PropertyLineEdit("Chicken Manure Price", "500", "$/kg"),
            PropertyLineEdit("Pig Manure Price", "500", "$/kg")
        ])
        biowaste_market_core.outputs = List([
            Commodity("Maize Straw", commodity_types[3], DatasetResolution.HOURLY),
            Commodity("Chicken Manure", commodity_types[3], DatasetResolution.HOURLY),
            Commodity("Pig Manure", commodity_types[3], DatasetResolution.HOURLY)
        ])
        biowaste_market_core.objective_function = "maize_straw_price * maize_straw " \
                                                  "++ chicken_manure_price * chicken_manure " \
                                                  "++ pig_manure_price * pig_manure"
        food_market = ProcessCore()
        food_market.name = "Food Market"
        food_market.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        food_market.category = ProcessCategory.DEMAND
        food_market.section = OverviewSelection.BUSINESS
        food_market.properties = List([
            PropertyLineEdit("Maize Sell Price", "0.5", "$/kg")
        ])
        food_market.inputs = List([
            Commodity("Maize", commodity_types[5], DatasetResolution.HOURLY)
        ])
        food_market.objective_function = "- maize_sell_price * maize"

        digester_core = ProcessCore()
        digester_core.name = "Biogas Digester"
        digester_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        digester_core.category = ProcessCategory.PROCESS
        digester_core.section = OverviewSelection.ENERGY
        digester_core.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS,
                             "", DisplayType.YES),
            PropertyVariable("Carbon", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Hydrogen", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Oxygen", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Nitrogen", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Sulphur", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_REALS)
        ])
        digester_core.data = List([
            PropertyValue("WACC", "0.15"),
            PropertyValue("Carbon MS", "0.39961"),
            PropertyValue("Hydrogen MS", "0.05462"),
            PropertyValue("Oxygen MS", "0.52694"),
            PropertyValue("Nitrogen MS", "0.01441"),
            PropertyValue("Sulphur MS", "0.00461"),
            PropertyValue("Water MS", "0.00006"),
            PropertyValue("Carbon CM", "0.07609"),
            PropertyValue("Hydrogen CM", "0.01334"),
            PropertyValue("Oxygen CM", "0.08046"),
            PropertyValue("Nitrogen CM", "0.00877"),
            PropertyValue("Sulphur CM", "0.00106"),
            PropertyValue("Water CM", "0.00075"),
            PropertyValue("Carbon PM", "0.1435"),
            PropertyValue("Hydrogen PM", "0.0193"),
            PropertyValue("Oxygen PM", "0.1191"),
            PropertyValue("Nitrogen PM", "0.0144"),
            PropertyValue("Sulphur PM", "0.0029"),
            PropertyValue("Water PM", "0.0005"),
        ])
        digester_core.properties = List([
            PropertyLineEdit("Rated Power", "0.2", "m3/h"),
            PropertyLineEdit("Life Time", "20", "a"),
            PropertyLineEdit("Investment Costs", "4512", "$/(m3/h)"),
            PropertyLineEdit("Fixed Costs", "362", "$/(m3/h)"),
            PropertyLineEdit("Variable Costs", "0", "$/m3")
        ])
        digester_core.inputs = List([
            Commodity("Maize Straw", commodity_types[3], DatasetResolution.YEARLY),
            Commodity("Chicken Manure", commodity_types[3], DatasetResolution.YEARLY),
            Commodity("Pig Manure", commodity_types[3], DatasetResolution.YEARLY),
            Commodity("Water", commodity_types[4], DatasetResolution.YEARLY)
        ])
        digester_core.outputs = List([
            Commodity("CH4", commodity_types[2], DatasetResolution.YEARLY),
            Commodity("CO2", commodity_types[2], DatasetResolution.YEARLY),
            Commodity("NH3", commodity_types[2], DatasetResolution.YEARLY),
            Commodity("H2S", commodity_types[2], DatasetResolution.YEARLY),
            Commodity("Water", commodity_types[4], DatasetResolution.YEARLY)
        ])
        digester_core.objective_function = "amount * rated_power * " \
                                           "(investment_costs * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc) " \
                                           "+ fixed_costs) ++ 8760 * (ch4 + co2 + nh3 + h2s) * variable_costs"
        digester_core.constraints = """
        carbon == carbon_ms * maize_straw + carbon_cm * chicken_manure + carbon_pm * pig_manure
        hydrogen == hydrogen_ms * maize_straw + hydrogen_cm * chicken_manure + hydrogen_pm * pig_manure
        oxygen == oxygen_ms * maize_straw + oxygen_cm * chicken_manure + oxygen_pm * pig_manure
        nitrogen == nitrogen_ms * maize_straw + nitrogen_cm * chicken_manure + nitrogen_pm * pig_manure
        sulphur == sulphur_ms * maize_straw + sulphur_cm * chicken_manure + sulphur_pm * pig_manure
        water_ms * maize_straw + water_cm * chicken_manure + water_pm * pig_manure + water_in - water_out >= (maize_straw + chicken_manure + pig_manure) * 0.3  
        carbon >= 20 * nitrogen
        carbon <= 30 * nitrogen
        ch4 == 0.930645204 * carbon + 2.772522162 * hydrogen - 0.349324969 * oxygen - 0.598518942 * nitrogen - 0.174297526 * sulphur
        co2 == 0.927066656 * carbon - 2.761861167 * hydrogen + 0.347981733 * oxygen + 0.596217497 * nitrogen + 0.173627311 * sulphur
        nh3 == 1.576155953 * nitrogen
        h2s == 0.691998896 * sulphur
        (ch4 + co2 + nh3 + h2s) <= amount * rated_power
        """

        biogas_gen_core = ProcessCore()
        biogas_gen_core.name = "Biogas Generator"
        biogas_gen_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        biogas_gen_core.category = ProcessCategory.PROCESS
        biogas_gen_core.section = OverviewSelection.ENERGY
        biogas_gen_core.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS,
                             "", DisplayType.YES)
            ])
        biogas_gen_core.data = List([PropertyValue("WACC", "0.15"),
                                     PropertyValue("Energy Density", "10", "kWh/m3")])
        biogas_gen_core.properties = List([
            PropertyLineEdit("Efficiency", "0.3", ""),
            PropertyLineEdit("Rated Power", "5", "kW"),
            PropertyLineEdit("Life Time", "23", "a"),
            PropertyLineEdit("Investment Costs", "652", "$/kW"),
            PropertyLineEdit("Fixed Costs", "26.9", "$/kW"),
            PropertyLineEdit("Variable Costs", "0.01", "$/kWh")
        ])
        biogas_gen_core.inputs = List([
            Commodity("CH4", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("CO2", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("NH3", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("H2S", commodity_types[2], DatasetResolution.HOURLY)
        ])
        biogas_gen_core.outputs = List([Commodity("Electricity", commodity_types[0], DatasetResolution.HOURLY)])
        biogas_gen_core.objective_function = "amount * rated_power * " \
                                         "(investment_costs * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc) " \
                                         "+ fixed_costs) ++ electricity * variable_costs"
        biogas_gen_core.constraints = """electricity <= amount * rated_power
                electricity == ch4 * energy_density * efficiency"""

        battery_core = ProcessCore()
        battery_core.name = "Battery"
        battery_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        battery_core.category = ProcessCategory.STORAGE
        battery_core.section = OverviewSelection.ENERGY
        battery_core.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS,
                             "", DisplayType.YES),
            PropertyVariable("Content", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS)
            ])
        battery_core.data = List([PropertyValue("WACC", "0.15")])
        battery_core.properties = List([
            PropertyLineEdit("Efficiency", "0.877", ""),
            PropertyLineEdit("Rated Power", "5", "kWh"),
            PropertyLineEdit("Life Time", "7.7", "a"),
            PropertyLineEdit("Investment Costs", "437", "$/kWh"),
            PropertyLineEdit("Fixed Costs", "30", "$/kWh")
        ])
        battery_core.inputs = List([Commodity("Electricity", commodity_types[0], DatasetResolution.HOURLY)])
        battery_core.outputs = List([Commodity("Electricity", commodity_types[0], DatasetResolution.HOURLY)])
        battery_core.objective_function = "amount * rated_power * " \
                                         "(investment_costs * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc) " \
                                         "+ fixed_costs)"
        battery_core.constraints = """
        content == content[-1] + electricity_in * efficiency - electricity_out / efficiency
        content <= amount * rated_power
        """

        biogas_tank_core = ProcessCore()
        biogas_tank_core.name = "Biogas Tank"
        biogas_tank_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        biogas_tank_core.category = ProcessCategory.STORAGE
        biogas_tank_core.section = OverviewSelection.ENERGY
        biogas_tank_core.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS,
                             "", DisplayType.YES),
            PropertyVariable("Content", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS)
        ])
        biogas_tank_core.data = List([PropertyValue("WACC", "0.15")])
        biogas_tank_core.properties = List([
            PropertyLineEdit("Size", "5", "m3"),
            PropertyLineEdit("Life Time", "10", "a"),
            PropertyLineEdit("Investment Costs", "19", "$/m3"),
            PropertyLineEdit("Fixed Costs", "0", "$/m3"),
            PropertyLineEdit("Variable Costs", "0", "$/m3")
        ])
        biogas_tank_core.inputs = List([
            Commodity("CH4", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("CO2", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("NH3", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("H2S", commodity_types[2], DatasetResolution.HOURLY)
        ])
        biogas_tank_core.outputs = List([
            Commodity("CH4", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("CO2", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("NH3", commodity_types[2], DatasetResolution.HOURLY),
            Commodity("H2S", commodity_types[2], DatasetResolution.HOURLY)
        ])
        biogas_tank_core.objective_function = "amount * size * " \
                                             "(investment_costs * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc) " \
                                             "+ fixed_costs)"
        biogas_tank_core.constraints = """
                content == content[-1] + ch4_in / 0.6 - ch4_out / 0.6
                co2_in == 0.3/0.6 * ch4_in
                co2_out == 0.3/0.6 * ch4_out
                nh3_in == 0.0995/0.6 * ch4_in
                nh3_out == 0.0995/0.6 * ch4_out
                h2s_in == 0.0005/0.6 * ch4_in
                h2s_out == 0.0005/0.6 * ch4_out
                content <= amount * size
                """

        electrical_demand_core = ProcessCore()
        electrical_demand_core.name = "Village Demand"
        electrical_demand_core.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        electrical_demand_core.category = ProcessCategory.DEMAND
        electrical_demand_core.section = OverviewSelection.ENERGY
        electrical_demand_core.properties = List([PropertyPopupMenu("Demand", time_series)])
        electrical_demand_core.inputs = List([Commodity("Electricity", commodity_types[0], DatasetResolution.HOURLY)])
        electrical_demand_core.constraints = "electricity == demand"

        water_pump = ProcessCore()
        water_pump.name = "Water Pump"
        water_pump.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        water_pump.category = ProcessCategory.PROCESS
        water_pump.section = OverviewSelection.WATER
        water_pump.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS,
                             "", DisplayType.YES)
            ])
        water_pump.data = List([
            PropertyValue("WACC", "0.15"),
            PropertyValue("Water Density", "1000", "kg/m3"),
            PropertyValue("Gravitation", "9.81", "m/s2")
        ])
        water_pump.properties = List([
            PropertyLineEdit("Rated Power", "5", "m3/h"),
            PropertyLineEdit("Efficiency", "0.5"),
            PropertyLineEdit("Total Dynamic Head", "38.1", "m"),
            PropertyLineEdit("Life Time", "25", "a"),
            PropertyLineEdit("Investment Costs", "1000", "$/(m3/h)"),
            PropertyLineEdit("Fixed Costs", "80", "$/(m3/h)"),
            PropertyLineEdit("Variable Costs", "0.1", "$/m3")
        ])
        water_pump.inputs = List([
            Commodity("Groundwater", commodity_types[4], DatasetResolution.HOURLY),
            Commodity("Electricity", commodity_types[0], DatasetResolution.HOURLY)
        ])
        water_pump.outputs = List([
            Commodity("Water", commodity_types[4], DatasetResolution.HOURLY)
            ])
        water_pump.objective_function = "amount * rated_power * (" \
                                        "investment_costs * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc)" \
                                        " + fixed_costs) ++ water * variable_costs"
        water_pump.constraints = """
        electricity * efficiency * 1000000 == water_density * gravitation * total_dynamic_head * water
        water == groundwater
        water <= amount * rated_power
        """

        village_water_demand = ProcessCore()
        village_water_demand.name = "Village Water Demand"
        village_water_demand.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        village_water_demand.category = ProcessCategory.DEMAND
        village_water_demand.section = OverviewSelection.WATER
        village_water_demand.properties = List([
            PropertyPopupMenu("Demand", time_series)
        ])
        village_water_demand.inputs = List([
            Commodity("Water", commodity_types[4], DatasetResolution.HOURLY)
        ])
        village_water_demand.constraints = "demand == water"

        aquifer = ProcessCore()
        aquifer.name = "Aquifer"
        aquifer.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        aquifer.category = ProcessCategory.STORAGE
        aquifer.section = OverviewSelection.WATER
        aquifer.variables = List([
            PropertyVariable("Content", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Shunt", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Influx", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS)
        ])
        aquifer.properties = List([
            PropertyLineEdit("Catchment Area", "2", "km2"),
            PropertyLineEdit("Aquifer Height", "0.8", "m")
        ])
        aquifer.inputs = List([
            Commodity("Groundwater", commodity_types[4], DatasetResolution.HOURLY)
        ])
        aquifer.outputs = List([
            Commodity("Groundwater", commodity_types[4], DatasetResolution.HOURLY)
        ])
        aquifer.objective_function = "influx * 1000"
        aquifer.constraints = """
        content == content[-1] + groundwater_in - groundwater_out + influx - shunt
        content <= aquifer_height * catchment_area * 1000000"""

        maize_field = ProcessCore()
        maize_field.name = "Maize Field"
        maize_field.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        maize_field.category = ProcessCategory.PROCESS
        maize_field.section = OverviewSelection.FOOD
        maize_field.variables = List([
            PropertyVariable("Evaporation Canopy", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Evaporation Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Evaporation Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number 1", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number 3", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Runoff", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Capacity Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Capacity Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Content Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Topsoil Overflow", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("Content Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("w1", DatasetResolution.DAILY, PyomoVarType.BOOLEAN),
            PropertyVariable("w2", DatasetResolution.DAILY, PyomoVarType.BOOLEAN),
            PropertyVariable("w3", DatasetResolution.DAILY, PyomoVarType.BOOLEAN),
            PropertyVariable("x1", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("x2", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("x3", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("y1", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("y2", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS),
            PropertyVariable("y3", DatasetResolution.DAILY, PyomoVarType.NON_NEGATIVE_REALS)
        ])
        maize_field.data = List([
            PropertyValue("WACC", "0.15"),
            PropertyValue("Curve Number 2", "85"),
            PropertyValue("Evaporation Topsoil Percentage", "1"),
            PropertyValue("Evaporation Middlesoil Percentage", "0.75"),
            PropertyValue("Biomass", "20000", "kg/ha"),
            PropertyValue("LAI max", "6.1"),
            PropertyValue("Canopy max", "4", "mm"),
            PropertyValue("Field Capacity", "0.32"),
            PropertyValue("Wilting Point", "0.15"),
            PropertyValue("Topsoil Thickness", "400", "mm"),
            PropertyValue("Seed Amount", "25", "kg/ha"),
            PropertyValue("Compound D Amount", "165", "kg/ha"),
            PropertyValue("Top Dressing Amount", "200", "kg/ha"),
            PropertyValue("Pesticides Amount", "200", "kg/ha"),
            PropertyValue("Labor Amount", "814", "h/ha"),
            PropertyValue("Maize Yield", "8000", "kg/ha"),
            PropertyValue("Maize Straw Yield", "8000", "kg/ha"),
        ])
        maize_field.properties = List([
            PropertyPopupMenu("Precipitation", time_series),
            PropertyPopupMenu("Evapotranspiration", time_series),
            PropertyPopupMenu("Leaf Area Index", time_series),
            PropertyPopupMenu("k_c", time_series),
            PropertyPopupMenu("Harvest Series", time_series),
            PropertyLineEdit("Life Time", "50", "a"),
            PropertyLineEdit("Irrigation System Investment", "2000", "$/ha"),
            PropertyLineEdit("Irrigation System Fixed Costs", "40", "$/ha"),
            PropertyLineEdit("Seed Price", "2.3", "$/kg"),
            PropertyLineEdit("Compound D Price", "1.04", "$/kg"),
            PropertyLineEdit("Top Dressing Price", "5.08", "$/kg"),
            PropertyLineEdit("Pesticides Price", "1.41", "$/kg"),
            PropertyLineEdit("Labor Price", "1.25", "$/h")
        ])
        maize_field.inputs = List([
            Commodity("Crop Land", commodity_types[6], DatasetResolution.YEARLY),
            Commodity("Water", commodity_types[4], DatasetResolution.DAILY)
        ])
        maize_field.outputs = List([
            Commodity("Groundwater", commodity_types[4], DatasetResolution.DAILY),
            Commodity("Maize", commodity_types[5], DatasetResolution.WEEKLY),
            Commodity("Maize Straw", commodity_types[3], DatasetResolution.WEEKLY)
        ])
        maize_field.objective_function = """crop_land * (irrigation_system_investment * ((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc)
         + irrigation_system_fixed_costs) 
        ++ (seed_price*seed_amount + compound_d_price*compound_d_amount + top_dressing_price*top_dressing_amount + 
        pesticides_price*pesticides_amount + labor_price*labor_amount)/maize_yield*maize*168 ++ content_middlesoil*10"""
        maize_field.constraints = """
        evaporation_canopy = min(precipitation, leaf_area_index/lai_max * canopy_max, evapotranspiration)
        evaporation_topsoil = (evapotranspiration - evaporation_canopy)*evaporation_topsoil_percentage*exp(-5*10**(-5)*biomass)
        evaporation_middlesoil = max(0, (evapotranspiration - evaporation_canopy-evaporation_topsoil)*evaporation_topsoil_percentage* exp(-5*10**(-5)*biomass))
        capacity_topsoil = (field_capacity-wilting_point)*topsoil_thickness
        capacity_middlesoil = (field_capacity-wilting_point-0.1)*(500 - topsoil_thickness)
        curve_number_1 = curve_number_2 - 20*(100-curve_number_2)/(100-curve_number_2+exp(2.533-0.0636*(100-curve_number_2)))
        curve_number_3 = curve_number_2*exp(0.00673*(100-curve_number_2))
        curve_number = curve_number_3 if (precipitation-evaporation_canopy > capacity_topsoil) else (curve_number_1 if (precipitation-evaporation_canopy < 0.001) else curve_number_2)
        runoff = min(precipitation-evaporation_canopy, (precipitation-evaporation_canopy-0.2*25.4*(1000/curve_number-10))**2/(precipitation-evaporation_canopy+0.5*25.4*(1000/curve_number_2-10)))
        content_topsoil[-1] + water + (precipitation - evaporation_canopy - runoff - evaporation_topsoil - evapotranspiration * k_c) * crop_land * 10/24 == x1 + y1 + topsoil_overflow
        content_topsoil == x1 + y1
        x1 <= capacity_topsoil*crop_land*10/24 - y1
        topsoil_overflow <= w1*48*10/24*100
        topsoil_overflow <= crop_land*10/24*max(0, precipitation - evaporation_canopy - runoff - evaporation_topsoil - evapotranspiration * k_c)
        y1 <= w1*capacity_topsoil*100*10/24
        y1 <= capacity_topsoil*crop_land*10/24
        y1 >= capacity_topsoil*crop_land*10/24 - (1-w1)*capacity_topsoil*100*10/24
        content_middlesoil[-1] + topsoil_overflow - evaporation_middlesoil * crop_land*10/24 == x2 + y2 - x3 + groundwater
        content_middlesoil == x2 + y2
        x2 <= capacity_middlesoil*crop_land*10/24 - y2 - y3
        x3 <= evaporation_middlesoil*10/24*100*w3
        x3 <= evaporation_middlesoil*crop_land*10/24 
        w2 + w3 <= 1
        groundwater <= w2*48*10/24*100
        groundwater <= crop_land*10/24*max(0, precipitation - evaporation_canopy - runoff - evaporation_topsoil - evapotranspiration * k_c)
        y2 <= w2*capacity_middlesoil*100*10/24
        y2 <= capacity_middlesoil*crop_land*10/24
        y2 >= capacity_middlesoil*crop_land*10/24 - (1-w2)*capacity_middlesoil*100*10/24
        y3 <= w3*evaporation_middlesoil*100*10/24
        y3 <= evaporation_middlesoil*crop_land*10/24
        y3 >= evaporation_middlesoil*crop_land*10/24 - (1-w3)*evaporation_middlesoil*100*10/24
        maize_straw == harvest_series * crop_land * maize_straw_yield / 168
        maize == harvest_series * crop_land * maize_yield / 168"""

        land_distribution = ProcessCore()
        land_distribution.name = "Land Distribution"
        land_distribution.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        land_distribution.category = ProcessCategory.SUPPLY
        land_distribution.section = OverviewSelection.FOOD
        land_distribution.properties = List([
            PropertyLineEdit("Total Land Size", "100", "ha"),
            PropertyLineEdit("Fallow Land Restriction", "100", "ha"),
            PropertyLineEdit("Forest Land Restriction", "100", "ha"),
            PropertyLineEdit("Crop Land Restriction", "100", "ha"),
        ])
        land_distribution.outputs = List([
            Commodity("Fallow Land", commodity_types[6], DatasetResolution.YEARLY),
            Commodity("Forest Land", commodity_types[6], DatasetResolution.YEARLY),
            Commodity("Crop Land", commodity_types[6], DatasetResolution.YEARLY)
        ])
        land_distribution.objective_function = ""
        land_distribution.constraints = """fallow_land <= fallow_land_restriction
        crop_land <= crop_land_restriction
        forest_land <= forest_land_restriction
        total_land_size == fallow_land + crop_land + forest_land"""

        maize_straw_bunker = ProcessCore()
        maize_straw_bunker.name = "Maize Straw Silo"
        maize_straw_bunker.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        maize_straw_bunker.category = ProcessCategory.STORAGE
        maize_straw_bunker.section = OverviewSelection.FOOD
        maize_straw_bunker.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS),
            PropertyVariable("Content", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS)
        ])
        maize_straw_bunker.data = List([
            PropertyValue("WACC", "0.15")
        ])
        maize_straw_bunker.properties = List([
            PropertyLineEdit("Size", "5", "t"),
            PropertyLineEdit("Life Time", "50", "a"),
            PropertyLineEdit("Investment Cost", "100", "$/kg")
        ])
        maize_straw_bunker.inputs = List([
            Commodity("Maize Straw", commodity_types[3], DatasetResolution.HOURLY)
        ])
        maize_straw_bunker.outputs = List([
            Commodity("Maize Straw", commodity_types[3], DatasetResolution.HOURLY)
        ])
        maize_straw_bunker.objective_function = "size*amount*investment_cost * " \
                                                "((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc)"
        maize_straw_bunker.constraints = """content == content[-1] + maize_straw_in - maize_straw_out
        content <= size*amount*1000"""

        water_tank = ProcessCore()
        water_tank.name = "Water Tank"
        water_tank.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        water_tank.category = ProcessCategory.STORAGE
        water_tank.section = OverviewSelection.WATER
        water_tank.variables = List([
            PropertyVariable("Amount", DatasetResolution.YEARLY, PyomoVarType.NON_NEGATIVE_INTEGERS),
            PropertyVariable("Content", DatasetResolution.HOURLY, PyomoVarType.NON_NEGATIVE_REALS)
        ])
        water_tank.data = List([
            PropertyValue("WACC", "0.15")
        ])
        water_tank.properties = List([
            PropertyLineEdit("Size", "20", "m3"),
            PropertyLineEdit("Life Time", "25", "a"),
            PropertyLineEdit("Investment Cost", "35", "$/m3"),
            PropertyLineEdit("Fixed Cost", "0.35", "$/m3")
        ])
        water_tank.inputs = List([
            Commodity("Water", commodity_types[4], DatasetResolution.HOURLY)
        ])
        water_tank.outputs = List([
            Commodity("Water", commodity_types[4], DatasetResolution.HOURLY)
        ])
        water_tank.objective_function = "size*amount*(investment_cost * " \
                                        "((1+wacc)**life_time-1)/((1+wacc)**life_time*wacc) + fixed_cost)"
        water_tank.constraints = """content == content[-1] + water_in - water_out
                content <= size*amount*1000"""

        forest_land = ProcessCore()
        forest_land.name = "Forest Land"
        forest_land.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        forest_land.category = ProcessCategory.SUPPLY
        forest_land.section = OverviewSelection.WATER
        forest_land.variables = List([
            PropertyVariable("Evaporation Canopy", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Evaporation Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Evaporation Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number 1", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number 3", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Runoff", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Capacity Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Capacity Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Content Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Topsoil Overflow", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Content Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO)
        ])
        forest_land.data = List([
            PropertyValue("WACC", "0.15"),
            PropertyValue("Curve Number 2", "79"),
            PropertyValue("Evaporation Topsoil Percentage", "1"),
            PropertyValue("Evaporation Middlesoil Percentage", "0.75"),
            PropertyValue("Biomass", "80000", "kg/ha"),
            PropertyValue("LAI max", "2.5"),
            PropertyValue("Canopy max", "3.5", "mm"),
            PropertyValue("Field Capacity", "0.32"),
            PropertyValue("Wilting Point", "0.15"),
            PropertyValue("Topsoil Thickness", "200", "mm")
        ])
        forest_land.properties = List([
            PropertyPopupMenu("Precipitation", time_series),
            PropertyPopupMenu("Evapotranspiration", time_series),
            PropertyPopupMenu("Leaf Area Index", time_series)
        ])
        forest_land.inputs = List([
            Commodity("Forest Land", commodity_types[6], DatasetResolution.YEARLY)
        ])
        forest_land.outputs = List([
            Commodity("Groundwater", commodity_types[4], DatasetResolution.DAILY)
        ])
        forest_land.constraints = """
                evaporation_canopy = min(precipitation, leaf_area_index/lai_max * canopy_max, evapotranspiration)
                evaporation_topsoil = (evapotranspiration - evaporation_canopy)*evaporation_topsoil_percentage*exp(-5*10**(-5)*biomass)
                evaporation_middlesoil = max(0, (evapotranspiration - evaporation_canopy-evaporation_topsoil)*evaporation_topsoil_percentage* exp(-5*10**(-5)*biomass))
                capacity_topsoil = (field_capacity-wilting_point)*topsoil_thickness
                capacity_middlesoil = (field_capacity-wilting_point-0.1)*(500 - topsoil_thickness)
                curve_number_1 = curve_number_2 - 20*(100-curve_number_2)/(100-curve_number_2+exp(2.533-0.0636*(100-curve_number_2)))
                curve_number_3 = curve_number_2*exp(0.00673*(100-curve_number_2))
                curve_number = curve_number_3 if (precipitation-evaporation_canopy > capacity_topsoil) else (curve_number_1 if (precipitation-evaporation_canopy < 0.001) else curve_number_2)
                runoff = min(precipitation-evaporation_canopy, (precipitation-evaporation_canopy-0.2*25.4*(1000/curve_number-10))**2/(precipitation-evaporation_canopy+0.5*25.4*(1000/curve_number_2-10)))
                content_topsoil = min((content_topsoil[-1] if content_topsoil[-1] else 0.2*capacity_topsoil) + precipitation - evaporation_canopy - runoff - evaporation_topsoil - transpiration_plant, capacity_topsoil)
                topsoil_overflow = max(0, (content_topsoil[-1] if content_topsoil[-1] else 0.2*capacity_topsoil) + precipitation - evaporation_canopy - runoff - evaporation_topsoil - transpiration_plant - capacity_topsoil)
                content_middlesoil = min((content_middlesoil[-1] if content_middlesoil[-1] else 0.2*capacity_middlesoil) + topsoil_overflow - evaporation_middlesoil, capacity_middlesoil)
                groundwater == forest_land * 10/24 * max(0, (content_middlesoil[-1] if content_middlesoil[-1] else 0.2*capacity_middlesoil) + topsoil_overflow - evaporation_middlesoil - capacity_middlesoil)"""

        fallow_land = ProcessCore()
        fallow_land.name = "Fallow Land"
        fallow_land.icon = QIcon(QPixmap(":/icons/img/[email protected]"))
        fallow_land.category = ProcessCategory.SUPPLY
        fallow_land.section = OverviewSelection.WATER
        fallow_land.variables = List([
            PropertyVariable("Evaporation Canopy", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Evaporation Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Evaporation Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number 1", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Curve Number 3", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Runoff", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Capacity Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Capacity Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Content Topsoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Topsoil Overflow", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO),
            PropertyVariable("Content Middlesoil", DatasetResolution.DAILY, PyomoVarType.NON_PYOMO)
        ])
        fallow_land.data = List([
            PropertyValue("WACC", "0.15"),
            PropertyValue("Curve Number 2", "93"),
            PropertyValue("Evaporation Topsoil Percentage", "1"),
            PropertyValue("Evaporation Middlesoil Percentage", "0.75"),
            PropertyValue("Biomass", "30", "kg/ha"),
            PropertyValue("LAI max", "0.2"),
            PropertyValue("Canopy max", "0.2", "mm"),
            PropertyValue("Field Capacity", "0.32"),
            PropertyValue("Wilting Point", "0.15"),
            PropertyValue("Topsoil Thickness", "50", "mm")
        ])
        fallow_land.properties = List([
            PropertyPopupMenu("Precipitation", time_series),
            PropertyPopupMenu("Evapotranspiration", time_series),
            PropertyPopupMenu("Leaf Area Index", time_series)
        ])
        fallow_land.inputs = List([
            Commodity("Fallow Land", commodity_types[6], DatasetResolution.YEARLY)
        ])
        fallow_land.outputs = List([
            Commodity("Groundwater", commodity_types[4], DatasetResolution.DAILY)
        ])
        fallow_land.constraints = """
                evaporation_canopy = min(precipitation, leaf_area_index/lai_max * canopy_max, evapotranspiration)
                evaporation_topsoil = (evapotranspiration - evaporation_canopy)*evaporation_topsoil_percentage*exp(-5*10**(-5)*biomass)
                evaporation_middlesoil = max(0, (evapotranspiration - evaporation_canopy-evaporation_topsoil)*evaporation_topsoil_percentage* exp(-5*10**(-5)*biomass))
                capacity_topsoil = (field_capacity-wilting_point)*topsoil_thickness
                capacity_middlesoil = (field_capacity-wilting_point-0.1)*(500 - topsoil_thickness)
                curve_number_1 = curve_number_2 - 20*(100-curve_number_2)/(100-curve_number_2+exp(2.533-0.0636*(100-curve_number_2)))
                curve_number_3 = curve_number_2*exp(0.00673*(100-curve_number_2))
                curve_number = curve_number_3 if (precipitation-evaporation_canopy > capacity_topsoil) else (curve_number_1 if (precipitation-evaporation_canopy < 0.001) else curve_number_2)
                runoff = min(precipitation-evaporation_canopy, (precipitation-evaporation_canopy-0.2*25.4*(1000/curve_number-10))**2/(precipitation-evaporation_canopy+0.5*25.4*(1000/curve_number_2-10)))
                content_topsoil = min((content_topsoil[-1] if content_topsoil[-1] else 0.2*capacity_topsoil) + precipitation - evaporation_canopy - runoff - evaporation_topsoil - transpiration_plant, capacity_topsoil)
                topsoil_overflow = max(0, (content_topsoil[-1] if content_topsoil[-1] else 0.2*capacity_topsoil) + precipitation - evaporation_canopy - runoff - evaporation_topsoil - transpiration_plant - capacity_topsoil)
                content_middlesoil = min((content_middlesoil[-1] if content_middlesoil[-1] else 0.2*capacity_middlesoil) + topsoil_overflow - evaporation_middlesoil, capacity_middlesoil)
                groundwater == fallow_land * 10/24 * max(0, (content_middlesoil[-1] if content_middlesoil[-1] else 0.2*capacity_middlesoil) + topsoil_overflow - evaporation_middlesoil - capacity_middlesoil)"""

        return List([pv_core, diesel_core, digester_core, diesel_market_core, biowaste_market_core, battery_core,
                     biogas_tank_core, biogas_gen_core, electrical_demand_core, village_water_demand, water_pump,
                     aquifer, maize_field, land_distribution, food_market, maize_straw_bunker, forest_land, fallow_land,
                     water_tank])
Пример #18
0
    def __init__(self, model, project_controller):
        super(ProjectView, self).__init__()

        self._model = model
        self._project_ctrl = project_controller
        self._ui = Ui_MainWindow()
        self._ui.setupUi(self)
        """connect widgets to controller"""
        # menu bar
        self._ui.action_save.triggered.connect(self._project_ctrl.save_model)
        self._ui.action_close.triggered.connect(self.close)
        self._ui.action_commodities.triggered.connect(
            self._project_ctrl.open_commodity_dialog)
        self._ui.action_processes.triggered.connect(
            self._project_ctrl.open_process_dialog)
        self._ui.action_timeseries.triggered.connect(
            self._project_ctrl.open_time_series_dialog)
        self._ui.action_scenarios.triggered.connect(
            self._project_ctrl.open_scenario_dialog)
        self._ui.action_execute.triggered.connect(
            self._project_ctrl.run_optimization)
        # overview toolbar
        self._ui.tool_scenarios.clicked.connect(
            self._project_ctrl.open_scenario_dialog)
        self._ui.tool_run.clicked.connect(self._project_ctrl.run_optimization)
        self._ui.tool_export.clicked.connect(
            self._project_ctrl.open_export_dialog)
        self._ui.tool_sidebar_overview.clicked.connect(
            lambda: self._project_ctrl.toggle_sidebar(PageType.OVERVIEW))
        # overview content
        self._ui.logo.hovered.connect(self._project_ctrl.change_icon)
        self._ui.logo.clicked.connect(
            lambda: self._project_ctrl.change_page(PageType.SECTIONS))
        # sections toolbar
        self._ui.tool_back_sections.clicked.connect(
            lambda: self._project_ctrl.change_page(PageType.OVERVIEW))
        self._ui.tool_draft.clicked.connect(self.on_draft_mode)
        self._ui.tool_sidebar_sections.clicked.connect(
            lambda: self._project_ctrl.toggle_sidebar(PageType.SECTIONS))
        # sections content
        self._ui.section_view.sidebar_toggled.connect(
            self.show_section_sidebar)
        self._ui.section_view.commodity_clicked.connect(
            self._project_ctrl.set_current_commodity)

        # draft toolbar
        self._ui.tool_back_draft.clicked.connect(
            lambda: self._project_ctrl.change_page(PageType.SECTIONS))
        self._ui.tool_cursor.clicked.connect(
            lambda: self._project_ctrl.toggle_select_connect(SelectConnect.
                                                             SELECT))
        self._ui.tool_connect.clicked.connect(
            lambda: self._project_ctrl.toggle_select_connect(SelectConnect.
                                                             CONNECT))
        self._ui.tool_sidebar_draft.clicked.connect(
            lambda: self._project_ctrl.toggle_sidebar(PageType.DRAFT))
        # draft content

        # graph toolbar
        self._ui.tool_back_graph.clicked.connect(
            lambda: self._project_ctrl.change_page(PageType.SECTIONS))
        self._ui.tool_export_graph.clicked.connect(
            self._project_ctrl.open_export_dialog)
        self._ui.tool_cursor_graph.clicked.connect(
            lambda: self._project_ctrl.change_zoom_mode(ZoomType.SELECT))
        self._ui.tool_zoom_in.clicked.connect(
            lambda: self._project_ctrl.change_zoom_mode(ZoomType.ZOOM_IN))
        self._ui.tool_zoom_out.clicked.connect(
            lambda: self._project_ctrl.change_zoom_mode(ZoomType.ZOOM_OUT))
        self._ui.tool_zoom_range.clicked.connect(
            lambda: self._project_ctrl.change_zoom_mode(ZoomType.ZOOM_RANGE))
        # graph content
        """listen for model event signals"""
        # stacked pages
        self._model.current_page_changed.connect(
            self._ui.stacked_pages.setCurrentIndex)
        # overview page
        self._model.overview_selection_changed.connect(
            self.on_selection_change)
        self._model.overview_properties_changed.connect(
            self._ui.sidebar_overview.load_data)
        self._model.overview_sidebar_out_changed.connect(
            self._ui.sidebar_overview.toggle)

        # sections page
        self._model.current_section_changed.connect(self.on_section_change)
        self._model.sections_sidebar_out_changed.connect(
            self._ui.sidebar_sections.toggle)

        # draft page
        self._model.draft_select_mode_changed.connect(
            self.on_select_mode_change)
        self._model.draft_sidebar_out_changed.connect(
            self._ui.sidebar_draft.toggle)

        # graph page
        self._model.graph_zoom_mode_changed.connect(self.on_zoom_mode_change)
        self._model.current_commodity_changed.connect(self.on_commodity_change)
        """initialise view"""
        self._ui.logo.updateGeometry()
        self._ui.stacked_pages.setCurrentIndex(
            OverviewSelection.OVERVIEW.value)
        self._ui.scenario_select.set_model(self._model.scenarios)
        self._ui.sidebar_overview.load_data(self._model.overview_properties)
        self._section_scenes = List([
            SectionScene(OverviewSelection.ENERGY,
                         self._model.project_elements, self._model.commodities,
                         self._model.process_cores),
            SectionScene(OverviewSelection.WATER, self._model.project_elements,
                         self._model.commodities, self._model.process_cores),
            SectionScene(OverviewSelection.FOOD, self._model.project_elements,
                         self._model.commodities, self._model.process_cores),
            SectionScene(OverviewSelection.BUSINESS,
                         self._model.project_elements, self._model.commodities,
                         self._model.process_cores),
        ])
        self._ui.section_view.setScene(
            self._section_scenes[OverviewSelection.ENERGY.value])
        self._ui.draft_view.setScene(
            self._section_scenes[OverviewSelection.ENERGY.value])
        self._ui.draft_view.draft_mode = True
Пример #19
0
 def __init__(self, commodity_list, process_list):
     super(Elements, self).__init__()
     self._commodity_list = List(commodity_list)
     self._process_list = List(process_list)
Пример #20
0
 def copy(self):
     """return new PropertyDialog based on original values"""
     values = List()
     for value in self.values:
         values.add(PropertyValue(value.name, value.value, value.unit))
     return PropertyDialog(super().name, values)
Пример #21
0
 def __init__(self, name="", values=[]):
     super().__init__(name)
     self._values = List(values)
     # create display value for sub-property properties
     display_text = ", ".join(map(str, values))
     PropertyDialog.value.fset(self, display_text)
Пример #22
0
 def __init__(self, name="", value=[], unit=""):
     super().__init__(name, "", unit)
     self._value = List(value)