Giter VIP home page Giter VIP logo

Comments (7)

fwitte avatar fwitte commented on August 10, 2024

Hi @mdonat,

you have to add the NonConvex on the input or output flow of the Converter, and the attribute min=1.

heat_pump = solph.components.Converter(
    "heat pump",
    inputs={b_electricity: solph.Flow()},
    outputs={
        b_heat: solph.Flow(min=1, nonconvex=solph.NonConvex(), nominal_value=10),  # e.g. 10 kW heat
    },
    conversion_factors={b_heat: COP}
)

from oemof-solph.

mdonat avatar mdonat commented on August 10, 2024

I tried this, but it seems that it cannot be solved.
This is the code:

        energysystem = solph.EnergySystem(timeindex=times)
        
        bel = solph.buses.Bus(label='electricity')
        b_heat = solph.buses.Bus(label='heat')
        
        
        # create source object representing the e commodity
        energysystem.add(
                solph.components.Source(
                label="e-in",
                outputs={
                bel: solph.flows.Flow(variable_costs=50)
                },
            )
        )
        
        # create storage object for heat
        nominal_capacity = 4000
        nominal_value = 400

        heat_storage = solph.components.GenericStorage(
            nominal_storage_capacity=nominal_capacity,
            label="STORAGE_HEAT",
            inputs={b_heat: solph.flows.Flow(nominal_value=nominal_value, variable_costs=0.001)},
            outputs={
                b_heat: solph.flows.Flow(
                    nominal_value=nominal_value, variable_costs=0.001
                )
            },
            loss_rate=0.00,
            initial_storage_level=0.5,
            inflow_conversion_factor=1,
            outflow_conversion_factor=1,
        )

        energysystem.add(heat_storage)
        
        sink = solph.components.Sink(
            label="demand_th",
            inputs={b_heat: solph.Flow(nominal_value=200, fix=1)}
        )
        
        energysystem.add(solph.components.Converter(label="heatPump",
           inputs={bel: solph.flows.Flow(
           )},
           outputs={b_heat: solph.flows.Flow(nominal_value=400,
           nonconvex=solph.NonConvex(),
           min=1,
           )},
           conversion_factors={b_heat: 1}
           ))
        
        energysystem.add(bel, b_heat, sink)
        
        
        # solve problem
        om = solph.Model(energysystem)
        om.solve(solver="cbc", solve_kwargs={"tee": True})

If I uncomment "min=1" it solves with constant flow value of 200.
With "min=1" it does not solve, ...only if I set nominal_value to 200, so that the heat pump will be constantly on.

from oemof-solph.

fwitte avatar fwitte commented on August 10, 2024

Your code is a incomplete, e.g. times is never defined, could you add that?

Also, the model might be infeasible, because your heat pump cannot provide 200 units of heat, only 400 or 0. Since your demand_th takes 200 units fixed at all times, nothing in your system can provide that amount of energy. The storage might be able to buffer that for up to 10 hours, but it is constrained to be cyclic by default. So depending on the number of timesteps you are running the model, it might be infeasible because the storage can never be balanced back to half way full.

To circumvent that, you could add an additional sink, which takes up any amount of heat but penalizes the model to do so (by giving the flow very high variable cost). Then you can check, why the infeasibility occurs.

from oemof-solph.

mdonat avatar mdonat commented on August 10, 2024

Missing code for times:

 today = datetime.date.today()
 start_day = today - datetime.timedelta(days=1)
 times = pd.date_range(start=start_day, end=today, freq='5T')

I have added an additional sink:

energysystem.add(
    solph.components.Sink(
        label="excess_bus_heat",
        inputs={b_heat: solph.flows.Flow(variable_costs=100)},
    )
)

But it does not work.
I thought that, if the heat pump is working half the time, it provides 200 units of heat to demand_th, and 200 units to the storage. The other half, when it is switched off, the storage provides 200 units of heat to demand_th.

from oemof-solph.

fwitte avatar fwitte commented on August 10, 2024

Okay, then it was a misunderstanding. I thought the problem was infeasible...

After running it, in my opinion, the issue here is, that the problem seems to have an extremely flat optimum: There is basically tons of solutions which all lead to the same objective but are very different in dispatch (the model really is indifferent on when to charge or discharge storage).

from oemof-solph.

mdonat avatar mdonat commented on August 10, 2024

Ok, that's right, there is no clear optimum.
But if I set min=0.5 it is working. Should have even more possible solutions then...
Thank you for the quick support. :-)

from oemof-solph.

fwitte avatar fwitte commented on August 10, 2024

But if I set min=0.5 it is working. Should have even more possible solutions then...

Due to the storage operation cost the optimum is then very easy to find: never use the storage. ;)

from oemof-solph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.