model MultiParameterCSTRWithObjectives // --- 1. Fixed Process Constants --- parameter Real V = 2.0 "Reactor volume (m3)"; parameter Real k0_A = 2.5e7 "Pre-exponential factor Reaction A->B (1/s)"; parameter Real k0_B = 4.0e7 "Pre-exponential factor Reaction B->C (1/s)"; parameter Real E_A = 48000 "Activation energy A->B (J/mol)"; parameter Real E_B = 52000 "Activation energy B->C (J/mol)"; parameter Real R = 8.314 "Ideal gas constant (J/mol.K)"; parameter Real deltaH_A = -65000 "Heat of reaction A->B (J/mol)"; parameter Real deltaH_B = -45000 "Heat of reaction B->C (J/mol)"; parameter Real rho = 950 "Fluid density (kg/m3)"; parameter Real Cp = 3800 "Fluid heat capacity (J/kg.K)"; parameter Real UA = 2500 "Heat transfer coefficient (W/K)"; parameter Real CB0 = 0.0 "Feed concentration of Product B (mol/m3)"; parameter Real CC0 = 0.0 "Feed concentration of Byproduct C (mol/m3)"; parameter Real Prod_target = 0.10 "Minimum production rate of B (mol/s)"; // --- 3. Multi-Parameter Inputs (Design Space for Sampling/Optimization) --- parameter Real F(start=0.4, min=0.05, max=0.5) = 0.4 "Volumetric flow rate (m3/s)"; parameter Real CA0(start=1.5, min=0.5, max=3.0) = 1.5 "Feed concentration of Reactant A (mol/m3)"; parameter Real T0(start=298.15, min=285.0, max=320.0) = 298.15 "Feed temperature (K)"; parameter Real Tc(start=310.0, min=275.0, max=600.0) = 310.0 "Cooling jacket fluid temperature (K)"; // --- 4. Process State Outputs (steady-state: algebraic, not integrated) --- output Real CA(start=0.5) "Concentration of Reactant A (mol/m3)"; output Real CB(start=0.5) "Concentration of Desired Product B (mol/m3)"; output Real CC(start=0.1) "Concentration of Undesired Byproduct C (mol/m3)"; output Real T(start=340.0) "Reactor Temperature (K)"; // --- 5. Optimization Target Metrics --- output Real Conversion "Conversion of reactant A (0 to 1)"; output Real Selectivity "Selectivity of B relative to C"; output Real Yield "Yield of desired product B (0 to 1)"; output Real Productivity "Production rate of B leaving the reactor (mol/s)"; output Real TargetMargin "Productivity - Prod_target; feasible when >= 0 (mol/s)"; // Internal reaction rates Real r_A "Rate of A consumption"; Real r_B "Rate of B production/consumption"; equation // Kinetic Equations (Arrhenius Dependency) r_A = k0_A * exp(-E_A / (R * T)) * CA; r_B = r_A - k0_B * exp(-E_B / (R * T)) * CB; // Steady-State Mass Balances (accumulation = 0) 0 = (F / V) * (CA0 - CA) - r_A; 0 = (F / V) * (CB0 - CB) + r_B; 0 = (F / V) * (CC0 - CC) + k0_B * exp(-E_B / (R * T)) * CB; // Steady-State Energy Balance (accumulation = 0) 0 = (F / V) * (T0 - T) - (deltaH_A / (rho * Cp)) * r_A - (deltaH_B / (rho * Cp)) * (k0_B * exp(-E_B / (R * T)) * CB) - (UA / (V * rho * Cp)) * (T - Tc); // --- 6. Performance & Objective Formulation --- // Avoid division by zero at start using small regularization or conditional bounds Conversion = (CA0 - CA) / max(CA0, 1e-5); Selectivity = CB / max(CB + CC, 1e-5); Yield = CB / max(CA0, 1e-5); Productivity = F * CB; TargetMargin = Productivity - Prod_target; end MultiParameterCSTRWithObjectives;