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)
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)];
f = G;
x0 = ;
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);