# Chapter 25 : Economic Scheduling of Hydrothermal Plants and Optimal Power Flows¶

## Example 25.1, Page No 817¶

In [2]:
import math
#initialisation of variables
q2=25.0
q3=25.0
q1=70-(q2+q3)
Wo=120.0
W3=50.0
Wi1=0
Wi2=0
W1=Wo+Wi1-q1
W2=W1+Wi2-q2

#Calculations
PH1=9.81*(10**-3)*20*(1+(.5*.006*(120+100)))*(20-2)
PH2=9.81*(10**-3)*20*(1+(.5*.006*(100+75)))*(23)		# Answer in the book is not Correct due to wrong calculation
PH3=9.81*(10**-3)*20*(1+(.5*.006*(75+50)))*(23)
PT1=8-PH1
PT2=12-PH2
PT3=7-PH3
L11=20+PT1			#dFT/dPT=PT+20
L12=20+PT2			#dF/dp=PT+20
L13=20+PT3			#dF/dp=PT+20
#dPL/dPH=0
L31=L11
L32=L12
L33=L13
e=0.006
ho=0.1962
Rho=2
L21=L31*ho*(1+(.5*e*(2*Wo+Wi1-2*q1+Rho)))
L22=L21-L31*(.5*ho*e*(q1-Rho))-L32*(.5*ho*e*(q2-Rho))#for m=1
L23=L22-L32*(.5*ho*e*(q2-Rho))-L33*(.5*ho*e*(q3-Rho))#for m=2
G1=L22-L32*ho*(1+.5*.006*(2*100-2*25+2))		#G1=dF/dq2 Answer doent match due to wrong calculation of PH2 in a book
G2=L23-L33*ho*(1+.5*.006*(2*W2+0-2*q3+Rho))		#G1=dF/dq3
a=0.4
qnew2=q2-a*G1# Answer differs due to wrong calculation of PH2 in the book
qnew3=q3-a*G2
q1=120-50-(qnew2+qnew3)

#Results
print("Let q2=%.0f   q3=%.0f    q1=%.0f" %(q2,q3,q1))
print("W1=%.0f    W2=%.0f" %(W1,W2))
print("PH1=%.2f     PH2=%.3f    PH3=%.1f" %(PH1,PH2,PH3))
print("Thermal generation during Three Intervals \n PT1=%.2f     PT2=%.2f    PT3=%.1f" %(PT1,PT2,PT3))
print("Value of L1 for the three intervals, \n L11=%.2f    L12=%.2f    L13=%.1f" %(L11,L12,L13))
print("Neglecting transmission losses we get\n L11=L31   L12=L32   L13=L33")
print("L21=%.3f" %(L21))
print("For m=1 and 2 we get \n L22=%.1f \n L23=%.1f" %(L22,L23))
print("Gradient Vectors \n dF/dq2=%.2f\n dF/dq3=%.1f" %(G1,G2))
print("q2new=%.3f \n q3new=%.1f\n q1=%.0f" %(qnew2,qnew3,q1))

Let q2=25   q3=25    q1=20
W1=100    W2=75
PH1=5.86     PH2=6.882    PH3=6.2
Thermal generation during Three Intervals
PT1=2.14     PT2=5.12    PT3=0.8
Value of L1 for the three intervals,
L11=22.14    L12=25.12    L13=20.8
Neglecting transmission losses we get
L11=L31   L12=L32   L13=L33
L21=6.975
For m=1 and 2 we get
L22=6.4
L23=5.8