-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimize2.py
More file actions
67 lines (52 loc) · 1.33 KB
/
Copy pathoptimize2.py
File metadata and controls
67 lines (52 loc) · 1.33 KB
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
59
60
61
62
63
64
65
66
67
"""
Example:
Minimize PQR by means of flow, UVT for the RED > 40
Next step - maximum RED for minimum PQR
"""
from gekko import GEKKO
import RZ_300_HDR
m = GEKKO()
def RED(P,Q,UVT):
P = P.value
Q = Q.value
UVT = UVT.value
Status = 100 # [%]
D1Log = 18 # [mJ/cm^2]
N_lamps = 1
return RZ_300_HDR.RED(P, Status, Q, UVT, D1Log, N_lamps)
def PQR(P,Q):
P = P.value
Q = Q.value
return P/Q
# Set up the accuracy
#m.options.RTOL = 0.1
#m.options.OTOL = 0.1
# Set up the variables, parameters, constants and limits
xP = m.Var(value=53,lb=40,ub=100)
#xP = m.Const(100)
#xP = m.Param(55)
xQ = m.Var(value=10,lb=1,ub=100)
xUVT = m.Var(value=70,lb=40,ub=95)
xRED = m.Var()
xPQR = m.Var()
m.Equation(xRED == RED(xP,xQ,xUVT))
m.Equation(xPQR == PQR(xP,xQ))
#targetRED = 40 # [mJ/cm^2]
targetRED = m.Param(value=40)
# Limiting factors and Objectives
m.Equation(xRED > targetRED)
m.options.IMODE = 3 #steady-state optimizer = 1-3
#m.options.SEQUENTIAL = 1
m.options.SOLVER = 3 # IPOPT
#m.options.SOLVER = 1 # APOPT
m.options.AUTO_COLD = 5 # Cold start after X cycles
# m.options.CV_TYPE = 2 # Quadric
#m.Obj(xPQR)
m.Minimize(xPQR)
#m.Maximize(xRED)
m.solve(disp=False) #disp is True by default
print(f'P = {xP.value}')
print(f'Q = {xQ.value}')
print(f'UVT = {xUVT.value}')
print(f'PQR = {xPQR.value}')
print(f'RED = {xRED.value}')