Demo entry 6850853

mt

   

Submitted by li on Jul 12, 2019 at 07:13
Language: Matlab. Code size: 5.0 kB.

clear all;close all;clc;
%--------------------------------------------------------
sv       = 10^6;                           %units: m^3/s   
area     = [24,2.2,8.5]*(10^6)*(10^7);                   %Ocean surface area,units:10^7km^2
dh       = [100,3700-100];                 %Average ocean depth(surface & deep),units:m
for i=1:3
    V(i)   = area(i)*dh(1); %Ocean volume,units:m^3
    V(7-i) = area(i)*dh(2);
end
c(1:6,1) = [0.1,0.2,0.15,0.3,0.4,0.35];    %Initial PO4 concentration,units mol/m^3
Qw       = [20*sv,10*sv,4*sv];             %Water transport of Ocean
% Qw       = [20*sv,10*sv,4*sv]/10;
sms      = 100;                            %Sources and Sinks
dt       = 3600*24*365;                    %Time step,units: s/year
imax     = 10000;
eps      = 10^-6;
%----------------------------------------------------------
i = 2;
F_inout(1)   = c(6,i-1)*Qw(1)-c(1,i-1)*Qw(1);                                      %Flux,Indo-Pacific(surface)
F_inout(2)   = (c(1,i-1)*Qw(1)+c(5,i-1)*Qw(2))-(c(2,i-1)*Qw(1)+c(2,i-1)*Qw(2));    %Flux,Southern Ocean(surface)
F_inout(3)   = c(2,i-1)*Qw(2)- c(3,i-1)*Qw(2);                                     %Flux,Atlantic(surface)
F_inout(4)   = (c(3,i-1)*Qw(2)+c(5,i-1)*Qw(3))-(c(4,i-1)*Qw(2)+c(4,i-1)*Qw(3));    %Flux,Indo-Pacific(deep)
F_inout(5)   = (c(2,i-1)*Qw(1)+c(4,i-1)*Qw(2)+c(4,i-1)*Qw(3))-(c(5,i-1)*Qw(1)+c(5,i-1)*Qw(2)+c(5,i-1)*Qw(3));                                   
                                                                                   %Flux,Southern Ocean(deep)
F_inout(6)   = c(5,i-1)*Qw(1)- c(6,i-1)*Qw(1);                                     %Flux,Atlantic(deep)
for i=1:6
    c(i,2) = c(i,1)+dt/V(i)*(F_inout(i));
end
for i=3:imax   
    F_inout(1)   = c(6,i-1)*Qw(1)-c(1,i-1)*Qw(1);                                      
    F_inout(2)   = (c(1,i-1)*Qw(1)+c(5,i-1)*Qw(2))-(c(2,i-1)*Qw(1)+c(2,i-1)*Qw(2));    
    F_inout(3)   = c(2,i-1)*Qw(2)- c(3,i-1)*Qw(2);                                     
    F_inout(4)   = (c(3,i-1)*Qw(2)+c(5,i-1)*Qw(3))-(c(4,i-1)*Qw(2)+c(4,i-1)*Qw(3));    
    F_inout(5)   = (c(2,i-1)*Qw(1)+c(4,i-1)*Qw(2)+c(4,i-1)*Qw(3))-(c(5,i-1)*Qw(1)+c(5,i-1)*Qw(2)+c(5,i-1)*Qw(3));                                   
    F_inout(6)   = c(5,i-1)*Qw(1)- c(6,i-1)*Qw(1);
    for j=1:6
        c(j,i) = c(j,i-1)+dt/V(j)*F_inout(j);
    end
    if (max(abs((c(:,i)-c(:,i-1))/c(:,i-1)))<=eps)
        break;
    end
