0% found this document useful (0 votes)
72 views7 pages

Block

This VBA code finds the lateral pressure, shear force, and bending moment at multiple depths (z-levels) due to multiple surface loads on a retaining wall. It starts by defining constants and variables, including an array to store the pressure, shear, and moment values at each depth. It then counts and collects properties of each surface load and calculates the pressure contribution of each load at each depth. Finally, it computes the shear and bending moment by integrating the pressure and prints the results to the Excel worksheet.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views7 pages

Block

This VBA code finds the lateral pressure, shear force, and bending moment at multiple depths (z-levels) due to multiple surface loads on a retaining wall. It starts by defining constants and variables, including an array to store the pressure, shear, and moment values at each depth. It then counts and collects properties of each surface load and calculates the pressure contribution of each load at each depth. Finally, it computes the shear and bending moment by integrating the pressure and prints the results to the Excel worksheet.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Option Explicit

Const MAX_NUMBER_LOADS = 20

Sub FindLateralPressure_multiple_loads()

Dim NFE_total&, Nloads&, i&, j&, i1&, nfe&

Dim A_total#, Yo#, Xj#, Yj#, H#, poi#, Lx#, Ly#, dx#, dy#, dz#, pfe#, A#, q#, P#

Dim rngRow As Range

Dim nx&, ny&, nz&

Dim ix&, iy&, iz&

Dim r1#, R2#

Dim x As Double, y As Double, z() As Double

Dim ph() As Double, V() As Double, M() As Double

Application.ScreenUpdating = False

Yo = Range("Ys")

H = Range("H")

poi = Range("poi")

nz = Range("nz") + 1

dz = H / (nz - 1)

ReDim z(1 To nz)

ReDim ph(1 To nz)

ReDim V(1 To nz)

ReDim M(1 To nz)


NFE_total = Range("NFE").Value

A_total = WorksheetFunction.Sum(Range("Ld1_q").Offset(0, 5).Resize(MAX_NUMBER_LOADS, 1))

z(1) = 0

For iz = 2 To nz

z(iz) = z(iz - 1) + dz

ph(iz) = 0

Next iz

'count the loads

Set rngRow = Range("Ld1_q").Resize(1, 7)

'1-q

' 2 - xo

' 3 - yo

'4-L

'5-B

'6-A

'7-P

j=0

For i1 = 1 To Range("Number_area_loads")

If IsNumeric(rngRow(6)) And rngRow(6).Value > 0 Then

j = j + 1 ' add load

q = rngRow(1)

Xj = rngRow(2)

Yj = rngRow(3)
Lx = rngRow(4)

Ly = rngRow(5)

A = rngRow(6)

P = rngRow(7)

' find number of FE in the load

nfe = Int(A * NFE_total / A_total)

nx = Int(Sqr(Lx * nfe / Ly)) + 1

ny = Int(nfe / nx) + 1

nfe = nx * ny

pfe = P / nfe

dx = Lx / nx

dy = Ly / ny

x = Xj - Lx / 2 - dx / 2

For ix = 1 To nx

x = x + dx

y = Yj + Yo - Ly / 2 - dy / 2

For iy = 1 To ny

y = y + dy

' calculate effect of this load

For iz = 1 To nz

r1 = Sqr(x * x + y * y)

R2 = Sqr(x * x + y * y + z(iz) * z(iz))

' ignore negative effect

ph(iz) = ph(iz) + (pfe / 2 / WorksheetFunction.Pi()) * (WorksheetFunction.Max(0, (3 * r1 * r1 *


z(iz) / R2 ^ 5 - _

(1 - 2 * poi) / R2 / (R2 + z(iz))) * x / r1))

Next iz
Next iy

Next ix

End If

Set rngRow = rngRow.Offset(1)

Next i1

'Compute shear force and moment

V(1) = 0: M(1) = 0

For iz = 2 To nz

V(iz) = V(iz - 1) + (ph(iz) + ph(iz - 1)) * dz / 2

M(iz) = M(iz - 1) + V(iz - 1) * dz + (dz * dz / 6) * (ph(iz) + 2 * ph(iz - 1))

Next iz

' Print output

Sheets("Input").Unprotect

With Range("FirstZ").Resize(200, 4)

.ClearContents

.Borders(xlInsideHorizontal).LineStyle = xlNone

.Borders(xlDiagonalDown).LineStyle = xlNone

.Borders(xlDiagonalUp).LineStyle = xlNone

.Borders(xlEdgeLeft).LineStyle = xlNone

.Borders(xlEdgeTop).LineStyle = xlNone

.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone

.Borders(xlInsideVertical).LineStyle = xlNone

.Borders(xlInsideHorizontal).LineStyle = xlNone

For iz = 1 To nz

.Cells(iz, 1).Value = z(iz)

.Cells(iz, 2).Value = ph(iz)

.Cells(iz, 3).Value = V(iz)

.Cells(iz, 4).Value = M(iz)

Next iz

End With

With Range("FirstZ").Resize(nz, 4)

With .Borders(xlEdgeLeft)

.LineStyle = xlContinuous

.ThemeColor = 5

.TintAndShade = 0

.Weight = xlMedium

End With

With .Borders(xlEdgeTop)

.LineStyle = xlContinuous

.ThemeColor = 5

.TintAndShade = 0

.Weight = xlMedium

End With

With .Borders(xlEdgeBottom)

.LineStyle = xlContinuous

.ThemeColor = 5

.TintAndShade = 0
.Weight = xlMedium

End With

With .Borders(xlEdgeRight)

.LineStyle = xlContinuous

.ThemeColor = 5

.TintAndShade = 0

.Weight = xlMedium

End With

With .Borders(xlInsideVertical)

.LineStyle = xlContinuous

.ThemeColor = 5

.TintAndShade = 0

.Weight = xlMedium

End With

.Borders(xlInsideHorizontal).LineStyle = xlNone

End With

Sheets("Input").Protect

Application.ScreenUpdating = True

End Sub

Sub Activate_wsInput()

ThisWorkbook.Sheets("Input").Activate

End Sub

Sub Activate_wsSketch()

ThisWorkbook.Sheets("Sketch").Activate
End Sub

You might also like