setrun.py Memorandums †
特に重要な変数を書き出してみる.
clawdata †
- clawdata.lower (list of float)
計算領域の端点の設定.
clawdata.lower[0] は西端の x (または lon),
clawdata.lower[1] は南端の y (または lat).
- clawdata.upper (list of float)
計算領域の端点の設定.
clawdata.upper[0] は東端の x (または lon),
clawdata.upper[1] は北端の y (または lat).
- clawdata.num_cells (list of int)
- clawdata.capa_index (int)
直交座標系か緯度経度かで異なる.
example を見ると直交座標系のときは 0 で緯度経度の時は 2.
amrdata.aux_type も参照.
- clawdata.bc_lower, clawdata.bc_upper
境界条件の設定.
名前とリストが意味するものはそれぞれ以下の通り.
# Choice of BCs at xlower and xupper:
# 0 => user specified (must modify bcN.f to use this option)
# 1 => extrapolation (non-reflecting outflow)
# 2 => periodic (must specify this at both boundaries)
# 3 => solid wall for systems where q(2) is normal velocity
clawdata.bc_lower[0] = 'extrap' # Western, x-direction
clawdata.bc_upper[0] = 'extrap' # Eastern, x-direction
clawdata.bc_lower[1] = 'extrap' # Southern, y-direction
clawdata.bc_upper[1] = 'extrap' # Northern, y-direction
入力値は数値でもテキストでもOKで,以下のように対応している.
1 <-> "extrap"
2 <-> "periodic"
3 <-> "wall"
- clawdata.t0 (float)
計算開始時の時刻設定.
基本的には 0.0 で良いが,storm-surge の計算でハリケーン上陸時刻を 0.0 という基準にすると,計算開始時の時刻はマイナスになる.
ike の examples を参照.
- clawdata.tfinal (float)
計算終了時刻.ただし,下にある clawdata.output_times の方が優先される.
リストで指定した clawdata.output_times の最後の出力時刻が clawdata.tfinal より早ければ,clawdata.output_times の最後の時刻をもって計算が終わる.
- clawdata.output_t0 (boolean)
True なら計算開始時のファイルを出力する.
- clawdata.output_step_interval (int)
出力の回数や時刻を指定するのではなく,出力するステップ数を指定する.
AMR では相性がよろしくなくあまり使わないような気がする(debug 時には便利).
# Output every iout timesteps with a total of ntot time steps:
clawdata.output_step_interval = 1
上記の3つの変数
clawdata.num_output_times (int)
clawdata.output_times (list of float)
clawdata.output_step_interval (int)
はいずれか一つを指定すればよい.重複しないように.
amrdata †
- amrdata.amr_levels_max
分割するレベルの数.Level 1 を一番粗いレベルとして,Level 4 までの 4種類のメッシュサイズとする場合は 4 を入れる.
- amrdata.refinement_ratios_x
Level k から Level k+1 となる時の, x 方向のメッシュサイズの比.\( \frac{\Delta x_{k+1}}{\Delta x_{k}} \)のこと.
したがって,Level 1 から 4 まである場合は 3要素のリストになる.
\( \frac{\Delta x_{2}}{\Delta x_{1}}, ~ \frac{\Delta x_{3}}{\Delta x_{2}}, ~ \frac{\Delta x_{4}}{\Delta x_{3}}, ~ \dots \) の順番で書く.
- amrdata.refinement_ratios_y
上に同じで,y 方向のレベル間のメッシュサイズ比. \( \frac{\Delta y_{k+1}}{\Delta y_{k}} \)のこと.
- amrdata.refinement_ratios_t
上に同じで,\( \frac{\Delta t_{k+1}}{\Delta t_{k}} \)のこと.
クーラン数を考慮すると,一般的には上の2変数と同一の値にするのが無難.
例えば 2430m → 810m → 270m → 90m という分割をしたい場合は以下のようになる.
# ---------------
# AMR parameters:
# ---------------
amrdata = rundata.amrdata
# max number of refinement levels:
amrdata.amr_levels_max = 4
# List of refinement ratios at each level (length at least mxnest-1)
amrdata.refinement_ratios_x = [3,3,3]
amrdata.refinement_ratios_y = [3,3,3]
amrdata.refinement_ratios_t = [3,3,3]
- amrdata.aux_type
リストの要素の数は clawdata.num_aux の値と一致している必要がある.
# Specify type of each aux variable in amrdata.auxtype.
# This must be a list of length maux, each element of which is one of:
# 'center', 'capacity', 'xleft', or 'yleft' (see documentation).
amrdata.aux_type = ['center','center','yleft'] # if x,y-coordinates
#amrdata.aux_type = ['center','capacity','yleft'] # if lonlat
geo_data †
topo_data †
- topo_data.topofiles (list of lists)
# topotype: format style
# fname: filename of the topography
topo_data.topofiles.append([topotype, minlevel, maxlevel, t1, t2, fname])
topotype=2 は header 6行,7行目から (my*mx)行 1列で配列したファイル形式.
topotype=3 は header 6行,7行目から my行 mx列.
1は古い形式らしく,4は NetCDF.
dtopo の topotype も同じ.
dtopo_data †
- dtopo_data.dtopofiles (list of lists)
# topotype: format style
# fname: filename of the topography
dtopo_data.dtopofiles.append([topotype, minlevel, maxlevel, fname])
- dtopo_data.dt_max_dtopo (float)
dtopo の input をしている間の dt の最大値.通常の clawdata.dt_max とは別で指定できる.
dtopo によって地形が変化している間,時間刻みの最大は dtopo_data.dt_max_dtopo と clawdata.dt_max の小さい方を優先する.
dtopo_data.dt_max_dtopo = 0.5
region †
topo を複数入力してそれぞれの範囲内で解像度の制限をかけたかったら.
# ---------------
# Regions:
# ---------------
regions = rundata.regiondata.regions
# to specify regions of refinement append lines of the form
# [minlevel,maxlevel,t1,t2,x1,x2,y1,y2]
## Level 1
regions.append([1, 1, clawdata.t0, clawdata.tfinal, clawdata.lower[0], clawdata.upper[0], clawdata.lower[1], clawdata.upper[1]])
## Level 2+
topo_file = topotools.Topography('topofile.asc', topo_type=3)
regions.append([1, 2, clawdata.t0, clawdata.tfinal, topo_file.x[0], topo_file.x[-1], topo_file.y[0], topo_file.y[-1]])
gauge †
時系列データ出力地点指定.
setrun.py の中で地点指定をすると,数が増えたり変更のときに煩雑になる.
事前に地点を入れた外部ファイルを用意しておいて,そのファイルを setrun.py の中で読ませるのが管理上健全.
# ---------------
# Gauges:
# ---------------
gauges = rundata.gaugedata.gauges
# for gauges append lines of the form [gaugeno, x, y, t1, t2]
dat = np.genfromtxt('gaugesetfile.txt', delimiter=',', skip_header=0, dtype='float')
[gauges.append(dat[i]) for i in range(0,dat.shape[0])]
fgmax †
topo ファイルごとに fgmax (fixed_grid max) を出したければ.
fgmax_files = rundata.fgmax_data.fgmax_files
# == fgmax.data values ==
# Domain 1
topo_file = topotools.Topography('topofile.asc', topo_type=3)
fg = fgmax_tools.FGmaxGrid()
fg.point_style = 2 # uniform rectangular x-y grid
fg.dx = topo_file.delta[0] # desired resolution of fgmax grid
fg.x1 = topo_file.x[0]
fg.x2 = topo_file.x[-1]
fg.y1 = topo_file.y[0]
fg.y2 = topo_file.y[-1]
fg.min_level_check = 1 # which levels to monitor max on
fg.arrival_tol = 1.0e-1
fg.tstart_max = 0.0 # just before wave arrives
fg.tend_max = 1.e10 # when to stop monitoring max values
fg.dt_check = 1.0 # how often to update max values
fg.interp_method = 0 # 0 ==> pw const in cells, recommended
rundata.fgmax_data.fgmax_grids.append(fg) # written to fgmax_grids.data
rundata.fgmax_data.num_fgmax_val = 5
fixed_grids †
Topo ファイルをもとに固定グリッド出力をするときに使う.
# == setfixedgrids.data values ==
fixedgrids = rundata.fixed_grid_data.fixedgrids
# for fixed grids append lines of the form
# [t1,t2,noutput,x1,x2,y1,y2,xpoints,ypoints,\
# ioutarrivaltimes,ioutsurfacemax]
topo_file = topotools.Topography(os.path.join(topodir, 'fileA.asc'))
fixedgrids.append([0.0, 21600.0, 361, topo_file.x[0], topo_file.x[-1], topo_file.y[0], topo_file.y[-1], topo_file.Z.shape[1], topo_file.Z.shape[0], 0, 0])
topo_file = topotools.Topography(os.path.join(topodir, 'fileB.asc'))
fixedgrids.append([0.0, 21600.0, 361, topo_file.x[0], topo_file.x[-1], topo_file.y[0], topo_file.y[-1], topo_file.Z.shape[1], topo_file.Z.shape[0], 0, 0])
この場合では t1,t2,noutput がそれぞれ 0.0, 21600.0,361 となっているので,
ファイル出力間隔が 60 秒,計 361 回(0〜6 時間)の出力になる.
当然 AMR のパッチ出力より容量が大きくなるので注意.