import math
import numpy as np
#initialisation of variables
#dF1/dP1=.4*P1+40 per MWhr
#dF2/dP2=.5*P1+30 per MWhr
print("Two equations are :")
print("%.1f P1 %.1f P2 = %.1f\n" %(.4,-.5,-10))
print("%.1f P1+ %.1fP2 = %.1f\n" %(1,1,180))
A=[[.4,1],[-.5,1]]
B=[-10,180]
P1=88.89
P2=91.11
#Calculations
F1=.2*(P1)**2 +40*P1+120
F2=.25*(P2)**2+30*P2+150
Total=F1+F2 #Total cost
print("(a)Cost of Generation=Rs %.2f /hr\n" %Total)
P1=90
P2=90
F1=.2*(P1)**2 +40*P1+120
F2=.25*(P2)**2+30*P2+150
Total2=F1+F2 #Total cost
savings=Total2-Total
#Results
print("(b)Savings=Rs %.2f /hr\n" %savings)
import math
#initialisation of variables
pf=10.0/8 #penalty factor
#Calculations
cost=(.1*10+3)*pf #Cost of recieved power=dF1/dP1
#Results
print("Penalty Factor = %.1f" %pf)
print("Cost of recieved Power = Rs %.1f /MWhr" %cost)
import math
#initialisation of variables
print("two equations are :")
print("%.3f P1 %.2f P2 = %.1f" %(0.048,-.08,-2))
print("%.1f P1+ %.1fP2 = %.1f" %(1,1,50))
#Calculations
A=[[.048,-.08],[1,1]]
B=[-2,50]
P1=15.625
P2=34.38
F1=(.024*(P1)**2 +8*P1+80)*(10**6)
F2=(.04*(P2)**2+6*P2+120)*(10**6)
print("when load is 150MW , equations are: :")
print("%.3f P1 %.2f P2 = %.1f" %(.048,-.08,-2))
print("%.1f P1+ %.1fP2 = %.1f" %(1,1,150))
A=[[.048,-.08],[1,1]]
B=[-2,150]
P1=78.125
P2=71.88
f1=(.024*(P1)**2 +8*P1+80)*(10**6)
f2=(.04*(P2)**2+6*P2+120)*(10**6)
Total=(F1+F2+f1+f2)*12*2/(10**6)
#Results
print("Total cost=Rs. %.2f" %(Total))