//this is a file in the VAc dynamic model software package //this is the main file for the simulation //Copyright: Rong Chen and Kedar Dave, June 2002 //VERSION 1.0 //This file integrates all the unit operation models ande completes the whole plant flowsheet //Please refer to the readme file for details //Please also refer to Luyben and Tyreus's previous work for other information #include #include #include "mex.h" void VAModel(double *dstatesdt, double *states_out, double *MVs_out, double *measurements, double states[], double MVs[], double time, int is_initial, int disturbance_ID) { //-------------------------------------------------------------------------- /*output: dstatesdt: state derivatives states_out: states (generated in initialization) MVs_out: (duplicated when no perfect control is selected), (partially calculated when perfect control is selected) or (generated in initialization) measurements: total available measurements, which can be easily extended by a user --------------------------------------------------------------------------*/ //-------------------------------------------------------------------------- /*input: states MVs time: current running time in minute is_initial: 1 for loading initial steady state data, 0 for dynamic simulation disturbance_ID: 1 and 2 --------------------------------------------------------------------------*/ /*---------------------------------constants-------------------------------*/ //physical properties //Data is not the same as Table 1 in Luyben's paper double Vi[7] = {64.178, 37.400, 49.347, 52.866, 101.564, 18.01, 61.445}; double AIJ[7][7]= { {0., 0., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 0., 1384.6, -136.1}, {0., 0., 0., 0., 2266.4, 0., 670.7}, {0., 0., 0., 0., 726.7, 230.6, 0.}, }; /*Data from Table 2 (Pure component physical properties).*/ double MW[7] = {32., 44.01, 28.052, 30.068, 86.088, 18.008, 60.052}; double SpG[7] = {0.5, 1.18, 0.57, 0.57, 0.85, 1.0, 0.98}; /*liquid specific gravity based on the density od water at 0 degC*/ double HVAP[7] = {2300., 2429., 1260., 1260., 8600., 10684., 5486.}; double HCAPLa[7] = {0.3, 0.6, 0.6, 0.6, 0.44, 0.99, 0.46}; double HCAPLb[7] = {0., 0., 0., 0., 0.0011, 0.0002, 0.0012}; double HCAPVa[7] = {0.218, 0.23, 0.37, 0.37, 0.29, 0.56, 0.52}; double HCAPVb[7] = {0.0001, 0., 0.0007, 0.0007, 0.0006, -0.0016, 0.0007}; /*Data from Table 3 (Component vapor pressure antoine coefficients*/ double A[7] = {9.2, 7.937, 9.497, 9.497, 12.6564, 14.6394, 14.5236}; double B[7] = {0., 0., -313., -313., -2984.45, -3984.92, -4457.83}; double C[7] = {273.16, 273.16, 273.16, 273.16, 226.66, 233.43, 258.45}; /*Others*/ double R = 1.987; /*Gas constant, kcal/(kmol*K)*/ double Dw = 999.; /*density of water at 0 degC, kg/m3*/ double T_ref = 273.16; /*Reference Temperature, K*/ /*---------------------------------constants-------------------------------*/ //feed stream properties /*F_O2 is MV 1*/ double y_O2[7]={1., 0., 0., 0., 0., 0., 0}; double T_O2[1]={30.}; double P_O2[1]={150.}; /*F_C2H4 is MV 2*/ double y_C2H4[7]={0., 0., 0.999, 0.001, 0., 0., 0}; double T_C2H4[1]={30.}; double P_C2H4[1]={128.}; /*F_HAc is MV 3*/ double x_HAc[7]={0., 0., 0., 0., 0., 0., 1.}; double T_HAc[1]={30.}; double P_HAc[1]={150.}; /*---------------------------------constants-------------------------------*/ /*Vaporizer*/ double Total_Volume_vaporizer[1] = {17.}; /*m3, which is 600/(3.2808)^3 in TMODS, not used in our model*/ double Working_Volume_vaporizer[1] = {4.}; /*m3, maximum measurable liquid holdup (100% level)*/ /*-----------------------------------------------------------------------------*/ /*Reactor*/ double friction_factor[1]={0.000794745091749963}; /*0.00147*2.20462*(3.2808)^3/144: deltaP=friction_factor*density*volumetric flowrate*volumetric flowrate*/ int NR[1] = {11}; double tube_L[1] ={10.}; int tube_number[1] = {622}; double tube_diameter[1] ={0.0371}; double tube_area[1] = {0.67240058914293}; /*tube_area=1/4*pi*tube_diameter*tube_diameter*tube_number. total intersection area, m^2*/ double UA_reactor[1] = {269.839144893182}; /*UA=4000*0.252*9/5/10/tube_area/1; kcal/min m^3 degC*/ double cata_bulk_density[1] = {385.}; double cata_heatcapacity[1] = {0.23}; double cata_porosity[1] = {0.8}; double cata_weight[1] = {2588.74226820028}; /*cata_weight=tube_area*tube_L*cata_bulk_density;*/ double E_r1[1] = {-42100.}; /*heat of reaction for r1, kcal/kmol*/ double E_r2[1] = {-316000.}; /*heat of reaction for r2, kcal/kmol*/ double sto1[7]={-0.5, 0., -1., 0., 1., 1., -1.}; double sto2[7]={-3., 2., -1., 0., 0., 2., 0.}; /*-----------------------------------------------------------------------------*/ /*FEHE*/ double UA_FEHE[1]={6483./60.0}; /*kcal/min degC*/ double Ref_hotflow[1]={589.670}; /*kg/min*/ double Ref_coolflow[1]={498.952}; /*kg/min*/ double Ref[1]={0.8}; /*-----------------------------------------------------------------------------*/ /*Separator*/ double Total_Volume_separator[1]={15.}; /*m3, which is 535/3.2808/3.2808/3.2808 in TMODS, not used in our model*/ double Working_Volume_separator[1]={8.}; /*m3, maximum measurable liquid holdup (100% level)*/ double Total_Gas_Loop_Volume[1]={170.}; /*m3, which is 6002/3.2808/3.2808/3.2808 in TMODS*/ double UA_separator[1]={20007.*0.252*9/5}; /*kcal/min degC*/ /*-----------------------------------------------------------------------------*/ /*Compressor*/ double Compressor_coefficient[1]={15000.}; /*delta_P=Compressor_coefficient*density/144*/ /*-----------------------------------------------------------------------------*/ /*Absorber*/ int NT_absorber[1]={8}; int NF_absorber[1]={2}; double Working_Volume_absorber[1]={8.5}; /*m3, which is 300/3.2808/3.2808/3.2808 in TMODS*/ double M0_absorber[8]={30/2.20462, 30/2.20462, 30/2.20462, 30/2.20462, 30/2.20462, 30/2.20462, 30/2.20462, 30/2.20462}; double L0_absorber[8]={16.327, 16.311, 0.911, 0.885, 0.853, 0.844, 0.829, 0.815}; double hydtau_absorber[1]={0.1}; double Nmt[8]={60/2.20462, 60/2.20462, 60/2.20462, 60/2.20462, 60/2.20462,60/2.20462, 60/2.20462, 60/2.20462}; double Qmt[8]={400*0.252, 400*0.252, 200*0.252, 200*0.252, 200*0.252, 200*0.252, 200*0.252, 200*0.252}; /*-----------------------------------------------------------------------------*/ /*CO2 Remove*/ double CO2_F_ref[1]={6.41360260517487}; double CO2_x_ref[1]={0.0134241598608995}; /*-----------------------------------------------------------------------------*/ /*Column*/ int NT_column[1]={20}; int NF_column[1]={15}; double P_top[1]={18.}; double P_bottom[1]={30.}; double K_decanter[3]={395., 0.05, 1.}; /*decanter partition coefficients*/ double hydtau_column[1]={0.1}; double M0_column[20]; /*Tray holdup (kmol)*/ double L0_column[20]; double Bottom_Working_Level_Volume[1]={5.66};/*m3, which is 200/3.2808/3.2808/3.2808 in TMODS*/ double Organic_Working_Level_Volume[1]={1.7};/*m3, which is 60/3.2808/3.2808/3.2808 in TMODS*/ double Aqueous_Working_Level_Volume[1]={1.7};/*m3, which is 60/3.2808/3.2808/3.2808 in TMODS*/ double HAcTank_Working_Level_Volume[1]={2.83};/*m3, which is 100/3.2808/3.2808/3.2808 in TMODS*/ double T_Column[20]={131, 121, 106, 96, 93, 92, 91, 90, 89, 88, 88, 87, 86, 85, 84, 80, 78, 77, 76, 75}; //initial guess of column temperature profile /*---------------------------------constants-------------------------------*/ /*---------------------------------variables-------------------------------*/ //vaporizer states double x_vaporizer[7], hup_vaporizer[1], T_vaporizer[1]; /*---------------------------------variables-------------------------------*/ //reactor states double C_O2[11], C_CO2[11], C_C2H4[11], C_VAc[11], C_H2O[11], C_HAc[11], T_reactor[11]; /*---------------------------------variables-------------------------------*/ //separator states double x_separator[7], hup_separator[1], TL_separator[1]; double y_separator[7], P_separator[1], TV_separator[1]; /*---------------------------------variables-------------------------------*/ //absorber states double x_absorber[8][7], M_absorber[8], TL_absorber[8]; double x_base[7], hup_base[1], T_base[1]; /*---------------------------------variables-------------------------------*/ //column, decanter and HAc tank states double x_column[20][7], M_column[20], x_bottom[7], hup_bottom[1]; double x_organic[7], hup_organic[1], x_aqueous[7], hup_aqueous[1]; double x_HAcTank[7], hup_HAcTank[1], T_HAcTank[1]; /*---------------------------------variables-------------------------------*/ //other states double T_VapHeaterOut[1], T_ABSIN_Gas[1], T_Circulation[1], T_Scrub[1], T_decanter[1], T_FEHEColdOut[1], T_SEPIN[1]; /*---------------------------------variables-------------------------------*/ /*---------------------------------MVs-------------------------------*/ double F_O2, F_C2H4, F_HAc, Q_Duty_Vaporizer, F_vaporizer, Q_Heater; double Shell_T_RCT, F_SepLiquidOUT, Shell_T_Sep, F_SepVaporOUT; double Q_Compressor, F_AbsLiquidOut, F_Circulation, Q_Circulation, F_Scrub, Q_Scrub; double F_CO2, F_Purge, bypass, F_Reflux, Q_Reboiler, F_Organic, F_Aqueous, F_Bottom, Q_Condenser, F_VapLiquidIn; /*---------------------------------MVs-------------------------------*/ /*---------------------------------Other Variables-------------------------------*/ double F_GasRemovalIn[1], x_GasRemovalIn[7], T_GasRemovalIn[1]; double F_ABSIN_Gas2[1], y_ABSIN_Gas2[7], T_ABSIN_Gas2[1]; double F_COLIN[1], x_COLIN[7], T_COLIN[1]; double F_CompressorIn[1],y_CompressorIn[7],T_CompressorIn[1]; double F_ABSIN_Gas[1], y_ABSIN_Gas[7], T_CompCoolerIn[1], P_recycle[1]; double dummy[1], HV_ABSIN_Gas[1], temp_x_HAcTank[7]={0.,0.,0.,0.,0.,0.,0.}; double temp_HV[1], HV_CompCoolerIn[1]; double AAA, BBB, CCC; double Level[1], TV[8], TL[8]; double F_AbsGasOut[1], y_AbsGasOut[7], T_AbsGasOut[1], x_AbsLiquidOut[7]; double T_AbsLiquidOut[1]; double F_CO2Purge[1], y_CO2Purge[7], T_CO2Purge[1], y_Purge[7], T_Purge[1], F_ToVap[1], y_ToVap[7]; double T_ToVap[1], F_FEHEIN_cold[1], y_FEHEIN_cold[7], T_FEHEIN_cold[1]; double ps[7], g[7]; double P_vaporizer[1], y_vaporizer[7], HV_vaporizer[1], HV_heaterOut[1]; double F_RCTIN[1], y_RCTIN[7], T_RCTIN[1], P_RCTIN, C_RCTIN, P_Drop, r_RCTIN, G_RCTIN, V_RCTIN; double C_FEHEIN_hot, F_FEHEIN_hot[1], y_FEHEIN_hot[7], T_FEHEIN_hot[1], F_FEHEColdOut[1], y_FEHEColdOut[7]; double F_SEPIN[1], y_SEPIN[7], F_VapVapIn[1], y_VapVapIn[7], T_VapVapIn[1], x_VapLiquidIn[7]={0.,0.,0.,0.,0.,0.,0.}, T_VapLiquidIn[1]; double P_Column[20], beta_out[1]; double Level_Vaporizer[1], y_Vaporizer[7], T_Vaporizer[1], P_Vaporizer[1]; double x_Organic[7], T_Organic[1], x_Aqueous[7], T_Aqueous[1]; double states_abs[72], states_vap[8], states_rct[70], states_sep[16], states_col[73]; double dstatesdt_abs[72], dstatesdt_vap[8], dstatesdt_rct[70], dstatesdt_sep[16], dstatesdt_col[73], dstatesdt_other[7]; double Q_Circulation_out[1], Q_Scrub_out[1], Q_Condenser_out[1]; int i, j; double sum1, sum2, sum3, temp_single_1[1], temp_single_2[1]; double VIJ[7][7]; for (i=0;i<7;i++) { for (j=0;j<7;j++) VIJ[i][j] = Vi[j]/Vi[i]; }; for (i=0;i