Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bus power equality doesn't trigger if bus doesn't exist, solves anyway #505

Open
Cellophil opened this issue Nov 24, 2022 · 0 comments
Open

Comments

@Cellophil
Copy link
Contributor

Hi,

We found a small bug, pypsa 0.21.1:

#%%
import pypsa

n = pypsa.Network()
n.set_snapshots(np.arange(10))
n.add('Generator', name='test', bus='nobus', p_nom=100)
n.add('Bus', name='bus')
n.add('Generator', name='test2', bus='bus', p_nom=100)
n.lopf(solver_name='glpk')

#%%
from pypsa.linopt import define_constraints, get_var, linexpr
def extra(network, snapshots):
    define_constraints(network, linexpr((1, get_var(network, 'Generator', 'p').loc[:, 'test'])), '>=', 40, 'test')

n.lopf(solver_name='glpk', extra_functionality=extra)

A generator is put at a bus that doesn't exist - I guess a frequent thing in models due to data issues, and certainly captured by consistency_check. First stage solves normally and you could assume it just creates a virtual bus, equalizing power to zero there. It might be good if that was a bit stricter there...

Second one is a bit more puzzling, you can force the generator to produce power into the void. It solves normally. Not the most frequent scenario, but maybe worth a look.

Best,
Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant