
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++ A full 3-D elastic model based on ++++++++++++;
%++++++++++++++++ the finite-volume method +++++++++++++++++;
%++++++++++ to approximate the momentum equations ++++++++++;
%++++++++++++++++++ inside an ice shelf ++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


clear

dens=910; % ice dencity

dens_w=1000; % water dencity

g=9.81; 



LXSho=16000; % ice shelf extent in X-direction

LYSho=800;  % ice shelf extent in Y-derection

HGrl=100; % ice thickness at the grounding line

HShTerm=100; % ice thickness at the terminus


T_Cr=2000; % spatial periodicity of the crevasses

Depth_Cr=20; % the crevasses depth

Width_Cr=500; % the crevasses width



                              
E_Yung=9.0*10^9; % Young's modulus 

P_Puasson=0.33; % Poisson's ratio



Kp1=2*(1-P_Puasson)/(1-2*P_Puasson);

Kp2=2*P_Puasson/(1-2*P_Puasson);

KpE=2*(1+P_Puasson)/E_Yung;

KpE0=E_Yung/(1+P_Puasson);



Kpb1=(1-P_Puasson)/(1-2*P_Puasson);

Kpb2=P_Puasson/(1-2*P_Puasson);


alfa1=0.0; alfa2=1.0; % the parameters of the model (see in (Konovalov, 2019))

alfa12=alfa1+alfa2;


%----------------------;

PT0=10; % initial value of the periodicity of the vibrations

D_PT=0.02; % the periodicity resolution  

AmSLC=1.0; % the amplitude of the incident wave

NFreq=300; % the number of the main cycle repeats


%-------------------;

Nx=241;  % grid points number in X-direction (horizontal direction)

Ny=13; % grid points number in Y-derection (horizontal direction)

Nz=6; % grid points number in Z-derection (vertical direction)


dx=LXSho/(Nx-1); % the resolution in the X-direction

dy=1/(Ny-1); % the resolution in the Y-direction (non-dimensional)

dz=1/(Nz-1); % the resolution in the Z-direction (non-dimensional)

%++++++++++++++++++++++++ L_X, L_Y, L_Z +++++++++++++++++++++++;


L_X=zeros(1,Nx);  

for ii=1:1:Nx, L_X(ii)=dx*(ii-1); end


L_Y=zeros(1,Ny);  

for jj=1:1:Ny, L_Y(jj)=dy*(jj-1); end


L_Z=zeros(1,Nz); 

for kk=1:1:Nz, L_Z(kk)=dz*(kk-1); end



%+++++ Ice Width in Y-direction (B), Y1(x), Y2(x), dB/dx ++++++++++++;

dfW=-1.0;

Wd1=LYSho; Wd2=LYSho+dfW;


Width=zeros(1,Nx); Y1=zeros(1,Nx); Y2=zeros(1,Nx);

for ii=1:1:Nx, Width(ii)=Wd1+((Wd2-Wd1)/LXSho)*L_X(ii); end

for ii=1:1:Nx, Y1(ii)=-0.5*(Wd1+((Wd2-Wd1)/LXSho)*L_X(ii)); end

for ii=1:1:Nx, Y2(ii)=0.5*(Wd1+((Wd2-Wd1)/LXSho)*L_X(ii)); end



%++++++ Ice Surface, Ice Base, Ice Thickness, Sea Bottom +++++++++++;

HIC0=zeros(Nx,Ny); 

for ii=1:1:Nx 
    for jj=1:1:Ny 
        HIC0(ii,jj)=HGrl+((HShTerm-HGrl)/LXSho)*L_X(ii);
    end 
end



HIC=zeros(Nx,Ny);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        HIC(ii,jj)=HIC0(ii,jj); 
    end 
end


%+++++++++++++++++++++++++++++++++++++++;
%++++++++ Rectangular Crevasses ++++++++;
%+++++++++++++++++++++++++++++++++++++++;

nn=1;

while (nn*T_Cr+Width_Cr/2)<LXSho
    
    for ii=1:1:Nx
        for jj=1:1:Ny
            if (L_X(ii)>(nn*T_Cr-Width_Cr/2)) && (L_X(ii)<(nn*T_Cr+Width_Cr/2))
                HIC(ii,jj)=HIC(ii,jj)-Depth_Cr*(dens_w/dens);
            end
        end
    end
    
    N_Cr=nn;
    
    nn=nn+1;
        
end


%++++++++++++++++++++++++++++++++++++++;
%++++++++ Triangular Crevasses ++++++++;
%++++++++++++++++++++++++++++++++++++++;


% nn=1;
% 
% while (nn*T_Cr + Width_Cr/2)<LXSho
%     
%     for ii=1:1:Nx
%         for jj=1:1:Ny
%             
%             if (L_X(ii)>(nn*T_Cr - Width_Cr/2)) && (L_X(ii)<=nn*T_Cr)
%                 HIC(ii,jj)=HIC(ii,jj)-(2*Depth_Cr/Width_Cr)*(L_X(ii)-(nn*T_Cr-Width_Cr/2))*(dens_w/dens);
%             end
%             
%             if (L_X(ii)>nn*T_Cr) && (L_X(ii)<(nn*T_Cr+Width_Cr/2))
%                 HIC(ii,jj)=HIC(ii,jj)-((-2*Depth_Cr/Width_Cr)*(L_X(ii)-(nn*T_Cr-Width_Cr/2))+2*Depth_Cr)*(dens_w/dens);
%             end
%             
%         end
%     end
%     
%     N_Cr=nn;
%     
%     nn=nn+1;
%         
% end


%-----------------------------------------------;

HSF0=zeros(Nx,Ny);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        HSF0(ii,jj)=HIC0(ii,jj)*(1-dens/dens_w); 
    end 
end


HSF=zeros(Nx,Ny);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        HSF(ii,jj)=HIC(ii,jj)*(1-dens/dens_w); 
    end 
end


%------------------------------------------------;

HBF0=zeros(Nx,Ny);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        HBF0(ii,jj)=-HIC0(ii,jj)*(dens/dens_w); 
    end 
end


HBF=zeros(Nx,Ny);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        HBF(ii,jj)=-HIC(ii,jj)*(dens/dens_w); 
    end 
end

%---------------------------------------------------;

HBSEA=zeros(Nx,Ny); 

C_depth_GrL=100; C_depth_Term=100; % The water channel depth at the grounding line and at the terminus, respectivelly;

for ii=1:1:Nx
    for jj=1:1:Ny 
        HBSEA(ii,jj)=HBF0(1,jj)-C_depth_GrL + (((HBF0(Nx,jj)-C_depth_Term)-(HBF0(1,jj)-C_depth_GrL))/LXSho)*L_X(ii); 
    end
end


WDepth_ij=zeros(Nx,Ny);

for ii=1:1:Nx
    for jj=1:1:Ny 
        WDepth_ij(ii,jj)=HBF(ii,jj)-HBSEA(ii,jj); 
    end 
end


%------------------------------------------------;

figure(1);

%surf(L_X./LXSho,L_Y,HBF'), title('Ice Shelf Base'), xlabel('X, m'), ylabel('Y, m'), zlabel('Elevation, m')

surf(L_X,L_Y.*LYSho,HBF'), title('Ice Shelf Base'), xlabel('X, m'), ylabel('Y, m'), zlabel('Elevation, m')

%contourf(L_X./Lo,L_Y,HBF), title('Ice Sheet Bed'), xlabel('X, m'), ylabel('Y, m')

figure(2);

%surf(L_X./LXSho,L_Y,HSF'), title('Ice Shelf Surface'), xlabel('X, m'), ylabel('Y, m'), zlabel('Elevation, m')

surf(L_X,L_Y.*LYSho,HSF'), title('Ice Shelf Surface'), xlabel('X, m'), ylabel('Y, m'), zlabel('Elevation, m')

%contourf(L_X./Lo,L_Y,HSF), title('Ice Sheet Surface'), xlabel('X, m'), ylabel('Y, m')

figure(3);

%surf(L_X./LXSho,L_Y,HBSEA'), title('Sea Bottom'), xlabel('X, m'), ylabel('Y, m'), zlabel('Elevation, m')

surf(L_X,L_Y.*LYSho,HBSEA'), title('Sea Bottom'), xlabel('X, m'), ylabel('Y, m'), zlabel('Elevation, m')

%contourf(L_X./Lo,L_Y,HSF), title('Ice Sheet Surface'), xlabel('X, m'), ylabel('Y, m')



LP_HSF=zeros(1,Nx); LP_HBF=zeros(1,Nx); LP_HBSEA=zeros(1,Nx); LP_HIC=zeros(1,Nx); LP_WDepth=zeros(1,Nx);

Jy=round(Ny/2)+1;

for ii=1:1:Nx, LP_HSF(ii)=HSF(ii,Jy); end

for ii=1:1:Nx, LP_HBF(ii)=HBF(ii,Jy); end

for ii=1:1:Nx, LP_HBSEA(ii)=HBSEA(ii,Jy); end

for ii=1:1:Nx, LP_HIC(ii)=HIC(ii,Jy); end

for ii=1:1:Nx, LP_WDepth(ii)=WDepth_ij(ii,Jy); end


figure(4);

plot(L_X,LP_HSF,'-b.',L_X,LP_HBF,'-rd',L_X,LP_HBSEA,'-k.'), title('Ice Shelf Centre Line Cross-section'), legend('Ice Shelf Surface','Ice Shelf Base','Sea Bottom'), xlabel('X, m'), ylabel('Elevation, m'), grid


figure(5);

plot(L_X,LP_HIC,'-b.',L_X,LP_WDepth,'-rd'), title('Ice Shelf Centre Line Thickness'), legend('Ice Shelf Thickness','Water Channel Depth'), xlabel('X, m'), ylabel('Thickness, m'), grid



%-------------- dB/dx, dY1/dx, dY2/dx -----------------;

difWd=zeros(1,Nx);

difWd(1)=(Width(2)-Width(1))/dx;
for ii=2:1:Nx-1, difWd(ii)=(Width(ii+1)-Width(ii-1))/(2*dx); end
difWd(Nx)=(Width(Nx)-Width(Nx-1))/dx;


difY1=zeros(1,Nx);

difY1(1)=(Y1(2)-Y1(1))/dx;
for ii=2:1:Nx-1, difY1(ii)=(Y1(ii+1)-Y1(ii-1))/(2*dx); end
difY1(Nx)=(Y1(Nx)-Y1(Nx-1))/dx;


difY2=zeros(1,Nx);

difY2(1)=(Y2(2)-Y2(1))/dx;
for ii=2:1:Nx-1, difY2(ii)=(Y2(ii+1)-Y2(ii-1))/(2*dx); end
difY2(Nx)=(Y2(Nx)-Y2(Nx-1))/dx;


%+++++++++++++++++++++++++++ dQ/dx, dQ/dy +++++++++++++++++++++++++++++++;

dQx=zeros(Nx,Ny);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        dQx(ii,jj)=-(1/Width(ii))*(difY1(ii)+L_Y(jj)*difWd(ii)); 
    end 
end


dQy=zeros(Nx,1);

for ii=1:1:Nx, dQy(ii)=1/Width(ii); end



%++++++++++++++++++++++++ dHs/dx, dHs/dy +++++++++++++++++++++++++++++;

dHsx=zeros(Nx,Ny); dHsy=zeros(Nx,Ny);


%--------------------- dHs/dx -----------------------;

dHsx(1,1)=(-HSF(3,1)+4*HSF(2,1)-3*HSF(1,1))/(2*dx)+((-HSF(1,3)+4*HSF(1,2)-3*HSF(1,1))/(2*dy))*dQx(1,1);

for jj=2:1:Ny-1 
    dHsx(1,jj)=(-HSF(3,jj)+4*HSF(2,jj)-3*HSF(1,jj))/(2*dx)+((HSF(1,jj+1)-HSF(1,jj-1))/(2*dy))*dQx(1,jj); 
end

dHsx(1,Ny)=(-HSF(3,Ny)+4*HSF(2,Ny)-3*HSF(1,Ny))/(2*dx)+((3*HSF(1,Ny)-4*HSF(1,Ny-1)+HSF(1,Ny-2))/(2*dy))*dQx(1,Ny);

for ii=2:1:Nx-1 
    dHsx(ii,1)=(HSF(ii+1,1)-HSF(ii-1,1))/(2*dx)+((-HSF(ii,3)+4*HSF(ii,2)-3*HSF(ii,1))/(2*dy))*dQx(ii,1);
end 

for ii=2:1:Nx-1 
    for jj=2:1:Ny-1 
        dHsx(ii,jj)=(HSF(ii+1,jj)-HSF(ii-1,jj))/(2*dx)+((HSF(ii,jj+1)-HSF(ii,jj-1))/(2*dy))*dQx(ii,jj); 
    end 
end

for ii=2:1:Nx-1 
    dHsx(ii,Ny)=(HSF(ii+1,Ny)-HSF(ii-1,Ny))/(2*dx)+((3*HSF(ii,Ny)-4*HSF(ii,Ny-1)+HSF(ii,Ny-2))/(2*dy))*dQx(ii,Ny); 
end

dHsx(Nx,1)=(3*HSF(Nx,1)-4*HSF(Nx-1,1)+HSF(Nx-2,1))/(2*dx)+((-HSF(Nx,3)+4*HSF(Nx,2)-3*HSF(Nx,1))/(2*dy))*dQx(Nx,1);

for jj=2:1:Ny-1 
    dHsx(Nx,jj)=(3*HSF(Nx,jj)-4*HSF(Nx-1,jj)+HSF(Nx-2,jj))/(2*dx)+((HSF(Nx,jj+1)-HSF(Nx,jj-1))/(2*dy))*dQx(Nx,jj); 
end

dHsx(Nx,Ny)=(3*HSF(Nx,Ny)-4*HSF(Nx-1,Ny)+HSF(Nx-2,Ny))/(2*dx)+((3*HSF(Nx,Ny)-4*HSF(Nx,Ny-1)+HSF(Nx,Ny-2))/(2*dy))*dQx(Nx,Ny);


%-------------------- dHs/dy ----------------------;

for ii=1:1:Nx, dHsy(ii,1)=((-HSF(ii,3)+4*HSF(ii,2)-3*HSF(ii,1))/(2*dy))*dQy(ii); end

for ii=1:1:Nx 
    for jj=2:1:Ny-1 
        dHsy(ii,jj)=((HSF(ii,jj+1)-HSF(ii,jj-1))/(2*dy))*dQy(ii); 
    end 
end

for ii=1:1:Nx, dHsy(ii,Ny)=((3*HSF(ii,Ny)-4*HSF(ii,Ny-1)+HSF(ii,Ny-2))/(2*dy))*dQy(ii); end



%++++++++++++++++++++++++ dHb/dx, dHb/dy +++++++++++++++++++++++++++++;

dHbx=zeros(Nx,Ny); dHby=zeros(Nx,Ny);


%--------------------------- dHb/dx ----------------------------;

dHbx(1,1)=(-HBF(3,1)+4*HBF(2,1)-3*HBF(1,1))/(2*dx)+((-HBF(1,3)+4*HBF(1,2)-3*HBF(1,1))/(2*dy))*dQx(1,1);

for jj=2:1:Ny-1 
    dHbx(1,jj)=(-HBF(3,jj)+4*HBF(2,jj)-3*HBF(1,jj))/(2*dx)+((HBF(1,jj+1)-HBF(1,jj-1))/(2*dy))*dQx(1,jj); 
end

dHbx(1,Ny)=(-HBF(3,Ny)+4*HBF(2,Ny)-3*HBF(1,Ny))/(2*dx)+((3*HBF(1,Ny)-4*HBF(1,Ny-1)+HBF(1,Ny-2))/(2*dy))*dQx(1,Ny);

for ii=2:1:Nx-1 
    dHbx(ii,1)=(HBF(ii+1,1)-HBF(ii-1,1))/(2*dx)+((-HBF(ii,3)+4*HBF(ii,2)-3*HBF(ii,1))/(2*dy))*dQx(ii,1);
end 

for ii=2:1:Nx-1 
    for jj=2:1:Ny-1 
        dHbx(ii,jj)=(HBF(ii+1,jj)-HBF(ii-1,jj))/(2*dx)+((HBF(ii,jj+1)-HBF(ii,jj-1))/(2*dy))*dQx(ii,jj); 
    end 
end

for ii=2:1:Nx-1 
    dHbx(ii,Ny)=(HBF(ii+1,Ny)-HBF(ii-1,Ny))/(2*dx)+((3*HBF(ii,Ny)-4*HBF(ii,Ny-1)+HBF(ii,Ny-2))/(2*dy))*dQx(ii,Ny); 
end

dHbx(Nx,1)=(3*HBF(Nx,1)-4*HBF(Nx-1,1)+HBF(Nx-2,1))/(2*dx)+((-HBF(Nx,3)+4*HBF(Nx,2)-3*HBF(Nx,1))/(2*dy))*dQx(Nx,1);

for jj=2:1:Ny-1 
    dHbx(Nx,jj)=(3*HBF(Nx,jj)-4*HBF(Nx-1,jj)+HBF(Nx-2,jj))/(2*dx)+((HBF(Nx,jj+1)-HBF(Nx,jj-1))/(2*dy))*dQx(Nx,jj); 
end

dHbx(Nx,Ny)=(3*HBF(Nx,Ny)-4*HBF(Nx-1,Ny)+HBF(Nx-2,Ny))/(2*dx)+((3*HBF(Nx,Ny)-4*HBF(Nx,Ny-1)+HBF(Nx,Ny-2))/(2*dy))*dQx(Nx,Ny);

%-------------------- dHb/dy ----------------------;

for ii=1:1:Nx, dHby(ii,1)=((-HBF(ii,3)+4*HBF(ii,2)-3*HBF(ii,1))/(2*dy))*dQy(ii); end

for ii=1:1:Nx 
    for jj=2:1:Ny-1 
        dHby(ii,jj)=((HBF(ii,jj+1)-HBF(ii,jj-1))/(2*dy))*dQy(ii); 
    end 
end

for ii=1:1:Nx, dHby(ii,Ny)=((3*HBF(ii,Ny)-4*HBF(ii,Ny-1)+HBF(ii,Ny-2))/(2*dy))*dQy(ii); end



%++++++++++++++++++++++++ dH/dx, dH/dy +++++++++++++++++++++++++++++;

dHx=zeros(Nx,Ny); dHy=zeros(Nx,Ny);


%------------------ dH/dx --------------------;

dHx(1,1)=(-HIC(3,1)+4*HIC(2,1)-3*HIC(1,1))/(2*dx)+((-HIC(1,3)+4*HIC(1,2)-3*HIC(1,1))/(2*dy))*dQx(1,1);

for jj=2:1:Ny-1 
    dHx(1,jj)=(-HIC(3,jj)+4*HIC(2,jj)-3*HIC(1,jj))/(2*dx)+((HIC(1,jj+1)-HIC(1,jj-1))/(2*dy))*dQx(1,jj); 
end

dHx(1,Ny)=(-HIC(3,Ny)+4*HIC(2,Ny)-3*HIC(1,Ny))/(2*dx)+((3*HIC(1,Ny)-4*HIC(1,Ny-1)+HIC(1,Ny-2))/(2*dy))*dQx(1,Ny);

for ii=2:1:Nx-1 
    dHx(ii,1)=(HIC(ii+1,1)-HIC(ii-1,1))/(2*dx)+((-HIC(ii,3)+4*HIC(ii,2)-3*HIC(ii,1))/(2*dy))*dQx(ii,1);
end 

for ii=2:1:Nx-1 
    for jj=2:1:Ny-1 
        dHx(ii,jj)=(HIC(ii+1,jj)-HIC(ii-1,jj))/(2*dx)+((HIC(ii,jj+1)-HIC(ii,jj-1))/(2*dy))*dQx(ii,jj); 
    end 
end

for ii=2:1:Nx-1 
    dHx(ii,Ny)=(HIC(ii+1,Ny)-HIC(ii-1,Ny))/(2*dx)+((3*HIC(ii,Ny)-4*HIC(ii,Ny-1)+HIC(ii,Ny-2))/(2*dy))*dQx(ii,Ny); 
end

dHx(Nx,1)=(3*HIC(Nx,1)-4*HIC(Nx-1,1)+HIC(Nx-2,1))/(2*dx)+((-HIC(Nx,3)+4*HIC(Nx,2)-3*HIC(Nx,1))/(2*dy))*dQx(Nx,1);

for jj=2:1:Ny-1 
    dHx(Nx,jj)=(3*HIC(Nx,jj)-4*HIC(Nx-1,jj)+HIC(Nx-2,jj))/(2*dx)+((HIC(Nx,jj+1)-HIC(Nx,jj-1))/(2*dy))*dQx(Nx,jj); 
end

dHx(Nx,Ny)=(3*HIC(Nx,Ny)-4*HIC(Nx-1,Ny)+HIC(Nx-2,Ny))/(2*dx)+((3*HIC(Nx,Ny)-4*HIC(Nx,Ny-1)+HIC(Nx,Ny-2))/(2*dy))*dQx(Nx,Ny);


%-------------------- dH/dy ----------------------;

for ii=1:1:Nx, dHy(ii,1)=((-HIC(ii,3)+4*HIC(ii,2)-3*HIC(ii,1))/(2*dy))*dQy(ii); end

for ii=1:1:Nx 
    for jj=2:1:Ny-1 
        dHy(ii,jj)=((HIC(ii,jj+1)-HIC(ii,jj-1))/(2*dy))*dQy(ii); 
    end 
end

for ii=1:1:Nx, dHy(ii,Ny)=((3*HIC(ii,Ny)-4*HIC(ii,Ny-1)+HIC(ii,Ny-2))/(2*dy))*dQy(ii); end



%++++++++++++++++++++++ dZ/dx, dZ/dy, dZ/dz +++++++++++++++++++++++++;

dZx=zeros(Nx,Ny,Nz);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        for kk=1:1:Nz 
            dZx(ii,jj,kk)=dHsx(ii,jj)/HIC(ii,jj)-dHx(ii,jj)*L_Z(kk)/HIC(ii,jj);
        end 
    end
end 


dZy=zeros(Nx,Ny,Nz);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        for kk=1:1:Nz 
            dZy(ii,jj,kk)=dHsy(ii,jj)/HIC(ii,jj)-dHy(ii,jj)*L_Z(kk)/HIC(ii,jj); 
        end 
    end
end


dZz=zeros(Nx,Ny);

for ii=1:1:Nx 
    for jj=1:1:Ny 
        dZz(ii,jj)=-1/HIC(ii,jj); 
    end 
end



%+++++++++++++++++++++++++ Arrays +++++++++++++++++++++++++++++++;


masU=zeros(Nx,Ny,Nz);
masV=zeros(Nx,Ny,Nz);
masW=zeros(Nx,Ny,Nz);


Delta_H=zeros(Nx,Ny,NFreq);
Delta_P=zeros(Nx,Ny,NFreq);
Delta_Ws=zeros(Nx,Ny,NFreq);


L_X_node_max=zeros(Nx,1);

L_X_node_min=zeros(Nx,1);


%---------------------------;

WDx_ij=zeros(Nx,Ny);
WDy_ij=zeros(Nx,Ny);
WDQxx_ij=zeros(Nx,Ny);
WDQxy_ij=zeros(Nx,Ny);
WDQx2y_ij=zeros(Nx,Ny);
WWx_i=zeros(Nx,1);


FullFeng=zeros(NFreq,1);

%----------------------------------;

MB=zeros(3*Nx*Ny*Nz+2*Nx*Ny);

VB=zeros(3*Nx*Ny*Nz+2*Nx*Ny,1);


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


for ii=2:1:Nx 
for jj=1:1:Ny
WDx_ij(ii,jj)=(WDepth_ij(ii-1,jj)+WDepth_ij(ii,jj))/2;
end
end

for ii=1:1:Nx 
for jj=2:1:Ny
WDy_ij(ii,jj)=(WDepth_ij(ii,jj-1)+WDepth_ij(ii,jj))/2;
end
end


for ii=2:1:Nx 
for jj=1:1:Ny
WDQxx_ij(ii,jj)=(WDepth_ij(ii-1,jj)*dQx(ii-1,jj)+WDepth_ij(ii,jj)*dQx(ii,jj))/2;
end
end


for ii=1:1:Nx 
for jj=2:1:Ny
WDQxy_ij(ii,jj)=(WDepth_ij(ii,jj-1)*dQx(ii,jj-1)+WDepth_ij(ii,jj)*dQx(ii,jj))/2;
end
end


for ii=1:1:Nx 
for jj=2:1:Ny
WDQx2y_ij(ii,jj)=(WDepth_ij(ii,jj-1)*dQx(ii,jj-1)^2+WDepth_ij(ii,jj)*dQx(ii,jj)^2)/2;
end
end


for ii=2:1:Nx 
WWx_i(ii)=(Width(ii-1)+Width(ii))/2;
end

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++++++++ THE MAIN CYCLE START +++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


for JFreq=1:1:NFreq

%-------------------------------;

MB=zeros(3*Nx*Ny*Nz+2*Nx*Ny);

VB=zeros(3*Nx*Ny*Nz+2*Nx*Ny,1);


%+++++++++ Arrays, F-energy +++++++++;

Utxx=zeros(Nx,Ny,Nz);
Utyy=zeros(Nx,Ny,Nz);
Utzz=zeros(Nx,Ny,Nz);
Utxy=zeros(Nx,Ny,Nz);
Utxz=zeros(Nx,Ny,Nz);
Utyz=zeros(Nx,Ny,Nz);

Uty=zeros(Nx,Ny,Nz);
Utz=zeros(Nx,Ny,Nz);
Vtx=zeros(Nx,Ny,Nz);
Vtz=zeros(Nx,Ny,Nz);
Wtx=zeros(Nx,Ny,Nz);
Wty=zeros(Nx,Ny,Nz);

Feng=zeros(Nx,Ny,Nz);

%++++++++++++++++++++++++++++++++++;



%------------------------------------------;
% frequency of vibrations of the ice shelf 
%------------------------------------------;

if (JFreq>=1) && (JFreq<=100)
   
    PT0=10; D_PT=0.03;
    
    Freq=2*pi/(PT0+JFreq*D_PT); 
    
end
    

if (JFreq>100) && (JFreq<=200)
   
    PT0=13; D_PT=0.04;
    
    Freq=2*pi/(PT0+(JFreq-100)*D_PT); 
    
end


if (JFreq>200) && (JFreq<=NFreq)
   
    PT0=17; D_PT=0.06;
    
    Freq=2*pi/(PT0+(JFreq-200)*D_PT);
    
end




%++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++ BOUNDARY CONDITIONS ++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++ Ix=1 (X=0) +++++++++++++++++++++++++;
%++++++++++ deformations at the grounding line +++++++++++++;
% In the model the boundary is considered as fixed boundary ;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

%------------- (U=0) ----------------;

for jj=1:1:Ny
for kk=1:1:Nz 
MB((jj-1)*Nz+kk,(jj-1)*Nz+kk)=1; 
end 
end

% for jj=1:1:Ny
% for kk=1:1:Nz 
% VB((jj-1)*Nz+kk)=0; 
% end 
% end

%-------------- (V=0) ----------------;

for jj=1:1:Ny
for kk=1:1:Nz 
MB(Nx*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(jj-1)*Nz+kk)=1; 
end 
end

% for jj=1:1:Ny
% for kk=1:1:Nz 
% VB(Nx*Ny*Nz+(jj-1)*Nz+kk)=0; 
% end 
% end

%-------------- (W=0) ----------------;

for jj=1:1:Ny
for kk=1:1:Nz 
MB(2*Nx*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(jj-1)*Nz+kk)=1; 
end 
end

% for jj=1:1:Ny
% for kk=1:1:Nz, 
% VB(2*Nx*Ny*Nz+(jj-1)*Nz+kk)=0; 
% end 
% end



%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++ Ice Shelf Terminus: Ix=Nx (X=LXSho) +++++++++++++;
%+++++++++++++++++++++ (free edge) +++++++++++++++++++++++++;



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%------------------ The first equation ----------------------;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - Kp1 0.5 (dU/dx)^k-1 (dZ/dx)^k-1/2  (1/dz)  ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-1)*Nz+kk-1)= -alfa2*Kp1*0.5*(1/(2*dx))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk-1)= -alfa2*Kp1*0.5*(-4/(2*dx))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz);
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)= -alfa2*Kp1*0.5*(3/(2*dx))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz);
end 
end 