end
figure(1)
plot(1:2500,c(1,1:2500),'r','MarkerSize',14,'linewidth',2);
hold on;            
plot(1:2500,c(2,1:2500),'g','MarkerSize',14,'linewidth',2);
hold on;
plot(1:2500,c(3,1:2500),'b','MarkerSize',14,'linewidth',2);
hold on;
plot(1:2500,c(4,1:2500),'r-.','MarkerSize',14,'linewidth',2);
hold on;
plot(1:2500,c(5,1:2500),'g-.','MarkerSize',14,'linewidth',2);
hold on
plot(1:2500,c(6,1:2500),'b-.','MarkerSize',14,'linewidth',2);
xlim([1,2000]);
xlabel({'\fontsize{15} Time(year)'});
ylabel('\fontsize{15} PO4 concentration(mol/m^3)'); 
hleg=legend('Indo-Pacific(surface)','Southern Ocean(surface)','Atlantic(surface)','Indo-Pacific(deep)','Southern Ocean(deep)','Atlantic(deep)','Location','SouthEast');
set (hleg,'FontSize',11);
% title('PO4 concentration and evolution(Vary Q/10)')
title('PO4 Evolution (time series)')
set(gca,'FontSize',15)
print('-dpng','-r900','ocean_box1_1.png');
%--------------------------------------------------------------------
P_f = 1/117/dt;
 for i=1:3
SMS(i) = -P_f*area(i);
SMS(7-i) = P_f*area(i);
end  
cs(:,1)=c(:,1);
for i=2:imax
F_inout(1) =cs(6,i-1)*Qw(1)-cs(1,i-1)*Qw(1); %Flux,Indo-Pacific(surface)
F_inout(2) =(cs(1,i-1)*Qw(1)+cs(5,i-1)*Qw(2))-(cs(2,i-1)*Qw(1)+cs(2,i-1)*Qw(2));
%Flux,Southern Ocean(surface)
F_inout(3) = cs(2,i-1)*Qw(2)-cs(3,i-1)*Qw(2); %Flux,Atlantic(surface)
F_inout(4) =(cs(3,i-1)*Qw(2)+cs(5,i-1)*Qw(3))-(cs(4,i-1)*Qw(2)+cs(4,i-1)*Qw(3));
%Flux,Indo-Pacific(deep)
F_inout(5) =(cs(2,i-1)*Qw(1)+cs(4,i-1)*Qw(2)+cs(4,i-1)*Qw(3))-(cs(5,i-1)*Qw(1)+cs(5,i-1)*Qw(2)+cs(5,i-1)*Qw(3));
%Flux,Southern Ocean(deep)
F_inout(6) = cs(5,i-1)*Qw(1)-cs(6,i-1)*Qw(1); %Flux,Atlantic(deep)
for j=1:6
cs(j,i) = cs(j,i-1)+dt/V(j)*(F_inout(j)+SMS(j));
end
if (max(abs((cs(:,i)-cs(:,i-1))/cs(:,i-1)))<=eps)
break;
end
end
figure(2)
cdiff_s = c(3,:)-c(1,:);
cdiff_d = c(4,:)-c(6,:);
csdiff_s = cs(3,:)-cs(1,:);
csdiff_d = cs(4,:)-cs(6,:);
plot(1:2500,cdiff_s(1:2500),'b','MarkerSize',14,'linewidth',2);
hold on;
plot(1:2500,cdiff_d(1:2500),'r','MarkerSize',14,'linewidth',2);
hold on
plot(1:2500,csdiff_s(1:2500),'b--','MarkerSize',14,'linewidth',2);
hold on;
plot(1:2500,csdiff_d(1:2500),'r--','MarkerSize',14,'linewidth',2);
xlabel({'\fontsize{15} Time(year)'});
ylabel('\fontsize{15} PO4 concentration(mol/m^3)');
hleg=legend('surface no sms','deep no sms ','surface with sms','deep with sms','Location','SouthEast');
set (hleg,'FontSize',11);
title({'PO4-concentration difference between Atlantic and Indo-Pacific Oceans'})
set(gca,'FontSize',15);
       

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).