Multiobjective optimization using aspen plus

Hi. I'm trying to optimize a distillation column in aspen plus by matlab. For that I am using the Optimization Toolbox with the gamultiobj algorithm. The objectives are to minimize the cost functions (TAC) for both fixed costs (TAC (1)) and for variable costs (TAC (2)). The cost calculation for the column, the referrer and the reboiler is included in the code. However, when the optimization starts, the following message appears: "struct contents reference from a non-struct array object". Can someone help me?
function TAC = Objective(x)
global Aspen
Aspen = actxserver('Apwn.Document.36.0');
[~,mess]=fileattrib;
Aspen.invoke('InitFromArchive2',[mess.Name '\SimulationACRYL2.bkp']);
Aspen.Visible = 1;
Aspen.SuppressDialogs = 1;
Aspen.Engine.Run2(1);
while Aspen.Engine.IsRunning == 1
pause(0.5);
end
Stages = round(x(1) + 2);
Pressure = x(2);
Feed_Stage = round((Stages-2)*x(3) + 1);
Aspen.Tree.FindNode("\Data\Blocks\B2\Input\NSTAGE").Value = Stages;
Aspen.Tree.FindNode("\Data\Blocks\B2\Subobjects\Column Internals\INT-1\Input\CA_STAGE2\INT-1\CS-1").Value = Stages - 1;
Aspen.Tree.FindNode("\Data\Blocks\B2\Input\PRES1").Value = Pressure;
Aspen.Tree.FindNode("\Data\Blocks\B2\Input\FEED_STAGE\S50").Value = Feed_Stage;
Aspen.Reinit; % Reinit simulation
Aspen.Engine.Run2(1); %Run the simulation. (1) ---> Matlab isnt busy; (0) Matlab is Busy;
time = 1;
Error = 0;
while Aspen.Engine.IsRunning == 1 % 1 --> If Aspen is running; 0 ---> If Aspen stop.
pause(0.5);
time = time+1;
if time==40 % Control of simulation time.
Aspen.Engine.Stop;
Error = 1;
end
end
% column cost
Lang_F = 4.74;
Diameter = Aspen.Tree.FindNode("\Data\Blocks\B2\Subobjects\Column Internals\INT-1\Input\CA_DIAM\INT-1\CS-1").Value;
Number_trays = double(Aspen.Tree.FindNode("\Data\Blocks\B2\Input\NSTAGE").Value - 2);
height_Column = 0.5*(Number_trays)+2;
heat_reboiler = (Aspen.Tree.FindNode("\Data\Blocks\B2\Output\REB_DUTY").Value)*4.1868;
Presure_project = 441.3;
Tension = 108000;
Column_thickness = ((Presure_project*Diameter)/((2*Tension*0.85)-(1.2*Presure_project))) + 0.003;
Density_carbon_steel = 7861.1;
Column_side_volume = 3.14*Column_thickness*height_Column*Diameter;
Column_side_mass = (Column_side_volume*Density_carbon_steel)*2.205;
External_radius = (Diameter + 2*Column_thickness)/2;
Cover_volume = 4*3.14*(External_radius^2)*Column_thickness*2;
Cover_mass = (Cover_volume*Density_carbon_steel)*2.205;
total_mass = Column_side_mass + Cover_mass;
Cv = exp((7.2756 + 0.18255*(log(total_mass))) + (0.02297*((log(total_mass))^2)));
Diameterft = Diameter*3.281;
height_Columnft = height_Column*3.281;
Cpl = 300.9*((Diameterft)^0.63316)*(height_Columnft^0.80161);
Factor_material_column = 1;
FNT = 1;
FTT = 1;
FTM = 1;
CBT = 468*exp(0.1739*Diameterft);
CT = CBT*FTM*FTT*FNT*Number_trays;
CP = Factor_material_column*Cv + Cpl;
Cost_column = CP + CT;
% condenser cost
Temp_out_fluid_cold = 20;
Temp_in_fluid_cold = 5;
Temp_in_fluid_hot = Aspen.Tree.FindNode("\Data\Streams\S4\Output\TEMP_OUT\MIXED").Value;
Temp_out_fluid_hot = Aspen.Tree.FindNode("\Data\Streams\S4\Output\TEMP_OUT\MIXED").Value;
Temperature_exchange_termic = ((Temp_in_fluid_hot - Temp_out_fluid_cold) - (Temp_out_fluid_hot - Temp_in_fluid_cold))/log((Temp_in_fluid_hot - Temp_out_fluid_cold)/(Temp_out_fluid_hot - Temp_in_fluid_cold));
Factor_exchange_termic = 0.85;
coefficient_exchange_termic = 850;
Heat_condenser = (Aspen.Tree.FindNode("\Data\Blocks\B2\Output\COND_DUTY").Value)*4.1868;
Area_condenser = ((Heat_condenser)/(Temperature_exchange_termic*coefficient_exchange_termic*Factor_exchange_termic))*10.76;
Cost_condenser = exp(11.0545 - 0.9228*(log(Area_condenser)) + 0.09861*(log(Area_condenser)^2));
Pipe_length = 1;
Type_Material_Condenser = 1;
pressure_condenser = 1;
Condenser_total_cost = Cost_condenser*Pipe_length*Type_Material_Condenser*pressure_condenser;
%Reboiler cost
Temp_in_fluid_hot_reboiler = 127.5;
Temp_out_fluid_hot_reboiler = 127.5;
Temp_out_fluid_cold_reboiler = Aspen.Tree.FindNode("\Data\Streams\12\Output\TEMP_OUT\MIXED").Value;
Temp_in_fluid_cold_reboiler = Aspen.Tree.FindNode("\Data\Streams\12\Output\TEMP_OUT\MIXED").Value;
Temperature_exchange_termic_reboiler = ((Temp_in_fluid_hot_reboiler - Temp_out_fluid_cold_reboiler) - (Temp_out_fluid_hot_reboiler - Temp_in_fluid_cold_reboiler))/log((Temp_in_fluid_hot_reboiler - Temp_out_fluid_cold_reboiler)/(Temp_out_fluid_hot_reboiler - Temp_in_fluid_cold_reboiler));
Factor_exchange_termic_reboiler = 0.85;
coefficient_exchange_termic_reboiler = 1560;
Area_reboiler = ((heat_reboiler)/(Temperature_exchange_termic_reboiler*coefficient_exchange_termic_reboiler*Factor_exchange_termic_reboiler))*10.76;
Cost_reboiler = exp(11.967 - 0.8709*(log(Area_reboiler)) + 0.09005*(log(Area_reboiler)^2));
Pipe_length_reboiler = 1;
Type_Material_reboiler = 1;
pressure_reboiler = 1;
Reboiler_total_cost = Cost_reboiler*Pipe_length_reboiler*Type_Material_reboiler*pressure_reboiler;
% cost of utilities
Chilled_water_cost = ((Aspen.Tree.FindNode("\Data\Blocks\B2\Output\COND_DUTY").Value)*4.1868)*31536000*0.0000000009258;
Steam_Cost = ((Aspen.Tree.FindNode("\Data\Blocks\B2\Output\REB_DUTY").Value)*4.1868)*0.000000004607*31536000;
Conv = Aspen.Tree.FindNode("\Data\Results Summary\Run-Status\Output\PER_ERROR").Value;
if Error == 0 && Conv == 1
TAC(1) = (Cost_column + Condenser_total_cost + Reboiler_total_cost)*Lang_F*1.14*1.1906/10;
TAC(2) = Steam_Cost + Chilled_water_cost;
else
TAC(1) = 2e8;
TAC(2) = 2e8;
end
end

