1 |
% This is a matlab script that generates the input data |
2 |
% variable x resolution |
3 |
prec='real*8'; |
4 |
ieee='b'; |
5 |
|
6 |
% Dimensions of grid |
7 |
%nx=50; |
8 |
nx=200; |
9 |
ny=45; |
10 |
nz=25; |
11 |
% Nominal depth of model (meters) |
12 |
H=3600.0; |
13 |
% Size of domain |
14 |
Ly=600.0e3; |
15 |
%Lx=500.0e3; |
16 |
Lx=2000.0e3; |
17 |
|
18 |
% Horizontal resolution (m) |
19 |
|
20 |
dx=zeros(nx,1); |
21 |
for i=1:nx |
22 |
dx(i) = Lx/(nx); |
23 |
end |
24 |
|
25 |
dy=zeros(ny,1); |
26 |
%for i=1:ny |
27 |
%dy(i) = Ly/(ny); |
28 |
%end |
29 |
|
30 |
% y-resolution ramps from 10km to 40km in southern basin: |
31 |
y = [0:600]; |
32 |
y0 = 420; yw = 40; r1 = 10; r2 = 40; |
33 |
dy = (r1+r2)/2 - (r1-r2)/2*tanh((y-y0)/yw); |
34 |
|
35 |
yg = 0; ii = 1; dely = dy(1); |
36 |
while yg(ii)<=max(y)-dely, |
37 |
dely = interp1(y,dy,yg(ii)); |
38 |
yg(ii+1) = yg(ii) + dely; |
39 |
ii = ii+1; |
40 |
end |
41 |
yg(ii) = max(y); |
42 |
|
43 |
%plot(yg,mean(dy),'b+'); hold on; |
44 |
%plot(0.5*(yg(1:end-1)+yg(2:end)),diff(yg),'rx-'); |
45 |
%plot(y,dy,'c.-'); grid on |
46 |
%pause |
47 |
dy = fliplr(diff(yg)*1e3); |
48 |
|
49 |
dz=zeros(nz,1); |
50 |
for i=1:nz |
51 |
dz(i)=H/nz; |
52 |
end |
53 |
%sprintf('delZ = %d * %7.6g,',nz,dz) |
54 |
|
55 |
z=zeros(nz,1); |
56 |
z(1) = -dz(1)/2.0; |
57 |
for i=2:nz |
58 |
z(i)=z(i-1) - dz(i); |
59 |
end |
60 |
|
61 |
% Stratification |
62 |
gravity=9.81; |
63 |
talpha=2.0e-4; |
64 |
rho0=1030.0; |
65 |
rhotop=1030.0; |
66 |
%rhobot=1030.0; |
67 |
rhobot=1032.0; |
68 |
|
69 |
%gravity=10; |
70 |
%talpha=1.0e-4; |
71 |
%rho0=1000.0; |
72 |
%rhotop=1000.0; |
73 |
%rhobot=1000.0; |
74 |
N2=((rhobot-rhotop)/H)/rho0*gravity |
75 |
Tz=N2/(gravity*talpha) ; |
76 |
|
77 |
% Temperature profile. tRef is a single reference temperature, Tbg is |
78 |
% a background profile, t is a three-dimensional initial stratification. |
79 |
tRef = 0; |
80 |
%Tref=Tz*(z+H) + (rhobot-rho0)/(rho0*talpha) + 1.0; |
81 |
%Tref=Tz*(z+H) + (rhobot-rho0)/(rho0*talpha) |
82 |
Tbg =Tz*(z+H) - (rhobot-rho0)/(rho0*talpha) + tRef; |
83 |
[sprintf('Tref =') sprintf(' %8.6g,',Tbg)] |
84 |
%t=0.00001*rand([nx,ny,nz]); |
85 |
t=0*rand([nx,ny,nz]); |
86 |
for k=1:nz |
87 |
t(:,:,k) = t(:,:,k) + Tbg(k); |
88 |
end |
89 |
fid=fopen('T.init','w',ieee); fwrite(fid,t,prec); fclose(fid); |
90 |
|
91 |
% this could be done more elegantly... |
92 |
x=zeros(nx,1); |
93 |
x(1) = 0.5*dx(1); % center of grid cell |
94 |
for i=2:nx |
95 |
x(i)=x(i-1) + 0.5*dx(i-1) + 0.5*dx(i); |
96 |
end |
97 |
|
98 |
y=zeros(ny,1); |
99 |
y(1) = dy(1); % north edge of grid cell |
100 |
for i=2:ny |
101 |
y(i) = y(i-1) + dy(i); |
102 |
end |
103 |
|
104 |
% Linear slope and embayment |
105 |
slope = 0.01; |
106 |
%slope = 0.005; |
107 |
lembay=50.0e3; % length of embayment |
108 |
eastwall = 1; % make a wall on the eastern boundary |
109 |
westwall = 0; % make a wall on the western boundary |
110 |
|
111 |
% These three parameters should match with Width, Dmax and Xcenter |
112 |
% (respectively) in data.obcs or else funny stuff will happen... |
113 |
wembay=100.0e3; % width of embayment |
114 |
dembay=600.0; % depth of embayment |
115 |
embay_ctr=1700.0e3; % x-coordinate of embayment center |
116 |
|
117 |
%xembay=Lx-150.0e3-wembay; %x location of start of embayment |
118 |
xembay=embay_ctr-wembay/2; |
119 |
d=0.0*rand([nx,ny]); |
120 |
for i=1:nx |
121 |
d(:,1) = 0.0; |
122 |
for j=2:ny |
123 |
yneg=Ly-y(j); |
124 |
if yneg < lembay |
125 |
if x(i) > xembay |
126 |
if x(i) < xembay+wembay |
127 |
d(i,j) = -dembay; |
128 |
else |
129 |
d(i,j) = 0.0; |
130 |
end |
131 |
else |
132 |
d(i,j) = 0.0; |
133 |
end |
134 |
else |
135 |
d(i,j) = -slope*(yneg - lembay) - dembay; |
136 |
end |
137 |
if d(i,j) < -H |
138 |
d(i,j) = -H; |
139 |
end |
140 |
end |
141 |
end |
142 |
if eastwall |
143 |
d(nx,:) = 0.0; % east wall |
144 |
end |
145 |
if westwall |
146 |
d(1,:) = 0.0; % west wall |
147 |
end |
148 |
fid=fopen('topog.slope','w',ieee); fwrite(fid,d,prec); fclose(fid); |
149 |
hold off; |
150 |
plot(x,d(:,2),'.-'); grid on |
151 |
%plot(y,d(2,:),'.-'); grid on |
152 |
|
153 |
%fid=fopen('delXvar','w',ieee); fwrite(fid,dx,prec); fclose(fid); |
154 |
fid=fopen('delYvar','w',ieee); fwrite(fid,dy,prec); fclose(fid); |