from numpy import arange, mat
#given
l1=700 ;t1=14 ;l2=500; t2=10
ac=24 ;bc=0.02#variables of cost equation
aw=6 ;bw=0.0025 #variables of watere quantity equation
b22=0.0005 #loss coefficient
r2=2.5
lam=arange(1,40,0.001)
gg=1; q=1
for lam in arange(25,40,0.001):
a=mat([[2*bc ,0],[0, r2*bw*2+2*b22*lam]])
b=([[lam-ac] ,[lam-aw*r2]])
pq=(a**-1)*b
g=round(pq[0]+pq[1])
lq=round(l2+b22*pq[1]**2)
if g>=lq:
print "\nfor load condition %dMW \n then, \n \t lamda %f \t p1=%fMW \n \t p2=%fMW \t pl=%fMW"%(l2,lam,pq[0],pq[1],2*b22*pq[1])
break
#end
#end
dwu=[(aw+bw*p)*p*t1+t2*(aw+bw*pq[1])*pq[1]]*3600
doc=[(ac+bc*p)*p*t1+(ac+bc*pq[0])*pq[0]*t2]
print "\ndaily water used %fm**3 \ndaily operating cost of thermal plant Rs%f"%(dwu[0],doc[0])
from math import sqrt
#given
p=250#load
rt=14 #run time
t=24#total time
ac=5 ;bc=8; cc=0.05 #variables of cost equation
bw=30; cw=0.05 #variables of water per power
qw=500#quantity of water
lam=bc+cc*2*p #lambda
a=-qw*(10**6)/(3600*rt)
inn=sqrt(bw**2-4*cw*a)
phh1=(-bw+inn)/(2*cw)#solution of quadratic equation
phh2=(-bw-inn)/(2*cw)
if phh1>0 :
r=lam/(bw+cw*phh1)
print " hydro plant power is %fMW \n the cost of water is %fRs.per hour/m**3/sec"%(phh1,r)
if phh2>0 :
r=lam/(bw+cw*phh2)
print " hydro plant power is %fMW \n the cost of water is %fRs.per hour/m**3/sec"%(phh2,r)