Main Content

Design Exploration Using Parameter Sampling (GUI)

This example shows how to sample and explore a design space using theSensitivity Analyzer. You explore the design of a Continuously Stirred Tank Reactor (CSTR) to minimize product concentration variation and production cost. The design must also account for the uncertainty in the temperature and concentration of the input feed to the reactor.

You explore the CSTR design by characterizing model parameters using probability distributions. You use the distributions to generate random samples and perform Monte-Carlo evaluation of the design at these sample points. You then create plots to visualize the design space and select the best design. You then use the best design as an initial guess for optimization of the design.

Continuously Stirred Tank Reactor (CSTR) Model

Continuously Stirred Tank Reactors (CSTRs) are common in the process industry. The Simulink® model,sdoCSTR, models a jacketed diabatic (i.e., non-adiabatic) tank reactor described in [1]. The CSTR is assumed to be perfectly mixed, with a single first-order exothermic and irreversible reaction,$A\rightarrow B$.$A$, the reactant, is converted to$B$, the product.

In this example, you use the following two-state CSTR model, which uses basic accounting and energy conservation principles:

$$\frac{d C_A}{dt} = \frac{F}{A * h}(C_{feed} - C_A)-r*C_A$$

$$\frac{d T}{dt} = \frac{F}{A * h}(T_{feed} - T) - \frac{H}{c_p \rho} r
-\frac{U}{c_p*\rho*h}(T - T_{cool})$$

$$r = k_0*e^{\frac{-E}{R*T}}$$

  • $C_A$, and$C_{feed}$- Concentrations of A in the CSTR and in the feed [kgmol/m^3]

  • $T$,$T_{feed}$, and$T_{cool}$- CSTR, feed, and coolant temperatures [K]

  • $F$and$\rho$- Volumetric flow rate [m^3/h] and the density of the material in the CSTR [1/m^3]

  • $h$and$A$- Height [m] and heated cross-sectional area [m^2] of the CSTR.

  • $k_0$- Pre-exponential non-thermal factor for reaction$A\rightarrow B$[1/h]

  • $E$andH美元- Activation energy and heat of reaction for$A\rightarrow B$[kcal/kgmol]

  • $R$- Boltzmann's gas constant [kcal/(kgmol * K)]

  • $c_p$and$U$- Heat capacity [kcal/K] and heat transfer coefficients [kcal/(m^2 * K * h)]

Open the Simulink model.

open_system('sdoCSTR');

CSTR Design Problem

假设that the CSTR is cylindrical, with the coolant applied to the base of the cylinder. Tune the CSTR cross-sectional area,$A$, and CSTR height,$h$, to meet the following design goals:

  • Minimize the variation in residual concentration,$C_A$. Variations in the residual concentration negatively affect the quality of the CSTR product. Minimizing the variations also improves CSTR profit.

  • Minimize the mean coolant temperature$T_{cool}$. Heating or cooling the jacket coolant is expensive. Minimizing the mean coolant temperature improves CSTR profit.

The quality of the feed to the reactor can differ among suppliers. Thus, the design must allow for variations in the supply feed concentration,$C_{feed}$, and feed temperature,$T_{feed}$. The quality of the feed differs from supplier to supplier and also varies within each supply batch.

Specify Design Variables

Open theSensitivity Analyzer. In the Simulink model from theAppstab, clickSensitivity AnalyzerunderControl Systems. The app opens with an empty Sensitivity Analysis session.

Create a parameter set that includes the CSTR design variablesAandhand the feed variation parametersFeedConc0andFeedTemp0. You randomly generate multiple values for these parameters to evaluate the CSTR design.

  • In theSensitivity Analysistab, in theSelect Parametersdrop-down menu, selectNew.

  • In the dialog box, selectA,FeedCon0,FeedTemp0, andh.

  • ClickOK. An empty parameter set,ParamSetis created in theParameter Setarea of the app browser.