%---(1.2): - Kp1 0.5 (dU/dx)^k (dZ/dx)^k-1/2 (1/dz)  ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-1)*Nz+kk)= -alfa2*Kp1*0.5*(1/(2*dx))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)= -alfa2*Kp1*0.5*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); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=  MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)+  alfa2*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(1/dz)*(0.5/(HIC(Nx,jj)*dz)); 
end  
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  Kp1 0.5 (dU/dx)^k+1 (dZ/dx)^k+1/2 (1/dz)  ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa2*Kp1*0.5*(1/(2*dx))*((dZx(Nx,jj,kk+1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa2*Kp1*0.5*(-4/(2*dx))*((dZx(Nx,jj,kk+1)+dZx(Nx,jj,kk))/2)*(0.5/dz);
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*N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z)*(0.5/(HIC(Nx,jj)*dz)); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*((dZx(Nx,jj,kk+1)+dZx(Nx,jj,kk))/2)*(1/dz)*(0.5/(HIC(Nx,jj)*dz)); 
end  
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - Kp1 0.5 (dU/dx)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-2)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-2)*Nz+kk) -alfa2*Kp1*0.5*(1/(2*dx))*((dQx(Nx,jj-1)+dQx(Nx,jj))/2)*(0.5/dy)*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-2)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-2)*Nz+kk) -alfa2*Kp1*0.5*(-4/(2*dx))*((dQx(Nx,jj-1)+dQx(Nx,jj))/2)*(0.5/dy)*((HIC(Nx,jj-1)+HI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,kk))/2)*0.5*(-1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*((dZx(Nx,jj-1,kk)+dZx(Nx,jj,kk))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  Kp1 0.5 (dU/dx)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+jj*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+jj*Nz+kk) +alfa2*Kp1*0.5*(1/(2*dx))*((dQx(Nx,jj+1)+dQx(Nx,jj))/2)*(0.5/dy)*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+jj*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+jj*Nz+kk)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IC(Nx,jj))/(2*HIC(Nx,jj))); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa2*((dZx(Nx,jj+1,kk)+dZx(Nx,jj,kk))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx H b dy dz / (b H dx dy dz) ++++;


%---(5.1): - Kp1 (dU/dx)^i-1/2 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk) -alfa2*Kp1*(-1/dx)*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+HIC(Nx,jj))/(2*HIC(Nx,jj)))*(1/dx); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk) -alfa2*Kp1*(1/dx)*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+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W/dz)^i (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1) -alfa2*Kp2*((dZz(Nx-1,jj)+dZz(Nx,jj))/2)*0.5*(-1/(2*dz))*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+HIC(Nx,jj))/(2*HIC(Nx,jj)))*(1/dx); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*Kp2*((dZz(Nx-1,jj)+dZz(Nx,jj))/2)*0.5*(1/(2*dz))*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+HIC(Nx,jj))/(2*HIC(Nx,jj)))*(1/dx); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ + KpE dens Freq^2 U ++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%------------------ The second equation ---------------------;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dQ/dy 0.5 (dU/dQ)^k-1 (dZ/dx)^k-1/2 (1/dz) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk-1)= -alfa2*dQy(Nx)*0.5*(-1/(2*dy))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk-1)=     -alfa2*dQy(Nx)*0.5*(1/(2*dy))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
end 
end 



%---(1.2): - dQ/dy 0.5 (dU/dQ)^k (dZ/dx)^k-1/2 (1/dz) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)= -alfa2*dQy(Nx)*0.5*(-1/(2*dy))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk)=     -alfa2*dQy(Nx)*0.5*(1/(2*dy))*((dZx(Nx,jj,kk-1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
end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++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dQ/dy 0.5 (dU/dQ)^k+1 (dZ/dx)^k+1/2 (1/dz) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk+1) +alfa2*dQy(Nx)*0.5*(-1/(2*dy))*((dZx(Nx,jj,kk+1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk+1)=    MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk+1)     +alfa2*dQy(Nx)*0.5*(1/(2*dy))*((dZx(Nx,jj,kk+1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
end 
end 



%---(2.2):  dQ/dy 0.5 (dU/dQ)^k (dZ/dx)^k-1/2 (1/dz) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk) +alfa2*dQy(Nx)*0.5*(-1/(2*dy))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+kk+1) +alfa2*Kp2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
end 
end 



%---(4.18):  Kp2 (dZ/dz)^j+1/2 0.5 (dW/dz)^j (1/(b dy)) ((H^j+1/2)/H^j) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1) +alfa2*Kp2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(-1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa2*Kp2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx b H dy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(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*((dZx(Nx-1,jj,kk)+dZx(Nx,jj,kk))/2)*0.5*(1/(2*dz))*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+HIC(Nx,jj))/(2*HIC(Nx,jj)))*(1/dx); 
end 
end 

  


%++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ + KpE dens Freq^2 V ++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++;


for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%------------------ The third equation ----------------------;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dZ/dz (dU/dz)^k-1/2 (dZ/dx)^k-1/2 (1/dz) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)= -alfa2*dZz(Nx,jj)*(-1/dz)*((dZx(Nx,jj,kk-1)+dZx(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Nz+kk-1)     -alfa2*dQy(Nx)*0.5*(1/(2*dy))*((dZy(Nx,jj,kk-1)+dZy(Nx,jj,kk))/2)*(0.5/dz);                                                                            
end 
end 



%---(1.9): - dQ/dy 0.5 (dW/dQ)^k (dZ/dy)^k-1/2 (1/dz) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk) -alfa2*dQy(Nx)*0.5*(-1/(2*dy))*((dZy(Nx,jj,kk-1)+dZy(Nx,jj,kk))/2)*(0.5/dz); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk)=    MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk)     -alfa2*dQy(Nx)*0.5*(1/(2*dy))*((dZy(Nx,jj,kk-1)+dZy(Nx,jj,kk))/2)*(0.5/dz);                                                                            
end 
end 



%---(1.10): - (dZ/dy)^k-1/2 (dW/dz)^k-1/2 (dZ/dy)^k-1/2 (1/dz) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1) -alfa2*(-1/dz)*((dZy(Nx,jj,kk-1)+dZy(Nx,jj,kk))/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Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1) +alfa2*Kp2*((dZy(Nx,jj,kk-1)+dZy(Nx,jj,kk))/2)*(-1/dz)*(0.5/(HIC(Nx,jj)*dz)); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=  MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)   +alfa2*Kp2*((dZy(Nx,jj,kk-1)+dZy(Nx,jj,kk))/2)*(1/dz)*(0.5/(HIC(Nx,jj)*dz)); 
end  
end 





%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dZ/dz (dU/dz)^k+1/2 (dZ/dx)^k+1/2 (1/dz) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=  MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)   +alfa2*dZz(Nx,jj)*(-1/dz)*((dZx(Nx,jj,kk+1)+dZx(Nx,jj,kk))/2)*(0.5/dz); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk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*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*Kp2*((dZy(Nx,jj,kk+1)+dZy(Nx,jj,kk))/2)*(1/dz)*(0.5/(HIC(Nx,jj)*dz)); 
end  
end 



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - (dZ/dz)^j-1/2 0.5 (dU/dz)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk-1) -alfa2*((dZz(Nx,jj-1)+dZz(Nx,jj))/2)*0.5*(-1/(2*dz))*((dQx(Nx,jj-1)+dQx(Nx,jj))/2)*(0.5/dy)*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk+1) -alfa2*((dZz(Nx,jj-1)+dZz(Nx,jj))/2)*0.5*(1/(2*dz))*((dQx(Nx,jj-1)+dQx(Nx,j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z+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*((dZy(Nx,jj-1,kk)+dZy(Nx,jj,kk))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
end 
end 



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1): - (dZ/dz)^j+1/2 0.5 (dU/dz)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk-1) +alfa2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(-1/(2*dz))*((dQx(Nx,jj+1)+dQx(Nx,jj))/2)*(0.5/dy)*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk+1) +alfa2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(1/(2*dz))*((dQx(Nx,jj+1)+dQx(Nx,jj))/2)*(0.5/dy)*((HIC(Nx,j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HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
end 
end 



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dZ/dz)^i-1/2 0.5 (dU/dz)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;

for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk-1) -alfa2*((dZz(Nx-1,jj)+dZz(Nx,jj))/2)*0.5*(-1/(2*dz))*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+HIC(Nx,jj))/(2*HIC(Nx,jj)))*(1/dx); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*((dZz(Nx-1,jj)+dZz(Nx,jj))/2)*0.5*(1/(2*dz))*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+HIC(Nx,jj))/(2*HIC(Nx,jj)))*(1/dx); 
end 
end 



%---(5.2): - (dZ/dz)^i-1/2 0.5 (dU/dz)^i (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^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x*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa2*((dZx(Nx-1,jj,kk)+dZx(Nx,jj,kk))/2)*0.5*(1/(2*dz))*((Width(Nx-1)+Width(Nx))/(2*Width(Nx)))*((HIC(Nx-1,jj)+HIC(Nx,jj))/(2*HIC(Nx,jj)))*(1/dx); 
end 
end 




%+++++++++++++++++++++ + KpE dens Freq^2 W +++++++++++++++++++++++++;


for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++ Basic Boundary Conditions at the terminus +++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++ The first equation ( basic equation #1) ++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++ KpE Fxx +++++++++++++++++;

%---------------- Kp1 dU/dx --------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-3)*Ny*Nz+(jj-1)*Nz+kk)+ alfa1*Kp1*(1/(2*dx));
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)+alfa1*Kp1*(-4/(2*dx));
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)+ alfa1*Kp1*(3/(2*dx));                                                      
end 
end


%-------------- Kp1 dQx dU/dQ -----------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)+alfa1*Kp1*(-1/(2*dy))*dQx(Nx,jj);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk)=    MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk)+     alfa1*Kp1*(1/(2*dy))*dQx(Nx,jj);                                                      
end 
end


%-------------- Kp1 dZx dU/dz -----------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)+alfa1*Kp1*(-1/(2*dz))*dZx(Nx,jj,kk);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)+ alfa1*Kp1*(1/(2*dz))*dZx(Nx,jj,kk);                                                      
end 
end



%-------------- Kp2 dQy dV/dQ -----------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)+alfa1*Kp2*(-1/(2*dy))*dQy(Nx);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk)=    MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk)+     alfa1*Kp2*(1/(2*dy))*dQy(Nx);                                                      
end 
end


%-------------- Kp2 dZy dV/dz -----------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)+alfa1*Kp2*(-1/(2*dz))*dZy(Nx,jj,kk);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)+ alfa1*Kp2*(1/(2*dz))*dZy(Nx,jj,kk);                                                      
end 
end


%-------------- Kp2 dZz dW/dz -----------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)+alfa1*Kp2*(-1/(2*dz))*dZz(Nx,jj);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)+ alfa1*Kp2*(1/(2*dz))*dZz(Nx,jj);                                                      
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++ The second equation (basic equation #2) +++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++ KpE Fyx ++++++++++++++++++++;

%------------------ dQy dU/dQ -------------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)+alfa1*(-1/(2*dy))*dQy(Nx);            
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk)=    MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+jj*Nz+kk)+     alfa1*(1/(2*dy))*dQy(Nx);                                                      
end 
end


%------------------ dZy dU/dz -------------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZy(Nx,jj,kk);            
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZy(Nx,jj,kk);                                                      
end 
end

%-------------------- dV/dx ---------------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+kk)+ alfa1*(1/(2*dx));
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)+alfa1*(-4/(2*dx));
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)+ alfa1*(3/(2*dx));                                        
end 
end

%----------------- dQx dV/dQ -------------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)+alfa1*(-1/(2*dy))*dQx(Nx,jj);            
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk)=    MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk)+     alfa1*(1/(2*dy))*dQx(Nx,jj);                                                      
end 
end


%----------------- dZx dV/dz ------------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZx(Nx,jj,kk);            
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZx(Nx,jj,kk);                                                      
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++ The third equation (basic equation) ++++++++++++; 
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++ KpE Fzx +++++++++++++++;

%-------------- dZz dU/dz --------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZz(Nx,jj);            
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZz(Nx,jj);                                                      
end 
end

%---------------- dW/dx ----------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+kk)+ alfa1*(1/(2*dx));
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+kk)+alfa1*(-4/(2*dx));
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk)+ alfa1*(3/(2*dx));                                
end
end

%-------------- dQx dW/dQ -------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+kk)+alfa1*(-1/(2*dy))*dQx(Nx,jj);            
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk)=    MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+kk) +    alfa1*(1/(2*dy))*dQx(Nx,jj);                                                      
end 
end


%-------------- dZx dW/dz -------------;

for jj=2:1:Ny-1
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZx(Nx,jj,kk);            
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZx(Nx,jj,kk);                                                      
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++ The lateral edge Y=Y1 (Jy=1) +++++++++++;
%++++++++++++++ (free lateral edge) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - Kp1 0.5 (dU/dx)^k-1 (dZ/dx)^k-1/2  (1/dz)  ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk-1)= -alfa2*Kp1*0.5*(-1/(2*dx))*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(0.5/dz); 
MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk-1)=     -alfa2*Kp1*0.5*(1/(2*dx))*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(0.5/dz); 
end 
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+kk,(Nx-3)*Ny*Nz+kk-1)= -alfa2*Kp1*0.5*(1/(2*dx))*((dZx(Nx,1,kk-1)+dZx(Nx,1,kk))/2)*(0.25/dz); 
MB((Nx-1)*Ny*Nz+kk,(Nx-2)*Ny*Nz+kk-1)= -alfa2*Kp1*0.5*(-4/(2*dx))*((dZx(Nx,1,kk-1)+dZx(Nx,1,kk))/2)*(0.25/dz);
MB((Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk-1)= -alfa2*Kp1*0.5*(3/(2*dx))*((dZx(Nx,1,kk-1)+dZx(Nx,1,kk))/2)*(0.25/dz);
end 



%---(1.2): - Kp1 0.5 (dU/dx)^k (dZ/dx)^k-1/2 (1/dz)  ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)= -alfa2*Kp1*0.5*(-1/(2*d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((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)+alfa2*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(-1/dz)*(0.5/(HIC(ii,1)*dz)); 
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=  MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)+  alfa2*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(1/dz)*(0.5/(HIC(ii,1)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1)=MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1)+alfa2*((dZx(Nx,1,kk-1)+dZx(Nx,1,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,1)*dz)); 
MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=  MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)+  alfa2*((dZx(Nx,1,kk-1)+dZx(Nx,1,kk))/2)*(1/dz)*(0.25/(HIC(Nx,1)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  Kp1 0.5 (dU/dx)^k+1 (dZ/dx)^k+1/2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/2 (1/(H dz)) -------;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=  MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)   -alfa2*((dZx(ii,1,kk+1)+dZx(ii,1,kk))/2)*(-1/dz)*(0.5/(HIC(ii,1)*dz)); 
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) -alfa2*((dZx(ii,1,kk+1)+dZx(ii,1,kk))/2)*(1/dz)*(0.5/(HIC(ii,1)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=  MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)   -alfa2*((dZx(Nx,1,kk+1)+dZx(Nx,1,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,1)*dz)); 
MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1)=MB((Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1) -alfa2*((dZx(Nx,1,kk+1)+dZx(Nx,1,kk))/2)*(1/dz)*(0.25/(HIC(Nx,1)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dQ/dx)^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++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx H b dy dz / (b H dx dy dz) ++++;


%---(5.1): - Kp1 (dU/dx)^i-1/2 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;


%---  1<i<=Nx, 1<k<Nz ---;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)=MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk) -alfa2*Kp1*(-1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk) -alfa2*Kp1*(1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 



%---(5.2): - Kp1 (dQ/dx)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;


%---  1<i<=Nx, 1<k<Nz ---;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)=     MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)      -alfa2*Kp1*((dQx(ii-1,1)+dQx(ii,1))/2)*0.5*(-3/(2*dy))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB((ii-1)*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))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) -alfa2*Kp2*((dZz(ii-1,1)+dZz(ii,1))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  Kp1 (dU/dx)^i+1/2 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk) +alfa2*Kp1*(-1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)=    MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)     +alfa2*Kp1*(1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 



%---(6.2):  Kp1 (dQ/dx)^i+1/2 0.5 (dU/dQ)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)=     MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)      +alfa2*Kp1*((dQx(ii+1,1)+dQx(ii,1))/2)*0.5*(-3/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+Nz+kk)=  MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+Nz+kk)   +alfa2*Kp1*((dQx(ii+1,1)+dQx(ii,1))/2)*0.5*(4/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx);
MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+2*Nz+kk)=MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+2*Nz+kk) +alfa2*Kp1*((dQx(ii+1,1)+dQx(ii,1))/2)*0.5*(-1/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx);
end 
end 



