I'm working on a project related with AC OPF (Optimal Power Flow) and I was trying to solve a problem in python, using pyomo. There are 3 buses and the bus voltage and bus angle are limited. However, the 1st bus must have a voltage=1 and an angle=0.
So, I tried this:
model.busvoltage = Var(model.bus, initialize=1, bounds=(0.95, 1.05), doc='Bus Voltage')
model.busvoltage[1].fixed=True
model.busangle = Var(model.bus, initialize=0, bounds=(-3.14, 3.14), doc='Bus angle')
model.busangle[1].fixed=True
The problem is that I just want to set the busvoltage and busangle for the first bus, without initializing the other ones with those values. I don't know if this is important to write, but I'm using ipopt as solver.
(This is my first time programming in Python) Any help would be appreciated!
You're after the .value attribute of the variable. Furthermore, setting the value of a variable and fixing it at the same time can be simplified to calling .fix():
model.busvoltage = Var(model.bus, bounds=(0.95, 1.05), doc='Bus Voltage')
model.busvoltage[1].fixed = True
model.busvoltage[1].value = 1
model.busangle = Var(model.bus, bounds=(-3.14, 3.14), doc='Bus angle')
model.busangle[1].fix(0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With