Define shortage in oemof

Thank you so much @pschoen for this example! it’s helping me to get the point that’s why I have further questions:

Do you mean the second source with cost can constantly provide [2,2,2,2]? the demand cannot be fulfilled in time step 4 because [3] from source 1 and [2] from source 2 in time step 4 are in total less than 8 right? That’s mean once I defined the shortage in this fictive energy system and the model is solved, I will see later the extracted energy flows data with [0, 0, 0, 3]. → In this case the shortage is resulted automatically [0, 0, 0, 3] because of the defined nominal_values of the sources and without the shortage as third source the model could not be solved right?

In an optimisation problem where the aim is to minimise the cost resulting in optimized capacities and flows of the assets the demand has to be fulfilled anyway, thereby the shortage is null and therefore there is no need to define it. Did I got the point?

Now I’m wondering what If I want to enforce a shortage in this simple system. I have a pv plant and dieselGen in the system. The objective is to determine the capacities of the assets pv and diesel based on the periodical costs. I have household demand with total_demand X in kWh. My goal is to consider the fact that 10% of the demand is not covered for example due a technical issue in the reality or something.
This is the way I tried to model a shortage. So I created a source with nominal value total_demand *0.1 and cost of 0.
I’m trying to apply your great example in my case but it’s not the same :confused: I Think this is wrong what I did :sweat_smile:

source_shortage = solph.Source(label= shortage_demand, 
                            outputs={el_ac_bus: solph.Flow(
                            nominal_value=0.1 * total_demand,
                            variable_costs=0)
                                    }
                            )

I’m grateful for any explanation or help. This is basic concept in oemof which I would love to understand better.