day=30 #days
pll=40 ;nll=5; tll=3 #light load
pfl=100; nfl=3 ;tfl=5 #fan load
prl=1*1000 #refrigerator
pml=1*1000; nml=1 #misc. load
t1=2.74 ;t11=15#tariff
t2=2.70 ;t22=25 #tariff on 25 units
tr=2.32 #reamaining units
tc=7.00 #constant charge
dis=0.05#discount for prompt payment
te=(pll*nll*tll+pfl*nfl*tfl)*day+prl*day+pml*day
tee=te/1000
mb=tc+tr*(tee-t11-t22)+t1*t11+t2*t22
nmb=mb*(1-dis)
print "total energy consumption in %d day %dunits \nthe monthly bill Rs%.2f \nnet monthly bill Rs%.2f"%(day,tee,mb,nmb)
l=100 #connected load
md=80 #maximum demand
wt=0.6 #working time
c=6000 #constant cost
t=700 #cost on per kW
re=1.8 #rate
ec=l*wt*8760#electricity consumption per year
teb=c+md*t+re*ec #total electricity bill per year
print " energy consumption %dkWh \n total electricity bill per year Rs%d"%(ec,teb)
md=160 ;lff=0.7 ;dfc=1.7#maximum demand #load factor#diversity factor bt consumers
ic=200 #installed capacity
ccp=30000#capital cost of plant per kW
ctds=1800*10**6 #capital cost of transmission and distribution
idi=0.11 #interest,depreciation insurance and taxes on capital investiment
fmc=30*10**6 #fixed managerial and general maintanance cost
ol=236*10**6 #operating labour,maintanance and suppies
cm=90*10**6 #cost of metering,billing and collection
eca=0.05 #energy consumed by auxillary
el=0.15#energy loss and maintanance
p=0.25
lf=0.8#load factor
ap=0.5 #addition energy for profit
print 'a'
print " capital cost of plant Rs%e \n total capital cost Rs%e\n interest,depereiation system Rs%e "%(ccp*ic*10**3,ccp*ic*10**3+ctds,(ccp*ic*10**3+ctds)*idi)
print "\n sum of maximum demand of consumers energy prodused %dMW \n energy produced %ekWh \n energy consumed by auxilliries %ekWh\n energy output %ekWH \n energy sold to consumer %ekWh\n"%(md*dfc,md*8760*lff*10**3,md*8760*lff*eca*10**3,md*8760*lff*10**3*(1-eca),md*8760*lff*10**3*(1-eca)*(1-el))
print '(b)fixed cost'
idetc=(ccp*ic*10**3+ctds)*idi
tot=idetc+fmc
print " interest, deprecition etc Rs%e per year\n managerial and maintence Rs%.eper year \n total \t Rs%e "%(idetc,fmc,tot)
pro=p*tot
gtot=tot+pro
print "\n profit@%d \tRs%eper year \n grand total Rs%e per year"%(p*100,pro,gtot)
print 'Operating cost'
tot2=ol+cm
pro2=tot2*p
gtot2=tot2+pro2
print " Operating labour,supplies maintenance etc Rs.%eper year \n metering,billing etc Rs%eper year\n total\t\tRs%e per year\n profit \t Rs%eper year \n grand total \t Rs%e per year"%(ol,cm,tot2,pro2,gtot2)
print 'tariff'
co=gtot/(md*dfc*1000)
es=md*8760*lff*10**3*(1-eca)*(1-el)
cs=gtot2/es
print " cost per kW \tRs%e \n cost per kWh \tRs%e"%(co,cs)
print '(b)'
ep=md*1000*8760*lf
print " energy produced %ekWh \n energy consumed by auxiliaries %ekWh/year \n energy output of plant %ekWh \n energy sold to consumer %ekWh"%(ep,ep*eca,ep*(1-eca),ep*(1-eca)*(1-el))
estc=ep*(1-eca)*(1-el)
v=230 ;ec=2020 #voltage #energy consumption
i=40; pf=1 ;t=2; c=3.5; rc=1.8 ;mon=30 #current/power factor/time/cost/reamining cost/month
ecd=v*i*pf*t*mon/1000 #energy corresponding to maximum demand
cost=ecd*c
ren=ec-ecd
rcost=ren*rc
tmb=cost+rcost
at=tmb/ec
print " energy corresponding to maximum demand %dkWh \n cost of above energy Rs%d \n remaining energy %dkWh \n cost of reamaining energy Rs%.1f \n total monthly bill Rs.%.1f\n avarage tariff Rs%.3fper kWh"%(ecd,cost,ren,rcost,tmb,at)
t1=3000 ;t11=0.9 #cost equation
t2=3 #rate
x=t1/(t2-t11)
print "if energy consumption per month is more than %.1fkWh,\ntariff is more suitable"%(x)
aec=201500 #annual energy consumption
lf=0.35#load factor constnt
t=4000#tariff
tmd=1200#tariff for maximum demand
t3=2.2
lfb=0.55 #load factor improved
ecd=0.25#energy consumption reduced
md=aec/(8760*lf)
yb=t+md*tmd+t3*aec
mdb=aec/(8760*lfb)
ybb=t+mdb*tmd+t3*aec
ne=aec*(1-ecd)
md3=ne/(8760*lf)
ybc=t+md3*tmd+t3*ne
aeca=yb/aec
aecb=ybb/aec
aecc=ybc/ne
print 'a'
print "maximum demand %.2fkW \n yearly bill Rs.%d per year \n(b)\n maximum demand %.2fkW \n yearly bill Rs.%dper year"%(md,yb,mdb,ybb)
print "c"
print " new energy %dkWh \n maximum demand %.2fkW \n yearly bill Rs.%dper year \n average energy cost in case a Rs%.4fper kWh \n average energy cost in case b Rs%.3fper kWh\n average energy cost in case c Rs%.3fper kWh "%(ne,md3,ybc,aeca,aecb,aecc)
pl1=20 ;pf1=0.8; t1=2000#load in MVA #power factor #duration
pl2=10 ;pf2=0.8 ;t2=1000#load in MVA #power factor #duration
pl3=2 ;pf3=0.8 ;t3=500#load in MVA #power factor #duration
pt=20 #/transformar power rating
fte=0.985 ;ste=0.99 #/full load efficiency for first and second transformer
ftl=120 ;stl=90 #core loss inKW for first and second transformer
cst=200000 #cost of second transformer with compared with first transformer
aid=0.15 #annual interest and depreciation
ce=0.8 #cost of energy
tfl=pt*(1-fte)*1000#total full load
fle=tfl-ftl #full load copper loss
elc=fle*t1+(fle*t2/(pt/pl2)**2)+(fle*t3/(pt/pl3)**2) #energy loss due to copper loss
eli=ftl*(t1+t2+t3)#energy loss due to iron loss
celo=(elc+eli)*ce #cost of energy loss
print " \nfirst transformer : "
print " total full load losses %dkW \n full load copper losses %dkW \n energy loss due to copper losses %dkWh/year\n energy loss due to iron losses %dkWh/year \n cost of energy losses Rs%dper year"%(tfl,fle,elc,eli,celo)
stfl=pt*(1-ste)*1000#total full load
sle=stfl-stl#full load copper loss
selc=sle*t1+(sle*t2/(pt/pl2)**2)+(sle*t3/(pt/pl3)**2)#energy loss due to copper loss
seli=stl*(t1+t2+t3)#energy loss due to iron loss
scelo=(selc+seli)*ce#cost of energy loss
print " \nsecond transformer :"
print " total full load losses %dkW \n full load copper losses %dkW \n energy loss due to copper losses %dkWh/year\n energy loss due to iron losses %dkWh/year \n cost of energy losses Rs%dper year"%(stfl,sle,selc,seli,scelo)
aidc=stfl*aid*1000
tybc=aidc+scelo
print " additional interest and depreciation due to higher cost of second transformer Rs%d \n total yearly charges for second transformer Rs%d per year"%(aidc,tybc)
from math import asin, acos, tan, cos
p=500 #load
pf=0.8#power factor
t=400 #tariff
md=100 #maximum demand tariff
ccb=600 #cost of capacitor bank
id=0.11#interest and deprecistion
sd=ccb*id/t#sin(ph2)
d2=asin(sd)
pf2=cos(d2)
kva=p*(tan(acos(pf))-tan(d2))
print " the most economic power factor %.3f lagging \n kvar requirement %.2fkVAR"%(pf2,kva)
from math import asin, acos, tan, cos
l1=300 #load and power factor for three different loads
pf1=1
l2=1000
pf2=0.9
l3=1500
pf3=0.8
print " for %dkW unit power factor load \n power factor angle %.f\n reactive power %.fkvr"%(l1,acos(pf1),l1*(tan(acos(pf1))))
print " \nfor %dkW unit power factor load \n power factor angle %.2f\n reactive power %.2fkvr"%(l2,acos(pf2),l2*(tan(acos(pf2))))
print " \nfor %dkW unit power factor load \n power factor angle %.2f\n reactive power %.2fkvr"%(l3,acos(pf3),l3*(tan(acos(pf3))))
tl=l1+l2+l3
tt=l3*(tan(acos(pf3)))+l2*(tan(acos(pf2)))+l1*(tan(acos(pf1)))
print "\n total kW \t%dkW\n total kVAR %.1fkVAR \n total kVA %.2fkVA \n overall power factor %.3flagging"%(tl,tt,(tl**2+tt**2)**0.5,tl/(tl**2+tt**2)**0.5)
print "\n the maximum unity power factor load which yhe station can supply is equal to the kVA i.e.%.2fkVR"%((tl**2+tt**2)**0.5)
from math import asin, acos, tan, cos,sqrt, pi
v=400#voltage
i=25#/current
pf=0.8#at power factor
pf2=0.9#over all power factor
kw=v*i*pf*sqrt(3)/1000
print "kw rating of induction motor %.2fkW"%(kw)
dm=acos(pf)
rp=kw*tan(dm)
print "\n power factor angle %.2f \n reactive power %.2fkVR"%(dm,rp)
fdm=acos(pf2)
rp2=kw*tan(fdm)
print "\n final power factor %.2f \n final reactance power %.2fkVR"%(fdm,rp2)
ckvb=rp-rp2
cc=ckvb*1000/(sqrt(3)*v)
vc=v/sqrt(3)
xc=vc/cc
f=50
cec=1*10**(6)/(xc*2*pi*f)
print "\n kvar rating of capacitor bank %.4f \n current through each capacitor %.2fA\n voltage across each capacitor %.2f \n reactance of each capacitor %.2fohm \n capacitance of each capacitance %.2fuf"%(ckvb,cc,vc,xc,cec)
from math import asin, acos, tan, cos,sqrt, pi
v=400#line voltage
i=50 #line current
pf=0.8 #at power factor
pf2=0.95 # overall power factor
sm=25 #hp of synchronous motor
e=0.9#efficiency
kwri=v*i*pf*sqrt(3)/1000
kvari=v*i*sqrt(3)/1000
karri=(-kwri**2+kvari**2)**0.5
kwsm=sm*735.5/(e*1000)
tkw=kwri+kwsm
print " kw rating of installation %.1fkW \n kVA rating of installation %.2fkva \n kVAR rating %.2fkvar \n kw input to synchrounous motor %.2fkw \n total kw=%.2f\n"%(kwri,kvari,karri,kwsm,tkw)
pd=acos(pf2)
tkr=tkw*tan(pd)
krsm=tkr-karri
kasm=(kwsm**2+krsm**2)**0.5
pfsm=kwsm/kasm
if krsm<0:
ch='capacitor'
ich='leading'
else:
ch='inductive'
ich='lagging'
print " overall power factor angle %.2fkw \n total kvar %.2fkvar \n kvar of synchrounous motor %.2fkvar %s \n kva of synchrounous motor %.2fkva \n power factor of synchrounous motor %.2f %s"%(pd,tkr,krsm,ch,kasm,pfsm,ich)
from math import asin, acos, tan, cos,sqrt, pi,sin, atan
psm=100 #power of synchrounous motors
pim=200 #power of inducion motor
v=400 #voltage
pff=0.71; pp=-1#power factor
rsm=0.1 #resistance of synchrounous motor
rt=0.03 #resistance of cable
#pf(1)=1 ;p(1)=1 #power factor in a
#pf(2)=0.8 ;p(2)=1 #power factor in b
#pf(3)=0.6 ;p(3)=1 #power factor in c
pf =[1,0.8,0.6]
p = [1,1,1]
i1=pim*1000/(v*pff*sqrt(3))
i11=i1*(complex(pff,pp*sin(acos(pff))))
i2f=psm*1000/(v*sqrt(3))
ch=['a', 'b', 'c']
it = range(0,3)
opf = range(0,3)
for i in range(0,3):
print "\n (%s)"%(ch[i])
d=acos(pf[i])
#it(i)=i11(1)+complex(i2f,(p(i)*i2f*tand(d)))
it[i]=i11+complex(i2f,(p[i]*i2f*tan(d)))
opf[i]=cos(atan((it[i]).imag/(it[i]).real))
clsm=3*((i2f)**2)*rsm
clt=3*(abs(it[i])**2)*rt/1000
print "\n total current =",it[i]
print "\n overall power factor %.3f lagging \n copper losses in synchrounous motor %.fW \n copper losses in cable %.2fKW"%(opf[i],clsm,clt)
print "(d)"
print "copper loss of synchronous motor this is evidently minimum when tand=%d cosd=%d"%(0,1)
from math import atan,tan,acos,pi
p=2#constant output in MW
pf=0.9#power factor
pa=10#load
pb=5
pfb=0.8#power factor at load of 5MW
td=tan(acos(pf))
go=p*(1-td*1J)
op=0.8
tp=tan(acos(pfb))
print "power factor of indection generator is leading therefor induction generator output %d%.2fiMVA /n (a) \n"%(go.real,go.imag)
tl=pa*(1+tp*1J)
sg=tl-go
da=atan(sg.imag/sg.real)
print " total load %d+%.1fiMW \n synchronous generator load %d+%.3fiMW \n\t\t=%.2fMW at angle %.2f \n power factor of synchronous generator is %.2flagging"%(tl.real,tl.imag,sg.real,sg.imag,abs(sg),da,cos(da))
tl1=pb*(1+tp*1J)
sg1=tl1-go
da1=atan(sg1.imag/sg1.real)
print "(b)"
print " total load %d+%.1fiMW \n synchronous generator load %d+%.3fiMW \n\t\t=%.2fMW at angle %.2f \n power factor of synchronous generator is %.2flagging"%(tl1.real,(tl1).imag,sg1.real,(sg1).imag,abs(sg1),da1,cos(da1))
from math import atan,tan,acos,pi,sqrt,sin
c=40*10**(-6) #bank of capacitors in farads
v=400 #line voltage
i=40#/line current
pf=0.8#power factor
f=50#line frequency
xc=1/(2*pi*f*c)
ic=v/(sqrt(3)*xc)
il=i*(pf-sin(acos(pf))*1J)
til=il+1J*ic
od=atan(til.imag/til.real)
opf=cos(od)
nlol=(abs(od)/i)**2
print "(a)"
print " line current of capacitor bank %.1fA \n load current %d%diA \n total line current %d%.1fjA \n overall p.f %.3f \n new line loss to old line loss %.3f"%(ic,il.real,il.imag,(til).real,(til).imag,opf,nlol)
pcb=(v/xc)
print "\n phase current of capacitor bank %.3fA"%(pcb)
lcb=pcb*sqrt(3)
print "\n line current of capacitor bank %.1fA"%(lcb)
tcu=il+lcb*1J
print "\n total current =",tcu
print "%.1fjA =%.2fA at an angle %.2f"%(tcu.imag,abs(tcu),atan(tcu.imag/tcu.real))
pf2=cos(atan(tcu.imag/(tcu).real))
print "\n power factor %.1f \n ratio of new line loss to original loss %.3f"%(pf2,(abs(tcu)/i)**2)
from math import atan,tan,acos,pi,sqrt
p=30 #b.h.p of induction motor
f=50#line frequency
v=400#line voltage
e=0.85#effiency
pf=0.8 #power factor
i=p*746/(v*e*pf*sqrt(3))
i=i*complex(pf,-sin(acos(pf)))
ccb=(i).imag/sqrt(3)
xc=v/ccb
c=10**6/(2*f*pi*xc)
prl=((abs(i)**2-i.real**2)/abs(i)**2)*100
print " current drawn by motor is %.1fA \n "%abs(i)
print "the line loss will be minimum when i is munimum.the minimum value of i is",i,"A"
print " and occurs when the capacitor bank draws a line current of %djA \n capacitor C %.2fuf \n percentage loss reduction %d"%(i.imag,abs(c),prl)
from math import atan,tan,acos,pi,sqrt
po=666.66 #power
f=50 #frequency
v=400 #voltage
pf=0.8 ;p=-1#power factor
pf2=0.95 ;p2=-1#improved power factor
vc=2200 #capacitor voltage
rc=vc
il=po*1000/(v*pf*sqrt(3))
il1=il*(complex(pf,p*sin(acos(pf))))
i2c=il*pf
tad=tan(acos(pf2))
i2=complex(i2c,i2c*tad*p2)
print " load current i1 =",il1,"A "
print "\n load current current on improved power factor =",i2,"A"
print "(a)"
ic=abs(il1-i2)
ilc=ic*v/vc
pic=ilc/sqrt(3)
xc=vc/pic
ca=10**6/(2*pi*f*xc)
print " line current of %dV capacitor bank %.2fA\n line current of %d capacitor bank %.2fA \n phase current of capacitor bank %.2fA \n reactance %.2f \n capacitance %.2fF*10**(-6)"%(v,ic,vc,ilc,pic,xc,ca)
print "(b)"
kr=3*vc*pic/1000
print " kVA rating %.1fkVA \n kVA rating of transformer to convert %dV to %dV will be the same as the kVA rating of capacitor bank"%(kr,v,vc)
pl=100*(abs(il1)**2-abs(i2)**2)/abs(il1)**2
print "percentage reduction in losses %d percent"%(pl)
print "(d)"
pi=ic/sqrt(3)
xcc=v/pi
cc=1*10**6/(2*pi*f*xcc)
roc=ca/cc
print " phase current %.1fA \n reactance %.2fohm \n capasitance %.2f*10**-6F \n ratio of capacitance %.3f"%(pi,xcc,cc,roc)
from math import acos,pi,sqrt,sin
v1=132#line voltage at primary
v2=11#line voltage at secondary
p=10 #power
pf=0.8 #power factor
mva=p*(complex(pf,sin(acos(pf))))
print " MVA rating of secondary = %dMVA =%d+%djMVA \n "%(p,abs(mva),mva.imag)
print "\n since the power factor at primary terminals is unity,rating of primary need be %dMVA only \n the tertiary will supply capacitor curren.since p.f is to be raised to 1 ,the mav compensation needed is 6MVA so rating of teritiary is %dMVA"%(abs(mva),mva.imag)
from math import sin,acos,pi,sqrt,acos,cos
v=11 #line voltage
f=50#line frequency
l=400 #load of alternator
pf=0.8 #power factor
e=0.85#efficiency
p=l/pf
lo=l+p*sin(acos(pf))*1J
print "a"
print "when pf is rased to 1 the alternator can supply %dkW for the same value of armture current hence it can supply %dKW to synchronous motor"%(p,p-l)
print "b"
print "b.h.p =%.2fHP"%(100*e/0.746)
kvam=p-lo
td=atan((kvam).imag/(kvam).real)
pff=cos(td)
print "\ncosd=%.3fleading"%(pff)
from math import tan,acos
kw=100 #let kw=100kw
pf=0.6 #power foctor
pf2=0.8 #power factor
kvar=kw*tan(acos(pf))
kvar2=kw*tan(acos(pf2))
ckar=((kvar-kvar2))/10
ck=round(ckar)*10
print " capacitor kVAR required for %dkW\n load for same power factor improvement %dKVAR"%(round(ckar),ck)
from __future__ import division
from math import tan,acos
p=160 #kva for transformer
pf=0.6 #power factor
el=96 #effective load
eli=120 #effective load increase
rc=eli*(tan(acos(pf))-tan(acos(eli/p)))
opf=eli/p
print " required capacitor kVAR %dKVAR \n overall power factor %.2f \n it is seen that point d is on %.2f line"%(rc,opf,opf)
from math import atan,tan,acos,pi,sqrt,sin
md=800 #maximum demand
pf=0.707 #power factor
c=80 #cost
p=200 #power
e=0.99#efficiency
pff=0.8 #fulload pf
ikva=md/pf
iafc=(round(ikva*100)*(c)/100)
rsm=ikva*pf
act=p*(0.7355)/e
at=-act*sin(acos(pff))
tkw=rsm+act
tkvr=rsm+at
tkva=(tkw**2+tkvr**2)**0.5
ikvad=tkva-ikva
infc=ikvad*c
print " initial kVA %.2fkVA \n initial annual fixed charges Rs%.1f \n after installation of synchronous motor reactive power of induction motor %dkVars\n active power input of synchrounous motor %.2fkW\n reactive power input to synchrounous motor %.2fKVAR \n total kW %.2fKW \n total kVars %.2fkVARS \n total kVA %.2fkVA \n increase in KVA demand %.2fkVA\n increase in annual fixed charges Rs%.1f "%(ikva,iafc,rsm,act,at,tkw,tkvr,tkva,ikvad,infc)
t=16#working time
d=300 #working days
hv=1 ;hvmd=50 #tariff on high voltage
lv=1.1 ;lvmd=60 #tariff on low voltage
al=250#avarage load
pf=0.8#power factor
md=300 #maximum demand
hvec=500#cost of hv equipment
l=0.05 #loss of hv equipment
id=0.12 #interest and deprecistion
ter=al*md*t
mdv=md/pf
print " total energy requirement %2.2ekWH \n maximum demand %dKVA"%(ter,mdv)
print "(a)HV supply"
chv=mdv*hvec
idc=chv*id
ere=ter/(1-l)
dch=mdv*hvmd
ech=round(ere*hv/1000)*1000
tanc=ech+dch+idc
print " cost of HV equipment Rs%e\n interest and depreciation charges Rs%d \n energy received %ekWh\n demand charges Rs%d \n energy charges Rs%2e \n total annual cost Rs%d"%(chv,idc,ere,dch,ech,tanc)
print "(b) LV supply"
lvdc=mdv*lvmd
lvec=ter*lv
lvtac=lvec+lvdc
lvdac=lvtac-tanc
print " demand charges Rs%d \n energy charges Rs%2.e \n total annual cost Rs%d \n difference in annual cost Rs%d"%(lvdc,lvec,lvtac,lvdac)