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)) rhs1 = SX.zeros(4) rhs1[0] = (1/tph)*(u1[0]*(cA0-cA) - k1*cA - k3*cA*cA) rhs1[1] = (1/tph)* (- u1[0]*cB + k1*cA - k2*cB) rhs1[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)) rhs1[3] = (1/tph)*((1/(mK*CPK))*(u1[1] + kw*AR*(theta-thetaK))) MPC.addPlantODEs(x1,rhs1) MPC.setInitCondition(x0) MPC.addMeasurementNoise([2,3],[5,5]) #### ESTIMATOR sigma_y = NP.array([5,5]) V = (sigma_y**2) * NP.eye(2) sigma_x0 = 0.05 P00 = (sigma_x0**2) * NP.eye(4) est = Estimator('ukf',[2,3],V,P00) x2 = est.addStates(4,[0.0,0.0,50.0,50.0],[10.0,10.0,250.0,250.0],[2.14,1.09,114.2,112.9,0.0]) u2 = est.addControls(2,[3.0,-9000.0],[35.0,0.0]) cA = x2[0] cB = x2[1] theta = x2[2] thetaK = x2[3]
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)) rhs1 = SX.zeros(4) rhs1[0] = (1 / tph) * (u1[0] * (cA0 - cA) - k1 * cA - k3 * cA * cA) rhs1[1] = (1 / tph) * (-u1[0] * cB + k1 * cA - k2 * cB) rhs1[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)) rhs1[3] = (1 / tph) * ((1 / (mK * CPK)) * (u1[1] + kw * AR * (theta - thetaK))) MPC.addPlantODEs(x1, rhs1) MPC.setInitCondition(x0) MPC.addMeasurementNoise([0, 3], [0.05, 5]) #### ESTIMATOR sigma_y = NP.array([0.05, 5]) V = (sigma_y**2) * NP.eye(2) sigma_x0 = 0.05 P00 = (sigma_x0**2) * NP.eye(4) est = Estimator('ukf', [0, 3], V, P00) x2 = est.addStates(4, [0.0, 0.0, 50.0, 50.0], [10.0, 10.0, 250.0, 250.0], [2.14, 1.09, 114.2, 112.9, 0.0]) u2 = est.addControls(2, [3.0, -9000.0], [35.0, 0.0]) cA = x2[0] cB = x2[1] theta = x2[2] thetaK = x2[3]
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)) rhs1 = SX.zeros(4) rhs1[0] = (1/tph)*(u1[0]*(cA0-cA) - k1*cA - k3*cA*cA) rhs1[1] = (1/tph)* (- u1[0]*cB + k1*cA - k2*cB) rhs1[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)) rhs1[3] = (1/tph)*((1/(mK*CPK))*(u1[1] + kw*AR*(theta-thetaK))) MPC.addPlantODEs(x1,rhs1) MPC.setInitCondition(x0) MPC.addMeasurementNoise([2,3],[2,2]) #### ESTIMATOR sigma_y = NP.array([2,2]) V = (sigma_y**2) * NP.eye(2) sigma_x0 = 0.00005 P00 = (1.0/sigma_x0) * NP.eye(4) est = Estimator('mhe',[0,3],V,P00) est.defineHorizon(20,10.) x2 = est.addStates(4,[0.0,0.0,50.0,50.0],[10.0,10.0,250.0,250.0],[2.14,1.09,114.2,112.9,0.0]) u2 = est.addControls(2,[3.0,-9000.0],[35.0,0.0]) cA = x2[0] cB = x2[1] theta = x2[2] thetaK = x2[3]
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)) rhs1 = SX.zeros(4) rhs1[0] = (1/tph)*(u1[0]*(cA0-cA) - k1*cA - k3*cA*cA) rhs1[1] = (1/tph)* (- u1[0]*cB + k1*cA - k2*cB) rhs1[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)) rhs1[3] = (1/tph)*((1/(mK*CPK))*(u1[1] + kw*AR*(theta-thetaK))) MPC.addPlantODEs(x1,rhs1) MPC.setInitCondition(x0) MPC.addMeasurementNoise([0,3],[0.05,5]) #### ESTIMATOR sigma_y = NP.array([0.05,5]) V = (sigma_y**2) * NP.eye(2) sigma_x0 = 0.05 P00 = (sigma_x0**2) * NP.eye(4) est = Estimator('ukf',[0,3],V,P00) x2 = est.addStates(4,[0.0,0.0,50.0,50.0],[10.0,10.0,250.0,250.0],[2.14,1.09,114.2,112.9,0.0]) u2 = est.addControls(2,[3.0,-9000.0],[35.0,0.0]) cA = x2[0] cB = x2[1] theta = x2[2] thetaK = x2[3]