Specify the parameter distributions and correlations.ParamSetwill be populate with parameter values selected randomly from the specified distributions:

  • SampleAfrom a uniform distribution with lower bound 0.2 m^2 and upper bound 2 m^2.

  • Samplehfrom a uniform distribution with lower bound 0.5 m and upper bound 3 m.

  • SampleFeedConc0from a normal distribution with mean 10 kgmol/m^3 and standard deviation 0.5 kgmol/m^3.

  • SampleFeedTemp0from a normal distribution with mean 295 K and standard deviation 3 K.

  • SpecifyFeedCon0andFeedTemp0as negatively correlated with covariance 0.6.

To generate 100 parameter values using the above distribution and correlation information, clickGenerate Values, and selectGenerate Random Values. For repeatability of the example reset the random number generator.

rng('default')

In theGenerate Random Parameter Valuesdialog box, specify the following:

  • Set the number of samples to 100

  • For parameterAselectUniformdistribution, set the lower bound to 0.2 and upper bound to 2.

  • For parameterFeedCon0selectNormaldistribution, setmuto 10 andsigmato 0.5, and checkcross-correlated.

  • For parameterFeedTemp0selectNormaldistribution, setmuto 295 andsigmato 3, and checkcross-correlated.

  • For parameterhselectUniformdistribution, set the lower bound to 0.5 and upper bound to 3.

  • In theCorrelation Matrixtab, set theFeedCon0,FeedTemp0covariance to -0.6.

  • ClickOKto generate the parameter values.

TheParamSettable is updated with the generated parameter values. Note that you can manually edit the generated parameter values in theParamSettable.

To plot the parameter set clickParamSetin theParameter Setsarea of the app browser. In thePlotstab, selectScatter Plotin the plots gallery. The plot shows the histogram of the generated parameters on the diagonal and pair-wise parameter values on the off-diagonal.

Note that due to the random number generator the specific values in the plots and tables below may differ from what you get when running the example.

Each marker on the plot represents one row of theParamSet表,每一行是同时displayed on all the plots. The correlation betweenFeedCon0andFeedTemp0can be seen on the plot.

Specify Requirements for Evaluation

The CSTR design is required to minimize the variation in residual concentration and minimize the mean coolant temperature. SelectNew Requirementand clickSignal Propertyto create a requirement to minimize the residual concentration variation.

In theCreate Requirementdialog box, specify the following fields:

  • In thePropertydrop-down list, selectSignal Variance.

  • In thetypedrop-down list, selectMinimize.

  • In theSelect Signalsarea, select a logged signal to apply the requirement to. To do so click+. ACreate Signal Setdialog box opens where you specify the logged signal. In the Simulink model, click the signal at theCAoutput of theCSTRblock. The dialog box now displays this signal. Add the signal to the signal set and clickOK.

  • Close the Signal Property requirement dialog by clicking the x in the upper right dialog corner.

Close theCreate Requirementdialog box. A new requirement,SignalProperty中列出的Requirementsarea of the app browser

  • Right-clickSignalProperty, selectRename; rename the requirement toConcVar.

SelectNew Requirementand clickSignal Propertyto create a requirement to minimize the coolant mean (output of blocksdoCSTR/Controller) temperature.

In theCreate Requirementdialog box, specify the following fields:

  • In thePropertydrop-down list, selectSignal Mean.

  • In theTypedrop-down list, selectMinimize.

  • In theSelect Signalsarea, add thesdoCSTR/Controllersignal to the requirement.

Close theCreate Requirementdialog box. A new requirement,SignalPropertyis created in theRequirementsarea of the app browser. Rename the requirementCoolMean.

Evaluate

In theSensitivity Analysistab, clickSelect for Evaluation. By default, all requirements are selected to be evaluated. ClickEvaluate Modelto evaluate theConcVarandCoolMeanrequirements for each row of parameter values inParamSet. Note you can speed up evaluation by using parallel computing if you have the Parallel Computing Toolbox (TM), or by using fast restart. For more information, see "Use Parallel Computing for Sensitivity Analysis" and "use Fast Restart Mode During Sensitivity Analysis" in the Simulink Design Optimization™ documentation.