%---(6.3):  Kp1 (dQ/dx)^i+1/2 0.5 (dU/dQ)^i (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=     MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)      +alfa2*Kp1*((dQx(ii+1,1)+dQx(ii,1))/2)*0.5*(-3/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii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nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1) +alfa2*Kp2*((dZz(ii+1,1)+dZz(ii,1))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) +alfa2*Kp2*((dZz(ii+1,1)+dZz(ii,1))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ + KpE dens Freq^2 U ++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk)=MB((Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk) + alfa2*KpE*dens*Freq^2*0.25; 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++ The second equation +++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dQ/dy 0.5 (dU/dQ)^k-1 (dZ/dx)^k-1/2 (1/dz) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)=      -alfa2*dQy(ii)*0.5*(-3/(2*dy))*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(0.5/dz); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk-1)=   -alfa2*dQy(ii)*0.5*(4/(2*dy))*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(0.5/dz); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk-1)= -alfa2*dQy(ii)*0.5*(-1/(2*dy))*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(0.5/dz); 
end 
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk-1)=      -alfa2*dQy(Nx)*0.5*(-3/(2*dy))*((dZx(Nx,1,kk-1)+dZx(Nx,1,kk))/2)*(0.25/dz); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+Nz+kk-1)=   -alfa2*dQy(Nx)*0.5*(4/(2*dy))*((dZx(Nx,1,kk-1)+dZx(Nx,1,kk))/2)*(0.25/dz); 
MB(N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*Ny*Nz+(ii-1)*Ny*Nz+kk)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)   +alfa2*((dZy(ii,1,kk-1)+dZy(ii,1,kk))/2)*(1/dz)*(0.5/(HIC(ii,1)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1) +alfa2*((dZy(Nx,1,kk-1)+dZy(Nx,1,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,1)*dz)); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=  MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)   +alfa2*((dZy(Nx,1,kk-1)+dZy(Nx,1,kk))/2)*(1/dz)*(0.25/(HIC(Nx,1)*dz)); 
end  





%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dQ/dy 0.5 (dU/dQ)^k+1 (dZ/dx)^k+1/2 (1/dz) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)=     MB(Nx*Ny*N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ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)   -alfa2*((dZy(ii,1,kk+1)+dZy(ii,1,kk))/2)*(-1/dz)*(0.5/(HIC(ii,1)*dz)); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) -alfa2*((dZy(ii,1,kk+1)+dZy(ii,1,kk))/2)*(1/dz)*(0.5/(HIC(ii,1)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=  MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)   -alfa2*((dZy(Nx,1,kk+1)+dZy(Nx,1,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,1)*dz)); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1) -alfa2*((dZy(Nx,1,kk+1)+dZy(Nx,1,kk))/2)*(1/dz)*(0.25/(HIC(Nx,1)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  dQ/dy (dU/dQ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Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) +alfa2*Kp2*((dZz(ii,2)+dZz(ii,1))/2)*0.5*(1/(2*dz))*(1/(Width(ii)*dy))*((HIC(ii,2)+HIC(ii,1))/(2*HIC(ii,1))); 
end 
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1) +alfa2*Kp2*((dZz(Nx,2)+dZz(Nx,1))/2)*0.5*(-1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,2)+HIC(Nx,1))/(2*HIC(Nx,1))); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1) +alfa2*Kp2*((dZz(Nx,2)+dZz(Nx,1))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,2)+HIC(Nx,1))/(2*HIC(Nx,1))); 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dQ/dy)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((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C(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) -alfa2*((dZx(ii-1,1,kk)+dZx(ii,1,kk))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dQ/dy)^i+1/2 0.5 (dU/dQ)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)      +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(-3/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+Nz+kk)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+Nz+kk)   +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(4/(2*dy))*((Width(ii+1)+Width(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Ny*Nz+ii*Ny*Nz+kk+1) +alfa2*((dZx(ii+1,1,kk)+dZx(ii,1,kk))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 



%---(6.9):  (dZ/dx)^i+1/2 0.5 (dV/dz)^i (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ---;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1) +alfa2*((dZx(ii+1,1,kk)+dZx(ii,1,kk))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) +alfa2*((dZx(ii+1,1,kk)+dZx(ii,1,kk))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 

    


%++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ + KpE dens Freq^2 V ++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk) + alfa2*KpE*dens*Freq^2*0.25; 
end  




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++++++ The third equation ++++++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dZ/dz (dU/dz)^k-1/2 (dZ/dx)^k-1/2 (1/dz) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)= -alfa2*dZz(ii,1)*(-1/dz)*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(0.5/dz); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=   -alfa2*dZz(ii,1)*(1/dz)*((dZx(ii,1,kk-1)+dZx(ii,1,kk))/2)*(0.5/dz); 
end 
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-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kk))/2)*(-1/dz)*(0.5/(HIC(ii,1)*dz)); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)   +alfa2*Kp2*((dZy(ii,1,kk-1)+dZy(ii,1,kk))/2)*(1/dz)*(0.5/(HIC(ii,1)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk-1) +alfa2*Kp2*((dZy(Nx,1,kk-1)+dZy(Nx,1,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,1)*dz)); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=  MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)   +alfa2*Kp2*((dZy(Nx,1,kk-1)+dZy(Nx,1,kk))/2)*(1/dz)*(0.25/(HIC(Nx,1)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dZ/dz (dU/dz)^k+1/2 (dZ/dx)^k+1/2 (1/dz) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-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x*Ny*Nz+(Nx-1)*Ny*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1) -alfa2*Kp2*((dZy(Nx,1,kk+1)+dZy(Nx,1,kk))/2)*(1/dz)*(0.25/(HIC(Nx,1)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1): - (dZ/dz)^j+1/2 0.5 (dU/dz)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk-1) +alfa2*((dZz(ii,2)+dZz(ii,1))/2)*0.5*(-1/(2*dz))*((dQx(ii,2)+dQx(ii,1))/2)*(1/dy)*((HIC(ii,2)+HIC(ii,1))/(2*HIC(ii,1))); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk+1) +alfa2*((dZz(ii,2)+dZz(ii,1))/2)*0.5*(1/(2*dz))*((dQx(ii,2)+dQx(ii,1))/2)*(1/dy)*((HIC(ii,2)+HIC(ii,1))/(2*HIC(ii,1))); 
end 
end 


%---  i=Nx, 1<k<Nz ---;

for k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*Ny*Nz+(ii-1)*Ny*Nz+kk)=   MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)    +alfa2*dQy(ii)*(-1/dy)*(1/(Width(ii)*dy))*((HIC(ii,2)+HIC(ii,1))/(2*HIC(ii,1))); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk) +alfa2*dQy(ii)*(1/dy)*(1/(Width(ii)*dy))*((HIC(ii,2)+HIC(ii,1))/(2*HIC(ii,1)));                                                                            
end 
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=   MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)    +alfa2*dQy(Nx)*(-1/dy)*(0.5/(Width(Nx)*dy))*((HIC(Nx,2)+HIC(Nx,1))/(2*HIC(Nx,1))); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz+kk) +alfa2*dQy(Nx)*(1/dy)*(0.5/(Width(Nx)*dy))*((HIC(Nx,2)+HIC(Nx,1))/(2*HIC(Nx,1)));                                                                            
end 



%---(4.11): - (dZ/dy)^j+1/2 0.5 (dW/dz)^j+1 (1/(b dy)) ((H^j+1/2)/H^j) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(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nx*Ny*Nz+(Nx-1)*Ny*Nz+kk+1) +alfa2*((dZy(Nx,2,kk)+dZy(Nx,1,kk))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,2)+HIC(Nx,1))/(2*HIC(Nx,1))); 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dZ/dz)^i-1/2 0.5 (dU/dz)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;


%---  1<i<=Nx, 1<k<Nz ---;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk-1) -alfa2*((dZz(ii-1,1)+dZz(ii,1))/2)*0.5*(-1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk+1) -alfa2*((dZz(ii-1,1)+dZz(ii,1))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 



%---(5.2): - (dZ/dz)^i-1/2 0.5 (dU/dz)^i (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^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*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) -alfa2*((dZx(ii-1,1,kk)+dZx(ii,1,kk))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dZ/dz)^i+1/2 0.5 (dU/dz)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk-1) +alfa2*((dZz(ii+1,1)+dZz(ii,1))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk+1) +alfa2*((dZz(ii+1,1)+dZz(ii,1))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 



%---(6.2):  (dZ/dz)^i+1/2 0.5 (dU/dz)^i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*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) +alfa2*((dZx(ii+1,1,kk)+dZx(ii,1,kk))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.5/dx); 
end 
end 




%+++++++++++++++++++++ + KpE dens Freq^2 W +++++++++++++++++++++++++;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk) + alfa2*KpE*dens*Freq^2*0.25; 
end  




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++ Basic Boundary Conditions at the lateral edge Y=Y1 ++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++ The first equation (basic equation#1) +++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

%++++++++++++++ Fxx nx + Fxy ny = fx(z) ++++++++++++++;

%----------------- Kp1 dU/dx Y1x -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)=MB((ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)+alfa1*Kp1*(-1/(2*dx))*difY1(ii);
MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)=    MB((ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)+    alfa1*Kp1*(1/(2*dx))*difY1(ii);                                          
end 
end


%-------- i=Nx ------;

for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+kk,(Nx-3)*Ny*Nz+kk)=MB((Nx-1)*Ny*Nz+kk,(Nx-3)*Ny*Nz+kk)+ alfa1*Kp1*(1/(2*dx))*difY1(ii); 
MB((Nx-1)*Ny*Nz+kk,(Nx-2)*Ny*Nz+kk)=MB((Nx-1)*Ny*Nz+kk,(Nx-2)*Ny*Nz+kk)+alfa1*Kp1*(-4/(2*dx))*difY1(ii); 
MB((Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk)=MB((Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk)+ alfa1*Kp1*(3/(2*dx))*difY1(ii); 
end


%----------------- Kp1 dQx dU/dQ --------------;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=     MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)+     alfa1*Kp1*dQx(ii,1)*(-3/(2*dy))*difY1(ii); 
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)=  MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)+   alfa1*Kp1*dQx(ii,1)*(4/(2*dy))*difY1(ii); 
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)+alfa1*Kp1*dQx(ii,1)*(-1/(2*dy))*difY1(ii); 
end 
end


%--------------- Kp1 dZx dU/dz Y1x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)+alfa1*Kp1*(-1/(2*dz))*dZx(ii,1,kk)*difY1(ii);
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)+ alfa1*Kp1*(1/(2*dz))*dZx(ii,1,kk)*difY1(ii);                                                          
end 
end



%--------------- Kp2 dQy dV/dQ Y1x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=     MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)+     alfa1*Kp2*(-3/(2*dy))*dQy(ii)*difY1(ii);
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)=  MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)+  alfa1*Kp2*(4/(2*dy))*dQy(ii)*difY1(ii);
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)=MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)+alfa1*Kp2*(-1/(2*dy))*dQy(ii)*difY1(ii);
end 
end

%--------------- Kp2 dZy dV/dz Y1x ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)+alfa1*Kp2*(-1/(2*dz))*dZy(ii,1,kk)*difY1(ii);
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)+ alfa1*Kp2*(1/(2*dz))*dZy(ii,1,kk)*difY1(ii);                                                          
end 
end

%--------------- Kp2 dZz dW/dz Y1x ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)+alfa1*Kp2*(-1/(2*dz))*dZz(ii,1)*difY1(ii);
MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)+alfa1*Kp2*(1/(2*dz))*dZz(ii,1)*difY1(ii);                                                          
end 
end



%--------------- - dQy dU/dQ -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=     MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)-     alfa1*(-3/(2*dy))*dQy(ii);
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)=  MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)-   alfa1*(4/(2*dy))*dQy(ii);
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)-alfa1*(-1/(2*dy))*dQy(ii);
end 
end

%--------------- - dZy dU/dz -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)-alfa1*(-1/(2*dz))*dZy(ii,1,kk);
MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)- alfa1*(1/(2*dz))*dZy(ii,1,kk);                                                          
end 
end

%----------------- - dV/dx -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-2)*Ny*Nz+kk)=MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-2)*Ny*Nz+kk)-alfa1*(-1/(2*dx));
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+ii*Ny*Nz+kk)=    MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+ii*Ny*Nz+kk)    - alfa1*(1/(2*dx));                                          
end 
end

%-------- i=Nx ------;

for kk=2:1:Nz-1                                              
MB((Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+kk)=MB((Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+kk)- alfa1*(1/(2*dx));
MB((Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+kk)=MB((Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+kk)-alfa1*(-4/(2*dx));
MB((Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=MB((Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)- alfa1*(3/(2*dx));
end 


%--------------- - dQx dV/dQ -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=     MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)-     alfa1*(-3/(2*dy))*dQx(ii,1);
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)=  MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)-   alfa1*(4/(2*dy))*dQx(ii,1);
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)=MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)-alfa1*(-1/(2*dy))*dQx(ii,1);
end 
end

%--------------- - dZx dV/dz -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)-alfa1*(-1/(2*dz))*dZx(ii,1,kk);
MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB((ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)- alfa1*(1/(2*dz))*dZx(ii,1,kk);                                                          
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++ The second equation (basic equation #2) +++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++;

%++++++++++ Fyx nx + Fyy ny = fy(z) +++++++++++++;

%--------------- dQy dU/dQ Y1x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)+     alfa1*(-3/(2*dy))*dQy(ii)*difY1(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)+   alfa1*(4/(2*dy))*dQy(ii)*difY1(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)+alfa1*(-1/(2*dy))*dQy(ii)*difY1(ii);
end 
end

%--------------- dZy dU/dz Y1x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)+alfa1*(-1/(2*dz))*dZy(ii,1,kk)*difY1(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)+ alfa1*(1/(2*dz))*dZy(ii,1,kk)*difY1(ii);                                                          
end 
end



%----------------- dV/dx Y1x -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-2)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-2)*Ny*Nz+kk)+alfa1*(-1/(2*dx))*difY1(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+ii*Ny*Nz+kk)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+ii*Ny*Nz+kk)+     alfa1*(1/(2*dx))*difY1(ii);                                          
end 
end

%------ i=Nx -------;

for kk=2:1:Nz-1
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+kk)+ alfa1*(1/(2*dx))*difY1(Nx);    
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+kk)+alfa1*(-4/(2*dx))*difY1(Nx);
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk)+ alfa1*(3/(2*dx))*difY1(Nx);                                          
end 

%--------------- dQx dV/dQ Y1x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)+     alfa1*(-3/(2*dy))*dQx(ii,1)*difY1(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)+   alfa1*(4/(2*dy))*dQx(ii,1)*difY1(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)+alfa1*(-1/(2*dy))*dQx(ii,1)*difY1(ii);
end 
end

%--------------- dZx dV/dz Y1x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)+alfa1*(-1/(2*dz))*dZx(ii,1,kk)*difY1(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)+ alfa1*(1/(2*dz))*dZx(ii,1,kk)*difY1(ii);                                                          
end 
end



%--------------- - Kp1 dQy dV/dQ -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk) -    alfa1*Kp1*(-3/(2*dy))*dQy(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)-   alfa1*Kp1*(4/(2*dy))*dQy(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)-alfa1*Kp1*(-1/(2*dy))*dQy(ii);
end 
end

%--------------- - Kp1 dZy dV/dz ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)-alfa1*Kp1*(-1/(2*dz))*dZy(ii,1,kk);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)- alfa1*Kp1*(1/(2*dz))*dZy(ii,1,kk);                                                          
end 
end



%----------------- - Kp2 dU/dx -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-2)*Ny*Nz+kk)-alfa1*Kp2*(-1/(2*dx));
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,ii*Ny*Nz+kk)    - alfa1*Kp2*(1/(2*dx));                                          
end 
end

%------ i=Nx -------;

for kk=2:1:Nz-1
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-3)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-3)*Ny*Nz+kk)- alfa1*Kp2*(1/(2*dx));    
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-2)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-2)*Ny*Nz+kk)-alfa1*Kp2*(-4/(2*dx));
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,(Nx-1)*Ny*Nz+kk)- alfa1*Kp2*(3/(2*dx));                                          
end 


%--------------- - Kp2 dQx dU/dQ -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk)-     alfa1*Kp2*(-3/(2*dy))*dQx(ii,1);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+Nz+kk)-   alfa1*Kp2*(4/(2*dy))*dQx(ii,1);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+2*Nz+kk)-alfa1*Kp2*(-1/(2*dy))*dQx(ii,1);
end 
end

%--------------- - Kp2 dZx dU/dz -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)-alfa1*Kp2*(-1/(2*dz))*dZx(ii,1,kk);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)- alfa1*Kp2*(1/(2*dz))*dZx(ii,1,kk);                                                          
end 
end

%--------------- - Kp2 dZz dW/dz ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)-alfa1*Kp2*(-1/(2*dz))*dZz(ii,1);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1) -alfa1*Kp2*(1/(2*dz))*dZz(ii,1);                                                          
end 
end



%+++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++ The third equation (basic equation #3) ++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++;

%+++++++++++++++ Fzx nx + Fzy ny = 0 ++++++++++++++++;

%--------------- dZz dU/dz Y1x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk-1)+alfa1*(-1/(2*dz))*dZz(ii,1)*difY1(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,(ii-1)*Ny*Nz+kk+1)+ alfa1*(1/(2*dz))*dZz(ii,1)*difY1(ii);                                                          
end 
end

%----------------- dW/dx Y1x -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-2)*Ny*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-2)*Ny*Nz+kk)+alfa1*(-1/(2*dx))*difY1(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+ii*Ny*Nz+kk)=    MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+ii*Ny*Nz+kk)+     alfa1*(1/(2*dx))*difY1(ii);                                          
end 
end

%-------- i=Nx ---------;

for kk=2:1:Nz-1
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(Nx-3)*Ny*Nz+kk)=MB(2*Nx*Ny*Nz+(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for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)+alfa1*(-1/(2*dz))*dZx(ii,1,kk)*difY1(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)+ alfa1*(1/(2*dz))*dZx(ii,1,kk)*difY1(ii);                                                          
end 
end

%--------------- - dZz dV/dz ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)-alfa1*(-1/(2*dz))*dZz(ii,1);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)- alfa1*(1/(2*dz))*dZz(ii,1);                                                          
end 
end

%--------------- - dQy dW/dQ -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk)=     MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk) -    alfa1*(-3/(2*dy))*dQy(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+kk)-   alfa1*(4/(2*dy))*dQy(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+kk)-alfa1*(-1/(2*dy))*dQy(ii);
end 
end

%--------------- - dZy dW/dz -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk-1)-alfa1*(-1/(2*dz))*dZy(ii,1,kk);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+kk+1)- alfa1*(1/(2*dz))*dZy(ii,1,kk);                                                          
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++ The lateral edge Y=Y2 (Jy=Ny) +++++++++++;
%++++++++++++++ (free lateral edge) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++ The first equation +++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)x /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+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=  MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)   +alfa2*((dZx(ii,Ny,kk-1)+dZx(ii,Ny,kk))/2)*(1/dz)*(0.5/(HIC(ii,Ny)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk-1) +alfa2*((dZx(Nx,Ny,kk-1)+dZx(Nx,Ny,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=  MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)   +alfa2*((dZx(Nx,Ny,kk-1)+dZx(Nx,Ny,kk))/2)*(1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  Kp1 0.5 (dU/dx)^k+1 (dZ/dx)^k+1/2 (1/dz)  ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2: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)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)   -alfa2*((dZx(Nx,Ny,kk+1)+dZx(Nx,Ny,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1) -alfa2*((dZx(Nx,Ny,kk+1)+dZx(Nx,Ny,kk))/2)*(1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - Kp1 0.5 (dU/dx)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-2)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-2)*Nz+kk) -alfa2*Kp1*0.5*(-1/(2*dx))*((dQx(ii,Ny-1)+dQx(ii,Ny))/2)*(1/dy)*((HIC(ii,Ny-1)+HIC(ii,Ny))/(2*HIC(ii,Ny))); 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-2)*Nz+kk)=    MB((ii-1)*Ny*N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%+++++++++++++++ KpE I(5)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx H b dy dz / (b H dx dy dz) ++++;


%---(5.1): - Kp1 (dU/dx)^i-1/2 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;


%---  1<i<=Nx, 1<k<Nz ---;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk) -alfa2*Kp1*(-1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk) -alfa2*Kp1*(1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
end 
end 



%---(5.2): - Kp1 (dQ/dx)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;


%---  1<i<=Nx, 1<k<Nz ---;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-3)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-3)*Nz+kk) -alfa2*Kp1*((dQx(ii-1,Ny)+dQx(ii,Ny))/2)*0.5*(1/(2*dy))*((Width(ii-1)+Width(ii))/(2*Width(ii)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*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1) -alfa2*Kp2*((dZz(ii-1,Ny)+dZz(ii,Ny))/2)*0.5*(-1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1) -alfa2*Kp2*((dZz(ii-1,Ny)+dZz(ii,Ny))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  Kp1 (dU/dx)^i+1/2 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk) +alfa2*Kp1*(-1/d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(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++++ + KpE dens Freq^2 U ++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.25; 
end  




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++ The second equation ++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dQ/dy 0.5 (dU/dQ)^k-1 (dZ/dx)^k-1/2 (1/dz) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2: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(Nx,Ny)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - dQ/dy (dU/dQ)^j-1/2 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk) -alfa2*dQy(ii)*(-1/dy)*((dQx(ii,Ny-1)+dQx(ii,Ny))/2)*(1/dy)*((HIC(ii,Ny-1)+HIC(ii,Ny))/(2*HIC(ii,Ny))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk) -alfa2*dQy(ii)*(1/dy)*((dQx(ii,Ny-1)+dQx(ii,Ny))/2)*(1/dy)*((HIC(ii,Ny-1)+HIC(ii,Ny))/(2*HIC(ii,Ny))); 
end 
end


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(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z+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1) -alfa2*Kp2*((dZz(Nx,Ny-1)+dZz(Nx,Ny))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,Ny-1)+HIC(Nx,Ny))/(2*HIC(Nx,Ny))); 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dQ/dy)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;


