summaryrefslogtreecommitdiff
path: root/416/CH10/EX10.1/exp10_1cpp.sce
blob: 99f6e450a72f9dfe4910ead667379e1c0cce6856 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
clear
clc
disp("example 10.1")
mp=250 //maximum power
function [ic]=unit1(p1) //ic equation of unit 1
    ic=0.2*p1+30
endfunction
function [ic]=unit2(p2)//ic equation of unit 2
    ic=0.15*p2+40
endfunction
mil=20//minimum load
disp("minimum load ic is")
ic=[unit1(mil),unit2(mil)]
[m,n]=max(ic)
if m==unit2(mil) then
    for x=20:100
      if m==unit1(x) then
        break
        end
    end
    printf("ic of unit1 =ic of unit2 when unit2=%dMW and unit1=%dMW",mil,x)
end
function [p1,p2]=un(ic)
    p1=(ic-30)/0.2
    p2=(ic-40)/0.15
endfunction
printf("load division \n")
me=ceil(unit2(mil)/10)
for x=me*10:5:100
   ii=0
    [m,n]=un(x)
    if m>=mp|n>=mp then
        if n>mp then
            p=2
        end
        if m>mp then
            p=1
        end
        for y=x-5:0.5:x
            [c,v]=un(y)
            m1=[c,v]
            if mp==m1(p) then
                ii=1
                break
            end
        end
        [pp qq]=un(y)
    printf("\n for plant ic %3.1fMW \tthen p1=%dMW\t p2 =%dMW",unit1(pp),pp,qq)
    ii=1
    break
    end
   if ii==0 then
       l=m+n
       printf("\n for plant ic %dMW \tthen p1 is %dMW\t plant2 is %dMW and total is %dMW ",x,m,n,l)
    end
end
a=unit1(mp);b=unit2(mp)
printf("\n for plant ic %dMW \tthen p1 is %dMW\t plant2 is %dMW and total is %dMW ",a,mp,mp,2*mp)