MATLAB Answers

optimizing the steady state temperature of an MSMPR

2 views (last 30 days)
Timothy Campbell
Timothy Campbell on 15 Dec 2020
Commented: Timothy Campbell on 15 Dec 2020
Hi I'm a Chemical Engineering PhD student and I'm struggling with solving this problem.
The problem posed is to set the steady state temperature (temperature doesnt change with time) of the MSMPR (Mixed suspension mixed product removal). For a bit of background; it's a type of crystallisation process used in pharmaceutical processing.
Currently my code optimizes the temperature for each of the individual time steps of the dx/dt equations. As a result the temperature goes all over the place with respect to time.
I'm trying to get the code to optimize the size of crystals at the end of the process (@t=400) through altering the steady state temperature of the process.
the iteration process is as follows. there are other sacripts necessary to run the process however I have included the main bits of the iteration.
many thanks in advance.
function [f] = TempOptMSMPR_AvgCrystSize(x)
%Initial conditions
mui = 0;
Ci = 1; %kg/kgwater
x0 = [mui mui mui mui Ci];
tspan = [0, 400];
G = [];
for i=1:1:22; %XXX
T = x(i);
sol = ode45(@TempOptMSMPR_Mod, tspan, x0, [], T);
x0 = sol.y(:,end);
G = [G,sol.y(:,end)];
%maximising Growth
f = G;
close all
%% Bounds
x0 = [315];
lb = 293*ones(1,22); %XXXX
ub = 315*ones(1,22); %XXXX
nvars = 22; %difference between ub and lb constraints.
opts = optimoptions('fmincon','OptimalityTolerance',1e-10);
options = optimoptions('ga','PlotFcn', @gaplotbestf, 'Display', 'iter','Generations', 50, 'PopulationSize', 100);
fitfun = @TempOptMSMPR_Fitfun;
[x,fval] = ga(fitfun,nvars,[],[],[],[],lb,ub,[],options);

Answers (1)

Hiro on 15 Dec 2020
I am not fully following your code but if you are using MATLAB R2020b (the latest), you should have "Task" in live editor.
From Task, you'll find the one for optimization, which surely helps you work on the optimization.
Actually there are two approaches for optimization in MATLAB:
  1. solver based
  2. problem based
I suppose what you used was (1) which is more difficult than (2) and you can easily set things up from TASK that uses (2) method.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!