%---  1<i<=Nx, 1<k<Nz ---;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-3)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-3)*Nz+kk) -alfa2*((dQy(ii-1)+dQy(ii))/2)*0.5*(1/(2*dy))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-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++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dQ/dy)^i+1/2 0.5 (dU/dQ)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-3)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-3)*Nz+kk) +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(1/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-2)*Nz+kk) +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(-4/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-1)*Nz+kk) +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(3/(2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*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.25; 
end  




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++ The third equation +++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dZ/dz (dU/dz)^k-1/2 (dZ/dx)^k-1/2 (1/dz) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)= -alfa2*dZz(ii,Ny)*(-1/dz)*((dZx(ii,Ny,kk-1)+dZx(ii,Ny,kk))/2)*(0.5/dz); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=   -alfa2*dZz(ii,Ny)*(1/dz)*((dZx(ii,Ny,kk-1)+dZx(ii,Ny,kk))/2)*(0.5/dz); 
end 
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk-1)= -alfa2*dZz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)   +alfa2*Kp2*((dZy(ii,Ny,kk-1)+dZy(ii,Ny,kk))/2)*(1/dz)*(0.5/(HIC(ii,Ny)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk-1) +alfa2*Kp2*((dZy(Nx,Ny,kk-1)+dZy(Nx,Ny,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=  MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)   +alfa2*Kp2*((dZy(Nx,Ny,kk-1)+dZy(Nx,Ny,kk))/2)*(1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dZ/dz (dU/dz)^k+1/2 (dZ/dx)^k+1/2 (1/dz) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny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dz)*(0.5/(HIC(ii,Ny)*dz)); 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=  MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)   -alfa2*Kp2*((dZy(Nx,Ny,kk+1)+dZy(Nx,Ny,kk))/2)*(-1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1) -alfa2*Kp2*((dZy(Nx,Ny,kk+1)+dZy(Nx,Ny,kk))/2)*(1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - (dZ/dz)^j-1/2 0.5 (dU/dz)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz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ny*Nz+(Ny-1)*Nz+kk-1) -alfa2*((dZy(Nx,Ny-1,kk)+dZy(Nx,Ny,kk))/2)*0.5*(-1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,Ny-1)+HIC(Nx,Ny))/(2*HIC(Nx,Ny))); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk+1) -alfa2*((dZy(Nx,Ny-1,kk)+dZy(Nx,Ny,kk))/2)*0.5*(1/(2*dz))*(0.5/(Width(Nx)*dy))*((HIC(Nx,Ny-1)+HIC(Nx,Ny))/(2*HIC(Nx,Ny))); 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dZ/dz)^i-1/2 0.5 (dU/dz)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;


%---  1<i<=Nx, 1<k<Nz ---;

for ii=2:1:Nx 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk-1) -alfa2*((dZz(ii-1,Ny)+dZz(ii,Ny))/2)*0.5*(-1/(2*dz))*((Width(ii-1)+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Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1) -alfa2*((dZx(ii-1,Ny,kk)+dZx(ii,Ny,kk))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
end 
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dZ/dz)^i+1/2 0.5 (dU/dz)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-1)*Nz+kk-1) +alfa2*((dZz(ii+1,Ny)+dZz(ii,Ny))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*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ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1) +alfa2*((dZx(ii+1,Ny,kk)+dZx(ii,Ny,kk))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.5/dx); 
end 
end 



%+++++++++++++++++++++ + KpE dens Freq^2 W +++++++++++++++++++++++++;


%---  1<i<Nx, 1<k<Nz ---;

for ii=2:1:Nx-1 
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 


%---  i=Nx, 1<k<Nz ---;

for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk) + alfa2*KpE*dens*Freq^2*0.25; 
end  




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++ Basic Boundary Conditions at the lateral edge Y=Y2 ++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++ The first equation (basic equation #1) ++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++ KpE Fxx nx ++++++++++++++++++;

%--------------- - Kp1 dU/dx Y2x -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)-alfa1*Kp1*(-1/(2*dx))*difY2(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-1)*Nz+kk)=    MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-1)*Nz+kk)  -   alfa1*Kp1*(1/(2*dx))*difY2(ii);                                          
end 
end

%-------- i=Nx --------;

for kk=2:1:Nz-1
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-3)*Ny*Nz+(Ny-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-3)*Ny*Nz+(Ny-1)*Nz+kk)- alfa1*Kp1*(1/(2*dx))*difY2(Nx);    
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-2)*Ny*Nz+(Ny-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-2)*Ny*Nz+(Ny-1)*Nz+kk)-alfa1*Kp1*(-4/(2*dx))*difY2(Nx);
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)- alfa1*Kp1*(3/(2*dx))*difY2(Nx);                                          
end 


%--------------- - Kp1 dQx dU/dQ Y2x ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)- alfa1*Kp1*(1/(2*dy))*dQx(ii,Ny)*difY2(ii);   
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)-alfa1*Kp1*(-4/(2*dy))*dQx(ii,Ny)*difY2(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)- alfa1*Kp1*(3/(2*dy))*dQx(ii,Ny)*difY2(ii);                              
end 
end

%--------------- - Kp1 dZx dU/dz Y2x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)-alfa1*Kp1*(-1/(2*dz))*dZx(ii,Ny,kk)*difY2(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)- alfa1*Kp1*(1/(2*dz))*dZx(ii,Ny,kk)*difY2(ii);                                                          
end 
end

%--------------- - Kp2 dQy dV/dQ Y2x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)- alfa1*Kp2*(1/(2*dy))*dQy(ii)*difY2(ii);    
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)-alfa1*Kp2*(-4/(2*dy))*dQy(ii)*difY2(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)- alfa1*Kp2*(3/(2*dy))*dQy(ii)*difY2(ii);                              
end 
end

%--------------- - Kp2 dZy dV/dz Y2x ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)-alfa1*Kp2*(-1/(2*dz))*dZy(ii,Ny,kk)*difY2(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)- alfa1*Kp2*(1/(2*dz))*dZy(ii,Ny,kk)*difY2(ii);                                                          
end 
end

%--------------- - Kp2 dZz dW/dz Y2x ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)-alfa1*Kp2*(-1/(2*dz))*dZz(ii,Ny)*difY2(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)- alfa1*Kp2*(1/(2*dz))*dZz(ii,Ny)*difY2(ii);                                                          
end 
end



%++++++++++++++++ KpE Fxy ny +++++++++++++++++;

%---------------- dQy dU/dQ ------------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)+ alfa1*(1/(2*dy))*dQy(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)+alfa1*(-4/(2*dy))*dQy(ii);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)+ alfa1*(3/(2*dy))*dQy(ii);                              
end 
end

%---------------- dZy dU/dz -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZy(ii,Ny,kk);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZy(ii,Ny,kk);                                                          
end 
end

%------------------ dV/dx -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)+alfa1*(-1/(2*dx));
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+ii*Ny*Nz+(Ny-1)*Nz+kk)=    MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+ii*Ny*Nz+(Ny-1)*Nz+kk)    + alfa1*(1/(2*dx));                                          
end 
end

%-------- i=Nx --------;

for kk=2:1:Nz-1
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(Ny-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(Ny-1)*Nz+kk)+ alfa1*(1/(2*dx));    
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(Ny-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(Ny-1)*Nz+kk)+alfa1*(-4/(2*dx));
MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+kk)+ alfa1*(3/(2*dx));                                          
end 


%--------------- dQx dV/dQ ---------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)+ alfa1*(1/(2*dy))*dQx(ii,Ny);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)+alfa1*(-4/(2*dy))*dQx(ii,Ny);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)+ alfa1*(3/(2*dy))*dQx(ii,Ny);                              
end 
end

%-------------- dZx dV/dz ---------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZx(ii,Ny,kk);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZx(ii,Ny,kk);                                                          
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++ The second equation (basic equation #2) +++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++ KpE Fyx nx +++++++++++++++++++;

%---------------- - dQy dU/dQ Y2x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)- alfa1*(1/(2*dy))*dQy(ii)*difY2(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)-alfa1*(-4/(2*dy))*dQy(ii)*difY2(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)- alfa1*(3/(2*dy))*dQy(ii)*difY2(ii);                              
end 
end

%---------------- - dZy dU/dz Y2x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny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                              
end 
end

%--------------- - dZx dV/dz Y2x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)-alfa1*(-1/(2*dz))*dZx(ii,Ny,kk)*difY2(ii);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)- alfa1*(1/(2*dz))*dZx(ii,Ny,kk)*difY2(ii);                                                          
end 
end



%+++++++++++++++++ KpE Fyy ny +++++++++++++++++;

%-------------- Kp1 dQy dV/dQ -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)+ alfa1*(1/(2*dy))*dQy(ii)*Kp1;
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)+alfa1*(-4/(2*dy))*dQy(ii)*Kp1;
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)+ alfa1*(3/(2*dy))*dQy(ii)*Kp1;                              
end 
end

%-------------- Kp1 dZy dV/dz ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZy(ii,Ny,kk)*Kp1;
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZy(ii,Ny,kk)*Kp1;                                                          
end 
end

%---------------- Kp2 dU/dx -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)+alfa1*(-1/(2*dx))*Kp2;
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,ii*Ny*Nz+(Ny-1)*Nz+kk)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1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+alfa1*(-4/(2*dy))*dQx(ii,Ny)*Kp2;
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)+ alfa1*(3/(2*dy))*dQx(ii,Ny)*Kp2;                              
end 
end

%-------------- Kp2 dZx dU/dz -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZx(ii,Ny,kk)*Kp2;
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZx(ii,Ny,kk)*Kp2;                                                          
end 
end

%--------------- Kp2 dZz dW/dz ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZz(ii,Ny)*Kp2;
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZz(ii,Ny)*Kp2;                                                          
end 
end



%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++ The third equation (basic equation #3) +++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++ KpE Fzx nx ++++++++++++++++++;

%---------------- - dZz dU/dz Y2x -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)-alfa1*(-1/(2*dz))*dZz(ii,Ny)*difY2(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)- alfa1*(1/(2*dz))*dZz(ii,Ny)*difY2(ii);                                                          
end 
end

%----------------- - dW/dx Y2x -----------------;

for ii=2:1:Nx-1
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-2)*Ny*Nz+(Ny-1)*Nz+kk)-alfa1*(-1/(2*dx))*difY2(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*N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*dZx(ii,Ny,kk)*difY2(ii);                                                          
end 
end



%++++++++++++++++ KpE Fzy ny +++++++++++++++++;

%----------------- dZz dV/dz ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZz(ii,Ny);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZz(ii,Ny);                                                          
end 
end

%---------------- dQy dW/dQ ----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+kk)+ alfa1*(1/(2*dy))*dQy(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+kk)+alfa1*(-4/(2*dy))*dQy(ii);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk)+ alfa1*(3/(2*dy))*dQy(ii);                              
end 
end

%---------------- dZy dW/dz -----------------;

for ii=2:1:Nx
for kk=2:1:Nz-1                                              
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk-1)+alfa1*(-1/(2*dz))*dZy(ii,Ny,kk);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+kk+1)+ alfa1*(1/(2*dz))*dZy(ii,Ny,kk);                                                          
end 
end





%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++ Ice Shelf Surface (k=1) +++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++ The first equation +++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)x / (b H dx dy dz) +++++++++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*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+2)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+2) -alfa2*((dZx(Nx,Ny,2)+dZx(Nx,Ny,1))/2)*(1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - Kp1 0.5 (dU/dx)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;


%---  1<i<Nx, j=1 ---;

% =0


%---  1<i<Nx, 1<j<=Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-2)*Ny*Nz+(jj-2)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-2)*Ny*Nz+(jj-2)*Nz+1) -alfa2*Kp1*0.5*(-1/(2*dx))*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,ii*Ny*Nz+(jj-2)*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,ii*Ny*Nz+(jj-2)*Nz+1)     -alfa2*Kp1*0.5*(1/(2*dx))*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 


%--- i=Nx, j=1 ---;

% =0

%--- i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*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+2) -alfa2*((dZx(Nx,jj-1,1)+dZx(Nx,jj,1))/2)*0.5*(4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3) -alfa2*((dZx(Nx,jj-1,1)+dZx(Nx,jj,1))/2)*0.5*(-1/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  Kp1 0.5 (dU/dx)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;


%---  1<i<Nx, 1<=j<Ny ---;

for ii=2:1:Nx-1 
for jj=1:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-2)*Ny*Nz+jj*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-2)*Ny*Nz+jj*Nz+1) +alfa2*Kp1*0.5*(-1/(2*dx))*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,ii*Ny*Nz+jj*Nz+1)=    MB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(4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3) +alfa2*((dZx(Nx,jj+1,1)+dZx(Nx,jj,1))/2)*0.5*(-1/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 


%--- i=Nx, j=Ny ---;

% =0




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx H b dy dz / (b H dx dy dz) ++++;


%---(5.1): - Kp1 (dU/dx)^i-1/2 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;


%---  1<i<=Nx, j=1 ---;

for ii=2:1:Nx 
MB((ii-1)*Ny*Nz+1,(ii-2)*Ny*Nz+1)=MB((ii-1)*Ny*Nz+1,(ii-2)*Ny*Nz+1) -alfa2*Kp1*(-1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)=MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1) -alfa2*Kp1*(1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
end 


%---  1<i<=Nx, 1<j<Ny ---;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IC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  Kp1 (dU/dx)^i+1/2 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)=MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1) +alfa2*Kp1*(-1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
MB((ii-1)*Ny*Nz+1,ii*Ny*Nz+1)=    MB((ii-1)*Ny*Nz+1,ii*Ny*Nz+1)     +alfa2*Kp1*(1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
end 


%---  1<i<Nx, 1<j<Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1) +alfa2*Kp1*(-1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(0.5/dx); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,ii*Ny*Nz+(jj-1)*Nz+1)=    MB((ii-1)*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(ii-1)*Ny*Nz+(Ny-1)*Nz+2) +alfa2*Kp2*((dZz(ii+1,Ny)+dZz(ii,Ny))/2)*0.5*(4/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+3)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+3) +alfa2*Kp2*((dZz(ii+1,Ny)+dZz(ii,Ny))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ + KpE dens Freq^2 U ++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)=MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1) + alfa2*KpE*dens*Freq^2*0.25; 
end  


%---  1<i<Nx, 1<j<Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.5; 
end  
end 


%---  1<i<Nx, j=Ny ---;

for ii=2:1:Nx-1 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.25; 
end  


%--- i=Nx, j=1 ---; 

MB((Nx-1)*Ny*Nz+1,(Nx-1)*Ny*Nz+1)=MB((Nx-1)*Ny*Nz+1,(Nx-1)*Ny*Nz+1) + alfa2*KpE*dens*Freq^2*0.125; 


%--- i=Nx, 1<j<Ny ---; 

for jj=2:1:Ny-1
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-1)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-1)*Ny*Nz+(jj-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.25; 
end  


%--- i=Nx, j=Ny ---; 

MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+1,(Nx-1)*Ny*Nz+(Ny-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+1,(Nx-1)*Ny*Nz+(Ny-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.125; 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++ The second equation +++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dQ/dy 0.5 (dU/dQ)^2 (dZ/dx)^3/2 (1/dz) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+2)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny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*Nz+(Ny-1)*Nz+2) -alfa2*((dZy(Nx,Ny,2)+dZy(Nx,Ny,1))/2)*(1/dz)*(0.25/(HIC(Nx,Ny)*dz)); 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - dQ/dy (dU/dQ)^j-1/2 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) -----;


%---  1<i<Nx, j=1 ---;

% =0


%---  1<i<Nx, 1<j<=Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-2)*Nz+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-2)*Nz+1) -alfa2*dQy(ii)*(-1/dy)*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1) -alfa2*dQy(ii)*(1/dy)*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 


%--- i=Nx, j=1 ---;

% =0


%--- i=Nx, 1<j<=Ny ---;

for jj=2:1:Ny
MB(Nx*Ny*Nz+(Nx-1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Width(ii)*dy))*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj)));                                                                            
end 
end 


%--- i=Nx, j=1 ---;

% =0


%--- i=Nx, 1<j<=Ny ---;

for jj=2:1:Ny
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-2)*Nz+1) -alfa2*Kp1*dQy(Nx)*(-1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1) -alfa2*Kp1*dQy(Nx)*(1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));                                                                            
end 



%---(3.10): - Kp1 (dZ/dy)^j-1/2 0.5 (dV/dz)^j-1 (1/(b dy)) ((H^j-1/2)/H^j) ---;


%---  1<i<Nx, j=1 ---;

% =0


%---  1<i<Nx, 1<j<=Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1) -alfa2*Kp1*((dZy(ii,jj-1,1)+dZy(ii,jj,1))/2)*0.5*(-3/(2*dz))*(0.5/(Width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Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+2) -alfa2*Kp2*((dZz(Nx,jj-1)+dZz(Nx,jj))/2)*0.5*(4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3) -alfa2*Kp2*((dZz(Nx,jj-1)+dZz(Nx,jj))/2)*0.5*(-1/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
end 





%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  dQ/dy (dU/dQ)^j+1/2 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) -----;


%---  1<i<Nx, 1<=j<Ny ---;

for ii=2:1:Nx-1 
for jj=1:1:Ny-1
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1) +alfa2*dQy(ii)*(-1/dy)*((dQx(ii,jj+1)+dQx(ii,jj))/2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1/dy)*(0.5/(Width(ii)*dy))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)     +alfa2*Kp1*dQy(ii)*(1/dy)*(0.5/(Width(ii)*dy))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj)));                                                                            
end 
end 


%---  1<i<Nx, j=Ny ---;

% =0


%--- i=Nx, 1<=j<Ny ---;

for jj=1:1:Ny-1
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1) +alfa2*Kp1*dQy(Nx)*(-1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+1)=    MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+1)     +alfa2*Kp1*dQy(Nx)*(1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));                                                                            
end 


%--- i=Nx, j=Ny ---;

% =0



%---(4.10):  Kp1 (dZ/dy)^j+1/2 0.5 (dV/dz)^j+1 (1/(b dy)) ((H^j+1/2)/H^j) ---;


%---  1<i<Nx, 1<=j<Ny ---;

for ii=2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HIC(Nx,jj))); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+2)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+2) +alfa2*Kp2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3) +alfa2*Kp2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(-1/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 


%--- i=Nx, j=Ny ---;

% =0



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dQ/dy)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;


%---  1<i<=Nx, j=1 ---;

for ii=2:1:Nx 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-2)*Ny*Nz+1)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+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++++++++++++++ KpE I(6)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dQ/dy)^i+1/2 0.5 (dU/dQ)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+1)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+1)      +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(-3/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+Nz+1)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+Nz+1)   +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(4/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+2*Nz+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+2*Nz+1) +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(-1/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx);
end 


%---  1<i<Nx, 1<j<Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,ii*Ny*Nz+(jj-2)*Nz+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1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)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.25; 
end  


%--- i=Nx, j=Ny ---; 

MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.125; 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++ The third equation ++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dZ/dz (dU/dz)^3/2 (dZ/dx)^3/2 (1/dz) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1) +alfa2*dZz(ii,1)*(-1/dz)*((dZx(ii,1,2)+dZx(ii,1,1))/2)*(0.5/dz); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+2)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+2) +alfa2*dZz(ii,1)*(1/dz)*((dZx(ii,1,2)+dZx(ii,1,1))/2)*(0.5/d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+(jj-1)*Nz+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1) +alfa2*((dZy(Nx,jj+1,1)+dZy(Nx,jj,1))/2)*0.5*(-3/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+2)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+2) +alfa2*((dZy(Nx,jj+1,1)+dZy(Nx,jj,1))/2)*0.5*(4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+3) +alfa2*((dZy(Nx,jj+1,1)+dZy(Nx,jj,1))/2)*0.5*(-1/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 


%--- i=Nx, j=Ny ---;

% =0



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx b H d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1))/2)*0.5*(-1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dZ/dz)^i+1/2 0.5 (dU/dz)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+1) +alfa2*((dZz(ii+1,1)+dZz(ii,1))/2)*0.5*(-3/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+2)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+2) +alfa2*((dZz(ii+1,1)+dZz(ii,1))/2)*0.5*(4/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+3)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,ii*Ny*Nz+3) +alfa2*((dZz(ii+1,1)+dZz(ii,1))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)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*Nz+(Nx-1)*Ny*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+1) + alfa2*KpE*dens*Freq^2*0.125; 


%--- i=Nx, 1<j<Ny ---; 

for jj=2:1:Ny-1
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.25; 
end  


%--- i=Nx, j=Ny ---; 

MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+1) + alfa2*KpE*dens*Freq^2*0.125; 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++ Basic Boundary Conditions at Ice Shelf Surface +++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ The first equation (basic equation #1) +++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++ - KpE Fxx dHs/dx ++++++++++++++++++++++;

%----------------- - Kp1 dU/dx dHs/dx -------------------;

for ii=2:1:Nx-1
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-2)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-2)*Ny*Nz+(jj-1)*Nz+1)-alfa1*Kp1*(-1/(2*dx))*dHsx(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,ii*Ny*Nz+(jj-1)*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,ii*Ny*Nz+(jj-1)*Nz+1)-     alfa1*Kp1*(1/(2*dx))*dHsx(ii,jj);                                                          
end 
end

%---- i=Nx ----;

for jj=1:1:Ny
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-3)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-3)*Ny*Nz+(jj-1)*Nz+1)- alfa1*Kp1*(1/(2*dx))*dHsx(Nx,jj);    
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-2)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-2)*Ny*Nz+(jj-1)*Nz+1)-alfa1*Kp1*(-4/(2*dx))*dHsx(Nx,jj);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-1)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,(Nx-1)*Ny*Nz+(jj-1)*Nz+1)- alfa1*Kp1*(3/(2*dx))*dHsx(Nx,jj);                                                          
end 


