Clear Filters
Clear Filters

Dynamic model for Steel purification in AOD converter

3 views (last 30 days)
%print("Dynamic Model for Evaluating Mass and Concentration variation");
%Pre-alloacation of Arrays
XbFe=zeros(1,i);
XbCr=zeros(1,i);
XbO2=zeros(1,i);
XbFeO=zeros(1,i);
XbCr2O3=zeros(1,i);
CbFe=zeros(1,i);
CbCr=zeros(1,i);
CbO2=zeros(1,i);
CbFeO=zeros(1,i);
CbCr2O3=zeros(1,i);
keq_FeO=zeros(1,i);
keq_Cr2O3=zeros(1,i);
val=zeros(1,i);
XiFe=zeros(1,i);
XiCr=zeros(1,i);
CiFe=zeros(1,i);
CiCr=zeros(1,i);
JFe=zeros(1,i);
JCr=zeros(1,i);
MolesTransFe=zeros(1,i);
MolesTransCr=zeros(1,i);
MolesTransfFeO=zeros(1,i);
MolesTransfCr2O3=zeros(1,i);
MolesTransO2=zeros(1,i);
MFe=zeros(1,i);
MCr=zeros(1,i);
MO2InMetal=zeros(1,i);
Moxy=zeros(1,i);
MCr2O3=zeros(1,i);
MFeO=zeros(1,i);
MassOfFe=zeros(1,i);
MassOfCr=zeros(1,i);
MassofO2=zeros(1,i);
MassOfFeO=zeros(1,i);
MassOfCr2O3=zeros(1,i);
TotalMolesInMetal=zeros(1,i);
TotalMolesInSlag=zeros(1,i);
TotalMassOfMetal=zeros(1,i);
TotalMassOfSlag=zeros(1,i);
VolOfMetal=zeros(1,i);
VolOfSlag=zeros(1,i);
MolarVolumeofMetal=zeros(1,i);
MolarVolumeofSlag=zeros(1,i);
PerFeInMetal=zeros(1,i);
PerCrInMetal=zeros(1,i);
PerO2InMetal=zeros(1,i);
PerFeOInSlag=zeros(1,i);
PerCr2O3InSlag=zeros(1,i);
time=zeros(1,i);
%Input from User
TotalMassOfMetal(1) = input("Input Total Mass of Metal:" );
TotalMassOfSlag(1) = input("Input Total Mass of Slag: ");
DensityOfMetal(1) = input("Input Density of Metal: ");
DensityOfSlag(1) = input("Input Density of Slag: ");
PerFeInMetal(1) = input("Input Percentage of Fe in Metal: ");
PerCrInMetal(1) = input("Input Percentage of Cr in Metal: ");
PerO2InMetal(1)= input("Input Percentage of O2 in Metal: ");
PerFeOInSlag(1) = input("Input Percentage of FeO in Slag: ");
PerCr2O3InSlag(1) = input("Input Percentage of Cr2O3 in Slag: ");
O2AddedFromTop(1) = input("Input Oxygen added from Top: ");
O2AddedFromBottom(1) = input("Input Oxygen added from bottom: ");
Del_T = input("Input time step of each calculation: ");
Temp=input("Operating range of Temperature:" );
MassTransCoeffFe=input("Mass transfer Coefficients of Fe: ");
MassTransCoeffCr=input("Mass transfer Coefficients of Cr: ");
AssumedArea=input("Area Assumed: ");
%Standard Known Values/ Given Inputs
AtomicMassofFe= 56;
AtomicMassofCr= 52;
AtomicMassofO2= 16;
AtomicMassofFeO= 72;
AtomicMassofCr2O3= 152;
%Volume of Metal and Slag
VolOfMetal(1)=TotalMassOfMetal(1)/DensityOfMetal;
VolOfSlag(1)=TotalMassOfSlag(1)/DensityOfSlag;
%Initial Moles of Metal and Slag in kmoles
MFe(1)=TotalMassOfMetal(1)*(PerFeInMetal(1)/100)*(1/AtomicMassofFe);
MCr(1)=TotalMassOfMetal(1)*(PerCrInMetal(1)/100)*(1/AtomicMassofCr);
MFeO(1)=TotalMassOfSlag(1)*(PerFeOInSlag(1)/100)*(1/AtomicMassofFeO);
MCr2O3(1)=TotalMassOfSlag(1)*(PerCr2O3InSlag(1)/100)*(1/AtomicMassofCr2O3);
MO2InMetal(1)=TotalMassOfMetal(1)*(PerO2InMetal(1)/100)*(1/AtomicMassofO2);
%Moles of Oxygen Added in kmoles
MO2Added=((O2AddedFromBottom+O2AddedFromTop)*2*(273/298)/(22.4*60));
Moxy(1)=MO2InMetal(1)+MO2Added;
%Total Moles in Metal and Slag in kMoles
TotalMolesInMetal(1)=MCr(1)+MFe(1)+Moxy(1);
TotalMolesInSlag(1)=MCr2O3(1)+MFeO(1);
%Molar Volume
MolarVolumeofMetal(1)=TotalMolesInMetal(1)/VolOfMetal(1);
MolarVolumeofSlag(1)=TotalMolesInSlag(1)/VolOfSlag(1);
time(1)=0;
for i= 1:1200
%Mole Fractions of elements
XbFe(i)=MFe(i)/TotalMolesInMetal(i);
XbCr(i)=MCr(i)/TotalMolesInMetal(i);
XbO2(i)=Moxy(i)/TotalMolesInMetal(i);
XbFeO(i)=MFeO(i)/TotalMolesInSlag(i);
XbCr2O3(i)=MCr2O3(i)/TotalMolesInSlag(i);
%Bulk Concentration of elements
CbFe(i)=XbFe(i)*MolarVolumeofMetal(i);
CbCr(i)=XbCr(i)*MolarVolumeofMetal(i);
CbO2(i)=XbO2(i)*MolarVolumeofMetal(i);
CbFeO(i)=XbFeO(i)*MolarVolumeofSlag(i);
CbCr2O3(i)=XbCr2O3(i)*MolarVolumeofSlag(i);
%Equilibriium Constant Identfication
keq_FeO(i)=exp((-121009.9+(53.114*Temp)+ (8.314* Temp*log(0.5585/16)))/(-8.314*Temp));
keq_Cr2O3(i)=exp((-274347+(120.55*Temp)+ (8.314* Temp*log(0.5585/16)))/(-8.314*Temp));
%Interface concentration calculation of Fe and Cr
val(i)=keq_Cr2O3(i)*XbO2(i);
XiFe(i)=XbFeO(i)/(keq_FeO(i)*XbO2(i));
XiCr(i)=(XbCr2O3(i)^(0.5))/(val(i)^(1.5));
CiFe(i)=XiFe(i)*MolarVolumeofMetal(i);
CiCr(i)=XiCr(i)*MolarVolumeofMetal(i);
%Mass Flux Balance
JFe(i)=-MassTransCoeffFe*(CbFe(i)-CiFe(i));
JCr(i)=-MassTransCoeffCr*(CbCr(i)-CiCr(i));
%Moles Transfered
MolesTransFe(i)=JFe(i)*Del_T*AssumedArea;
MolesTransCr(i)=JCr(i)*Del_T*AssumedArea;
MolesTransfFeO(i)=MolesTransFe(i);
MolesTransfCr2O3(i)=0.5*MolesTransCr(i);
MolesTransO2(i)=MolesTransFe(i)+1.5*MolesTransCr(i);
%Moles of elements after this iteration
MFe(i+1)=MFe(i)+MolesTransFe(i);
MCr(i+1)=MCr(i)+MolesTransCr(i);
MO2InMetal(i+1)=MO2InMetal(i)+MolesTransO2(i);
Moxy(i+1)=Moxy(i)+MolesTransO2(i)+MO2Added;
MCr2O3(i+1)=MCr2O3(i)-MolesTransfCr2O3(i);
MFeO(i+1)=MFeO(i)-MolesTransfFeO(i);
%Mass of each elements
MassOfFe(i+1)=MFe(i+1)*AtomicMassofFe;
MassOfCr(i+1)=MCr(i+1)*AtomicMassofCr;
MassofO2(i+1)=Moxy(i+1)*AtomicMassofO2;
MassOfFeO(i+1)=MFeO(i+1)*AtomicMassofFeO;
MassOfCr2O3(i+1)=MCr2O3(i+1)*AtomicMassofCr2O3;
%Total Moles in metal and Slag
TotalMolesInMetal(i+1)=MCr(i+1)+MFe(i+1)+Moxy(i+1);
TotalMolesInSlag(i+1)=MCr2O3(i+1)+MFeO(i+1);
%Total Mass of Metal and Slag
TotalMassOfMetal(i+1)=MassOfFe(i+1)+MassofO2(i+1)+MassOfCr(i+1);
TotalMassOfSlag(i+1)=MassOfCr2O3(i+1)+MassOfFeO(i+1);
%Molar Volumes
VolOfMetal(i+1)=TotalMassOfMetal(i+1)/DensityOfMetal;
VolOfSlag(i+1)=TotalMassOfSlag(i+1)/DensityOfSlag;
MolarVolumeofMetal(i+1)=TotalMolesInMetal(i+1)/VolOfMetal(i);
MolarVolumeofSlag(i+1)=TotalMolesInSlag(i+1)/VolOfSlag(i);
%Percentage of elements
PerFeInMetal(i+1)=(MFe(i+1)*100*AtomicMassofFe)/TotalMassOfMetal(i+1);
PerCrInMetal(i+1)=(MCr(i+1)*100*AtomicMassofCr)/TotalMassOfMetal(i+1);
PerO2InMetal(i+1)=(Moxy(i+1)*100*AtomicMassofO2)/TotalMassOfMetal(i+1);
PerFeOInSlag(i+1)=(MFeO(i+1)*100*AtomicMassofFeO)/TotalMassOfSlag(i+1);
PerCr2O3InSlag(i+1)=(MCr2O3(i+1)*100*AtomicMassofCr2O3)/TotalMassOfSlag(i+1);
time(i+1)=time(i)+i/10;
%temperature iterations
Temp=Temp+0.02;
end
I am constantly getting :
Error using zeros
Size vector must be a row vector with real elements.
Error in dynamic_model (line 5)
XbFe=zeros(1,i);

Accepted Answer

Star Strider
Star Strider on 7 Nov 2020
The problem with this assignment (and the others like it):
XbFe=zeros(1,i);
is that ‘i’ needs to be defined as a scalar double. It does not appear to be in the code you posted. In that absence, MATLAB interprets ‘i’ as the imaginary operator and it throws the error you got.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!