102 #define RPENALTY (0.1) 144 static double T_x(
double T,
double x)
151 double P1,P2,P1_T,P2_T, F_T, F_x,
T_x;
159 F_T=x*P1_T+(1-x)*P2_T;
167 static void enthalpies_1(
double Temp,
double Pres,
double *hL1,
double *hV1,
double *hL1_T)
173 const double h11 = 18.31 ;
174 const double h21 = 1.713E-2 ;
175 const double h31 = 6.399E-5 ;
176 const double Tc1 = 512.6 ;
177 const double Pc1 = 8.096E6 ;
178 const double OMEGA1 = 0.557 ;
180 double TR1, PR1, Dhv1;
184 Dhv1 =
Rconst*Tc1*
sqrt(1-PR1/
pow(TR1,3))*(6.09648-1.28862*TR1+
185 1.016*
pow(TR1,7)+OMEGA1*(15.6875-13.4721*TR1+2.615*
pow(TR1,7)));
186 *hL1=(h11*(Temp-273.15)+h21*
pow(Temp-273.15,2)+h31*
pow(Temp-273.15,3))*4.186;
188 *hL1_T=(h11+h21*2*(Temp-273.15)+h31*3*
pow(Temp-273.15,2))*4.186;
191 static void enthalpies_2(
double Temp,
double Pres,
double *hL2,
double *hV2,
double *hL2_T)
197 const double h12 = 31.92 ;
198 const double h22 = 4.49E-2 ;
199 const double h32 = 9.663E-5 ;
200 const double Tc2 = 536.7 ;
201 const double Pc2 = 5.166E6 ;
202 const double OMEGA2 = 0.612 ;
204 double TR2, PR2, Dhv2;
208 Dhv2 =
Rconst*Tc2*
sqrt(1-PR2/
pow(TR2,3))*(6.09648-1.28862*TR2+
209 1.016*
pow(TR2,7)+OMEGA2*(15.6875-13.4721*TR2+2.615*
pow(TR2,7)));
210 *hL2=(h12*(Temp-273.15)+h22*
pow(Temp-273.15,2)+h32*
pow(Temp-273.15,3))*4.186;
212 *hL2_T=(h12+h22*2*(Temp-273.15)+h32*3*
pow(Temp-273.15,2))*4.186;
217 static void enthalpies(
double Temp,
double Pres,
double x,
double y,
218 double *hL,
double *hV,
double *hL_x_total)
226 double hL1, hV1, hL1_T, hL2, hV2, hL2_T, hL_x, hL_T;
232 hL_T=hL1_T*x+hL2_T*(1-x);
248 double d_m, vm, d_p, vp, vol_p, vol_m, vol_sum, v_mix;
249 d_m = 2.288/
pow(0.2685,(1+
pow((1 - TK/512.4),0.2453)));
252 d_p = 1.235/
pow(0.27136, (1+
pow((1- TK/536.4),0.24)));
257 vol_sum = vol_m + vol_p;
272 else if (x<R) xo=0.5*(x+
log(2*cosh(x)));
290 double volumeholdup, volumeoutflow, outflow, l_per_kmol;
291 const double alpha=500;
293 volumeholdup=l_per_kmol * n;
294 volumeoutflow = flowwidth*(
295 pow(1/alpha*
ramp(alpha*(volumeholdup-refvol)),1.5)
298 outflow=volumeoutflow / l_per_kmol;
328 double dummy, hL, hV, deltaH, Qloss;
360 par.
Tfeed = p[12] +273.15;
361 par.
Tcond = p[13] +273.15;
365 for (i=0; i<= 39; i++)
369 par.
Temp[i]=xa[80+i];
371 par.
Temp[40]=xa[120];
372 par.
Temp[41]=xa[121];
374 for (i=0; i<= 41; i++)
377 for (i=1; i<= 40; i++)
383 for (i=41; i>=1; i--)
392 for (i=0; i<= 41; i++)
396 par.
y[i]=par.
P1[i]*par.
x[i]/par.
Pres[i];
399 for (i=1; i<=
Nfeed; i++)
402 for (i=
Nfeed+1; i<= 40; i++)
419 Vc = (Q-Qloss)/deltaH;
422 for (i=0; i<= 41; i++)
424 if (i==0) holdup=par.
nvolB;
427 else if (i<41) holdup=par.
nvolK;
428 else if (i==41) holdup=par.
nvolD;
462 double Vmol, dVmol_x;
469 dx[i] = 1 / (par.
n[i]*(1 + dVmol_x * par.
x[i] / Vmol) )
470 * (par.
L[i+1]*par.
x[i+1] - par.
V[i]*par.
y[i] - par.
L[i]*par.
x[i]);
474 for (i=1; i<=40; i++)
476 dx[i] = -(1/par.
n[i])*par.
V[i]*(par.
y[i]-par.
x[i]);
477 dn[i-1] = -par.
V[i]-par.
L[i];
479 dx[i] += (1/par.
n[i])*par.
L[i+1]*(par.
x[i+1]-par.
x[i]);
480 dn[i-1] += par.
L[i+1];
482 dx[i] += (1/par.
n[i])*par.
V[i-1]*(par.
y[i-1]-par.
x[i]);
483 dn[i-1] += par.
V[i-1];
487 dx[i] += (1/par.
n[i])*par.
F*(par.
xF-par.
x[i]);
497 dx[i] = 1 / (par.
n[i]*(1 + dVmol_x * par.
x[i] / Vmol) )
498 * (par.
V[i-1]*par.
y[i-1] - par.
V[i]*par.
y[i] - par.
L[i]*par.
x[i]);
502 static void ffcn(
double *t,
double *xd,
double *xa,
double *u,
503 double *p,
double *
rhs ){
516 xdcopy[i]=xd[i]*1e-3;
522 xacopy[i]=xa[i]*1e-5;
524 xacopy[i]=xa[i]+273.15;
526 insert(xdcopy, xacopy, u, p);
542 static void gfcn(
double *t,
double *xd,
double *xa,
double *u,
543 double *p,
double *
rhs ){
548 double hL_x[42], hL[42], hV[42];
549 double dx[42],dn[42];
550 double Pfeed, yfeed, P1, P2, dummy;
551 double hLfeed, hVfeed;
564 xdcopy[i]=xd[i]*1e-3;
571 xacopy[i]=xa[i]*1e-5;
574 xacopy[i]=xa[i]+273.15;
578 insert(xdcopy, xacopy, u, p);
582 for (i=0; i<= 41; i++)
591 Pfeed=P1*par.
xF+(1-par.
xF)*P2;
592 yfeed=P1*par.
xF/Pfeed;
607 for (i=1; i<=40; i++)
624 rhs[40+i-1] = par.
V[i-1]*(hV[i-1] - hL[i])
625 - par.
V[i]*(hV[i] -hL[i])
626 + par.
L[i+1]*(hL[i+1]-hL[i])
627 - par.
n[i]*hL_x[i]*dx[i];
630 rhs[40+i-1] += par.
F*(hLfeed - hL[i]) + (1-
qF)*hVfeed;
636 for (i=0; i<= 41; i++)
637 rhs[80+i]=1-par.
P1[i]/par.
Pres[i]*par.
x[i]-(1-par.
x[i])*par.
P2[i]/par.
Pres[i];
static double ramp(double x)
IntermediateState sqrt(const Expression &arg)
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
static void enthalpies(double Temp, double Pres, double x, double y, double *hL, double *hV, double *hL_x_total)
static void enthalpies_1(double Temp, double Pres, double *hL1, double *hV1, double *hL1_T)
static void diffeq(double *dx, double *dn)
IntermediateState pow(const Expression &arg1, const Expression &arg2)
static double T_x(double T, double x)
static void gfcn(double *t, double *xd, double *xa, double *u, double *p, double *rhs)
static void ffcn(double *t, double *xd, double *xa, double *u, double *p, double *rhs)
void rhs(const real_t *x, real_t *f)
static double kmol_per_sec_outflow(double n, double TK, double x_m, double refvol, double flowwidth)
static void enthalpies_2(double Temp, double Pres, double *hL2, double *hV2, double *hL2_T)
static double litre_per_kmol(double TK, double x_m)
IntermediateState exp(const Expression &arg)
static void insert(double *xd, double *xa, double *u, double *p)
IntermediateState log(const Expression &arg)