Regression of my Experimental data for Ternary mixture into Non-randomness two liquid model (NRTL) thermodynamic model

조회 수: 3 (최근 30일)
Dear all,
I am trying to regress my experimental data for ternary mixture using NRTL multicomponent model. can you please help me out with this. I couldn't able to get the good fitting, the reason for this i don't know. hence if you could please change my code and modify it so that i can get the perfect fitting than it would be so gratefulness of yours.
Please note that consider the "Equation" i have written is correct. And if you have time then you can even write whole equation by your logic as well.
clear all;
clc;
alpha=0.3;
%% where, Xd(:,1)= Temperature, xd(:,2)=Mole fraction of 1, xd(:,3)=Mole fraction of 3, xd(:,4)=Psat of component 1, xd(:,5)=Psat of component 2
%% where, Psat of Component 3rd is negligible and hence Activity in below equation
%% yd is Experimental data
%% a is the parameters to be found out by regression
xd(:,1)=[313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15;313.15;318.15;323.15;328.15;333.15;338.15;343.15;348.15;353.15;358.15;363.15;368.15;373.15;378.15;383.15;388.15;393.15;398.15;403.15];
length(xd(:,1))
xd(:,2)=[0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.476;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.526;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.596;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.353;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.524;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.595;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.436;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.454;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.592;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.274;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.519;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182;0.182];
length(xd(:,2))
xd(:,3)=[0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.275;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.249;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.212;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.276;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.235;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.366;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.376;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.281;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.533;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.378;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818;0.818];
length(xd(:,3))
xd(:,4)=[7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36;7.39;9.6;12.36;15.77;19.96;25.05;31.22;38.61;47.43;57.89;70.21;84.64;101.45;120.94;143.43;169.24;198.73;232.31;270.36];
length(xd(:,4))
xd(:,5)=[0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316;0.091;0.129;0.181;0.252;0.345;0.47;0.632;0.844;1.117;1.466;1.908;2.466;3.164;4.031;5.102;6.417;8.021;9.967;12.316];
length(xd(:,5))
yd=[2.4;2.8;3.2;4.0;4.7;5.5;6.7;8.6;9.9;11.9;13.6;15.6;17.9;19.6;22.2;26.0;27.8;30.7;32.9;2.3;2.7;3.3;4.2;5.0;6.2;7.6;9.4;11.4;13.2;14.9;16.9;19.0;21.1;23.8;26.4;28.9;30.9;33.1;2.7;3.2;4.0;4.9;5.9;7.5;9.2;10.8;12.5;15.7;18.6;20.9;23.9;26.9;30.9;34.1;38.0;41.3;43.9;2.3;2.6;2.9;3.2;3.7;4.3;5.0;6.1;7.2;8.4;9.4;10.1;11.2;11.9;12.6;13.8;15.2;16.4;17.8;2.3;2.5;3.1;3.8;4.8;5.9;7.1;8.6;10.2;12.4;15;17.4;19.7;21.4;24.3;27.8;30.1;32.1;35;2.8;3.2;4.2;5.3;6.6;8.2;10.2;12.4;15.4;17.8;20.4;23.5;27.0;30.0;34.0;37.4;39.6;43.1;47.3;2.1;2.6;3.1;3.8;4.7;5.6;7.2;8.3;9.9;11.7;13.3;14.4;16.7;17.9;19.0;21.0;22.2;23.5;25.0;2.1;2.5;3.0;3.6;4.6;5.9;7.0;8.0;9.0;10.5;12.1;13.6;14.8;16.7;18.6;20.5;21.8;23.8;26.5;2.6;3.5;4.0;5.1;6.6;8.3;9.8;11.4;13.5;14.9;16.9;18.0;20.3;21.8;25.3;27.8;30.1;32.8;35.0;1.9;2.3;2.7;3.2;3.7;4.2;4.8;5.7;6.7;7.7;9.2;10.4;11.1;12.4;14.3;16.3;17.7;19.2;20.1;2.8;3.7;4.9;6.1;7.6;9.0;11.2;13.8;17.0;20.8;25.2;29.7;34.0;37.5;41.0;44.2;47.5;49.8;52.0;2.1;2.6;3.6;4.4;5.6;6.9;8.1;9.0;10.6;12.2;14.2;17.0;20.0;23.3;26.3;29.0;31.0;35.1;38.9];
length(yd)
FitnessFunction = @(a,xd)curvefit_multiobjective_two(a,xd);
options = optimoptions('lsqcurvefit','Algorithm','levenberg-marquardt','MaxFunEvals',2000000,'MaxIter',200000,'TolX',1e-100,'TolFun',1e-100)
lb = [];
ub = [];
A=0.1;
a0=[A A A A A A A A A A A A]; %% Initial guess values of the paramters to be found out
[a,residuals,resnorm]=lsqcurvefit(FitnessFunction,a0,xd,yd,lb,ub,options)
C=[0 a(1) a(2); a(3) 0 a(4); a(5) a(6) 0] %% Parameters to be found out by regression
D=[0 a(7) a(8); a(9) 0 a(10); a(11) a(12) 0] %% Parameters to be found out by regression
p1=[a(1) a(2) a(3) a(4) a(5) a(6) a(7) a(8) a(9) a(10) a(11) a(12)]
Below is the other function that i have used in it.
You can take below equation granted and move ahead for regressoin and if you suspect something in equation than please look into below equation as well. This below screenshot shows you the equation for your reference purpose.
function yd=curvefit_multiobjective_two(a,xd)
alpha=0.3;
tow11=0;
tow12=(a(1)+(a(7)./(xd(:,1))));
tow13=(a(2)+(a(8)./(xd(:,1))));
tow21=(a(3)+(a(9)./(xd(:,1))));
tow22=0;
tow23=(a(4)+(a(10)./(xd(:,1))));
tow31=(a(5)+(a(11)./(xd(:,1))));
tow32=(a(6)+(a(12)./(xd(:,1))));
tow33=0;
G11=exp(-alpha.*tow11);
G12=exp(-alpha.*tow12);
G13=exp(-alpha.*tow13);
G21=exp(-alpha.*tow21);
G22=exp(-alpha.*tow22);
G23=exp(-alpha.*tow23);
G31=exp(-alpha.*tow31);
G32=exp(-alpha.*tow32);
G33=exp(-alpha.*tow33);
%%%% this a1, a2, ....., a8 are the breaked parts of the NRTL equation (Above shown in screenshot).
a1=((xd(:,2).*tow11.*G11)+(xd(:,3).*tow21.*G21)+((1-xd(:,2)-xd(:,3)).*tow31.*G31))./((xd(:,2).*G11)+(xd(:,3).*G21)+((1-xd(:,2)-xd(:,3)).*G31));
a2=((xd(:,2).*G11)./((xd(:,2).*G11)+(xd(:,3).*G21)+((1-xd(:,2)-xd(:,3)).*G31))).*(tow11-(((xd(:,2).*tow11.*G11)+(xd(:,3).*tow21.*G21)+((1-xd(:,2)-xd(:,3)).*tow31.*G31))./((xd(:,2).*G11)+(xd(:,3).*G21)+((1-xd(:,2)-xd(:,3)).*G31))));
a3=((xd(:,3).*G12)./((xd(:,2).*G12)+(xd(:,3).*G22)+((1-xd(:,2)-xd(:,3)).*G32))).*(tow12-(((xd(:,2).*tow12.*G12)+(xd(:,3).*tow22.*G22)+((1-xd(:,2)-xd(:,3)).*tow32.*G32))./((xd(:,2).*G12)+(xd(:,3).*G22)+((1-xd(:,2)-xd(:,3)).*G32))));
a4=(((1-xd(:,2)-xd(:,3)).*G13)./((xd(:,2).*G13)+(xd(:,3).*G23)+((1-xd(:,2)-xd(:,3)).*G33))).*(tow13-(((xd(:,2).*tow13.*G13)+(xd(:,3).*tow23.*G23)+((1-xd(:,2)-xd(:,3)).*tow33.*G33))./((xd(:,2).*G13)+(xd(:,3).*G23)+((1-xd(:,2)-xd(:,3)).*G33))));
a5=((xd(:,2).*tow12.*G12)+(xd(:,3).*tow22.*G22)+((1-xd(:,2)-xd(:,3)).*tow32.*G32))./((xd(:,2).*G12)+(xd(:,3).*G22)+((1-xd(:,2)-xd(:,3)).*G32));
a6=((xd(:,2).*G21)./((xd(:,2).*G11)+(xd(:,3).*G21)+((1-xd(:,2)-xd(:,3)).*G31))).*(tow21-(((xd(:,2).*tow11.*G11)+(xd(:,3).*tow21.*G21)+((1-xd(:,2)-xd(:,3)).*tow31.*G31))./((xd(:,2).*G11)+(xd(:,3).*G21)+((1-xd(:,2)-xd(:,3)).*G31))));
a7=((xd(:,3).*G22)./((xd(:,2).*G12)+(xd(:,3).*G22)+((1-xd(:,2)-xd(:,3)).*G32))).*(tow22-(((xd(:,2).*tow12.*G12)+(xd(:,3).*tow22.*G22)+((1-xd(:,2)-xd(:,3)).*tow32.*G32))./((xd(:,2).*G12)+(xd(:,3).*G22)+((1-xd(:,2)-xd(:,3)).*G32))));
a8=(((1-xd(:,2)-xd(:,3)).*G23)./((xd(:,2).*G13)+(xd(:,3).*G23)+((1-xd(:,2)-xd(:,3)).*G33))).*(tow23-(((xd(:,2).*tow13.*G13)+(xd(:,3).*tow23.*G23)+((1-xd(:,2)-xd(:,3)).*tow33.*G33))./((xd(:,2).*G13)+(xd(:,3).*G23)+((1-xd(:,2)-xd(:,3)).*G33))));
gamma_one=exp(a1+a2+a3+a4);
gamma_two=exp(a5+a6+a7+a8);
yd=(xd(:,2).*gamma_one.*xd(:,4))+(xd(:,3).*gamma_two.*xd(:,5));
end
Please have a look into this code as i am stucked in this code since 2 months (probably it's hard to believe but it's true).
Hoping for a valuable response from all Dear ones.
Thanking you,
Ashish Kundaliya
  댓글 수: 5
Ashish Kundaliya
Ashish Kundaliya 2020년 6월 7일
Thanks for this assistance. But i found that 1stOpt is a paid version not a free version.! so how will i get that. can you have any idea about it.
I mean if you know any free software similar to 1stOpt then please suggest me that software and share appropriate code for that as well.
Sorry for this much inconvinience from you, but i have no choice other than regression.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Thermal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by