1、材料力学上机作业题目五:梁的强度校核摘要本程序使用 Microsoft Visual Basic编写,由输入梁的支撑条件,输入梁的受力状态,实现了梁危险截面的最大正应力计算与梁的强度校核。在校核结果为否定的情况下还可由许用应力值进行部分截面设计和许用载荷计算等功能。数学原理及数学模型材料力学公式有:1.梁弯曲正应力公式 zxWMma2.抗弯截面系数矩形截面 62bhz圆形截面 32dz空心圆截面 , 式中 )1(4DWz Dd3.采用一定数量级上的穷举法计算出最大弯矩 Mz。VB 所做软件1. 软件部分窗体截图2. 程序结构图3. 不安全安全开始选择支撑条件悬臂梁直接计算出各截面弯矩并找出最大
2、值 Mz外伸梁和简支梁根据受力情况求出支反力 fa 和 fb,进而求 Mz选择截面形状和输入尺寸计算抗弯截面系数矩形截面输入宽 b和高h计算得 Wz圆截面输入直径 d计算得 Wz空心截面输入内外直径D、d 求得Wz工字钢直接查表输入 Wz求出正应力并与许用应力比较结束进行截面设计和许用载荷计算输入受力情 况应用实例1.验证新编材料力学书中 P247 例 12-9该题由正应力强度条件求得题中矩形截面悬臂梁许用载荷为 q9.1kN/m,现加载q=8kN/m,看是否符合正应力强度要求。已知左悬臂梁 l=3m,=120Mpa,b=80mm,h=160mm,整个梁承受向下的均布载荷 q解:1.运行程序进
3、入主页面2.点击开始并选择支撑条件为左固定端悬臂梁,点击确定。如图3.选择梁的截面形状并输入尺寸参数,点击确定。如图4.输入受力条件,点击确定进行计算。如图5.程序运行结果如图计算结果与实际运算结果相同2.求解新编材料力学P246 例 12-8。解: 1.运行程序计入主界面,点击开始。2.选择支撑条件为右外伸梁,点击确定。3.选择梁的截面形状并输入尺寸,点击确定。如图, (不妨先设 b=10,h=30。注意,应避免 b 或 h 为零以防止出现除数为零的情况使程序出错)4.输入受力情况及右支架位置并点击确定,如图(如果未能输入右支架位置,可能使程序出错)5.得到计算结果计算结果与答案 b=30m
4、m,h=60mm 一致,不过以截面抗弯系数代替截面具体尺寸。其中小数点后的微量误差受穷举法所采用数量级的影响。值得注意的是,由于本程序涉及的截面形状及载荷种类较多,而且载荷位置不固定,因此截面设计和许用载荷计算难以得到最终的具体结果。时间仓促,为减小工作量,本程序将许用载荷计算简化为梁截面所能承受的最大弯矩的计算。将截面设计略微简化为截面最小抗弯系数的设计。验证表明,计算结果同样精确。主要算法代码和部分窗体截图:部分窗体截图:Form9 窗体内源代码:Private Sub Command1_Click() 进入实际工作界面Form0.ShowMe.HideEnd SubPrivate Sub
5、 Command2_Click() 若点击“结束”按钮则结束程序EndEnd SubForm0 窗体内源代码:Public l As Double 声明变量Public q As DoublePublic f1 As DoublePublic f2 As DoublePublic f As DoublePublic m1 As DoublePublic m2 As DoublePublic m As DoublePublic x As DoublePublic xa As DoublePublic xb As DoublePublic xq1 As DoublePublic xq2 As Do
6、ublePublic xf1 As DoublePublic xf2 As DoublePublic xm1 As DoublePublic xm2 As DoublePublic x1 As DoublePublic x2 As DoublePublic x3 As DoublePublic x4 As DoublePublic x5 As DoublePublic x6 As DoublePublic fa As DoublePublic fb As DoublePublic w As DoublePublic b As DoublePublic h As DoublePublic d1
7、As DoublePublic d2 As DoublePublic d3 As DoublePublic wz As DoublePublic syl As DoublePublic xyl As DoublePublic pi As DoublePublic zdzh As DoublePrivate Sub Command1_Click() 进入截面形状选择及尺寸参数输入界面Form7.ShowMe.HideEnd SubPrivate Sub Command2_Click() 若点击“结束”按钮则终止程序EndEnd SubPrivate Sub Form_Load() End Sub
8、Private Sub Option1_Click() 选择支撑条件Option1.Value = TrueEnd SubPrivate Sub Option2_Click()Option2.Value = TrueEnd SubPrivate Sub Option3_Click()Option3.Value = TrueEnd SubPrivate Sub Option4_Click()Option4.Value = TrueEnd SubPrivate Sub Option5_Click()Option5.Value = TrueEnd SubPrivate Sub Option6_Cli
9、ck()Option6.Value = TrueEnd SubForm7 窗体内源代码: 本窗体为截面形状选择及尺寸输入界面Private Sub Command1_Click()If Form0.Option1.Value = True Then 根据用户选择的不同支撑条件调用不jz.Show 同窗体ElseIf Form0.Option2.Value = True Thenzxb.ShowElseIf Form0.Option3.Value = True Thenyxb.ShowElseIf Form0.Option4.Value = True Thenzws.ShowElseIf For
10、m0.Option5.Value = True Thenyws.ShowElsesws.ShowEnd IfMe.HideEnd SubPrivate Sub Command2_Click()Form0.ShowMe.HideEnd SubPrivate Sub Form_Load()End SubPrivate Sub Option1_Click() 选择不同的截面形状Option1.Value = TrueEnd SubPrivate Sub Option2_Click()Option2.Value = TrueEnd SubPrivate Sub Option3_Click()Optio
11、n3.Value = TrueEnd SubPrivate Sub Option4_Click()Option4.Value = TrueEnd SubForm1(简支梁)窗体内源代码: 本窗体完成支撑条件简支梁部分计算Private Sub Command1_Click()Dim i As DoubleDim k As Doublepi = 3.1415926 给变量赋值l = Val(Form7.l.Text)If Form7.Option1.Value = True Then 计算截面抗弯系数b = Val(Form7.b.Text)h = Val(Form7.h.Text)wz = b
12、 * h 2 / 6ElseIf Form7.Option2.Value = True Thend1 = Val(Form7.d1.Text)wz = pi * d1 3 / 32ElseIf Form7.Option3.Value = True Thend2 = Val(Form7.d2.Text)d3 = Val(Form7.D.Text)wz = pi * d3 3 * (1 - d2 4 / d3 4) / 32ElseIf Form7.Option4.Value = True Thenwz = Val(Form7.wz.Text)End Iff1 = Val(f11.Text) 通过
13、用户输入,给变量赋值f2 = Val(f21.Text)xf1 = Val(xf11.Text)xf2 = Val(xf21.Text)m1 = Val(m11.Text)m2 = Val(m21.Text)xm1 = Val(xm11.Text)xm2 = Val(xm21.Text)q = Val(q1.Text)xq1 = Val(xq11.Text)xq2 = Val(xq21.Text)If xf1 xf2 Then 确定 f1,f2 的位置前后,便于后续计算k = f1f1 = f2f2 = kk = xf1xf1 = xf2xf2 = kEnd IfIf xm1 xm2 Then
14、 确定 m1,m2 的位置前后,便于后续计算k = m1m1 = m2m2 = kk = xm1xm1 = xm2xm2 = kEnd Ifl = l / 1000xf1 = xf1 / 1000xf2 = xf2 / 1000xm1 = xm1 / 1000xm2 = xm2 / 1000xq1 = xq1 / 1000xq2 = xq2 / 1000fb = (m1 + m2 + f1 * xf1 + f2 * xf2 + q * (xq2 - xq1) * (xq1 + xq2) / 2) / l 求支反力fa = f1 + f2 + q * (xq2 - xq1) - fbm = 0k
15、 = 0For i = 0 To l Step l / 1000000 该循环用于求截面最大弯矩m = fa * iIf xf1 i Thenm = m - q * (i - xq1) 2 / 2End IfIf xq2 k 2 Thenk = mEnd IfNext im = k 求得最大截面弯矩syl = m / wz 计算最大正应力syl = (syl 2) 0.5 * 10 3Form8.Label3.Caption = “实际最大正应力为 “ & syl & “Mpb“ 显示结果xyl = Val(Form7.xyl.Text) zdzh = wz * xyl / 10 3 许用载荷
16、计算w = m / xyl 截面设计计算w = (w 2) 0.5If syl xyl ThenForm8.Label1.Caption = “由“ & syl & “ & xyl & vbCrLf & vbclf & “实际应力大于许用应力,不安全。“ & vbCrLf & vbCrLf & “可改变梁的载荷使梁截面上最大弯矩小于等于 “ & zdzh & “N.m。“ & vbCrLf & vbCrLf & “或者改变梁截面形状和尺寸,使其截面抗弯系数大于等于 “ & w & “cm3“ElseForm8.Label1.Caption = “由“ & syl & “ xf2 Thenk =
17、 f1f1 = f2f2 = kk = xf1xf1 = xf2xf2 = kEnd IfIf xm1 xm2 Thenk = m1m1 = m2m2 = kk = xm1xm1 = xm2xm2 = kEnd Ifl = l / 1000xf1 = xf1 / 1000xf2 = xf2 / 1000xm1 = xm1 / 1000xm2 = xm2 / 1000xq1 = xq1 / 1000xq2 = xq2 / 1000k = 0m = 0For i = 0 To l Step l / 1000000m = 0If (l - xf1) i Thenm = m - q * (i + xq
18、2 - l) 2 / 2End IfIf (l - xq1) k 2 Thenk = mEnd IfNext im = ksyl = m / wzsyl = (syl 2) 0.5 * 10 3Form8.Label3.Caption = “实际最大正应力为 “ & syl & “Mpb“xyl = Val(Form7.xyl.Text)zdzh = wz * xyl / 10 3w = m / xylw = (w 2) 0.5If syl xyl ThenForm8.Label1.Caption = “由“ & syl & “ & xyl & vbCrLf & vbclf & “实际应力大于
19、许用应力,不安全。“ & vbCrLf & vbCrLf & “可改变梁的载荷使梁截面上最大弯矩小于等于 “ & zdzh & “N.m。“ & vbCrLf & vbCrLf & “或者改变梁截面形状和尺寸,使其截面抗弯系数大于等于 “ & w & “cm3“ElseForm8.Label1.Caption = “由“ & syl & “ xf2 Thenk = f1f1 = f2f2 = kk = xf1xf1 = xf2xf2 = kEnd IfIf xm1 xm2 Thenk = m1m1 = m2m2 = kk = xm1xm1 = xm2xm2 = kEnd Ifl = l / 1
20、000xf1 = xf1 / 1000xf2 = xf2 / 1000xm1 = xm1 / 1000xm2 = xm2 / 1000xq1 = xq1 / 1000xq2 = xq2 / 1000k = 0For i = 0 To l Step l / 1000000m = 0If xf1 i Thenm = m - q * (i - xq1) 2 / 2End IfIf xq2 k 2 Thenk = mEnd IfNext im = ksyl = m / wzsyl = (syl 2) 0.5 * 10 3Form8.Label3.Caption = “实际最大正应力为 “ & syl
21、& “Mpb“xyl = Val(Form7.xyl.Text)zdzh = wz * xyl / 10 3w = m / xylw = (w 2) 0.5If syl xyl ThenForm8.Label1.Caption = “由“ & syl & “ & xyl & vbCrLf & vbclf & “实际应力大于许用应力,不安全。“ & vbCrLf & vbCrLf & “可改变梁的载荷使梁截面上最大弯矩小于等于 “ & zdzh & “N.m。“ & vbCrLf & vbCrLf & “或者改变梁截面形状和尺寸,使其截面抗弯系数大于等于 “ & w & “cm3“ElseFor
22、m8.Label1.Caption = “由“ & syl & “ xf2 Thenk = f1f1 = f2f2 = kk = xf1xf1 = xf2xf2 = kEnd IfIf xm1 xm2 Thenk = m1m1 = m2m2 = kk = xm1xm1 = xm2xm2 = kEnd Ifl = l / 1000xf1 = xf1 / 1000xf2 = xf2 / 1000xm1 = xm1 / 1000xm2 = xm2 / 1000xq1 = xq1 / 1000xq2 = xq2 / 1000xa = xa / 1000fa = (-m1 - m2 + f1 * (l
23、- xf1) + f2 * (l - xf2) + q * (xq2 - xq1) * (2 * l - xq1 - xq2) / 2) / (l - xa)fb = f1 + f2 + q * (xq2 - xq1) - fam = 0k = 0For i = 0 To l Step l / 1000000m = 0If xa i Thenm = m - q * (i - xq1) 2 / 2End IfIf xq2 k 2 Thenk = mEnd IfNext im = ksyl = m / wzsyl = (syl 2) 0.5 * 10 3Form8.Label3.Caption =
24、 “实际最大正应力为 “ & syl & “Mpb“xyl = Val(Form7.xyl.Text)zdzh = wz * xyl / 10 3w = m / xylw = (w 2) 0.5If syl xyl ThenForm8.Label1.Caption = “由“ & syl & “ & xyl & vbCrLf & vbclf & “实际应力大于许用应力,不安全。“ & vbCrLf & vbCrLf & “可改变梁的载荷使梁截面上最大弯矩小于等于 “ & zdzh & “N.m。“ & vbCrLf & vbCrLf & “或者改变梁截面形状和尺寸,使其截面抗弯系数大于等于 “
25、 & w & “cm3“ElseForm8.Label1.Caption = “由“ & syl & “ xf2 Thenk = f1f1 = f2f2 = kk = xf1xf1 = xf2xf2 = kEnd IfIf xm1 xm2 Thenk = m1m1 = m2m2 = kk = xm1xm1 = xm2xm2 = kEnd Ifl = l / 1000xf1 = xf1 / 1000xf2 = xf2 / 1000xm1 = xm1 / 1000xm2 = xm2 / 1000xq1 = xq1 / 1000xq2 = xq2 / 1000xb = xb / 1000fb = (
26、f1 * xf1 + f2 * xf2 + q * (xq2 - xq1) * (xq1 + xq2) / 2 - m1 - m2) / xbfa = f1 + f2 + q * (xq2 - xq1) - fbm = 0k = 0For i = 0 To l Step l / 1000000m = 0If xa i Thenm = m - q * (i - xq1) 2 / 2End IfIf xq2 k 2 Thenk = mEnd IfNext im = ksyl = m / wzsyl = (syl 2) 0.5 * 10 3Form8.Label3.Caption = “实际最大正应
27、力为 “ & syl & “Mpb“xyl = Val(Form7.xyl.Text)zdzh = wz * xyl / 10 3w = m / xylw = (w 2) 0.5If syl xyl ThenForm8.Label1.Caption = “由“ & syl & “ & xyl & vbCrLf & vbclf & “实际应力大于许用应力,不安全。“ & vbCrLf & vbCrLf & “可改变梁的载荷使梁截面上最大弯矩小于等于 “ & zdzh & “N.m。“ & vbCrLf & vbCrLf & “或者改变梁截面形状和尺寸,使其截面抗弯系数大于等于 “ & w & “
28、cm3“ElseForm8.Label1.Caption = “由“ & syl & “ xf2 Thenk = f1f1 = f2f2 = kk = xf1xf1 = xf2xf2 = kEnd IfIf xm1 xm2 Thenk = m1m1 = m2m2 = kk = xm1xm1 = xm2xm2 = kEnd Ifl = l / 1000xf1 = xf1 / 1000xf2 = xf2 / 1000xm1 = xm1 / 1000xm2 = xm2 / 1000xq1 = xq1 / 1000xq2 = xq2 / 1000xa = xa / 1000xb = xb / 1000
29、fb = (m1 + m2 + f1 * xf1 + f2 * xf2 + q * (xq2 - xq1) * (xq1 + xq2) / 2) - (f1 + f2 + q * (xq2 - xq1) * xa / (xb - xa)fa = f1 + f2 + q * (xq2 - xq1) - fbm = 0k = 0For i = 0 To l Step l / 1000000m = 0If xa i Thenm = m - q * (i - xq1) 2 / 2End IfIf xq2 k 2 Thenk = mEnd IfNext im = ksyl = m / wzsyl = (
30、syl 2) 0.5 * 10 3Form8.Label3.Caption = “实际最大正应力为 “ & syl & “Mpb“xyl = Val(Form7.xyl.Text)zdzh = wz * xyl / 10 3w = m / xylw = (w 2) 0.5If syl xyl ThenForm8.Label1.Caption = “由“ & syl & “ & xyl & vbCrLf & vbclf & “实际应力大于许用应力,不安全。“ & vbCrLf & vbCrLf & “可改变梁的载荷使梁截面上最大弯矩小于等于 “ & zdzh & “N.m。“ & vbCrLf & vbCrLf & “或者改变梁截面形状和尺寸,使其截面抗弯系数大于等于 “ & w & “cm3“ElseForm8.Label1.Caption = “由“ & syl & “ & xyl & vbCrLf & vbCrLf & “实际应力小于许用应力,安全“End IfForm8.ShowMe.HideEnd SubPrivate Sub Command2_Click()Form7.ShowMe.HideEnd SubForm8 窗体内源代码Private Sub Command1_Click()EndEnd Sub