%-------------- - Kp1 dQ/dx dU/dQ dHs/dx ---------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)=     MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)-     alfa1*Kp1*(-3/(2*dy))*dQx(ii,1)*dHsx(ii,1);     
MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+Nz+1)=  MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+Nz+1)-   alfa1*Kp1*(4/(2*dy))*dQx(ii,1)*dHsx(ii,1);            
MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+2*Nz+1)=MB((ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+2*Nz+1)-alfa1*Kp1*(-1/(2*dy))*dQx(ii,1)*dHsx(ii,1);                                                          
end


%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-2)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-2)*Nz+1)-alfa1*Kp1*(-1/(2*dy))*dQx(ii,jj)*dHsx(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+jj*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+jj*Nz+1)-     alfa1*Kp1*(1/(2*dy))*dQx(ii,jj)*dHsx(ii,jj);                                                          
end 
end


%----- j=Ny -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-3)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-3)*Nz+1)- alfa1*Kp1*(1/(2*dy))*dQx(ii,Ny)*dHsx(ii,Ny);     
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-2)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-2)*Nz+1)-alfa1*Kp1*(-4/(2*dy))*dQx(ii,Ny)*dHsx(ii,Ny);            
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1)- alfa1*Kp1*(3/(2*dy))*dQx(ii,Ny)*dHsx(ii,Ny);                                                          
end


%-------------- - Kp1 dZ/dx dU/dz dHs/dx ----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB((ii-1)*Ny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ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1)-alfa1*Kp2*(-1/(2*dy))*dQy(ii)*dHsx(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)-     alfa1*Kp2*(1/(2*dy))*dQy(ii)*dHsx(ii,jj);                                                          
end 
end

%----- j=Ny -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+1)- alfa1*Kp2*(1/(2*dy))*dQy(ii)*dHsx(ii,Ny);    
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+1)-alfa1*Kp2*(-4/(2*dy))*dQy(ii)*dHsx(ii,Ny);            
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+1)- alfa1*Kp2*(3/(2*dy))*dQy(ii)*dHsx(ii,Ny);                                                          
end


%----------- - Kp2 dZ/dy dV/dz dHs/dx --------------;

for ii=2:1:Nx
for jj=1:1:Ny
M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-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+3)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+3)-alfa1*Kp2*(-1/(2*dz))*dZz(ii,jj)*dHsx(ii,jj);
end 
end


%++++++++++++++++++ - KpE Fxy dHs/dy ++++++++++++++++++++++;


%---------------- - dQ/dy dU/dQ dHs/dy ----------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+1)=     MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+1)-     alfa1*(-3/(2*dy))*dQy(ii)*dHsy(ii,1);     
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+Nz+1)=  MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+Nz+1)-   alfa1*(4/(2*dy))*dQy(ii)*dHsy(ii,1);            
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+2*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+2*Nz+1)-alfa1*(-1/(2*dy))*dQy(ii)*dHsy(ii,1);                                                          
end

%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-2)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-2)*Nz+1)-alfa1*(-1/(2*dy))*dQy(ii)*dHsy(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+jj*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+jj*Nz+1)-     alfa1*(1/(2*dy))*dQy(ii)*dHsy(ii,jj);                                                          
end 
end

%----- j=Ny -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-3)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-3)*Nz+1)- alfa1*(1/(2*dy))*dQy(ii)*dHsy(ii,Ny);     
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-2)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-2)*Nz+1)-alfa1*(-4/(2*dy))*dQy(ii)*dHsy(ii,Ny);            
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1)- alfa1*(3/(2*dy))*dQy(ii)*dHsy(ii,Ny);                                                          
end


%------------- - dZ/dy dU/dz dHs/dy ----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)-alfa1*(-3/(2*dz))*dZy(ii,jj,1)*dHsy(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+2)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+2)- alfa1*(4/(2*dz))*dZy(ii,jj,1)*dHsy(ii,jj);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+3)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+3)-alfa1*(-1/(2*dz))*dZy(ii,jj,1)*dHsy(ii,jj);
end 
end


%------------------ - dV/dx dHs/dy -----------------;

for ii=2:1:Nx-1
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-2)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-2)*Ny*Nz+(jj-1)*Nz+1)-alfa1*(-1/(2*dx))*dHsy(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+ii*Ny*Nz+(jj-1)*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+ii*Ny*Nz+(jj-1)*Nz+1)-     alfa1*(1/(2*dx))*dHsy(ii,jj);                                                          
end 
end

%---- i=Nx ----;

for jj=1:1:Ny
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+1)- alfa1*(1/(2*dx))*dHsy(Nx,jj);    
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+1)-alfa1*(-4/(2*dx))*dHsy(Nx,jj);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1)- alfa1*(3/(2*dx))*dHsy(Nx,jj);                                                          
end 


%-------------- - dQ/dx dV/dQ dHs/dy ---------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+1)=     MB((ii-1)*Ny*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+1)-     alfa1*(-3/(2*dy))*dQx(ii,1)*dHsy(ii,1);    
MB((ii-1)*Ny*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+1)=  MB((ii-1)*Ny*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+1)-   alfa1*(4/(2*dy))*dQx(ii,1)*dHsy(ii,1);            
MB((ii-1)*Ny*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+1)=MB((ii-1)*Ny*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+1)-alfa1*(-1/(2*dy))*dQx(ii,1)*dHsy(ii,1);                                                          
end

%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1)-alfa1*(-1/(2*dy))*dQx(ii,jj)*dHsy(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)-     alfa1*(1/(2*dy))*dQx(ii,jj)*dHsy(ii,jj);                                                          
end 
end

%----- j=Ny -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*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ii,jj);
end 
end



%+++++++++++++++++++++++ KpE Fxz ++++++++++++++++++++++;

%------------------ dZ/dz dU/dz -------------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)+alfa1*(-3/(2*dz))*dZz(ii,jj);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+2)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+2)+ alfa1*(4/(2*dz))*dZz(ii,jj);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+3)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+3)+alfa1*(-1/(2*dz))*dZz(ii,jj);                                                          
end 
end

%-------------------- dW/dx ------------------;

for ii=2:1:Nx-1
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-2)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-2)*Ny*Nz+(jj-1)*Nz+1)+alfa1*(-1/(2*dx));            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+ii*Ny*Nz+(jj-1)*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+ii*Ny*Nz+(jj-1)*Nz+1)+     alfa1*(1/(2*dx));                                                          
end 
end

%---- i=Nx ----;

for jj=1:1:Ny
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+1)+ alfa1*(1/(2*dx));    
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+1)+alfa1*(-4/(2*dx));            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+1)+ alfa1*(3/(2*dx));                                                          
end 


%---------------- dQ/dx dW/dQ ------------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1)=     MB((ii-1)*Ny*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1)+     alfa1*(-3/(2*dy))*dQx(ii,1);    
MB((ii-1)*Ny*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+1)=  MB((ii-1)*Ny*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+1)+   alfa1*(4/(2*dy))*dQx(ii,1);            
MB((ii-1)*Ny*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+1)=MB((ii-1)*Ny*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+1)+alfa1*(-1/(2*dy))*dQx(ii,1);                                                          
end

%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+1)+alfa1*(-1/(2*dy))*dQx(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+1)+     alfa1*(1/(2*dy))*dQx(ii,jj);                                                          
end 
end

%----- j=Ny -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-3)*Nz+1)+ alfa1*(1/(2*dy))*dQx(ii,Ny);    
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-2)*Nz+1)+alfa1*(-4/(2*dy))*dQx(ii,Ny);            
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+1)+ alfa1*(3/(2*dy))*dQx(ii,Ny);                                                          
end


%----------------- dZ/dx dW/dz ------------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1)+alfa1*(-3/(2*dz))*dZx(ii,jj,1);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+2)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+2)+ alfa1*(4/(2*dz))*dZx(ii,jj,1);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+3)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+1,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+3)+alfa1*(-1/(2*dz))*dZx(ii,jj,1);                                                          
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++ The second equation (basic equation #2) +++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++ - KpE Fyx dHs/dx ++++++++++++++++++++++++;

%-------------------- - dQ/dy dU/dQ dHs/dx -----------------------;

%----- j=1 -----;

for ii=2:1:Nx
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+1)-     alfa1*(-3/(2*dy))*dQy(ii)*dHsx(ii,1);    
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+Nz+1)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+Nz+1)-   alfa1*(4/(2*dy))*dQy(ii)*dHsx(ii,1); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+2*Nz+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+1,(ii-1)*Ny*Nz+2*Nz+1)-alfa1*(-1/(2*dy))*dQy(ii)*dHsx(ii,1); 
end

%---- 1<j<Ny ----;

for ii=2:1:Nx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2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-2)*Nz+1)+alfa1*Kp2*(-4/(2*dy))*dQx(ii,Ny);            
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+1,(ii-1)*Ny*Nz+(Ny-1)*Nz+1)+ alfa1*Kp2*(3/(2*dy))*dQx(ii,Ny);                                                          
end


%------------------ Kp2 dZ/dx dU/dz -----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+1)+alfa1*Kp2*(-3/(2*dz))*dZx(ii,jj,1);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+2)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+2)+ alfa1*Kp2*(4/(2*dz))*dZx(ii,jj,1);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+3)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,(ii-1)*Ny*Nz+(jj-1)*Nz+3)+alfa1*Kp2*(-1/(2*dz))*dZx(ii,jj,1);                                                          
end 
end


%-----------------  Kp2 dQ/dy dV/dQ ------------------;

%----- j=1 -----;

for ii=2:1:Nx
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+1)=     MB(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(ii-1)*Ny*Nz+(jj-1)*Nz+3)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+1,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+3)+alfa1*Kp2*(-1/(2*dz))*dZy(ii,jj,1);                                                          
end 
end






%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++ Ice-shelf base (k=Nz) +++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++++ The first equation ++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - Kp1 0.5 (dU/dx)^Nz-1 (dZ/dx)^Nz-1/2  (1/dz)  ----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB((ii-1)*Ny*Nz+Nz,(ii-2)*Ny*Nz+Nz-1)= -alfa2*Kp1*0.5*(-1/(2*dx))*((dZx(ii,1,Nz-1)+dZx(ii,1,Nz))/2)*(0.5/dz); 
MB((ii-1)*Ny*Nz+Nz,ii*Ny*Nz+Nz-1)=     -alfa2*Kp1*0.5*(1/(2*dx))*((dZx(ii,1,Nz-1)+dZx(ii,1,Nz))/2)*(0.5/dz); 
end 
 

%---  1<i<Nx, 1<j<Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-2)*Ny*Nz+(jj-1)*Nz+Nz-1)= -alfa2*Kp1*0.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(HIC(Nx,Ny)*dz)); 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  - KpE P'(dZ/dx)^Nz H b dx dy / (b H dx dy dz) ++++;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB((ii-1)*Ny*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+1)=MB((ii-1)*Ny*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+1) - alfa2*KpE*dZx(ii,1,Nz)*(0.5/dz); 
end 


%---  1<i<Nx, 1<j<Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj) - alfa2*KpE*dZx(ii,jj,Nz)*(1/dz); 
end 
end 


%---  1<i<Nx, j=Ny ---;

for ii=2:1:Nx-1 
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny) - alfa2*KpE*dZx(ii,Ny,Nz)*(0.5/dz); 
end 



%--- i=Nx, j=1 ---; 

MB((Nx-1)*Ny*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+1)=MB((Nx-1)*Ny*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+1) - alfa2*KpE*dZx(Nx,1,Nz)*(0.25/dz); 

%--- i=Nx, 1<j<Ny ---;

for jj=2:1:Ny-1
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+jj)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+jj) - alfa2*KpE*dZx(Nx,jj,Nz)*(0.5/dz); 
end 

%--- i=Nx, j=Ny ---; 

MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+Ny)=MB((Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+Ny) - alfa2*KpE*dZx(Nx,Ny,Nz)*(0.25/dz);





%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - Kp1 0.5 (dU/dx)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;


%---  1<i<Nx, j=1 ---;

% =0


%---  1<i<Nx, 1<j<=Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-2)*Ny*Nz+(jj-2)*Nz+Nz)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-2)*Ny*Nz+(jj-2)*Nz+Nz) -alfa2*Kp1*0.5*(-1/(2*dx))*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB((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Nz-2)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-2) -alfa2*((dZx(Nx,jj-1,Nz)+dZx(Nx,jj,Nz))/2)*0.5*(1/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-1) -alfa2*((dZx(Nx,jj-1,Nz)+dZx(Nx,jj,Nz))/2)*0.5*(-4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=  MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)   -alfa2*((dZx(Nx,jj-1,Nz)+dZx(Nx,jj,Nz))/2)*0.5*(3/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj-1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  Kp1 0.5 (dU/dx)^j+1 (dQ/dx)^j+1/2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Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-2)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-2) +alfa2*((dZx(Nx,jj+1,Nz)+dZx(Nx,jj,Nz))/2)*0.5*(1/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-1)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-1) +alfa2*((dZx(Nx,jj+1,Nz)+dZx(Nx,jj,Nz))/2)*0.5*(-4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=  MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)   +alfa2*((dZx(Nx,jj+1,Nz)+dZx(Nx,jj,Nz))/2)*0.5*(3/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 


%--- i=Nx, j=Ny ---;

% =0




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx H b dy dz / (b H dx dy dz) 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+(Ny-1)*Nz+Nz-1)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz-1) -alfa2*Kp2*((dZz(ii-1,Ny)+dZz(ii,Ny))/2)*0.5*(-4/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)=  MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)   -alfa2*Kp2*((dZz(ii-1,Ny)+dZz(ii,Ny))/2)*0.5*(3/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  Kp1 (dU/dx)^i+1/2 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB((ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz)=MB((ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz) +alfa2*Kp1*(-1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
MB((ii-1)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ny*Nz+(Ny-1)*Nz+Nz) + alfa2*KpE*dens*Freq^2*0.125; 




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++++++ The second equation +++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dQ/dy 0.5 (dU/dQ)^Nz-1 (dZ/dx)^Nz-1/2 (1/dz) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz-1)=      -alfa2*dQy(ii)*0.5*(-3/(2*dy))*((dZx(ii,1,Nz-1)+dZx(ii,1,Nz))/2)*(0.5/dz); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz+Nz-1)=   -alfa2*dQy(ii)*0.5*(4/(2*dy))*((dZx(ii,1,Nz-1)+dZx(ii,1,Nz))/2)*(0.5/dz);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+2*Nz+Nz-1)= -alfa2*dQy(ii)*0.5*(-1/(2*dy))*((dZx(ii,1,Nz-1)+dZx(ii,1,Nz))/2)*(0.5/dz);
end 


%---  1<i<Nx, 1<j<Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz-1)= -alfa2*dQy(ii)*0.5*(-1/(2*dy))*((dZ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- i=Nx, 1<j<Ny ---;

for jj=2:1:Ny-1
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+jj)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+jj) - alfa2*KpE*dZy(Nx,jj,Nz)*(0.5/dz); 
end 

%--- i=Nx, j=Ny ---; 

MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+Ny)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+Ny) - alfa2*KpE*dZy(Nx,Ny,Nz)*(0.25/dz); 





%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - dQ/dy (dU/dQ)^j-1/2 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) -----;


%---  1<i<Nx, j=1 ---;

% =0


%---  1<i<Nx, 1<j<=Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz) -alfa2*dQy(ii)*(-1/dy)*((dQx(ii,jj-1)+dQx(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++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  dQ/dy (dU/dQ)^j+1/2 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) -----;


%---  1<i<Nx, 1<=j<Ny ---;

for ii=2:1:Nx-1 
for jj=1:1:Ny-1
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz) +alfa2*dQy(ii)*(-1/dy)*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz)     +alfa2*dQy(ii)*(1/dy)*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 


%---  1<i<Nx, j=Ny ---;

% =0


%--- i=Nx, 1<=j<Ny ---;

for jj=1:1:Ny-1
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz) +alfa2*dQy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y))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+Nz)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+Nz)     +alfa2*Kp1*dQy(ii)*(1/dy)*(0.5/(Width(ii)*dy))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj)));                                                                            
end 
end 


%---  1<i<Nx, j=Ny ---;

% =0


%--- i=Nx, 1<=j<Ny ---;

for jj=1:1:Ny-1
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz) +alfa2*Kp1*dQy(Nx)*(-1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+Nz)=    MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+Nz)     +alfa2*Kp1*dQy(Nx)*(1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));                                                                            
end 


%--- i=Nx, j=Ny ---;

% =0



%---(4.10):  Kp1 (dZ/dy)^j+1/2 0.5 (dV/dz)^j+1 (1/(b dy)) ((H^j+1/2)/H^j) ---;


%---  1<i<Nx, 1<=j<Ny ---;

for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z+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)   +alfa2*Kp2*((dZz(Nx,jj+1)+dZz(Nx,jj))/2)*0.5*(3/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 


%--- i=Nx, j=Ny ---;

% =0



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dQ/dy)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;


%---  1<i<=Nx, j=1 ---;

for ii=2:1:Nx 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-2)*Ny*Nz+Nz)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-2)*Ny*Nz+Nz)      -alfa2*((dQy(ii-1)+dQy(ii))/2)*0.5*(-3/(2*dy))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-2)*Ny*Nz+Nz+Nz)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-2)*Ny*Nz+Nz+Nz)   -alfa2*((dQy(ii-1)+dQy(ii))/2)*0.5*(4/(2*dy))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-2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/dx);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)   -alfa2*((dZx(ii-1,Ny,Nz)+dZx(ii,Ny,Nz))/2)*0.5*(3/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dQ/dy)^i+1/2 0.5 (dU/dQ)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,ii*Ny*Nz+Nz)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,ii*Ny*Nz+Nz)      +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(-3/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,1)+HIC(ii,1))/(2*HIC(ii,1)))*(0.25/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,ii*Ny*Nz+Nz+Nz)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,ii*Ny*Nz+Nz+Nz)   +alfa2*((dQy(ii+1)+dQy(ii))/2)*0.5*(4/(2*dy))*((Width(ii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,Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz) + alfa2*KpE*dens*Freq^2*0.125; 

%--- i=Nx, 1<j<Ny ---; 

for jj=2:1:Ny-1
MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz) + alfa2*KpE*dens*Freq^2*0.25; 
end  

%--- i=Nx, j=Ny ---; 

MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz)=MB(Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz) + alfa2*KpE*dens*Freq^2*0.125; 




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++ The third equation +++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dZ/dz (dU/dz)^Nz-1/2 (dZ/dx)^Nz-1/2 (1/dz) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(2*Nx*Ny*Nz+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z+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+Ny)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+Ny) + alfa2*KpE*(0.25/(HIC(Nx,Ny)*dz)); 





%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - (dZ/dz)^j-1/2 0.5 (dU/dz)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;


%---  1<i<Nx, j=1 ---;

% =0


%---  1<i<Nx, 1<j<=Ny ---;

for ii=2:1:Nx-1 
for jj=2:1:Ny
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz-2)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz-2) -alfa2*((dZz(ii,jj-1)+dZz(ii,jj))/2)*0.5*(1/(2*dz))*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz-1) -alfa2*((dZz(ii,jj-1)+dZz(ii,jj))/2)*0.5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 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1): - (dZ/dz)^j+1/2 0.5 (dU/dz)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;


%---  1<i<Nx, 1<=j<Ny ---;

for ii=2:1:Nx-1 
for jj=1:1:Ny-1
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz-2)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz-2) +alfa2*((dZz(ii,jj+1)+dZz(ii,jj))/2)*0.5*(1/(2*dz))*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz-1) +alfa2*((dZz(ii,jj+1)+dZz(ii,jj))/2)*0.5*(-4/(2*dz))*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(0.5/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj)));
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)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ny*Nz+jj*Nz+Nz)     +alfa2*dQy(ii)*(1/dy)*(0.5/(Width(ii)*dy))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj)));                                                                            
end 
end 


%---  1<i<Nx, j=Ny ---;

% =0


%--- i=Nx, 1<=j<Ny ---;

for jj=1:1:Ny-1
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz) +alfa2*dQy(Nx)*(-1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj))); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+Nz)=    MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+jj*Nz+Nz)     +alfa2*dQy(Nx)*(1/dy)*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));                                                                            
end 


%--- i=Nx, j=Ny ---;

% =0



%---(4.11): - (dZ/dy)^j+1/2 0.5 (dW/dz)^j+1 (1/(b dy)) ((H^j+1/2)/H^j) ----;


%---  1<i<Nx, 1<=j<Ny ---;

for ii=2:1:Nx-1 
for jj=1:1:Ny-1
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+Nz-2)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*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Nx,jj))/(2*HIC(Nx,jj))); 
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-1)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz-1) +alfa2*((dZy(Nx,jj+1,Nz)+dZy(Nx,jj,Nz))/2)*0.5*(-4/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=  MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)   +alfa2*((dZy(Nx,jj+1,Nz)+dZy(Nx,jj,Nz))/2)*0.5*(3/(2*dz))*(0.25/(Width(Nx)*dy))*((HIC(Nx,jj+1)+HIC(Nx,jj))/(2*HIC(Nx,jj)));
end 


%--- i=Nx, j=Ny ---;

% =0




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dZ/dz)^i-1/2 0.5 (dU/dz)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;


%---  1<i<=Nx, j=1 ---;

for ii=2:1:Nx 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz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(Ny-1)*Nz+Nz-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz-1) -alfa2*((dZx(ii-1,Ny,Nz)+dZx(ii,Ny,Nz))/2)*0.5*(-4/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)   -alfa2*((dZx(ii-1,Ny,Nz)+dZx(ii,Ny,Nz))/2)*0.5*(3/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,Ny)+HIC(ii,Ny))/(2*HIC(ii,Ny)))*(0.25/dx);
end 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dZ/dz)^i+1/2 0.5 (dU/dz)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;


%---  1<i<Nx, j=1 ---;

for ii=2:1:Nx-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,ii*Ny*Nz+Nz-2)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,ii*Ny*Nz+Nz-2) +alfa2*((dZz(ii+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nz+Nz) + alfa2*KpE*dens*Freq^2*0.25; 
end  



%--- i=Nx, j=1 ---; 

MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+Nz) + alfa2*KpE*dens*Freq^2*0.125; 

%--- i=Nx, 1<j<Ny ---; 

for jj=2:1:Ny-1
MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz) + alfa2*KpE*dens*Freq^2*0.25; 
end  

%--- i=Nx, j=Ny ---; 

MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz)=MB(2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(Ny-1)*Nz+Nz) + alfa2*KpE*dens*Freq^2*0.125; 




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++ Basic Boundary Conditions at Ice Shelf Base ++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ The first equation (basic equation #1) +++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

 
%++++++++++++++++++++++ KpE Fxx dHb/dx ++++++++++++++++++++++;

%--------------------- Kp1 dU/dx dHb/dx ---------------------;

for ii=2:1:Nx-1
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-2)*Ny*Nz+(jj-1)*Nz+Nz)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-2)*Ny*Nz+(jj-1)*Nz+Nz)+alfa1*Kp1*(-1/(2*dx))*dHbx(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,ii*Ny*Nz+(jj-1)*Nz+Nz)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,ii*Ny*Nz+(jj-1)*Nz+Nz)+     alfa1*Kp1*(1/(2*dx))*dHbx(ii,jj);                                                          
end 
end

%---- i=Nx ----;

for jj=1:1:Ny
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-3)*Ny*Nz+(jj-1)*Nz+Nz)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-3)*Ny*Nz+(jj-1)*Nz+Nz)+ alfa1*Kp1*(1/(2*dx))*dHbx(Nx,jj);       
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-2)*Ny*Nz+(jj-1)*Nz+Nz)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-2)*Ny*Nz+(jj-1)*Nz+Nz)+alfa1*Kp1*(-4/(2*dx))*dHbx(Nx,jj);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)+ alfa1*Kp1*(3/(2*dx))*dHbx(Nx,jj);                                                          
end 


%---------------- Kp1 dQ/dx dU/dQ dHb/dx ----------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz)=     MB((ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz)+     alfa1*Kp1*(-3/(2*dy))*dQx(ii,1)*dHbx(ii,1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ny)*dHbx(ii,Ny);            
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)+ alfa1*Kp1*(3/(2*dy))*dQx(ii,Ny)*dHbx(ii,Ny);                                                          
end


%--------------- Kp1 dZ/dx dU/dz dHb/dx ----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-2)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-2)+ alfa1*Kp1*(1/(2*dz))*dZx(ii,jj,Nz)*dHbx(ii,jj);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)+alfa1*Kp1*(-4/(2*dz))*dZx(ii,jj,Nz)*dHbx(ii,jj);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)=  MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)+   alfa1*Kp1*(3/(2*dz))*dZx(ii,jj,Nz)*dHbx(ii,jj);                                                          
end 
end


%--------------- Kp2 dQ/dy dV/dQ dHb/dx -----------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz)=     MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz)+     alfa1*Kp2*(-3/(2*dy))*dQy(ii)*dHbx(ii,1);     
MB((ii-1)*Ny*Nz+Nz,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Nz+Nz,(ii-1)*Ny*Nz+2*Nz+Nz)+alfa1*(-1/(2*dy))*dQy(ii)*dHby(ii,1);                                                          
end

%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz)+alfa1*(-1/(2*dy))*dQy(ii)*dHby(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz)+     alfa1*(1/(2*dy))*dQy(ii)*dHby(ii,jj);                                                          
end 
end

%----- j=Ny -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-3)*Nz+Nz)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-3)*Nz+Nz)+ alfa1*(1/(2*dy))*dQy(ii)*dHby(ii,Ny);
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-2)*Nz+Nz)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-2)*Nz+Nz)+alfa1*(-4/(2*dy))*dQy(ii)*dHby(ii,Ny);            
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)=MB((ii-1)*Ny*Nz+(Ny-1)*Nz+Nz,(ii-1)*Ny*Nz+(Ny-1)*Nz+Nz)+ alfa1*(3/(2*dy))*dQy(ii)*dHby(ii,Ny);                                                          
end


%------------------- dZ/dy dU/dz dHb/dy ------------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-2)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-2)+ alfa1*(1/(2*dz))*dZy(ii,jj,Nz)*dHby(ii,jj);
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)+alfa1*(-4/(2*dz))*dZy(ii,jj,Nz)*dHby(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)=  MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)+   alfa1*(3/(2*dz))*dZy(ii,jj,Nz)*dHby(ii,jj);                                                          
end 
end


%--------------------- dV/dx dHb/dy ---------------------;

for ii=2:1:Nx-1
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-2)*Ny*Nz+(jj-1)*Nz+Nz)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-2)*Ny*Nz+(jj-1)*Nz+Nz)+alfa1*(-1/(2*dx))*dHby(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+ii*Ny*Nz+(jj-1)*Nz+Nz)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+ii*Ny*Nz+(jj-1)*Nz+Nz)+     alfa1*(1/(2*dx))*dHby(ii,jj);                                                          
end 
end

%---- i=Nx ----;

for jj=1:1:Ny
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+Nz)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-3)*Ny*Nz+(jj-1)*Nz+Nz)+ alfa1*(1/(2*dx))*dHby(Nx,jj);    
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+Nz)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-2)*Ny*Nz+(jj-1)*Nz+Nz)+alfa1*(-4/(2*dx))*dHby(Nx,jj);            
MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)=MB((Nx-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)+ alfa1*(3/(2*dx))*dHby(Nx,jj);                                                          
end 


%------------ dQ/dx dV/dQ dHb/dy ---------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz)=     MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz)+     alfa1*(-3/(2*dy))*dQx(ii,1)*dHby(ii,1);    
MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+Nz)=  MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+Nz)+   alfa1*(4/(2*dy))*dQx(ii,1)*dHby(ii,1);            
MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+Nz)=MB((ii-1)*Ny*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+Nz)+alfa1*(-1/(2*dy))*dQx(ii,1)*dHby(ii,1);                                                          
end

%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1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Nz+Nz,2*Nx*Ny*Nz+(Nx-1)*Ny*Nz+(jj-1)*Nz+Nz)- alfa1*(3/(2*dx));                                                          
end 


%------------------- - dQ/dx dW/dQ ---------------------;

%----- j=1 -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz)=     MB((ii-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz)-     alfa1*(-3/(2*dy))*dQx(ii,1);    
MB((ii-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+Nz)=  MB((ii-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz+Nz)-   alfa1*(4/(2*dy))*dQx(ii,1);            
MB((ii-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+Nz)=MB((ii-1)*Ny*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+2*Nz+Nz)-alfa1*(-1/(2*dy))*dQx(ii,1);                                                          
end

%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1:Ny-1
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+Nz)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+Nz)-alfa1*(-1/(2*dy))*dQx(ii,jj);            
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+Nz)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+Nz)-     alfa1*(1/(2*dy))*dQx(ii,jj);                                                          
end 
end

%----- j=Ny -----;

for ii=2:1:Nx
MB((ii-1)*Ny*Nz+(Ny-1)*Nz+N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*Nz+Nz)=  MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)-   alfa1*(3/(2*dz))*dZx(ii,jj,Nz);                                                          
end 
end



%-----------------  KpE dHb/dx P' -----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj) + alfa1*KpE*dHbx(ii,jj);                                                          
end 
end




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++ The second equation (basic equation #2) +++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++ KpE Fyx dHs/dx ++++++++++++++++++++++++;

%--------------------- dQ/dy dU/dQ dHb/dx ---------------------;

%----- j=1 -----;

for ii=2:1:Nx
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz)=     MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz)+     alfa1*(-3/(2*dy))*dQy(ii)*dHbx(ii,1);    
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz+Nz)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz+Nz)+   alfa1*(4/(2*dy))*dQy(ii)*dHbx(ii,1); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+2*Nz+Nz)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+2*Nz+Nz)+alfa1*(-1/(2*dy))*dQy(ii)*dHbx(ii,1); 
end

%----- 1<j<Ny -----;

for ii=2:1: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ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-2)- alfa1*(1/(2*dz))*dZy(ii,jj,Nz);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)-alfa1*(-4/(2*dz))*dZy(ii,jj,Nz);
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)=  MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)-   alfa1*(3/(2*dz))*dZy(ii,jj,Nz); 
end 
end


%------------------  KpE dHb/dy P' -----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj) + alfa1*KpE*dHby(ii,jj);                                                          
end 
end




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++ The third equation (basic equation #3) +++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++ KpE Fzx dHb/dx ++++++++++++++++++++;

%------------------ dZ/dz dU/dz dHb/dx -----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(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ny*Nz+(jj-1)*Nz+Nz)- alfa1*Kp2*(3/(2*dx));                                                          
end 


%--------------- - Kp2 dQ/dx dU/dQ ----------------;

%----- j=1 -----;

for ii=2:1:Nx
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz)=     MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz)-     alfa1*Kp2*(-3/(2*dy))*dQx(ii,1);    
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz+Nz)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+Nz+Nz)-   alfa1*Kp2*(4/(2*dy))*dQx(ii,1);            
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+2*Nz+Nz)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+Nz,(ii-1)*Ny*Nz+2*Nz+Nz)-alfa1*Kp2*(-1/(2*dy))*dQx(ii,1);                                                          
end

%----- 1<j<Ny -----;

for ii=2:1:Nx
for jj=2:1:Ny-1
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+(jj-2)*Nz+Nz)-alfa1*Kp2*(-1/(2*dy))*dQx(ii,jj);            
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz)=    MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,(ii-1)*Ny*Nz+jj*Nz+Nz)-     alfa1*Kp2*(1/(2*dy))*dQx(ii,jj);                                                          
end 
end

%----- j=Ny -----;

for ii=2:1:Nx
MB(2*Nx*Ny*Nz+(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x*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-2)- alfa1*Kp2*(1/(2*dz))*dZy(ii,jj,Nz);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz-1)-alfa1*Kp2*(-4/(2*dz))*dZy(ii,jj,Nz);
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)-   alfa1*Kp2*(3/(2*dz))*dZy(ii,jj,Nz);                                                          
end 
end


%------------------ - KpE P' -----------------;

for ii=2:1:Nx
for jj=1:1:Ny
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj) - alfa1*KpE;                                                          
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++ The momentum equations inside the ice shelf +++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++ 1<Ix<Nx; 1<Jy<Ny; 1<Kz<Nz +++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%---------------------- first equation ----------------------;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - Kp1 0.5 (dU/dx)^k-1 (dZ/dx)^k-1/2  (1/dz)  ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk-1)= -alfa12*Kp1*0.5*(-1/(2*dx))*((dZx(ii,jj,kk-1)+dZx(ii,jj,kk))/2)*(1/dz); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk-1)=     -alfa12*Kp1*0.5*(1/(2*dx))*((dZx(ii,jj,kk-1)+dZx(ii,jj,kk))/2)*(1/dz); 
end 
end 
end


%---(1.2): - Kp1 0.5 (dU/dx)^k (dZ/dx)^k-1/2 (1/dz)  ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk)= -alfa12*Kp1*0.5*(-1/(2*dx))*((dZx(ii,jj,kk-1)+dZx(ii,jj,kk))/2)*(1/dz); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk)=     -alfa12*Kp1*0.5*(1/(2*dx))*((dZx(ii,jj,kk-1)+dZx(ii,jj,kk))/2)*(1/dz); 
end 
end 
end



%---(1.3): - Kp1 dQ/dx 0.5 (dU/dQ)^k-1 (dZ/dx)^k-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nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=  MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)+  alfa12*((dZx(ii,jj,kk-1)+dZx(ii,jj,kk))/2)*(1/dz)*(1/(HIC(ii,jj)*dz)); 
end  
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  Kp1 0.5 (dU/dx)^k+1 (dZ/dx)^k+1/2 (1/dz)  ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa12*Kp1*0.5*(-1/(2*dx))*((dZx(ii,jj,kk+1)+dZx(ii,jj,kk))/2)*(1/dz); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk+1)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk+1)     +alfa12*Kp1*0.5*(1/(2*dx))*((dZx(ii,jj,kk+1)+dZx(ii,jj,kk))/2)*(1/dz); 
end 
end 
end



%---(2.2):  Kp1 0.5 (dU/dx)^k (dZ/dx)^k-1/2 (1/dz)  ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-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++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - Kp1 0.5 (dU/dx)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-2)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-2)*Nz+kk) -alfa12*Kp1*0.5*(-1/(2*dx))*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-2)*Nz+kk)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-2)*Nz+kk)     -alfa12*Kp1*0.5*(1/(2*dx))*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end


%---(3.2): - Kp1 0.5 (dU/dx)^j (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk) -alfa12*Kp1*0.5*(-1/(2*dx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ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  Kp1 0.5 (dU/dx)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+jj*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+jj*Nz+kk) +alfa12*Kp1*0.5*(-1/(2*dx))*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+jj*Nz+kk)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+jj*Nz+kk)     +alfa12*Kp1*0.5*(1/(2*dx))*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end



%---(4.2):  Kp1 0.5 (dU/dx)^j (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*N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++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fxx H b dy dz / (b H dx dy dz) ++++;


%---(5.1): - Kp1 (dU/dx)^i-1/2 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk) -alfa12*Kp1*(-1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk) -alfa12*Kp1*(1/dx)*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end



%---(5.2): - Kp1 (dQ/dx)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-2)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-2)*Nz+kk)-alfa12*Kp1*((dQx(ii-1,jj)+dQx(ii,jj))/2)*0.5*(-1/(2*dy))*((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Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa12*Kp2*((dZz(ii-1,jj)+dZz(ii,jj))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)x / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fxx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  Kp1 (dU/dx)^i+1/2 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk) +alfa12*Kp1*(-1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk)=    MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk)     +alfa12*Kp1*(1/dx)*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end



%---(6.2):  Kp1 (dQ/dx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Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk-1) +alfa12*Kp2*((dZz(ii+1,jj)+dZz(ii,jj))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa12*Kp2*((dZz(ii+1,jj)+dZz(ii,jj))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ + KpE dens Freq^2 U ++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=MB((ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk) + alfa12*KpE*dens*Freq^2; 
end  
end 
end





%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%------------------------ second equation ------------------------;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++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ii,jj,kk-1)+dZy(ii,jj,kk))/2)*(1/dz)*(1/(HIC(ii,jj)*dz)); 
end  
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dZ/dx)^k+1/2 H b dx dy / (b H dx dy dz) ++++;


%---(2.1):  dQ/dy 0.5 (dU/dQ)^k+1 (dZ/dx)^k+1/2 (1/dz) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-2)*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-2)*Nz+kk+1) +alfa12*dQy(ii)*0.5*(-1/(2*dy))*((dZx(ii,jj,kk+1)+dZx(ii,jj,kk))/2)*(1/dz); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk+1)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk+1)     +alfa12*dQy(ii)*0.5*(1/(2*dy))*((dZx(ii,jj,kk+1)+dZx(ii,jj,kk))/2)*(1/dz); 
end 
end 
end



%---(2.2):  dQ/dy 0.5 (dU/dQ)^k (dZ/dx)^k-1/2 (1/dz) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1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Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+kk+1)+alfa12*Kp1*dQy(ii)*0.5*(-1/(2*dy))*((dZy(ii,jj,kk+1)+dZy(ii,jj,kk))/2)*(1/dz); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+kk+1)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+kk+1)    +alfa12*Kp1*dQy(ii)*0.5*(1/(2*dy))*((dZy(ii,jj,kk+1)+dZy(ii,jj,kk))/2)*(1/dz);                                                                            
end 
end 
end



%---(2.10):  Kp1 dQ/dy 0.5 (dV/dQ)^k (dZ/dy)^k+1/2 (1/dz) ---------;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-2)*Nz+kk)+alfa12*Kp1*dQy(ii)*0.5*(-1/(2*dy))*((dZy(ii,jj,kk+1)+dZy(ii,jj,kk))/2)*(1/dz); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+kk)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+kk)    +alfa12*Kp1*dQy(ii)*0.5*(1/(2*dy))*((dZy(ii,jj,kk+1)+dZy(ii,jj,kk))/2)*(1/dz);                                                                            
end 
end 
end



%---(2.11):  Kp1 (dZ/dy)^k+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kk+1) -alfa12*((dZy(ii,jj,kk+1)+dZy(ii,jj,kk))/2)*(1/dz)*(1/(HIC(ii,jj)*dz)); 
end  
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - dQ/dy (dU/dQ)^j-1/2 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-2)*Nz+kk) -alfa12*dQy(ii)*(-1/dy)*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk) -alfa12*dQy(ii)*(1/dy)*((dQx(ii,jj-1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj-1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end



%---(3.2): - (dZ/dy)^j-1/2 0.5 (dU/dz)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for k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) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  dQ/dy (dU/dQ)^j+1/2 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-1)*Nz+kk) +alfa12*dQy(ii)*(-1/dy)*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk)     +alfa12*dQy(ii)*(1/dy)*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end



%---(4.2):  (dZ/dy)^j+1/2 0.5 (dU/dz)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*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end 
end



%---(4.18):  Kp2 (dZ/dz)^j+1/2 0.5 (dW/dz)^j (1/(b dy)) ((H^j+1/2)/H^j) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk-1) +alfa12*Kp2*((dZz(ii,jj+1)+dZz(ii,jj))/2)*0.5*(-1/(2*dz))*(1/(Width(ii)*dy))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa12*Kp2*((dZz(ii,jj+1)+dZz(ii,jj))/2)*0.5*(1/(2*dz))*(1/(Width(ii)*dy))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dQ/dy)^i-1/2 0.5 (dU/dQ)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=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++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)y / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fyx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dQ/dy)^i+1/2 0.5 (dU/dQ)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-2)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-2)*Nz+kk) +alfa12*((dQy(ii+1)+dQy(ii))/2)*0.5*(-1/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+jj*Nz+kk)=    MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+jj*Nz+kk)     +alfa12*((dQy(ii+1)+dQy(ii))/2)*0.5*(1/(2*dy))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end



%---(6.2):  (dQ/dy)^i+1/2 0.5 (dU/dQ)^i (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+(jj-2)*Nz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Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa12*((dZx(ii+1,jj,kk)+dZx(ii,jj,kk))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end

    


%++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ + KpE dens Freq^2 V ++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk) + alfa12*KpE*dens*Freq^2; 
end  
end 
end




%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%------------------------ third equation -------------------------;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (1) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(1)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dZ/dx)^k-1/2 H b dx dy / (b H dx dy dz) ++++;


%---(1.1): - dZ/dz (dU/dz)^k-1/2 (dZ/dx)^k-1/2 (1/dz) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*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Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+kk)=    MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+jj*Nz+kk)     +alfa12*Kp2*dQy(ii)*0.5*(1/(2*dy))*(1/(HIC(ii,jj)*dz)); 
end 
end 
end



%---(1.19):  Kp2 (dZ/dy)^k-1/2 (dV/dz)^k-1/2 (1/(H dz)) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk-1) +alfa12*Kp2*((dZy(ii,jj,kk-1)+dZy(ii,jj,kk))/2)*(-1/dz)*(1/(HIC(ii,jj)*dz)); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)   +alfa12*Kp2*((dZy(ii,jj,kk-1)+dZy(ii,jj,kk))/2)*(1/dz)*(1/(HIC(ii,jj)*dz)); 
end  
end 
end




%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (2) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(2)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx (dZ/dx)^k+1/2 H b dx dy /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*(1/(HIC(ii,jj)*dz)); 
end 
end 
end



%---(2.19): - Kp2 (dZ/dy)^k+1/2 (dV/dz)^k+1/2 (1/(H dz)) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=  MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)   -alfa12*Kp2*((dZy(ii,jj,kk+1)+dZy(ii,jj,kk))/2)*(-1/dz)*(1/(HIC(ii,jj)*dz)); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa12*Kp2*((dZy(ii,jj,kk+1)+dZy(ii,jj,kk))/2)*(1/dz)*(1/(HIC(ii,jj)*dz)); 
end  
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (3) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(3)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx (dQ/dx)^j-1/2 b H dx dz / (b H dx dy dz) ++++;


%---(3.1): - (dZ/dz)^j-1/2 0.5 (dU/dz)^j-1 (dQ/dx)^j-1/2 (1/dy) ((H^j-1/2)/H^j) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)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%++++++++++++++++++++++++++ (4) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(4)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx (dQ/dx)^j+1/2 b H dx dz / (b H dx dy dz) ++++;


%---(4.1):  (dZ/dz)^j+1/2 0.5 (dU/dz)^j+1 (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk-1) +alfa12*((dZz(ii,jj+1)+dZz(ii,jj))/2)*0.5*(-1/(2*dz))*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-1)*Ny*Nz+jj*Nz+kk+1) +alfa12*((dZz(ii,jj+1)+dZz(ii,jj))/2)*0.5*(1/(2*dz))*((dQx(ii,jj+1)+dQx(ii,jj))/2)*(1/dy)*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end



