Esempio n. 1
0
w = prob.addControllerInputs(3, [-.5, -.5, 0.0], [.5] * 3)
#w.fix()
w.plot()
u = prob.addControllerInputs(1, [0.0], [1.0])

rhs = Expression(SX.zeros(3))
rhs[0] = x[0] - x[0] * x[1] + w[0]
rhs[1] = -x[1] + x[0] * x[1] + u * x[2] * x[1] + w[1]
rhs[2] = -x[2] + 0.50 + w[2]
m = SX.zeros(2, 2)
m[0, 0] = 2 + 1.414
m[1, 0] = 1 + 1.414
m[0, 1] = 1 + 1.414
m[1, 1] = 1 + 1.414

prob.addControllerODEs(x, rhs)
f = sum((1 - x[0]('coll')) * (1 - x[0]('coll')) + (1 - x[1]('coll')) *
        (1 - x[1]('coll')) + u('coll') * u('coll')) + (mul((mul(
            (x[0:2](-1).T, m)), x[0:2](-1))))
prob.addControlObjective(f)
#prob.addConstraints(x(0),[1,1,0.50])
x1 = prob.addPlantStates(3)
u1 = prob.addPlantInputs(1)
rhs1 = SX.zeros(3)
rhs1[0] = x1[0] - x1[0] * x1[1]
rhs1[1] = -x1[1] + x1[0] * x1[1] + u1 * x1[2] * x1[1]
rhs1[2] = -x1[2] + 0.50
prob.addPlantODEs(x1, rhs1)
x0 = NP.array([1, 1, 0.50])
prob.setInitCondition(x0)
solver = MPCsolve(prob, printlevel=0)
Esempio n. 2
0
r0 = NP.array([2.14, 1.09, 114.2, 112.9, 14.19, -1113.5])
r1 = NP.array([2.9805, 0.9612, 106.0, 100.75, 18.038, -4565.88])
r2 = NP.array([3.5176, 0.7395, 87.0, 79.8, 8.256, -6239.33])

tph = 3600.0

x0 = NP.array([1.0, 0.5, 100.0, 100.0])
#########
MPC = MPCproblem(50, total_plant=3000, dis='MultipleShooting')
x1 = MPC.addControllerStates(4, [0.0, 0.0, 50.0, 50.0, -1.0e06],
                             [10.0, 10.0, 250.0, 250.0, 1.0e06],
                             [2.14, 1.09, 114.2, 112.9, 0.0])

u1 = MPC.addControllerInputs(2, [3.0, -9000.0], [35.0, 0.0])

cA = x1[0]
cB = x1[1]
theta = x1[2]
thetaK = x1[3]
k1 = k10 * exp(E1 / (273.15 + theta))
k2 = k20 * exp(E2 / (273.15 + theta))
k3 = k30 * exp(E3 / (273.15 + theta))
rhs = SX.zeros(4)
rhs[0] = (1 / tph) * (u1[0] * (cA0 - cA) - k1 * cA - k3 * cA * cA)
rhs[1] = (1 / tph) * (-u1[0] * cB + k1 * cA - k2 * cB)
rhs[2] = (1 / tph) * (u1[0] * (theta0 - theta) - (1 / (rho * Cp)) *
                      (k1 * cA * H1 + k2 * cB * H2 + k3 * cA * cA * H3) +
                      (kw * AR / (rho * Cp * VR)) * (thetaK - theta))
rhs[3] = (1 / tph) * ((1 / (mK * CPK)) * (u1[1] + kw * AR * (theta - thetaK)))
MPC.addControllerODEs(x1, u1, rhs)
Esempio n. 3
0
rhs[11] = stream_6_flow * (stream_6_conc[2]) - stream_7_flow * (
    stream_7_conc[2]) + reactor_conv_rate[2]
rhs[12] = stream_6_flow * (stream_6_conc[3]) - stream_7_flow * (
    stream_7_conc[3]) + reactor_conv_rate[3]
rhs[13] = stream_6_flow * (stream_6_conc[4]) - stream_7_flow * (
    stream_7_conc[4]) + reactor_conv_rate[4]
