-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.m
118 lines (104 loc) · 3.62 KB
/
example.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
% DESCRIPTION:
% Generate FVCOM 3.x format input files based on a ADCIRC grad file and
% spicific open obundary elevation
%
% OUTPUT:
% FVCOM input files: (casename='test')
% ./
% 念岸岸 test_cor.dat
% 念岸岸 test_dep.dat
% 念岸岸 test_grd.dat
% 念岸岸 test_obc.dat
% 念岸岸 test_obc.nc
% 念岸岸 test_river.nc
% 念岸岸 test_sigma.dat
% 念岸岸 test_spg.dat
% 弩岸岸 test_tsobc.nc
%
% EXAMPLE USAGE
%
% Author(s):
% li12242 (Tianjin University)
%
%==============================================================================
global ftbverbose
ftbverbose = true;
%================================================%
casename = 'test';
filepath = '/Users/mac/Documents/Model/FVCOM/FVCOM3.2.1/Examples/IdealEstuary2';
inDir = [filepath, '/map/map/'];
outDir = [filepath, '/inp'];
%% mesh
import FVCOM.Mesh.*
Mobj = read_ADCIRC_cartesian_mesh([inDir, 'IdealEstuary.grd']);
import FVCOM.PreProcess.*
% write cor.dat file
write_FVCOM_bath(Mobj,casename)
% write grd.dat file
write_FVCOM_grid(Mobj,casename)
% write obc.dat file
write_FVCOM_obc(Mobj,casename)
% write dep.dat file
write_FVCOM_depth(Mobj,casename)
%% show map
FVCOM.PostProcess.draw_map(Mobj)
hold on;
plot(Mobj.x(Mobj.obc_nodes{1}), Mobj.y(Mobj.obc_nodes{1}), 'ro') % plot boundary
%% open boundary
startTimeStr = '2014-01-01 00:00:00'; endTimeStr = '2014-01-03 10:00:00';
interval = 1./2./24; % days
timeSer = FVCOM.Time.get_julian_time(startTimeStr, endTimeStr, interval);
Mobj.surfaceElevation = set_elevtide(Mobj, timeSer, @functional_elev);
MJD = timeSer;
% write obc.nc file
write_FVCOM_elevtide(Mobj,MJD,casename,casename)
%% sponge file
% write sponge propertity into Mobj
SpongeCoeff = 0.001;
% assume the boundary node number is [1:Mobj.nObcNodes]
[spongeRadius] = calc_sponge_radius(Mobj,1:Mobj.nObcNodes);
SpongeName = 'spong1';
[Mobj] = add_sponge_nodes_list(Mobj,1:Mobj.nObcNodes,SpongeName,spongeRadius,SpongeCoeff);
% write spg.dat file
write_FVCOM_sponge(Mobj,casename)
%% sigma layer
Mobj.nSiglay = 10; Mobj.sigType = 'Uniform';
write_FVCOM_sigma(casename, Mobj.sigType, Mobj.nSiglay+1)
%% ts obc file
in_temp = 26; in_salt = 33;
write_FVCOM_tsobc(casename,MJD,Mobj.nSiglay,in_temp,in_salt,Mobj)
%% river file
nTimes = numel(timeSer);
totalFlux = ones(1, nTimes); totalFlux(:) = 625; % m3/s
node_id = 1893:1897; % river nodes
temp = 26*ones(nTimes,1);
salt = 10*ones(nTimes,1);
RiverFile = [casename,'_river.nc'];
nRivnodes = numel(node_id);
RiverInfo1 = 'idealized estuary river';
RiverInfo2 = 'event profile';
RiverName = 'tstRiver';
write_FVCOM_river(RiverFile,RiverName,nRivnodes,MJD,totalFlux,temp,salt,...
RiverInfo1,RiverInfo2)
River_vertical_distribution = zeros(1, Mobj.nSiglay);
River_vertical_distribution(:) = 1./Mobj.nSiglay;
RiverNameList = 'tstRiver_namelist.nml';
write_FVCOM_riverNameList(RiverNameList, RiverFile, RiverName, node_id,...
River_vertical_distribution)
%% move file
movefile([pwd,'/',casename,'_cor.dat'],outDir);
movefile([pwd,'/',casename,'_grd.dat'],outDir);
movefile([pwd,'/',casename,'_obc.dat'],outDir);
movefile([pwd,'/',casename,'_spg.dat'],outDir);
movefile([pwd,'/',casename,'_dep.dat'],outDir);
movefile([pwd,'/',casename,'_obc.nc'],outDir);
movefile([pwd,'/',casename,'_sigma.dat'],outDir);
movefile([pwd,'/',casename,'_tsobc.nc'],outDir);
movefile([pwd,'/',casename,'_river.nc'],outDir);
movefile([pwd,'/',RiverNameList],outDir);
%================================================%
% estimate the out mode time
%================================================%
zeta = max(max(abs(Mobj.surfaceElevation))); u =0.1;
[Mobj] = estimate_ts(Mobj,u,zeta);
%================================================%