9 comentarios

I suggest you try
dbstop if warning
Eduardo Braga
Eduardo Braga el 18 de Feb. de 2021
Thanks for the answer. I'm a new user, where would I write this code?
in the command line. Then run the code. It will stop where the warning is generated. You might need to use
dbup
one or more times to determine which line led to the problem
Eduardo Braga
Eduardo Braga el 7 de Mzo. de 2021
the following messages appeared:
Warning from rankAndDistance>globaloptim\private\rankAndDistance (line 22) warning('globaloptim:rankAndDistance:complexScore',msg)
warning('optim:optimtool:DeprecationMsg',deprecation_msg)
Walter Roberson
Walter Roberson el 8 de Mzo. de 2021
Those are warnings and would not cause the code to stop running in themselves.
You want to run until you get the struct contents reference from a non-struct array object error you mentioned before, and then examine to see which line of code triggered it.
Eduardo Braga
Eduardo Braga el 8 de Mzo. de 2021
Ataklti Kahsay
Ataklti Kahsay el 31 de Mayo de 2021
Please contact me on alemusegen@gmail.com i can share you some files and i am working on optimization too
PREETHI SRIDHAR
PREETHI SRIDHAR el 27 de Ag. de 2022
Hi I am running an optimization problem quite similar. I have used statemnet for checcking covergence as :
Conv = Aspen.Tree.FindNode("\Data\Results Summary\Run-Status\Output\PER_ERROR").Value;
I am getting an error suddenly after certain interations ( sometimes 1/5/20 iterations) that dot indexing not supported in the statement above. When I go and check the aspen file it just shows required input complete, but does not run. At the start I have reinit the code and I do run the engine, but it still shows required input complete, and the simulation does not run. Does anyone face a similar problem like this?
zhizhang
zhizhang el 27 de Nov. de 2024
I have the same problem like you, so how do you deal with it?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 17 de Feb. de 2021

Comentada:

el 27 de Nov. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by