rhs[14] = stream_6_flow * (stream_6_conc[5]) - stream_7_flow * (
    stream_7_conc[5]) + reactor_conv_rate[5]
rhs[15] = stream_6_flow * (stream_6_conc[6]) - stream_7_flow * (
    stream_7_conc[6]) + reactor_conv_rate[6]
rhs[16] = stream_6_flow * (stream_6_conc[7]) - stream_7_flow * (
    stream_7_conc[7]) + reactor_conv_rate[7]
rhs[17] = ((1 / 1000.0) * stream_6_flow * stream_6_cp *
           (mixing[8] - reactor[8]) - Qr - reactor_exoth_heat) / reactor_Ncp

MPC.addControllerODEs(x, rhs)

r = NP.array([
    393.5,
    2.745,
    25.93,
    114.5 / 3600.0,
    98.0 / 3600.0,
    11.2 / 3600.0,
])
h = NP.array([reactor[8], pr_MPa, u[0], u[1], u[2], u[3]])
H = h - r
S = [9.8657122193156304e-01, 0.1428778068436973e-01, 0.01, 0.01, 0.01, 0.01]

ff = sum(S[0] * H[0]('coll') * H[0]('coll') +
         S[1] * H[1]('coll') * H[1]('coll') +
Esempio n. 4
0
rhs[5] = u[2] * stream_3_conc_F + stream_5_flow * stream_5_conc_F + stream_8_flow * stream_8_conc_F - stream_6_flow * (mixing[5]/mixing_zone_N)
rhs[6] = stream_5_flow * stream_5_conc_G + stream_8_flow * stream_8_conc_G - stream_6_flow * (mixing[6]/mixing_zone_N)
rhs[7] = stream_5_flow * stream_5_conc_H + stream_8_flow * stream_8_conc_H - stream_6_flow * (mixing[7]/mixing_zone_N)
rhs[8] = (u[3] * stream_1_cp * (stream_1_T - mixing[8]) + u[1] * stream_2_cp * (stream_2_T - mixing[8]) + u[2] * stream_3_cp * (stream_3_T - mixing[8]) + stream_5_flow * stream_5_cp * (Tstr - mixing[8]) + stream_8_flow * stream_8_cp * (stream_8_T - mixing[8]))/mixing_zone_Ncp;

rhs[9] = stream_6_flow * (stream_6_conc[0]) - stream_7_flow * (stream_7_conc[0]) + reactor_conv_rate[0];
rhs[10] = stream_6_flow * (stream_6_conc[1]) - stream_7_flow * (stream_7_conc[1]) + reactor_conv_rate[1];
rhs[11] = stream_6_flow * (stream_6_conc[2]) - stream_7_flow * (stream_7_conc[2]) + reactor_conv_rate[2];
rhs[12] = stream_6_flow * (stream_6_conc[3]) - stream_7_flow * (stream_7_conc[3]) + reactor_conv_rate[3];
rhs[13] = stream_6_flow * (stream_6_conc[4]) - stream_7_flow * (stream_7_conc[4]) + reactor_conv_rate[4];
rhs[14] = stream_6_flow * (stream_6_conc[5]) - stream_7_flow * (stream_7_conc[5]) + reactor_conv_rate[5];
rhs[15] = stream_6_flow * (stream_6_conc[6]) - stream_7_flow * (stream_7_conc[6]) + reactor_conv_rate[6];
rhs[16] = stream_6_flow * (stream_6_conc[7]) - stream_7_flow * (stream_7_conc[7]) + reactor_conv_rate[7];
rhs[17] = ((1/1000.0) * stream_6_flow * stream_6_cp * (mixing[8] - reactor[8]) - Qr - reactor_exoth_heat)/reactor_Ncp;

MPC.addControllerODEs(x,rhs)

r = NP.array([393.5,2.745,25.93,114.5/3600.0,98.0/3600.0,11.2/3600.0,])
h = NP.array([reactor[8],pr_MPa,u[0],u[1],u[2],u[3]])
H = h - r
S = [9.8657122193156304e-01,0.1428778068436973e-01,0.01,0.01,0.01,0.01]

ff = sum(S[0]*H[0]('coll')*H[0]('coll')+S[1]*H[1]('coll')*H[1]('coll')+S[2]*H[2]('coll')*H[2]('coll')+S[3]*H[3]('coll')*H[3]('coll')+S[4]*H[4]('coll')*H[4]('coll')+S[5]*H[5]('coll')*H[5]('coll')) 
MPC.addControlObjective(ff)

x1 = MPC.addPlantStates(18)
u1 = MPC.addPlantInputs(4)

mixing = x1[0:9] #mixing(8) is temperature
reactor = x1[9:18] #reactor(8) is temperature
w = prob.addControllerInputs(3,[-.5,-.5,0.0],[.5]*3)
#w.fix()
w.plot()
u = prob.addControllerInputs(1,[0.0],[1.0])

rhs = Expression(SX.zeros(3))
rhs[0] = x[0] - x[0]*x[1] + w[0]
rhs[1] = -x[1] + x[0]*x[1] + u*x[2]*x[1] + w[1]
rhs[2] = -x[2] + 0.50 + w[2]
m = SX.zeros(2,2)
m[0,0] = 2 + 1.414
m[1,0] = 1 + 1.414
m[0,1] = 1 + 1.414
m[1,1] = 1 + 1.414

prob.addControllerODEs(x,rhs)
f = sum((1 - x[0]('coll'))*(1 - x[0]('coll')) + (1 - x[1]('coll'))*(1-x[1]('coll')) + u('coll')*u('coll')) + (mul((mul((x[0:2](-1).T,m)),x[0:2](-1))))
prob.addControlObjective(f)
#prob.addConstraints(x(0),[1,1,0.50])
x1 = prob.addPlantStates(3)
u1 = prob.addPlantInputs(1)
rhs1 = SX.zeros(3)
rhs1[0] = x1[0] - x1[0]*x1[1]
rhs1[1] = -x1[1] + x1[0]*x1[1] + u1*x1[2]*x1[1]
rhs1[2] = -x1[2] + 0.50
prob.addPlantODEs(x1,rhs1)
x0 = NP.array([1,1,0.50])
prob.setInitCondition(x0)
solver = MPCsolve(prob,printlevel=0)
solver.solve()
solver.plotStates()#
Esempio n. 6
0
S22 = 0.5
S33 = 0.2
S44 = 0.5000
S55 = 0.0000005
r0 = NP.array([2.14, 1.09, 114.2, 112.9, 14.19, -1113.5])
r1 = NP.array([2.9805,0.9612,106.0,100.75,18.038,-4565.88])
r2 = NP.array([3.5176,0.7395,87.0,79.8,8.256,-6239.33])

tph = 3600.0

x0 = NP.array([1.0,0.5,100.0,100.0])
#########
MPC = MPCproblem(50,total_plant=3000,dis='MultipleShooting')
x1 = MPC.addControllerStates(4,[0.0,0.0,50.0,50.0,-1.0e06],[10.0,10.0,250.0,250.0,1.0e06],[2.14,1.09,114.2,112.9,0.0])

u1 = MPC.addControllerInputs(2,[3.0,-9000.0],[35.0,0.0])

cA = x1[0]
cB = x1[1]
theta = x1[2]
thetaK = x1[3]
k1 = k10*exp(E1/(273.15 +theta))
k2 = k20*exp(E2/(273.15 +theta))
k3 = k30*exp(E3/(273.15 +theta))
rhs = SX.zeros(4)
rhs[0] = (1/tph)*(u1[0]*(cA0-cA) - k1*cA - k3*cA*cA)
rhs[1] = (1/tph)* (- u1[0]*cB + k1*cA - k2*cB)
rhs[2] = (1/tph)*(u1[0]*(theta0-theta) - (1/(rho*Cp)) *(k1*cA*H1 + k2*cB*H2 + k3*cA*cA*H3)+(kw*AR/(rho*Cp*VR))*(thetaK -theta))
rhs[3] = (1/tph)*((1/(mK*CPK))*(u1[1] + kw*AR*(theta-thetaK)))
MPC.addControllerODEs(x1,u1,rhs)