%---(4.2):  (dZ/dz)^j+1/2 0.5 (dU/dz)^j (dQ/dx)^j+1/2 (1/dy) ((H^j+1/2)/H^j) ----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*N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1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa12*((dZy(ii,jj+1,kk)+dZy(ii,jj,kk))/2)*0.5*(1/(2*dz))*(1/(Width(ii)*dy))*((HIC(ii,jj+1)+HIC(ii,jj))/(2*HIC(ii,jj))); 
end 
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (5) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(5)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++ - KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(5.1): - (dZ/dz)^i-1/2 0.5 (dU/dz)^i-1 (1/dx) ((b^i-1/2)/b^i) ((H^i-1/2)/H^i) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk-1) -alfa12*((dZz(ii-1,jj)+dZz(ii,jj))/2)*0.5*(-1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,(ii-2)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa12*((dZz(ii-1,jj)+dZz(ii,jj))/2)*0.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x*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) -alfa12*((dZx(ii-1,jj,kk)+dZx(ii,jj,kk))/2)*0.5*(1/(2*dz))*((Width(ii-1)+Width(ii))/(2*Width(ii)))*((HIC(ii-1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++ (6) +++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ KpE I(6)z / (b H dx dy dz) +++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%++++  KpE Fzx b H dy dz / (b H dx dy dz) ++++;


%---(6.1):  (dZ/dz)^i+1/2 0.5 (dU/dz)^i+1 (1/dx) ((b^i+1/2)/b^i) ((H^i+1/2)/H^i) -----;

for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk-1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk-1) +alfa12*((dZz(ii+1,jj)+dZz(ii,jj))/2)*0.5*(-1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,ii*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(j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ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk+1) +alfa12*((dZx(ii+1,jj,kk)+dZx(ii,jj,kk))/2)*0.5*(1/(2*dz))*((Width(ii+1)+Width(ii))/(2*Width(ii)))*((HIC(ii+1,jj)+HIC(ii,jj))/(2*HIC(ii,jj)))*(1/dx); 
end 
end 
end



%+++++++++++++++++++++ + KpE dens Freq^2 W +++++++++++++++++++++++++;


for ii=2:1:Nx-1 
for jj=2:1:Ny-1
for kk=2:1:Nz-1 
MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk)=MB(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk) + alfa12*KpE*dens*Freq^2; 
end  
end 
end





%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++ Sea Water under the Ice Shelf ++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
    
    
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++++ W=W' +++++++++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
    
for ii=1:1:Nx
for jj=1:1:Ny
MB(3*Nx*Ny*Nz+(ii-1)*Ny+jj,2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+Nz)=-1;
MB(3*Nx*Ny*Nz+(ii-1)*Ny+jj,3*Nx*Ny*Nz+(ii-1)*Ny+jj)=1;
end
end
    

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++ Wave equation & Boundary conditions +++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%--------------- X=0 (Ix=1): dP'/dx=0 ---------------;


for jj=1:1:Ny
    MB(3*Nx*Ny*Nz+Nx*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+jj)=     -3/(2*dx);
    MB(3*Nx*Ny*Nz+Nx*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+Ny+jj)=   4/(2*dx);
    MB(3*Nx*Ny*Nz+Nx*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+2*Ny+jj)=-1/(2*dx);
end


%---------- X=L (Ix=Nx): P'= p g dz cos (wt) ----------;

for jj=1:1:Ny

    MB(3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+jj)=1;
    
    
    VB(3*Nx*Ny*Nz+Nx*Ny+(Nx-1)*Ny+jj)=dens_w*g*AmSLC;
      
      
end


%------------- Y=Y1 (J=1): dP'/dn = dP'/dx dY1/dx + dQx dP'/dq dY1/dx - dQy dP'/dq = 0 ---------------;

% for ii=2:1:Nx-1
%     
%     MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+1,3*Nx*Ny*Nz+Nx*Ny+(ii-2)*Ny+1)=(-1/(2*dx))*difY1(ii);     
%     MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+1,3*Nx*Ny*Nz+Nx*Ny+ii*Ny+1)=     (1/(2*dx))*difY1(ii);
%     
%     
%     MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+1,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+1)=(-3/(2*dy))*dQx(ii,1)*difY1(ii);     
%     MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+1,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+2)=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nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny)+   (3/(2*dy))*dQy(ii);
%     
% end


%------------- Y=Y2 (J=Ny): dP'/dy=0 --------------;

for ii=2:1:Nx-1
    
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny-2)= 1/(2*dy);
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny-1)=-4/(2*dy);     
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+Ny)=   3/(2*dy);
    
end



%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++ The wave equation for the water layer ++++++++++++;    
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


for ii=2:1:Nx-1
for jj=2:1:Ny-1
    
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+(ii-1)*Ny+jj)=Freq^2;
   
    %------- (1) d/dx ( D dP'/dx ) ---------;
    
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-2)*Ny+jj)= (1/dens_w)*(WDx_ij(ii,jj)*WWx_i(ii)/Width(ii))*(1/dx^2);     
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj)=-(1/dens_w)*((WDx_ij(ii,jj)*WWx_i(ii)+WDx_ij(ii+1,jj)*WWx_i(ii+1))/Width(ii))*(1/dx^2);
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+ii*Ny+jj)=     (1/dens_w)*(WD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x*Ny*Nz+Nx*Ny+(ii-2)*Ny+jj+1)+(1/dens_w)*(-WDQxy_ij(ii,jj+1)/(4*dy*dx)); 
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+ii*Ny+jj+1)=    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+ii*Ny+jj+1)     +(1/dens_w)*(WDQxy_ij(ii,jj+1)/(4*dy*dx));
    
    
    %------ (5) dQx d/dq ( D dQx dP'/dq ) --------;
    
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj-1)=MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj-1)+(1/dens_w)*(WDQx2y_ij(ii,jj)/dy^2);     
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj)=  MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj)  +(1/dens_w)*(-(WDQx2y_ij(ii,jj)+WDQx2y_ij(ii,jj+1))/dy^2);
    MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj+1)=MB(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj,3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj+1)+(1/dens_w)*(WDQx2y_ij(ii,jj+1)/dy^2);
            
        
end
end

     

%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
    
        
    SolveUVW=linsolve(MB,VB);
        
    
%-----------------------------------------------------------------;

for ii=1:1:Nx
for jj=1:1:Ny
for kk=1:1:Nz 
    masU(ii,jj,kk)=SolveUVW((ii-1)*Ny*Nz+(jj-1)*Nz+kk); 
end 
end
end
                                                                           
for ii=1:1:Nx 
for jj=1:1:Ny
for kk=1:1:Nz 
    masV(ii,jj,kk)=SolveUVW(Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk); 
end 
end
end

for ii=1:1:Nx
for jj=1:1:Ny
for kk=1:1:Nz 
    masW(ii,jj,kk)=SolveUVW(2*Nx*Ny*Nz+(ii-1)*Ny*Nz+(jj-1)*Nz+kk); 
end 
end
end


for ii=1:1:Nx
for jj=1:1:Ny 
    Delta_H(ii,jj,JFreq)=SolveUVW(3*Nx*Ny*Nz+(ii-1)*Ny+jj); 
end
end


for ii=1:1:Nx
for jj=1:1:Ny 
    Delta_P(ii,jj,JFreq)=SolveUVW(3*Nx*Ny*Nz+Nx*Ny+(ii-1)*Ny+jj); 
end
end
    

for ii=1:1:Nx
for jj=1:1:Ny 
    Delta_Ws(ii,jj,JFreq)=masW(ii,jj,1); 
end
end



%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%++++++++++++++++++++++++++   F-energy  ++++++++++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


%+++++++++++++++++++++++++++++++;
%++++++++++ (1) Utxx +++++++++++;
%+++++++++++++++++++++++++++++++;

%-------- Ix=1 --------;

Utxx(1,1,1)=(-masU(3,1,1)+4*masU(2,1,1)-3*masU(1,1,1))/(2*dx)+dQx(1,1)*(-masU(1,3,1)+4*masU(1,2,1)-3*masU(1,1,1))/(2*dy)+dZx(1,1,1)*(-masU(1,1,3)+4*masU(1,1,2)-3*masU(1,1,1))/(2*dz); 

for kk=2:1:Nz-1
    Utxx(1,1,kk)=(-masU(3,1,kk)+4*masU(2,1,kk)-3*masU(1,1,kk))/(2*dx)+dQx(1,1)*(-masU(1,3,kk)+4*masU(1,2,kk)-3*masU(1,1,kk))/(2*dy)+dZx(1,1,kk)*(masU(1,1,kk+1)-masU(1,1,kk-1))/(2*dz); 
end

Utxx(1,1,Nz)=(-masU(3,1,Nz)+4*masU(2,1,Nz)-3*masU(1,1,Nz))/(2*dx)+dQx(1,1)*(-masU(1,3,Nz)+4*masU(1,2,Nz)-3*masU(1,1,Nz))/(2*dy)+dZx(1,1,Nz)*(3*masU(1,1,Nz)-4*masU(1,1,Nz-1)+masU(1,1,Nz-2))/(2*dz); 



for jj=2:1:Ny-1
    Utxx(1,jj,1)=(-masU(3,jj,1)+4*masU(2,jj,1)-3*masU(1,jj,1))/(2*dx)+dQx(1,jj)*(masU(1,jj+1,1)-masU(1,jj-1,1))/(2*dy)+dZx(1,jj,1)*(-masU(1,jj,3)+4*masU(1,jj,2)-3*masU(1,jj,1))/(2*dz); 
end 

for jj=2:1:Ny-1
for kk=2:1:Nz-1
    Utxx(1,jj,kk)=(-masU(3,jj,kk)+4*masU(2,jj,kk)-3*masU(1,jj,kk))/(2*dx)+dQx(1,jj)*(masU(1,jj+1,kk)-masU(1,jj-1,kk))/(2*dy)+dZx(1,jj,kk)*(masU(1,jj,kk+1)-masU(1,jj,kk-1))/(2*dz); 
end 
end

for jj=2:1:Ny-1
    Utxx(1,jj,Nz)=(-masU(3,jj,Nz)+4*masU(2,jj,Nz)-masU(1,jj,Nz))/(2*dx)+dQx(1,jj)*(masU(1,jj+1,Nz)-masU(1,jj-1,Nz))/(2*dy)+dZx(1,jj,Nz)*(3*masU(1,jj,Nz)-4*masU(1,jj,Nz-1)+masU(1,jj,Nz-2))/(2*dz); 
end



Utxx(1,Ny,1)=(-masU(3,Ny,1)+4*masU(2,Ny,1)-3*masU(1,Ny,1))/(2*dx)+dQx(1,Ny)*(3*masU(1,Ny,1)-4*masU(1,Ny-1,1)+masU(1,Ny-2,1))/(2*dy)+dZx(1,Ny,1)*(-masU(1,Ny,3)+4*masU(1,Ny,2)-3*masU(1,Ny,1))/(2*dz); 

for kk=2:1:Nz-1
    Utxx(1,Ny,kk)=(-masU(3,Ny,kk)+4*masU(2,Ny,kk)-3*masU(1,Ny,kk))/(2*dx)+dQx(1,Ny)*(3*masU(1,Ny,kk)-4*masU(1,Ny-1,kk)+masU(1,Ny-2,kk))/(2*dy)+dZx(1,Ny,kk)*(masU(1,Ny,kk+1)-masU(1,Ny,kk-1))/(2*dz); 
end

Utxx(1,Ny,Nz)=(-masU(3,Ny,Nz)+4*masU(2,Ny,Nz)-3*masU(1,Ny,Nz))/(2*dx)+dQx(1,Ny)*(3*masU(1,Ny,Nz)-4*masU(1,Ny-1,Nz)+masU(1,Ny-2,Nz))/(2*dy)+dZx(1,Ny,Nz)*(3*masU(1,Ny,Nz)-4*masU(1,Ny,Nz-1)+masU(1,Ny,Nz-2))/(2*dz); 



%--------- 1<Ix<Nx --------;

for ii=2:1:Nx-1
for jj=2:1:Ny-1
    Utxx(ii,jj,1)=(masU(ii+1,jj,1)-masU(ii-1,jj,1))/(2*dx)+dQx(ii,jj)*(masU(ii,jj+1,1)-masU(ii,jj-1,1))/(2*dy)+dZx(ii,jj,1)*(-masU(ii,jj,3)+4*masU(ii,jj,2)-3*masU(ii,jj,1))/(2*dz); 
end
end


for ii=2:1:Nx-1
    Utxx(ii,1,1)=(masU(ii+1,1,1)-masU(ii-1,1,1))/(2*dx)+dQx(ii,1)*(-masU(ii,3,1)+4*masU(ii,2,1)-3*masU(ii,1,1))/(2*dy)+dZx(ii,1,1)*(-masU(ii,1,3)+4*masU(ii,1,2)-3*masU(ii,1,1))/(2*dz); 
end 

for ii=2:1:Nx-1
for kk=2:1:Nz-1
    Utxx(ii,1,kk)=(masU(ii+1,1,kk)-masU(ii-1,1,kk))/(2*dx)+dQx(ii,1)*(-masU(ii,3,kk)+4*masU(ii,2,kk)-3*masU(ii,1,kk))/(2*dy)+dZx(ii,1,kk)*(masU(ii,1,kk+1)-masU(ii,1,kk-1))/(2*dz); 
end 
end

for ii=2:1:Nx-1
    Utxx(ii,1,Nz)=(masU(ii+1,1,Nz)-masU(ii-1,1,Nz))/(2*dx)+dQx(ii,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x(Nx,Ny,Nz)*(3*masU(Nx,Ny,Nz)-4*masU(Nx,Ny,Nz-1)+masU(Nx,Ny,Nz-2))/(2*dz); 



%+++++++++++++++++++++++++++++++;
%++++++++++ (2) Utyy +++++++++++;
%+++++++++++++++++++++++++++++++;


%-------- Jy=1 ---------;

for ii=1:1:Nx
    Utyy(ii,1,1)=dQy(ii)*(-masV(ii,3,1)+4*masV(ii,2,1)-3*masV(ii,1,1))/(2*dy)+dZy(ii,1,1)*(-masV(ii,1,3)+4*masV(ii,1,2)-3*masV(ii,1,1))/(2*dz); 
end 

for ii=1:1:Nx
for kk=2:1:Nz-1
    Utyy(ii,1,kk)=dQy(ii)*(-masV(ii,3,kk)+4*masV(ii,2,kk)-3*masV(ii,1,kk))/(2*dy)+dZy(ii,1,kk)*(masV(ii,1,kk+1)-masV(ii,1,kk-1))/(2*dz); 
end 
end

for ii=1:1:Nx
    Utyy(ii,1,Nz)=dQy(ii)*(-masV(ii,3,Nz)+4*masV(ii,2,Nz)-3*masV(ii,1,Nz))/(2*dy)+dZy(ii,1,Nz)*(3*masV(ii,1,Nz)-4*masV(ii,1,Nz-1)+masV(ii,1,Nz-2))/(2*dz); 
end 


%--------- 1<Jy<Ny ----------;

for ii=1:1:Nx
for jj=2:1:Ny-1
    Utyy(ii,jj,1)=dQy(ii)*(masV(ii,jj+1,1)-masV(ii,jj-1,1))/(2*dy)+dZy(ii,jj,1)*(-masV(ii,jj,3)+4*masV(ii,jj,2)-3*masV(ii,jj,1))/(2*dz); 
end
end

for ii=1:1:Nx
for jj=2:1:Ny-1
for kk=2:1:Nz-1
    Utyy(ii,jj,kk)=dQy(ii)*(masV(ii,jj+1,kk)-masV(ii,jj-1,kk))/(2*dy)+dZy(ii,jj,kk)*(masV(ii,jj,kk+1)-masV(ii,jj,kk-1))/(2*dz); 
end 
end
end

for ii=1:1:Nx
for jj=2:1:Ny-1
    Utyy(ii,jj,Nz)=dQy(ii)*(masV(ii,jj+1,Nz)-masV(ii,jj-1,Nz))/(2*dy)+dZy(ii,jj,Nz)*(3*masV(ii,jj,Nz)-4*masV(ii,jj,Nz-1)+masV(ii,jj,Nz-2))/(2*dz); 
end
end


%--------- Jy=Ny ----------;

for ii=1:1:Nx
    Utyy(ii,Ny,1)=dQy(ii)*(3*masV(ii,Ny,1)-4*masV(ii,Ny-1,1)+masV(ii,Ny-2,1))/(2*dy)+dZy(ii,Ny,1)*(-masV(ii,Ny,3)+4*masV(ii,Ny,2)-3*masV(ii,Ny,1))/(2*dz); 
end

for ii=1:1:Nx
for kk=2:1:Nz-1
    Utyy(ii,Ny,kk)=dQy(ii)*(3*masV(ii,Ny,kk)-4*masV(ii,Ny-1,kk)+masV(ii,Ny-2,kk))/(2*dy)+dZy(ii,Ny,kk)*(masV(ii,Ny,kk+1)-masV(ii,Ny,kk-1))/(2*dz); 
end 
end

for ii=1:1:Nx
    Utyy(ii,Ny,Nz)=dQy(ii)*(3*masV(ii,Ny,Nz)-4*masV(ii,Ny-1,Nz)+masV(ii,Ny-2,Nz))/(2*dy)+dZy(ii,Ny,Nz)*(3*masV(ii,Ny,Nz)-4*masV(ii,Ny,Nz-1)+masV(ii,Ny,Nz-2))/(2*dz); 
end



%+++++++++++++++++++++++++++++++;
%++++++++++ (3) Utzz +++++++++++;
%+++++++++++++++++++++++++++++++;


for ii=1:1:Nx
for jj=1:1:Ny
    Utzz(ii,jj,1)=dZz(ii,jj)*(-masW(ii,jj,3)+4*masW(ii,jj,2)-3*masW(ii,jj,1))/(2*dz); 
end
end

for ii=1:1:Nx
for jj=1:1:Ny
for kk=2:1:Nz-1
    Utzz(ii,jj,kk)=dZz(ii,jj)*(masW(ii,jj,kk+1)-masW(ii,jj,kk-1))/(2*dz); 
end 
end
end

for ii=1:1:Nx
for jj=1:1:Ny
    Utzz(ii,jj,Nz)=dZz(ii,jj)*(3*masW(ii,jj,Nz)-4*masW(ii,jj,Nz-1)+masW(ii,jj,Nz-2))/(2*dz); 
end
end



%+++++++++++++++++++++++++++++++;
%++++++++++ (4) Utxy +++++++++++;
%+++++++++++++++++++++++++++++++;


%+++++++++ dU/dy ++++++++;

%-------- Jy=1 ---------;

for ii=1:1:Nx
    Uty(ii,1,1)=dQy(ii)*(-masU(ii,3,1)+4*masU(ii,2,1)-3*masU(ii,1,1))/(2*dy)+dZy(ii,1,1)*(-masU(ii,1,3)+4*masU(ii,1,2)-3*masU(ii,1,1))/(2*dz); 
end 

for ii=1:1:Nx
for kk=2:1:Nz-1
    Uty(ii,1,kk)=dQy(ii)*(-masU(ii,3,kk)+4*masU(ii,2,kk)-3*masU(ii,1,kk))/(2*dy)+dZy(ii,1,kk)*(masU(ii,1,kk+1)-masU(ii,1,kk-1))/(2*dz); 
end 
end

for ii=1:1:Nx
    Uty(ii,1,Nz)=dQy(ii)*(-masU(ii,3,Nz)+4*masU(ii,2,Nz)-3*masU(ii,1,Nz))/(2*dy)+dZy(ii,1,Nz)*(3*masU(ii,1,Nz)-4*masU(ii,1,Nz-1)+masU(ii,1,Nz-2))/(2*dz); 
end 


%--------- 1<Jy<Ny ----------;

for ii=1:1:Nx
for jj=2:1:Ny-1
    Uty(ii,jj,1)=dQy(ii)*(masU(ii,jj+1,1)-masU(ii,jj-1,1))/(2*dy)+dZy(ii,jj,1)*(-masU(ii,jj,3)+4*masU(ii,jj,2)-3*masU(ii,jj,1))/(2*dz); 
end
end

for ii=1:1:Nx
for jj=2:1:Ny-1
for kk=2:1:Nz-1
    Uty(ii,jj,kk)=dQy(ii)*(masU(ii,jj+1,kk)-masU(ii,jj-1,kk))/(2*dy)+dZy(ii,jj,kk)*(masU(ii,jj,kk+1)-masU(ii,jj,kk-1))/(2*dz); 
end 
end
end

for ii=1:1:Nx
for jj=2:1:Ny-1
    Uty(ii,jj,Nz)=dQy(ii)*(masU(ii,jj+1,Nz)-masU(ii,jj-1,Nz))/(2*dy)+dZy(ii,jj,Nz)*(3*masU(ii,jj,Nz)-4*masU(ii,jj,Nz-1)+masU(ii,jj,Nz-2))/(2*dz); 
end
end


%--------- Jy=Ny ----------;

for ii=1:1:Nx
    Uty(ii,Ny,1)=dQy(ii)*(3*masU(ii,Ny,1)-4*masU(ii,Ny-1,1)+masU(ii,Ny-2,1))/(2*dy)+dZy(ii,Ny,1)*(-masU(ii,Ny,3)+4*masU(ii,Ny,2)-3*masU(ii,Ny,1))/(2*dz); 
end

for ii=1:1:Nx
for kk=2:1:Nz-1
    Uty(ii,Ny,kk)=dQy(ii)*(3*masU(ii,Ny,kk)-4*masU(ii,Ny-1,kk)+masU(ii,Ny-2,kk))/(2*dy)+dZy(ii,Ny,kk)*(masU(ii,Ny,kk+1)-masU(ii,Ny,kk-1))/(2*dz); 
end 
end

for ii=1:1:Nx
    Uty(ii,Ny,Nz)=dQy(ii)*(3*masU(ii,Ny,Nz)-4*masU(ii,Ny-1,Nz)+masU(ii,Ny-2,Nz))/(2*dy)+dZy(ii,Ny,Nz)*(3*masU(ii,Ny,Nz)-4*masU(ii,Ny,Nz-1)+masU(ii,Ny,Nz-2))/(2*dz); 
end



%+++++++++ dV/dx ++++++++;

%-------- Ix=1 --------;

Vtx(1,1,1)=(-masV(3,1,1)+4*masV(2,1,1)-3*masV(1,1,1))/(2*dx)+dQx(1,1)*(-masV(1,3,1)+4*masV(1,2,1)-3*masV(1,1,1))/(2*dy)+dZx(1,1,1)*(-masV(1,1,3)+4*masV(1,1,2)-3*masV(1,1,1))/(2*dz); 

for kk=2:1:Nz-1
    Vtx(1,1,kk)=(-masV(3,1,kk)+4*masV(2,1,kk)-3*masV(1,1,kk))/(2*dx)+dQx(1,1)*(-masV(1,3,kk)+4*masV(1,2,kk)-3*masV(1,1,kk))/(2*dy)+dZx(1,1,kk)*(masV(1,1,kk+1)-masV(1,1,kk-1))/(2*dz); 
end

Vtx(1,1,Nz)=(-masV(3,1,Nz)+4*masV(2,1,Nz)-3*masV(1,1,Nz))/(2*dx)+dQx(1,1)*(-masV(1,3,Nz)+4*masV(1,2,Nz)-3*masV(1,1,Nz))/(2*dy)+dZx(1,1,Nz)*(3*masV(1,1,Nz)-4*masV(1,1,Nz-1)+masV(1,1,Nz-2))/(2*dz); 



for jj=2:1:Ny-1
    Vtx(1,jj,1)=(-masV(3,jj,1)+4*masV(2,jj,1)-3*masV(1,jj,1))/(2*dx)+dQx(1,jj)*(masV(1,jj+1,1)-masV(1,jj-1,1))/(2*dy)+dZx(1,jj,1)*(-masV(1,jj,3)+4*masV(1,jj,2)-3*masV(1,jj,1))/(2*dz); 
end 

for jj=2:1:Ny-1
for kk=2:1:Nz-1
    Vtx(1,jj,kk)=(-masV(3,jj,kk)+4*masV(2,jj,kk)-3*masV(1,jj,kk))/(2*dx)+dQx(1,jj)*(masV(1,jj+1,kk)-masV(1,jj-1,kk))/(2*dy)+dZx(1,jj,kk)*(masV(1,jj,kk+1)-masV(1,jj,kk-1))/(2*dz); 
end 
end

for jj=2:1:Ny-1
    Vtx(1,jj,Nz)=(-masV(3,jj,Nz)+4*masV(2,jj,Nz)-masV(1,jj,Nz))/(2*dx)+dQx(1,jj)*(masV(1,jj+1,Nz)-masV(1,jj-1,Nz))/(2*dy)+dZx(1,jj,Nz)*(3*masV(1,jj,Nz)-4*masV(1,jj,Nz-1)+masV(1,jj,Nz-2))/(2*dz); 
end



Vtx(1,Ny,1)=(-masV(3,Ny,1)+4*masV(2,Ny,1)-3*masV(1,Ny,1))/(2*dx)+dQx(1,Ny)*(3*masV(1,Ny,1)-4*masV(1,Ny-1,1)+masV(1,Ny-2,1))/(2*dy)+dZx(1,Ny,1)*(-masV(1,Ny,3)+4*masV(1,Ny,2)-3*masV(1,Ny,1))/(2*dz); 

for kk=2:1:Nz-1
    Vtx(1,Ny,kk)=(-masV(3,Ny,kk)+4*masV(2,Ny,kk)-3*masV(1,Ny,kk))/(2*dx)+dQx(1,Ny)*(3*masV(1,Ny,kk)-4*masV(1,Ny-1,kk)+masV(1,Ny-2,kk))/(2*dy)+dZx(1,Ny,kk)*(masV(1,Ny,kk+1)-masV(1,Ny,kk-1))/(2*dz); 
end

Vtx(1,Ny,Nz)=(-masV(3,Ny,Nz)+4*masV(2,Ny,Nz)-3*masV(1,Ny,Nz))/(2*dx)+dQx(1,Ny)*(3*masV(1,Ny,Nz)-4*masV(1,Ny-1,Nz)+masV(1,Ny-2,Nz))/(2*dy)+dZx(1,Ny,Nz)*(3*masV(1,Ny,Nz)-4*masV(1,Ny,Nz-1)+masV(1,Ny,Nz-2))/(2*dz); 



%--------- 1<Ix<Nx --------;

for ii=2:1:Nx-1
for jj=2:1:Ny-1
    Vtx(ii,jj,1)=(masV(ii+1,jj,1)-masV(ii-1,jj,1))/(2*dx)+dQx(ii,jj)*(masV(ii,jj+1,1)-masV(ii,jj-1,1))/(2*dy)+dZx(ii,jj,1)*(-masV(ii,jj,3)+4*masV(ii,jj,2)-3*masV(ii,jj,1))/(2*dz); 
end
end


for ii=2:1:Nx-1
    Vtx(ii,1,1)=(masV(ii+1,1,1)-masV(ii-1,1,1))/(2*dx)+dQx(ii,1)*(-masV(ii,3,1)+4*masV(ii,2,1)-3*masV(ii,1,1))/(2*dy)+dZx(ii,1,1)*(-masV(ii,1,3)+4*masV(ii,1,2)-3*masV(ii,1,1))/(2*dz); 
end 

for ii=2:1:Nx-1
for kk=2:1:Nz-1
    Vtx(ii,1,kk)=(masV(ii+1,1,kk)-masV(ii-1,1,kk))/(2*dx)+dQx(ii,1)*(-masV(ii,3,kk)+4*masV(ii,2,kk)-3*masV(ii,1,kk))/(2*dy)+dZx(ii,1,kk)*(masV(ii,1,kk+1)-masV(ii,1,kk-1))/(2*dz); 
end 
end

for ii=2:1:Nx-1
    Vtx(ii,1,Nz)=(masV(ii+1,1,Nz)-masV(ii-1,1,Nz))/(2*dx)+dQx(ii,1)*(-masV(ii,3,Nz)+4*masV(ii,2,Nz)-3*masV(ii,1,Nz))/(2*dy)+dZx(ii,1,Nz)*(3*masV(ii,1,Nz)-4*masV(ii,1,Nz-1)+masV(ii,1,Nz-2))/(2*dz); 
end 


for ii=2:1:Nx-1
for jj=2:1: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,jj,kk)+Vtx(ii,jj,kk))/2; 
end 
end
end