A results scatter plot showing each parameter vs each requirement is updated during model evaluation. At the end of evaluation a table with the evaluation results is created, each row in the evaluation result table contains values forA,FeedCon0,FeedTemp0,hand the resulting requirement valuesConcVarandCoolMean. The evaluation results are stored in theEvalResultvariable in theResultsarea of the app.

Analyze the Evaluation Results

The results scatter plot forEvalResultshows thatCoolMeanis inversely correlated withh(increasinghdecreasesCoolMean) and that low values ofhcan result in high values forConcVar. The plot shows that low values ofAcan result in high values forConcVar, but it is not clear from the plot howAis correlated withConcVarorCoolMeanor which parameter influencesConcVarthe most. To investigate further, in theStatisticstab, select all the analysis methods and types and clickCompute Statistics. This performs analysis on the evaluation results and creates a tornado plot. The tornado plot shows the influence of each parameter on each requirement:

  • his inversely correlated withCoolMean, and is the parameter that influencesCoolMeanthe most.

  • Ais inversely correlated withCoolMean.

  • FeedCon0andFeedTemp0are inversely correlated withCoolMean.

  • Ais inversely correlated withConcVar, and is the parameter that influencesConcVarthe most.

  • his inversely correlated withConcVar.

  • FeedCon0andFeedTemp0have mixed correlation withConVar, but have minimal correlation withConcVar.

The analysis shows that choosing a largeh, to reduceCoolMeanand choosing a largeAto reduceCoolVarwould appear to be a good design choice. You can confirm this by creating a contour plot ofCoolMeanandCoolVarversushandA. SelectEvalResultfrom theResultsarea of the app browser, and in thePlotstab, in the plots gallery clickContour plot. On the contour plot selecthfor theY parameter, note that largehmedium values ofAgive low values for bothConcVarandCoolMean.

Choose an Initial Guess for Optimization

Sort the Evaluation Result table by decreasingh, and select a row that has lowConcVarandCoolMeanvalues. Right-click the selected row and clickExtract Parameter Values. The extracted parameter values are saved in theParamValuesvariable in theResultsarea of the app browser. These parameter values are used as the initial guess for optimization.

Optimize

Use the data in theSensitivity Analyzerto create an optimization problem to optimizeAandh. In theSensitivity Analysistab clickOptimize, and selectCreate Response Optimization Session. This opens a dialog to import data from Sensitivity Analysis to Response Optimizer.

  • Select both theConcVarandCoolMeanrequirements to import.

  • SelectParamValuesto import as design variables for optimization.

  • SelectEvalResultto import as uncertain variables to use during optimization.

  • ClickOKto import the data to theResponse Optimizer

Configure theResponse Optimizerto optimize the CSTR design:

  • Click the pencil icon to edit theParamValuesdesign variable set, and remove theFeedCon0andFeedTemp0variables from the design variable set.

  • SelectEvalResultas the uncertain variable set, click the pencil icon to editEvalResult, and removeAandhfrom the uncertain variable set.

Add iteration plots to see how the variablesParamValues(Aandh), and optimization requirementsConcVarandCoolMeanchange during optimization.

  • Select the variables in theData to Plotdrop-down list, and selectIteration Plotin theAdd Plotdrop-down list.

  • ClickOptimize.

The optimization minimizesCoolMeanandConcVarin the presence of varyingFeedCon0andFeedTemp0.

相关的例子

To learn how to explore the CSTR design space using thesdo.evaluatecommand, seeDesign Exploration Using Parameter Sampling (Code).

References

[1] Bequette, B.W.Process Dynamics: Modeling, Analysis and Simulation.1st ed. Upper Saddle River, NJ: Prentice Hall, 1998.

Close the model

bdclose('sdoCSTR')

Related Topics