SUNTANS模型学习(3)——学习cylinder算例
學習cavity算例
- 簡介
- 網格配置
- 參數配置
- Input file for SUNTANS部分
- Grid Files部分
- Output Data Files和Input Data Files部分
- Use output to calculate Strouhal number部分
- 其余參數
- 模型運行
- 模擬結果
簡介
Cylinder Flow(圓柱繞流)是流體數值模型的經典算例。對于平面對稱布置的圓柱繞流工況,在理想狀態下,圓柱兩側繞流流線呈對稱狀。但隨著雷諾數的增大,圓柱上下游的流線會逐漸失去對稱性,而在圓柱后側的流場中產生卡門渦街。卡門渦街是流體力學中重要的現象,對于卡門渦街的模擬也常被用于模型檢驗。
在suntans模型代碼包中,內置有一圓柱繞流算例cylinder。模擬的配置文件位于 /examples/cylinder 文件夾中。在本算例中,模型預設了兩套網格配置(三角形網格、三角形和矩形混合的網格),以及垂向平均流動與三維流動的參數配置。模擬工況匯總如下:
| 1 | 三角形網格 | 二維淺水模擬 |
| 2 | 三角形網格 | 三維流動模擬 |
| 3 | 三角形、矩形混合網格 | 二維淺水模擬 |
| 4 | 三角形、矩形混合網格 | 三維流動模擬 |
通過模擬本算例,主要學習參數文件suntans.dat中各主要參數的設定及其物理含義。
網格配置
兩套網格配置如下圖所示(上圖為三角形網格,下圖為三角形、矩形混合網格):
其中的紅點為各個網格的Voronoi點。
如果模擬三維流動,則需要設定垂向網格配置。在本算例中,我們設定垂向網格總數為Nkmax=20;垂向網格上疏下密(垂向網格由suntans.dat文件中的rstretch參數控制,這個下一節中細講)。
參數配置
對于本算例,模型參數由suntans.dat文件給出;文件中的參數共包含以下5個部分:
Input file for SUNTANS部分
這是這個參數文件的主體部分,這里我們以三角形網格的三維流動模擬為例,看看各個控制參數。以下就是各參數,輸入方式為【參數名】+【空格】+【參數值】;#號后側的為注釋;即
variablename variablevalue # Description of variable以下是suntans.dat中第一部分的內容,在此附上中文說明:
Nkmax 20 # 最大的垂向網格數字,以此為例,垂向網格最多的地方有20層網格。 stairstep 0 # 該值可取1或0;1表示每層垂向網格間距在水平方向上不變,不過這也有可能導致某處最低網格底面低于實際深度;#0表示在底面附近網格使用partial-stepping,使單元的底面與深度的實際值相一致。 rstretch -1.05 # 垂向網格拉伸系數,取值范圍(-1.1, 1)或(1, 1.1);當 r<0,底部網格得到了加密,反之,則加密頂上的網格 CorrectVoronoi -1 # 關于是否啟用三角網格修正,包含兩種方法,即該值有兩個取值:1或-1。# 當取1時,對Voronoi點距離過近的網格進行校正;當取-1時,將鈍角三角形的Voronoi點移動到它的形心。 VoronoiRatio 0 # Voronoi點的校正因子。當不啟用CorrectVoronoi時,該值取0;# 當CorrectVoronoi=1,該值取[0,1];當CorrectVoronoi=-1,該值取角度[0,90];(詳見手冊) vertgridcorrect 0 # 對最小水深D_min<Δz的情況進行校正;當該值為1,遇此情況時有Δz=D_min,從而使Nkmax = D_max /D_min IntDepth 0 # 如果取1,Voronoi點的水深由depth文件給出(空間插值);否則,水深在initialization.c中設定。 dzsmall 0.1 # 校正前網格最小間距比【這個參數不再使用,不必設置】 scaledepth 0 # 對水深的縮放(一般用于測試);當取值為1,則該功能啟動 scaledepthfactor 0 # 水深縮放比例因子,在scaledepth=1的時候生效 thetaramptime 1 # ramp time(詳見手冊),給初始化時一個緩慢的物理量變化過程,來抑制瞬態的正壓效應;在本例子中,該值取1s。 beta 0 # 鹽度擴散系數(本例中取0) theta 0.55 # 控制時間數值積分的顯式/隱式/半隱式的系數(對于水動力控制方程) # θ = 0: 顯式(不穩定);θ = 0.5: Crank-Nicolson ;θ = 1.0: 隱式;θ = 0.55: 常用設置。 thetaS 0.55 # 控制時間數值積分格式的系數(對于對流-擴散方程) thetaB 0.55 # 【不再使用的參數】 kappa_s 0 # 鹽度的垂直擴散系數 kappa_sH 0 # 鹽度的水平擴散系數(詳見手冊) gamma 1 # 溫度的擴散系數 kappa_T 0 # 溫度的垂直擴散系數 kappa_TH 0 # 溫度的水平擴散系數(詳見手冊) nu 5e-4 # 水的垂直方向粘度 (m^2 s^-1) (對于層流) nu_H 5e-4 # 水的水平方向粘度 (m^2 s^-1) (對于層流) tau_T 0 # 風應力 z0T 0.0 # 水面邊界的粗糙度 (單位:m),用于計算CdT z0B 0.0 # 底面邊界的粗糙度 (單位:m),用于計算CdB CdT 0.0 # 如果z0T=0,則頂部的阻力系數由這個常數給出;否則,這個參數不生效。如果用free-slip條件,則取-1。 CdB -1 # 如果z0B=0,則頂部的阻力系數由這個常數給出;否則,這個參數不生效。如果用free-slip條件,則取-1。 CdW 0.0 # 側向邊界阻力系數;只有當壁面沒有延伸到自由表面時,才計算側壁上的阻力(例如漫灘情況下,不計算側向阻力) turbmodel 0 # 紊流模型 (0 - 不使用, 1 - MY25) AB 3 # Adam-Bashforth法的階數(2或3,對應2階或3階A-B方法) dt 2.5e-3 # 時間步長 grav 9.81e10 # 重力加速度(默認為9.81,此算例中采用了一個較大值以控制雷諾數) Cmax 1 # Courant數的最大允許值 nsteps 1600 # 時間步總數 ntout 80 # 輸出文件的步頻,此處表示每80個dt輸出一次 ntprog 5 # 報告運算進度的頻率 (%) ntconserve 1 # 輸出 conserved data 的步頻(例如質量、體積、勢能等),詳見phys.c中函數OutputData nonhydrostatic 1 # 0 - 應用靜水壓假定, 1 = 非靜壓模擬 cgsolver 1 # 線性方程組的求解方法 0 = GS, 1 = CG 【這個參數已不再使用】 maxiters 1000 # CG 法(共軛梯度法)迭代的最大次數 qmaxiters 2000 # CG 法迭代的最大次數 (泊松方程) qprecond 2 # 是否對泊松方程進行預處理(0 - 不處理;1 - Diagonal預處理;2 - Block-diagonal預處理) epsilon 1e-10 # CG法中收斂性判別所允許的最小值 qepsilon 1e-5 # CG法中收斂性判別所允許的最小值(壓力泊松方程) resnorm 0 # 在計算CG求解器的公差準則時是否對殘差進行歸一化(0和1對應了不同的誤差形式) relax 1 # CG求解器的松弛系數 amp 0.8 # 用于指定boundaries.c中的參數prop->amp (振幅) omega 0 # 用于指定boundaries.c中的參數prop->omega (圓頻率) flux 0 # 用于指定boundaries.c中的參數prop->flux (通量或流量) timescale 0 # 用于指定boundaries.c中的參數prop->timescale(應用于開邊界的時間尺度) volcheck 0 # 是否檢查體積守恒(0-不檢查;1-檢查) masscheck 0 # 是否檢查質量守恒(0-不檢查;1-檢查) interp 1 # 插值方法(0-經典Perot方法;1-二次插值) nonlinear 2 # 動量方程對流項格式(0-無對流;1-迎風格式;2-中心差分格式) laxWendroff 0 # Lax Wendroff擴散系數(0-不應用Lax Wendroff法;1-當nonlinear=2時,渦粘系數通過Lax Wendroff法給出) newcells 0 # 1 if adjust momentum in surface cells as the volume changes, 0 otherwise wetdry 0 # 是否采用干-濕網格設置 (1-使用, 0-不使用) Coriolis_f 0 # 科氏力參數 f=2*Omega*sin(phi) sponge_distance 0 # 海綿邊界層衰減距離(詳見phys.c) sponge_decay 0 # 海綿邊界層衰減時間系數 readSalinity 0 # 0-垂直鹽度分布在initilization.c中設定;1-從InitSalinityFile中讀取垂直鹽度分布,文件必須為二進制格式,且必須按照從上到下的順序包含N_kmax個雙精度值。 readTemperature 0 # 與readSalinity類似,當取1時,從InitTemperatureFile中讀取垂直溫度分布Grid Files部分
網格文件均是ASCII的二進制文件。suntans.dat文件中需要設定它們的文件名。
pslg full_circle.dat # 平面直線圖形文件;詳見手冊第3章。 (input) 【本例中不采用】 points points.dat # 網格節點文件 (input) edges edges.dat # 網格邊配置文件 (input) cells cells.dat # 網格連接關系文件 (input) depth depth.dat # 水深文件 (若INTERPDEPTH=1,則應用該文件) (input) nodes nodes.dat # 節點的拓撲關系 (output) celldata celldata.dat # 每個線程的網格中心數據 (output) edgedata edgedata.dat # 每個線程的網格邊界數據t (output) vertspace vertspace.dat # 垂向網格間距 (output) topology topology.dat # 每個線程的網格拓撲關系各個文件的格式詳見手冊第7章。
Output Data Files和Input Data Files部分
######################################################################## # Output Data Files ######################################################################## FreeSurfaceFile fs.dat #自由水面高程 HorizontalVelocityFile u.dat #水平流速 VerticalVelocityFile w.dat #垂向流速 SalinityFile s.dat #鹽度場數據 BGSalinityFile s0.dat # TemperatureFile T.dat #溫度 PressureFile q.dat #動水壓力 VerticalGridFile g.dat #垂向網格 ConserveFile e.dat #守恒性檢查 ProgressFile step.dat #模擬進度 StoreFile store.dat #保存數據,用于熱啟動的文件 StartFile start.dat #用于熱啟動的文件 EddyViscosityFile nut.dat #渦粘系數 ScalarDiffusivityFile kappat.dat #標量擴散系數 ######################################################################## # Input Data Files 【本例中不采用】 ######################################################################## InitSalinityFile sinit.dat #初始鹽度場 InitTemperatureFile Tinit.dat #初始溫度場Use output to calculate Strouhal number部分
ProfileVariables u # 輸出的變量值 DataLocations dataxy.dat # 變量所在位置的x,y坐標 ProfileDataFile profdata.dat # 垂向剖面信息 ntoutProfs 10 # 每次輸出配置文件數據所間隔的時間步;此處含義為每10個時間步輸出配置文件數據 NkmaxProfs 1 # 輸出文件的最頂層 numInterpPoints 1 # 是否”僅輸出最鄰近的點“注:這個部分在手冊中也并未詳細描述;在此先略過。
其余參數
在目錄/examples/cylinder下輸入以下指令以運行三角形網格淺水流動:
make test指令框中將會顯示一些參數未被設定,但模型運行時自動采用了其默認值。詳細信息如下:
Warning in MPI_GetValue...retrieved default value of maxFaces=3.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of ntoutStore=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of TVDsalt=4.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of TVDtemp=4.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of TVDturb=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of TVDmomentum=3.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of conserveMomentum=1.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of thetaM=-1.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of mergeArrays=1.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of computeSediments=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of calcage=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of agemethod=1.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of calcaverage=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of latitude=29.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of gmtoffset=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of metmodel=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of varmodel=1.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of nugget=0.10 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of sill=0.90 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of range=100000.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of outputNetcdf=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of netcdfBdy=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of readinitialnc=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of Lsw=2.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of Cda=1100.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of Ce=1400.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of Ch=1400.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of hprecond=1.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of prettyplot=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of linearFS=0.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of fixdzz=1.00 which was not specified in data/suntans.dat. Warning in MPI_GetValue...retrieved default value of smoothbot=0.00 which was not specified in data/suntans.dat.這里面的參數包括:
maxFaces=3.00 # 網格的最大邊界數,默認應用三角形網格,故取3 ntoutStore=0.00 # TVDsalt=4.00 # 求解鹽度控制方程所選用的TVD格式 TVDtemp=4.00 # 求解溫度控制方程所選用的TVD格式 TVDturb=0.00 # 求解紊流模型控制方程所選用的TVD格式 TVDmomentum=3.00 # 求解動量方程所選用的TVD格式 conserveMomentum=1.00 # 是否進行動量的守恒性檢查 thetaM=-1.00 # 求解動量方程所選用的TVD格式 mergeArrays=1.00 # 求解垂向對流項的格式;當大于0.5表示隱式,當等于-1表示在UPredictor()中使用了原來的保守方案 computeSediments=0.00 # 是否求解泥沙模塊 calcage=0.00 # 是否模擬水齡 agemethod=1.00 # 水齡模擬的方式 1-使用河流邊界,2-使用內部源項 calcaverage=0.00 # 是否計算平均水齡##以下幾個參數用于熱量和太陽輻射模塊## latitude=29.00 # 緯度,在計算太陽輻射時候使用 gmtoffset=0.00 # 用于修正太陽輻射的參數 metmodel=0.00 # 關于太陽輻射熱量模型 0-無氣象數據輸入,1-COARE3.0,計算輻射短波和長波 varmodel=1.00 # 太陽輻射模型中所用插值方法 0-反距離比例插值,2-克里金法 nugget=0.10 # 克里金插值中所需給定的參數 sill=0.90 # 克里金插值中所需給定的參數 range=100000.00 # 變差函數參數范圍 outputNetcdf=0.00 # 輸出文件格式 0-二進制格式,1-netcdf格式 netcdfBdy=0.00 # netcdf文件的輸出步頻 readinitialnc=0.00 # 是否采用netcdf格式的初始條件 Lsw=2.00 # Light extinction depth (m) Cda=1100.00 # 阻力系數 Ce=1400.00 # 傳熱系數 Ch=1400.00 # 傳熱系數 ##########################hprecond=1.00 # 對于自由水面方程求解食肉采用預處理求解器 0-不使用,1-Jacobi預處理求解器 prettyplot=0.00 # 是否使用二次插值得出的輸出值,若為1則使用;否則,請指定 linearFS=0.00 # 對自由水面求解是否采用線性方法 fixdzz=1.00 # 對底網格高度的處理 0-不調整,1-假設底部單元高度必須大于dzsmall*dz[Nkmax-1],2-假設底部單元高度必須大于dzsmall smoothbot=0.00 # 在SetFluxHeight和ComputeVelocityVector中是否進行平滑處理模型運行
考慮到有四個模擬工況,模型代碼中預載了下面四個指令來分別運行。
注意:在每次模擬前,記得先使用make clobber取消編譯;之后再使用上述指令進行編譯+運行;運行結果生成在 /examples/cylinder/data中。
還需要注意的是使用make clobber會自動刪除 /examples/cylinder/data 這個目錄的文件夾(刪除掉這個data文件夾),所以每次運行的結果記得先存好。
模擬結果
由上一節的內容可知,模型的時間步長dt=2.5e-3s,共運行1600步;ntout=80,故每個文件包含了 1+floor(Nsteps/Ntout) = 21個時間步的流場信息。
利用代碼包/mfiles文件夾下的getcdata.m讀取二進制文件,可以獲得每一時間步及每個網格的流場數據,使用getcdata函數的示例參考SUNTANS模型學習(2)——用MATLAB工具提取Time Accuracy算例的計算數據。
以下展示二維淺水模擬結果中形成的卡門渦街(水平流速云圖,T = 1600*dt):
總結
以上是生活随笔為你收集整理的SUNTANS模型学习(3)——学习cylinder算例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python_dya02_基础运算符
- 下一篇: 鞋业ERP系统