%+++++++++++++++++++++++++++++++;
%++++++++++ (5) Utxz +++++++++++;
%+++++++++++++++++++++++++++++++;


%++++++++++++ dU/dz ++++++++++++;


for ii=1:1:Nx
for jj=1:1:Ny
    Utz(ii,jj,1)=dZz(ii,jj)*(-masU(ii,jj,3)+4*masU(ii,jj,2)-3*masU(ii,jj,1))/(2*dz); 
end
end

for ii=1:1:Nx
for jj=1:1:Ny
for kk=2:1:Nz-1
    Utz(ii,jj,kk)=dZz(ii,jj)*(masU(ii,jj,kk+1)-masU(ii,jj,kk-1))/(2*dz); 
end 
end
end

for ii=1:1:Nx
for jj=1:1:Ny
    Utz(ii,jj,Nz)=dZz(ii,jj)*(3*masU(ii,jj,Nz)-4*masU(ii,jj,Nz-1)+masU(ii,jj,Nz-2))/(2*dz); 
end
end



%++++++++++++ dW/dx ++++++++++++;


%-------- Ix=1 --------;

Wtx(1,1,1)=(-masW(3,1,1)+4*masW(2,1,1)-3*masW(1,1,1))/(2*dx)+dQx(1,1)*(-masW(1,3,1)+4*masW(1,2,1)-3*masW(1,1,1))/(2*dy)+dZx(1,1,1)*(-masW(1,1,3)+4*masW(1,1,2)-3*masW(1,1,1))/(2*dz); 

for kk=2:1:Nz-1
    Wtx(1,1,kk)=(-masW(3,1,kk)+4*masW(2,1,kk)-3*masW(1,1,kk))/(2*dx)+dQx(1,1)*(-masW(1,3,kk)+4*masW(1,2,kk)-3*masW(1,1,kk))/(2*dy)+dZx(1,1,kk)*(masW(1,1,kk+1)-masW(1,1,kk-1))/(2*dz); 
end

Wtx(1,1,Nz)=(-masW(3,1,Nz)+4*masW(2,1,Nz)-3*masW(1,1,Nz))/(2*dx)+dQx(1,1)*(-masW(1,3,Nz)+4*masW(1,2,Nz)-3*masW(1,1,Nz))/(2*dy)+dZx(1,1,Nz)*(3*masW(1,1,Nz)-4*masW(1,1,Nz-1)+masW(1,1,Nz-2))/(2*dz); 



for jj=2:1:Ny-1
    Wt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Ny)*(3*masW(1,Ny,Nz)-4*masW(1,Ny-1,Nz)+masW(1,Ny-2,Nz))/(2*dy)+dZx(1,Ny,Nz)*(3*masW(1,Ny,Nz)-4*masW(1,Ny,Nz-1)+masW(1,Ny,Nz-2))/(2*dz); 



%--------- 1<Ix<Nx --------;

for ii=2:1:Nx-1
for jj=2:1:Ny-1
    Wtx(ii,jj,1)=(masW(ii+1,jj,1)-masW(ii-1,jj,1))/(2*dx)+dQx(ii,jj)*(masW(ii,jj+1,1)-masW(ii,jj-1,1))/(2*dy)+dZx(ii,jj,1)*(-masW(ii,jj,3)+4*masW(ii,jj,2)-3*masW(ii,jj,1))/(2*dz); 
end
end


for ii=2:1:Nx-1
    Wtx(ii,1,1)=(masW(ii+1,1,1)-masW(ii-1,1,1))/(2*dx)+dQx(ii,1)*(-masW(ii,3,1)+4*masW(ii,2,1)-3*masW(ii,1,1))/(2*dy)+dZx(ii,1,1)*(-masW(ii,1,3)+4*masW(ii,1,2)-3*masW(ii,1,1))/(2*dz); 
end 

for ii=2:1:Nx-1
for kk=2:1:Nz-1
    Wtx(ii,1,kk)=(masW(ii+1,1,kk)-masW(ii-1,1,kk))/(2*dx)+dQx(ii,1)*(-masW(ii,3,kk)+4*masW(ii,2,kk)-3*masW(ii,1,kk))/(2*dy)+dZx(ii,1,kk)*(masW(ii,1,kk+1)-masW(ii,1,kk-1))/(2*dz); 
end 
end

for ii=2:1:Nx-1
    Wtx(ii,1,Nz)=(masW(ii+1,1,Nz)-masW(ii-1,1,Nz))/(2*dx)+dQx(ii,1)*(-masW(ii,3,Nz)+4*masW(ii,2,Nz)-3*masW(ii,1,Nz))/(2*dy)+dZx(ii,1,Nz)*(3*masW(ii,1,Nz)-4*masW(ii,1,Nz-1)+masW(ii,1,Nz-2))/(2*dz); 
end 


for ii=2:1:Nx-1
for jj=2:1:Ny-1
for kk=2:1:Nz-1
    Wtx(ii,jj,kk)=(masW(ii+1,jj,kk)-masW(ii-1,jj,kk))/(2*dx)+dQx(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++++++++++++++++++++++++++;


%++++++++++++ dV/dz ++++++++++++;


for ii=1:1:Nx
for jj=1:1:Ny
    Vtz(ii,jj,1)=dZz(ii,jj)*(-masV(ii,jj,3)+4*masV(ii,jj,2)-3*masV(ii,jj,1))/(2*dz); 
end
end

for ii=1:1:Nx
for jj=1:1:Ny
for kk=2:1:Nz-1
    Vtz(ii,jj,kk)=dZz(ii,jj)*(masV(ii,jj,kk+1)-masV(ii,jj,kk-1))/(2*dz); 
end 
end
end

for ii=1:1:Nx
for jj=1:1:Ny
    Vtz(ii,jj,Nz)=dZz(ii,jj)*(3*masV(ii,jj,Nz)-4*masV(ii,jj,Nz-1)+masV(ii,jj,Nz-2))/(2*dz); 
end
end


%++++++++++++ dW/dy ++++++++++++;


%-------- Jy=1 ---------;

for ii=1:1:Nx
    Wty(ii,1,1)=dQy(ii)*(-masW(ii,3,1)+4*masW(ii,2,1)-3*masW(ii,1,1))/(2*dy)+dZy(ii,1,1)*(-masW(ii,1,3)+4*masW(ii,1,2)-3*masW(ii,1,1))/(2*dz); 
end 

for ii=1:1:Nx
for kk=2:1:Nz-1
    Wty(ii,1,kk)=dQy(ii)*(-masW(ii,3,kk)+4*masW(ii,2,kk)-3*masW(ii,1,kk))/(2*dy)+dZy(ii,1,kk)*(masW(ii,1,kk+1)-masW(ii,1,kk-1))/(2*dz); 
end 
end

for ii=1:1:Nx
    Wty(ii,1,Nz)=dQy(ii)*(-masW(ii,3,Nz)+4*masW(ii,2,Nz)-3*masW(ii,1,Nz))/(2*dy)+dZy(ii,1,Nz)*(3*masW(ii,1,Nz)-4*masW(ii,1,Nz-1)+masW(ii,1,Nz-2))/(2*dz); 
end 


%--------- 1<Jy<Ny ----------;

for ii=1:1:Nx
for jj=2:1:Ny-1
    Wty(ii,jj,1)=dQy(ii)*(masW(ii,jj+1,1)-masW(ii,jj-1,1))/(2*dy)+dZy(ii,jj,1)*(-masW(ii,jj,3)+4*masW(ii,jj,2)-3*masW(ii,jj,1))/(2*dz); 
end
end

for ii=1:1:Nx
for jj=2:1:Ny-1
for kk=2:1:Nz-1
    Wty(ii,jj,kk)=dQy(ii)*(masW(ii,jj+1,kk)-masW(ii,jj-1,kk))/(2*dy)+dZy(ii,jj,kk)*(masW(ii,jj,kk+1)-masW(ii,jj,kk-1))/(2*dz); 
end 
end
end

for ii=1:1:Nx
for jj=2:1:Ny-1
    Wty(ii,jj,Nz)=dQy(ii)*(masW(ii,jj+1,Nz)-masW(ii,jj-1,Nz))/(2*dy)+dZy(ii,jj,Nz)*(3*masW(ii,jj,Nz)-4*masW(ii,jj,Nz-1)+masW(ii,jj,Nz-2))/(2*dz); 
end
end


%--------- Jy=Ny ----------;

for ii=1:1:Nx
    Wty(ii,Ny,1)=dQy(ii)*(3*masW(ii,Ny,1)-4*masW(ii,Ny-1,1)+masW(ii,Ny-2,1))/(2*dy)+dZy(ii,Ny,1)*(-masW(ii,Ny,3)+4*masW(ii,Ny,2)-3*masW(ii,Ny,1))/(2*dz); 
end

for ii=1:1:Nx
for kk=2:1:Nz-1
    Wty(ii,Ny,kk)=dQy(ii)*(3*masW(ii,Ny,kk)-4*masW(ii,Ny-1,kk)+masW(ii,Ny-2,kk))/(2*dy)+dZy(ii,Ny,kk)*(masW(ii,Ny,kk+1)-masW(ii,Ny,kk-1))/(2*dz); 
end 
end

for ii=1:1:Nx
    Wty(ii,Ny,Nz)=dQy(ii)*(3*masW(ii,Ny,Nz)-4*masW(ii,Ny-1,Nz)+masW(ii,Ny-2,Nz))/(2*dy)+dZy(ii,Ny,Nz)*(3*masW(ii,Ny,Nz)-4*masW(ii,Ny,Nz-1)+masW(ii,Ny,Nz-2))/(2*dz); 
end



%--------------------------------------;


for ii=1:1:Nx
for jj=1:1:Ny
for kk=1:1:Nz
    Utyz(ii,jj,kk)=(Vtz(ii,jj,kk)+Wty(ii,jj,kk))/2; 
end 
end
end



%+++++++++++++++++++++++++ F-energy ++++++++++++++++++++++++++++++++;


for ii=1:1:Nx
for jj=1:1:Ny
for kk=1:1:Nz
    
    Uikp2=(Utxx(ii,jj,kk))^2 + (Utyy(ii,jj,kk))^2 + (Utzz(ii,jj,kk))^2 + 2*(Utxy(ii,jj,kk))^2 + 2*(Utxz(ii,jj,kk))^2 + 2*(Utyz(ii,jj,kk))^2;
    
    Uiip2=(Utxx(ii,jj,kk)+Utyy(ii,jj,kk)+Utzz(ii,jj,kk))^2;
    
    Feng(ii,jj,kk)=(KpE0/2)*(Uikp2+Kpb2*Uiip2);
    
end 
end
end


%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++++++++++ Full F-energy ++++++++++++++++++++++++;
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;


IntFeng=0;

%----------------------;
%-------- Ix=1 --------;
%----------------------;

%---- Jy=1 ----;

IntFeng=IntFeng+Feng(1,1,1)*(1/8)*Width(1)*HIC(1,1)*dx*dy*dz+Feng(1,1,Nz)*(1/8)*Width(1)*HIC(1,1)*dx*dy*dz;

for kk=2:1:Nz-1
    IntFeng=IntFeng+Feng(1,1,kk)*(1/4)*Width(1)*HIC(1,1)*dx*dy*dz;
end 


%---- 1<Jy<Ny ----;

for jj=2:1:Ny-1
    
    IntFeng=IntFeng+Feng(1,jj,1)*(1/4)*Width(1)*HIC(1,jj)*dx*dy*dz+Feng(1,jj,Nz)*(1/4)*Width(1)*HIC(1,jj)*dx*dy*dz;
    
    for kk=2:1:Nz-1
        IntFeng=IntFeng+Feng(1,jj,kk)*(1/2)*Width(1)*HIC(1,jj)*dx*dy*dz;
    end 
    
end


%---- Jy=Ny ----;

IntFeng=IntFeng+Feng(1,Ny,1)*(1/8)*Width(1)*HIC(1,Ny)*dx*dy*dz+Feng(1,Ny,Nz)*(1/8)*Width(1)*HIC(1,Ny)*dx*dy*dz;

for kk=2:1:Nz-1
    IntFeng=IntFeng+Feng(1,Ny,kk)*(1/4)*Width(1)*HIC(1,Ny)*dx*dy*dz;
end 



%-------------------------;
%-------- 1<Ix<Nx --------;
%-------------------------;


for ii=2:1:Nx-1
    
    %---- Jy=1 ----;
   
    IntFeng=IntFeng+Feng(ii,1,1)*(1/4)*Width(ii)*HIC(ii,1)*dx*dy*dz+Feng(ii,1,Nz)*(1/4)*Width(ii)*HIC(ii,1)*dx*dy*dz;

    for kk=2:1:Nz-1
        IntFeng=IntFeng+Feng(ii,1,kk)*(1/2)*Width(ii)*HIC(ii,1)*dx*dy*dz;
    end 
    
    
    %---- 1<Jy<Ny ----;

    for jj=2:1:Ny-1
    
        IntFeng=IntFeng+Feng(ii,jj,1)*(1/2)*Width(ii)*HIC(ii,jj)*dx*dy*dz+Feng(ii,jj,Nz)*(1/2)*Width(ii)*HIC(ii,jj)*dx*dy*dz;
    
        for kk=2:1:Nz-1
            IntFeng=IntFeng+Feng(ii,jj,kk)*Width(ii)*HIC(ii,jj)*dx*dy*dz;
        end 
    
    end
    
    
    %---- Jy=Ny ----;

    IntFeng=IntFeng+Feng(ii,Ny,1)*(1/4)*Width(ii)*HIC(ii,Ny)*dx*dy*dz+Feng(ii,Ny,Nz)*(1/4)*Width(ii)*HIC(ii,Ny)*dx*dy*dz;

    for kk=2:1:Nz-1
        IntFeng=IntFeng+Feng(ii,Ny,kk)*(1/2)*Width(ii)*HIC(ii,Ny)*dx*dy*dz;
    end 
    
    
end



%----------------------;
%-------- Ix=Nx -------;
%----------------------;

%---- Jy=1 ----;

IntFeng=IntFeng+Feng(Nx,1,1)*(1/8)*Width(Nx)*HIC(Nx,1)*dx*dy*dz+Feng(Nx,1,Nz)*(1/8)*Width(Nx)*HIC(Nx,1)*dx*dy*dz;

for kk=2:1:Nz-1
    IntFeng=IntFeng+Feng(Nx,1,kk)*(1/4)*Width(Nx)*HIC(Nx,1)*dx*dy*dz;
end 


%---- 1<Jy<Ny ----;

for jj=2:1:Ny-1
    
    IntFeng=IntFeng+Feng(Nx,jj,1)*(1/4)*Width(Nx)*HIC(Nx,jj)*dx*dy*dz+Feng(Nx,jj,Nz)*(1/4)*Width(Nx)*HIC(Nx,jj)*dx*dy*dz;
    
    for kk=2:1:Nz-1
        IntFeng=IntFeng+Feng(Nx,jj,kk)*(1/2)*Width(Nx)*HIC(Nx,jj)*dx*dy*dz;
    end 
    
end


%---- Jy=Ny ----;

IntFeng=IntFeng+Feng(Nx,Ny,1)*(1/8)*Width(Nx)*HIC(Nx,Ny)*dx*dy*dz+Feng(Nx,Ny,Nz)*(1/8)*Width(Nx)*HIC(Nx,Ny)*dx*dy*dz;

for kk=2:1:Nz-1
    IntFeng=IntFeng+Feng(Nx,Ny,kk)*(1/4)*Width(Nx)*HIC(Nx,Ny)*dx*dy*dz;
end 


%++++++++++++++++++++++++

FullFeng(JFreq)=IntFeng;



%+++++++++++++++++++++++++++++++++++++++++++++++++++++++;

    disp(JFreq);
    
    datestr(clock)


end


%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
%+++++++++++++++++++++++ THE MAIN CYCLE END ++++++++++++++++++++++++++++;
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;

%-----------------------------------------------------------------------;
%----------------- Results: the free energy spectrum -------------------;
% ( the overall free energy of the ice shelf vs periodicity/frequency ) ;
%-----------------------------------------------------------------------;


L_Freq1=zeros(NFreq,1); L_Freq2=zeros(NFreq,1); L_PT=zeros(NFreq,1);



for JFreq=1:1:NFreq


if (JFreq>=1) && (JFreq<=100)
   
    PT0=10; D_PT=0.03;
    
    Freq=2*pi/(PT0+JFreq*D_PT);
    
    L_PT(JFreq)=PT0+JFreq*D_PT;  L_Freq1(JFreq)=2*pi/(PT0+JFreq*D_PT); L_Freq2(JFreq)=1/(PT0+JFreq*D_PT);
    
end
    

if (JFreq>100) && (JFreq<=200)
   
    PT0=13; D_PT=0.04;
    
    Freq=2*pi/(PT0+(JFreq-100)*D_PT);
    
    L_PT(JFreq)=PT0+(JFreq-100)*D_PT;  L_Freq1(JFreq)=2*pi/(PT0+(JFreq-100)*D_PT); L_Freq2(JFreq)=1/(PT0+(JFreq-100)*D_PT);
    
end


if (JFreq>200) && (JFreq<=NFreq)
   
    PT0=17; D_PT=0.06;
    
    Freq=2*pi/(PT0+(JFreq-200)*D_PT);
    
    L_PT(JFreq)=PT0+(JFreq-200)*D_PT;  L_Freq1(JFreq)=2*pi/(PT0+(JFreq-200)*D_PT); L_Freq2(JFreq)=1/(PT0+(JFreq-200)*D_PT);
    
end

end


figure(6);

plot(L_Freq1,FullFeng,'-r.'), title('Free Energy Spectrum'), xlabel('Frequency (Hz)'), ylabel('Energy (J)'), grid;


figure(7);

plot(L_PT,FullFeng,'-r.'), title('Free Energy Spectrum'), xlabel('Periodicity (s)'), ylabel('Energy (J)'), grid;


save E:\Results\Freq1.txt -ascii L_Freq1

save E:\Results\Freq2.txt -ascii L_Freq2

save E:\Results\Periodicity.txt -ascii L_PT


save E:\Results\FullFreeEnergy.txt -ascii FullFeng

%------------------------------------------------------------------;


