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,., the reactant, is converted to, the product.
In this example, you use the following two-state CSTR model, which uses basic accounting and energy conservation principles:
, and- Concentrations of A in the CSTR and in the feed [kgmol/m^3]
,, and- CSTR, feed, and coolant temperatures [K]
and- Volumetric flow rate [m^3/h] and the density of the material in the CSTR [1/m^3]
and- Height [m] and heated cross-sectional area [m^2] of the CSTR.
- Pre-exponential non-thermal factor for reaction[1/h]
and- Activation energy and heat of reaction for[kcal/kgmol]
- Boltzmann's gas constant [kcal/(kgmol * K)]
and- 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,, and CSTR height,, to meet the following design goals:
Minimize the variation in residual concentration,. 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. 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,, and feed temperature,. 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 variablesA
andh
and the feed variation parametersFeedConc0
andFeedTemp0
. 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, select
A
,FeedCon0
,FeedTemp0
, andh
.ClickOK. An empty parameter set,
ParamSet
is created in theParameter Setarea of the app browser.
Specify the parameter distributions and correlations.ParamSet
will be populate with parameter values selected randomly from the specified distributions:
Sample
A
from a uniform distribution with lower bound 0.2 m^2 and upper bound 2 m^2.Sample
h
from a uniform distribution with lower bound 0.5 m and upper bound 3 m.Sample
FeedConc0
from a normal distribution with mean 10 kgmol/m^3 and standard deviation 0.5 kgmol/m^3.Sample
FeedTemp0
from a normal distribution with mean 295 K and standard deviation 3 K.Specify
FeedCon0
andFeedTemp0
as 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 parameter
A
selectUniformdistribution, set the lower bound to 0.2 and upper bound to 2.For parameter
FeedCon0
selectNormaldistribution, setmu
to 10 andsigma
to 0.5, and checkcross-correlated
.For parameter
FeedTemp0
selectNormaldistribution, setmu
to 295 andsigma
to 3, and checkcross-correlated
.For parameter
h
selectUniformdistribution, set the lower bound to 0.5 and upper bound to 3.In theCorrelation Matrixtab, set the
FeedCon0
,FeedTemp0
covariance to -0.6.ClickOKto generate the parameter values.
TheParamSet
table is updated with the generated parameter values. Note that you can manually edit the generated parameter values in theParamSet
table.
To plot the parameter set clickParamSet
in 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 betweenFeedCon0
andFeedTemp0
can 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+. A
Create Signal Set
dialog box opens where you specify the logged signal. In the Simulink model, click the signal at theCA
output of theCSTR
block. 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-click
SignalProperty
, 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 the
sdoCSTR/Controller
signal to the requirement.
Close theCreate Requirementdialog box. A new requirement,SignalProperty
is 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 theConcVar
andCoolMean
requirements 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
,h
and the resulting requirement valuesConcVar
andCoolMean
. The evaluation results are stored in theEvalResult
variable in theResultsarea of the app.
Analyze the Evaluation Results
The results scatter plot forEvalResult
shows thatCoolMean
is inversely correlated withh
(increasingh
decreasesCoolMean
) and that low values ofh
can result in high values forConcVar
. The plot shows that low values ofA
can result in high values forConcVar
, but it is not clear from the plot howA
is correlated withConcVar
orCoolMean
or which parameter influencesConcVar
the 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:
h
is inversely correlated withCoolMean
, and is the parameter that influencesCoolMean
the most.A
is inversely correlated withCoolMean
.FeedCon0
andFeedTemp0
are inversely correlated withCoolMean
.A
is inversely correlated withConcVar
, and is the parameter that influencesConcVar
the most.h
is inversely correlated withConcVar
.FeedCon0
andFeedTemp0
have mixed correlation withConVar
, but have minimal correlation withConcVar
.
The analysis shows that choosing a largeh
, to reduceCoolMean
and choosing a largeA
to reduceCoolVar
would appear to be a good design choice. You can confirm this by creating a contour plot ofCoolMean
andCoolVar
versush
andA
. SelectEvalResult
from theResultsarea of the app browser, and in thePlotstab, in the plots gallery clickContour plot. On the contour plot selecth
for theY parameter, note that largeh
medium values ofA
give low values for bothConcVar
andCoolMean
.
Choose an Initial Guess for Optimization
Sort the Evaluation Result table by decreasingh
, and select a row that has lowConcVar
andCoolMean
values. Right-click the selected row and clickExtract Parameter Values. The extracted parameter values are saved in theParamValues
variable 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 optimizeA
andh
. In theSensitivity Analysistab clickOptimize, and selectCreate Response Optimization Session. This opens a dialog to import data from Sensitivity Analysis to Response Optimizer.
Select both the
ConcVar
andCoolMean
requirements to import.Select
ParamValues
to import as design variables for optimization.Select
EvalResult
to 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 the
ParamValues
design variable set, and remove theFeedCon0
andFeedTemp0
variables from the design variable set.
Select
EvalResult
as the uncertain variable set, click the pencil icon to editEvalResult
, and removeA
andh
from the uncertain variable set.
Add iteration plots to see how the variablesParamValues
(A
andh
), and optimization requirementsConcVar
andCoolMean
change during optimization.
Select the variables in the
Data to Plot
drop-down list, and selectIteration Plot
in theAdd Plot
drop-down list.ClickOptimize.
The optimization minimizesCoolMean
andConcVar
in the presence of varyingFeedCon0
andFeedTemp0
.
相关的例子
To learn how to explore the CSTR design space using thesdo.evaluate
command, 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')