|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
Dim I, J As Double
Dim NN As Integer, ELE As Integer, MS As Integer
Dim GD As Integer, JZ As Integer, ZC As Integer, PN As Integer
Dim LRN(1 To 12, 1 To 12) As Double, L(1 To 7) As Double, G(1 To 21, 1 To 21) As Double
Dim EA(1 To 7) As Double, EI(1 To 7) As Double, Cn As Double, Sn As Double
Dim X(1 To 7) As Double, Y(1 To 7) As Double, P(1 To 21) As Double
Dim TKE(1 To 21, 1 To 21) As Double, TKE1(1 To 21, 1 To 21) As Double
Dim BKE(1 To 6, 1 To 6) As Double, T(1 To 6, 1 To 6) As Double
Dim TZ(1 To 6, 1 To 6) As Double, Z(1 To 21) As Double
Dim LN(1 To 6) As Integer, RN(1 To 6) As Integer
Dim FX(1 To 7) As Double, FY(1 To 7) As Double, MOMENT(1 To 7) As Double
Private Sub Form_Click()
Open "e:\homework\gginput.txt" For Input As #1
Open "e:\homework\ggoutput.txt" For Output As #2
Call Data ';输入数据
Call ZG ';总刚度矩阵
Call Boundary '; 输入边界条件
Call load ';输入荷载
Call Result ';计算结果(杆端力)
Close #1
Close #2
End Sub
Public Sub Data() ';数据的准备与输入
Print #2, "平面杆系有限元程序——斜腿刚构计算"
Print #2, "========================================="
Print #2, "原始数据的输入"
Print #2,
Print #2, "结点数"; Spc(3); "单元数"; Spc(3); "固定支座数"; Spc(3); "铰支座数"; Spc(3); "支承数"; Spc(3); "结点荷载数"; Spc(3); "系统总自由度数"
Input #1, NN, GD, JZ, ZC, PN
MS = 3 * NN: ELE = NN - 1
Print #2, NN; Spc(6); ELE; Spc(6); GD; Spc(6); JZ; Spc(6); ZC; Spc(6); PN; Spc(6); MS
Print #2,
Print #2, "========================================="
Print #2, "结点坐标的输入"
Print #2,
Print #2, "结点"; Spc(3); "X"; Spc(6); "Y"; Spc(3); "单位:米"
For I = 1 To NN
Input #1, I, X(I), Y(I)
Print #2, I; Spc(3); X(I); Spc(6); Y(I)
Next I
Print #2,
Print #2, "========================================="
Print #2, "杆件相关信息的输入"
Print #2,
Print #2, "杆件号"; Spc(3); "左结点号"; Spc(3); "右结点号"; Spc(3); "抗弯刚度"; Spc(3); "抗拉刚度"; Spc(3); "杆件长度"; Spc(3); "E=2.06E+11N/m2"
For I = 1 To ELE
Input #1, I, LN(I), RN(I), EI(I), EA(I)
Next I
For I = 1 To ELE
L(I) = Sqr((Y(RN(I)) - Y(LN(I))) ^ 2 + (X(RN(I)) - X(LN(I))) ^ 2)
Print #2, I; Spc(8); LN(I); Spc(8); RN(I); Spc(8); Format(EI(I), "0.000E+00"); Spc(8); Format(EA(I), "0.000E+00"); Spc(8); (Format(L(I), "0.000"))
Next I
';输入结点编号
LRN(1, 1) = 3#: LRN(1, 2) = 3#: LRN(1, 3) = 4#
LRN(2, 1) = 1#: LRN(2, 2) = 2#: LRN(2, 3) = 3#
LRN(1, 4) = 5#: LRN(1, 5) = 7#: LRN(1, 6) = 6#
LRN(2, 4) = 4#: LRN(2, 5) = 5#: LRN(2, 6) = 5#
Print #2,
Print #2, "========================================="
Print #2, "输入结点荷载"
Print #2,
Print #2, "结点号"; Spc(3); "FX"; Spc(4); "FY"; Spc(4); "MOMENT"; Spc(4); "单位:N"
For I = 1 To NN
Input #1, I, FX(I), FY(I), MOMENT(I)
Next I
For I = 1 To NN
Print #2, I; Spc(3); Format(FX(I), "0.0E+"); Spc(4); Format(FY(I), "0.0E+"); Spc(4); Format(MOMENT(I), "0.0E+")
Next I
Print #2,
Print #2, "========================================="
Print #2, "输入约束条件"
End Sub
Public Sub DG(K) ';形成单元刚度矩阵
';For K = 1 To ELE
For I = 1 To 6
For J = 1 To 6
BKE(I, J) = 0#
Next J
Next I
BKE(1, 1) = EA(K) / L(K)
BKE(2, 1) = 0#
BKE(2, 2) = 12 * EI(K) / L(K) * L(K) * L(K)
BKE(3, 1) = 0#
BKE(3, 2) = 6 * EI(K) / L(K) * L(K)
BKE(3, 3) = 4 * EI(K) / L(K)
BKE(4, 1) = -EA(K) / L(K)
BKE(4, 2) = 0#
BKE(4, 3) = 0#
BKE(4, 4) = EA(K) / L(K)
BKE(5, 1) = 0#
BKE(5, 2) = -12 * EI(K) / L(K) * L(K) * L(K)
BKE(5, 3) = -6 * EI(K) / L(K) * L(K)
BKE(5, 4) = 0#
BKE(5, 5) = 12 * EI(K) / L(K) * L(K) * L(K)
BKE(6, 1) = 0#
BKE(6, 2) = 6 * EI(K) / L(K) * L(K)
BKE(6, 3) = 2 * EI(K) / L(K)
BKE(6, 4) = 0#
BKE(6, 5) = -6 * EI(K) / L(K) * L(K)
BKE(6, 6) = 4 * EI(K) / L(K)
For I = 1 To 6
For J = 1 To 6
BKE(I, J) = BKE(J, I)
Next J
Next I
'rint #2, K, "单刚"
'; For I = 1 To ELE
'; For J = 1 To ELE
'; Print #2, (Format(BKE(I, J), "0.000")); Spc(2);
'; Next J
'; Print #2,
'; Next I
'; Next K
End Sub
Public Sub Translate(K) ';形成坐标变换矩阵
'; For K = 1 To ELE
Cn = (X(RN(K)) - X(LN(K))) / L(K)
Sn = (Y(RN(K)) - Y(LN(K))) / L(K)
For I = 1 To 6
For J = 1 To 6
T(I, J) = 0#
Next J
Next I
T(1, 1) = Cn
T(1, 2) = Sn
T(1, 3) = 0#
T(2, 1) = -Sn
T(2, 2) = Cn
T(2, 3) = 0#
T(3, 1) = 0#
T(3, 2) = 0#
T(3, 3) = 1#
For I = 1 To 3
For J = 1 To 3
T(I + 3, J + 3) = T(I, J)
Next J
Next I
'; Print #2, K; "单元", "坐标变换矩阵"
'; For I = 1 To ELE
'; For J = 1 To ELE
'; Print #2, (Format(T(I, J), "0.000")); Spc(2);
'; Next J
'; Print #2,
'; Next I
'; Next K
';形成坐标变换矩阵的转置矩阵(逆矩阵)
For I = 1 To 6
For J = 1 To 6
TZ(I, J) = T(J, I)
Next J
Next I
End Sub
Public Sub ZG() ';形成总体刚度矩阵
Dim M As Integer, M1 As Integer, H As Integer, H1 As Integer
Dim I As Integer, J As Integer, W As Integer, II As Integer, JJ As Integer
For I = 1 To MS
For J = 1 To MS
TKE(I, J) = 0#
Next J
Next I
For W = 1 To ELE
';形成总体坐标的单元刚度矩阵
Call Translate(W)
Call DG(W)
Call MULT(BKE, T, G, 6, 6, 6)
Call MULT(TZ, G, TKE1, 6, 6, 6)
';形成总体刚度矩阵
For I = 1 To 2
For II = 1 To 3
M = 3 * (I - 1) + II
M1 = 3 * (LRN(I, W) - 1) + I
For J = 1 To 2
For JJ = 1 To 3
H = 3 * (J - 1) + JJ
H1 = 3 * (LRN(J, W) - 1) + JJ
TKE(M1, H1) = TKE(M1, H1) + TKE1(M, H)
Next JJ
Next J
Next II
Next I
Next W
Print #2, "总刚"
For I = 1 To MS
For J = 1 To MS
Print #2, (Format(TKE(I, J), "0.0E+00")); Spc(2);
Next J
Print #2,
Next I
End Sub
Public Sub MULT(A, B, C, N1, N2, N3) ';矩阵相乘运算
Dim A(N1, N2) As Double, B(N2, N3) As Double, C(N1, N3) As Double
For I = 1 To N1
For J = 1 To N3
C(I, J) = 0#
Next J
Next I
For I = 1 To N1
For J = 1 To N3
For K = 1 To N2
C(I, J) = C(I, J) + A(I, K) * B(K, J)
Next K
Next J
Next I
End Sub
Public Sub GAS(A, B, N, X) ';高斯消元法
Dim K As Double, H As Double
For K = 1 To N - 1
For J = K + 1 To N
A(K, J) = A(K, J) / A(K, K)
Next J
B(K) = B(K) / A(K, K)
For I = K + 1 To N
For J = K + 1 To N
A(I, J) = A(I, J) - A(I, K) * A(K, J)
Next J
B(I) = B(I) - A(I, K) * B(K)
Next I
Next K
X(N) = B(N) / A(N, N)
For I = N - 1 To 1 Step -1
H = 0
For J = I + 1 To N
H = H + A(I, J) * X(J)
Next J
X(I) = B(I) - H
Next I
End Sub
Public Sub load() ';形成结点荷载向量
For I = 1 To MS
P(I) = 0#
Next I
P(1) = 0#
P(2) = 0#
P(3) = 0#
P(4) = 0#
P(5) = 0#
P(6) = 0#
P(7) = 0#
P(8) = 0#
P(9) = 0#
P(10) = 0#
P(11) = -100000
P(12) = 0#
P(13) = 35000
P(14) = 0#
P(15) = 0#
P(16) = 0#
P(17) = 0#
P(18) = 0#
P(19) = 0#
P(20) = 0#
P(21) = 0#
'rint #2, "结点荷载列向量"
';For I = 1 To MS
'; Print #2, (Format(P(I), "#.##E+"))
';Next I
End Sub
Public Sub Boundary() ';边界条件处理
For I = 4 To 5
For J = 1 To MS
TKE(I, J) = 0#
Next J
Next I
For J = 4 To 5
For I = 1 To MS
TKE(I, J) = 0#
Next I
Next J
For I = 19 To 20
For J = 1 To MS
TKE(I, J) = 0#
Next J
Next I
For J = 19 To 20
For I = 1 To MS
TKE(I, J) = 0#
Next I
Next J
For J = 1 To MS
TKE(2, J) = 0#
Next J
For I = 1 To MS
TKE(I, 2) = 0#
Next I
For J = 1 To MS
TKE(17, J) = 0#
Next J
For I = 1 To MS
TKE(I, 17) = 0#
Next I
TKE(2, 2) = 1#
TKE(4, 4) = 1#
TKE(5, 5) = 1#
TKE(17, 17) = 1#
TKE(19, 19) = 1#
TKE(20, 20) = 1#
End Sub
Public Sub Result() ';计算杆端位移和杆端力
Dim Q(1 To 6) As Double, F(1 To 6) As Double
Call GAS(TKE, P, MS, Z)
Call MULT(TKE, Z, P, MS, MS)
Print #2, "======================================"
Print #2, "计算数据输出"
Print #2, "======================================"
Print #2, "杆端位移"
Print #2, "结点号", "水平方向u", "垂直方向v", "转角fai"
Print #2, "======================================"
Print #2, "杆端力"
Print #2, "杆件号", "U(左端)"; Spc(4); "V(左端)"; Spc(4); "M(左端)"; Spc(4); "U(右端)"; Spc(4); "V(右端)"; Spc(4); "M(右端)"
For I = 1 To MS
Print #2, Format(Z(I), "0.00E-00")
Next I
Print #2,
Print #2,
For I = 1 To MS
Print #2, Format(P(I), "0.00000E+00")
Next I
End Sub
Public Sub MULT1(A, B, C, N1, N2) ';矩阵与向量相乘
For I = 1 To N1
C(I) = 0#
Next I
For I = 1 To N1
For J = 1 To N2
C(I) = C(I) + A(I, J) * B(J)
Next J
Next I
End Sub
|
|