吳立明
(遷安市水利局,河北 遷安 064400)
Delphi是一種優(yōu)秀的軟件開發(fā)工具,它具有可視化、簡潔明快、組件可擴展等特點?!奥斆鞯某绦騿T用Delphi”是業(yè)界廣為人知的名言。使用Delphi開發(fā)軟件能大大提高軟件的開發(fā)效率。
Delphi的可視化開發(fā)環(huán)境IDE提供了大量的組件,這使得用戶無需在編寫界面時編寫大量代碼,只需將相應(yīng)的控件添加到界面窗體上,調(diào)整其大小、位置即可。同時,程序的各種屬性設(shè)置、代碼編寫、調(diào)試、運行及生成可執(zhí)行文件等都可以在一個開發(fā)環(huán)境中進(jìn)行,軟件開發(fā)效率非常高效。
面向?qū)ο驩OP是Delphi誕生的基礎(chǔ),它支持封裝,且具有繼承性和多態(tài)性。這使得Delphi具有了真正的面向?qū)ο蟮奶攸c。
Y=R+e+A
(1)
式(1)中:Y—堤頂超高(m);R—設(shè)計波浪爬高(m);e—設(shè)計風(fēng)壅增水高度(m);A—安全加高(m)。
堤防工程的安全加高值根據(jù)規(guī)范確定。1級堤防工程的安全加高,經(jīng)過論證可適當(dāng)加大但≤1.50 m。山區(qū)河流洪水歷時較短時,可適當(dāng)降低安全加高。
計算設(shè)計波浪爬高,需先按下式計算相關(guān)波浪要素:
(2)
(3)
(4)
(5)
(6)
③當(dāng)斜坡坡率1.00 風(fēng)壅水面高度按下式計算: (7) 式(7)中:e—計算點的風(fēng)壅水面高度(m),K—綜合摩阻系數(shù),采用《碾壓式土石壩設(shè)計規(guī)范》的K值,即K=3.6×10-6,β—風(fēng)向與垂直于堤軸線的法線的夾角(度)。 通過在設(shè)計窗口中添加Edit、Button、ComboBox、Label、GroupBox等控件,設(shè)計出軟件界面。 2.6.1 計算平均波高函數(shù) function CalcT(V,g,H:Extended):Extended; begin Result:=13.9*power(g*H/(V*V),0.5)*V/g; end; 2.6.2 計算波長函數(shù) function CalcL(g,T,d:real):real; var L:real; begin L:=g*T*T/(2*pi)*TANH(2*pi*d/L); Result:=L; end; 2.6.3 計算經(jīng)驗系數(shù)Kv函數(shù) function CalcKv(V,g,dq,Kv:real):real; var Dlessquty:real; begin Dlessquty:=V/sqrt(g*dq); if Dlessquty<=1 then Kv:=1 else if Dlessquty>=5 then Kv:=1.30 else if Dlessquty=1.5 then Kv:=1.02 else if Dlessquty=2 then Kv:=1.08 else if Dlessquty=2.5 then Kv:=1.16 else if Dlessquty=3 then Kv:=1.22 else if Dlessquty=3.5 then Kv:=1.25 else if Dlessquty=4 then Kv:=1.28 else begin if(Dlessquty>1.5) and (Dlessquty<2) then Kv:=(1.08-1.02)*(Dlessquty-1.5)/(2-1.5)+1.02; if(Dlessquty>2) and (Dlessquty<2.5) then Kv:=(1.16-1.08)*(Dlessquty-2)/(2.5-2)+1.08; if(Dlessquty>2.5) and (Dlessquty<3) then Kv:=(1.22-1.16)*(Dlessquty-2.5)/(3-2.5)+1.16; if(Dlessquty>3) and (Dlessquty<3.5) then Kv:=(1.25-1.22)*(Dlessquty-3)/(3.5-3)+1.22; if(Dlessquty>3.5) and (Dlessquty<4) then Kv:=(1.28-1.25)*(Dlessquty-3.5)/(4-3.5)+1.25; if(Dlessquty>4) and (Dlessquty<5) then Kv:=(1.30-1.28)*(Dlessquty-4)/(5-4)+1.28; end; Result:=Kv; end; 2.6.4 計算波浪爬高函數(shù) function CalcR(H,d,L,P,Rp,KΔ,Kv,m:real):real; var Dlessquty:real; Kp,R0,y1,y2:real; begin Dlessquty:=H/d; if Dlessquty<0.1 then begin if p=0.1 then Kp:=2.66 else if p=1 then Kp:=2.23 else if p=2 then Kp:=2.07 else if p=3 then Kp:=1.97 else if p=4 then Kp:=1.90 else if p=5 then Kp:=1.84 else if p=10 then Kp:=1.64 else if p=13 then Kp:=1.54 else if p=20 then Kp:=1.39 else if p=50 then Kp:=0.96; end else if(Dlessquty>=0.1) and (Dlessquty<=0.3) then begin if p=0.1 then Kp:=2.44 else if p=1 then Kp:=2.08 else if p=2 then Kp:=1.94 else if p=3 then Kp:=1.86 else if p=4 then Kp:=1.80 else if p=5 then Kp:=1.75 else if p=10 then Kp:=1.57 else if p=13 then Kp:=1.48 else if p=20 then Kp:=1.36 else if p=50 then Kp:=0.97; end else if Dlessquty>0.3 then begin if p=0.1 then Kp:=2.13 else if p=1 then Kp:=1.86 else if p=2 then Kp:=1.76 else if p=3 then Kp:=1.70 else if p=4 then Kp:=1.65 else if p=5 then Kp:=1.61 else if p=10 then Kp:=1.48 else if p=13 then Kp:=1.40 else if p=20 then Kp:=1.31 else if p=50 then Kp:=0.99; end; if (m>=1.5) and (m<=5.0) then Rp:=KΔ*Kv*Kp/sqrt(1+m*m)*sqrt(H*L) else if m<=1.0 then begin if m=0 then R0:=1.24 else if m=0.5 then R0:=1.45 else if m=1.0 then R0:=2.20; Rp:=KΔ*Kv*Kp*R0*H; end else if (m>1.0) and (m<1.5) then begin y1:=KΔ*Kv*Kp/sqrt(1+1*1)*sqrt(H*L); y2:=KΔ*Kv*Kp/sqrt(2+1.5*1.5)*sqrt(H*L); Rp:=(y2-y1)*(m-1)/(1.5-1)+y1; end; Result:=Rp; end; 2.6.5 計算風(fēng)壅水面高度函數(shù) function Calce(K,V,F,g,d,β:Extended):Extended; var Ang:Double; //角度轉(zhuǎn)弧度 π/180×角度 //弧度變角度 180/π×弧度 begin Ang:=β*pi/180; Result:=K*V*V*F*Cos(Ang)/(2*g*d); end; 在計算按鈕的OnClick事件中編寫代碼 procedure TForm1.Button1Click(Sender:TObject); var i:integer; isEditempty:Boolean; K,V,F,g,d,β, m,KΔ,dq,p,Kv,Rp, H,T,L,e,y,A:Extended; begin for i:=0 to ComponentCount-1 do begin if (Components[i] is TEdit) then begin if (Components[i] as TEdit).Text='' then begin isEditempty:=True; break; end else isEditempty:=False; end; end; if ComboBox2.ItemIndex=-1 then showmessage('請先選擇堤防等級后再計算!') else if isEditempty=true then showmessage('請?zhí)顚懭啃畔⒑笤儆嬎悖?) else begin K:=StrToFloat(Edit9.Text); V:=StrToFloat(Edit4.Text); F:=StrToFloat(Edit5.Text); g:=StrToFloat(Edit8.Text); d:=StrToFloat(Edit6.Text); β:=StrToFloat(Edit10.Text); m:=StrToFloat(Edit2.Text); dq:=StrToFloat(Edit3.Text); KΔ:=StrToFloat(Edit11.Text); P:=StrToFloat(Edit7.Text); A:=StrToFloat(Edit1.Text); H:=RoundFloat(CalcH(g,d,V,F),5); T:=RoundFloat(CalcT(V,g,H),5); L:=RoundFloat(CalcL(g,T,d),5); Kv:=RoundFloat(CalcKv(V,g,dq,Kv),5); Rp:=RoundFloat(CalcR(H,d,L,P,Rp,KΔ,Kv,m),5); e:=RoundFloat(Calce(K,V,F,g,d,β),5); Y:=Rp+e+A; Label19.Caption:=FloatToStr(H); Label21.Caption:=FloatToStr(T); Label26.Caption:=FloatToStr(L); Label3.Caption:=FloatToStr(Rp); Label5.Caption:=FloatToStr(e); Label7.Caption:=FloatToStr(Y); end; end; 壩頂超高計算在堤身設(shè)計中意義重大,是關(guān)系到堤身安全、工程投資的重要環(huán)節(jié)。通過Delphi編寫程序,只需輸入具體數(shù)值,就能自動計算出結(jié)果,大大減少了繁瑣的計算,節(jié)省了工作時間,提高了工作效率。在工作中,可以運用Delphi編寫其他程序,應(yīng)用到水利相關(guān)的工作中,解決傳統(tǒng)手工計算效率低、容易出錯等問題,提高計算效率和精確度。2.4 風(fēng)壅水面高度計算
2.5 Delphi界面設(shè)計
2.6 Delphi函數(shù)設(shè)計
2.7 函數(shù)調(diào)用
3 結(jié)語