1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| Option Explicit
Public Const indFrnt = 0
Public Const indRear = 1
Public Const indPlaceMax = indRear
Public Const rowCoeffFront = 36 ' Input
Public Const rowCoeffRear = 47
Public Const colCoeff = 2
Public Const nbrGcFront = 7 ' Front Ground Clearance
Public Const nbrGcRear = 9 ' Rear Ground Clearance
Public Const groundClearanceIncr = 5
Public Const rowDeflectFront = 90 ' Output
Public Const rowDeflectRear = 101
Public Const nbrDeflect = 9
Public Const colDeflect = 1
Public Const colRideHeight = colDeflect + 1
Public Const colSpeedMax = colDeflect + 50
Public Const speedMax = 400
Public Const speedIncr = 10
Public Const deflectionDelta = -5
Public arrCoef(indPlaceMax, nbrGcFront, nbrGcRear) As Double
Public Sub RideHeightDeflection()
Application.ScreenUpdating = False
RhdCoef
RhdClear
RhdDraw RhdBuild()
Application.ScreenUpdating = True
End Sub
Public Sub RhdCoef()
Dim indRow As Integer, indCol As Integer
Dim indGcFront As Integer, indGcRear As Integer, indPlace As Integer
For indGcFront = 0 To nbrGcFront - 1
For indGcRear = 0 To nbrGcRear - 1
indCol = indGcRear + colCoeff
For indPlace = indFrnt To indRear
indRow = IIf(indPlace = indFrnt, rowCoeffFront, rowCoeffRear) + indGcFront
arrCoef(indPlace, indGcFront, indGcRear) = Cells(indRow, indCol)
Next
Next
Next
End Sub
Public Sub RhdClear()
Dim indPlace As Integer, rowRhd As Integer
For indPlace = indFrnt To indRear
rowRhd = IIf(indPlace = indFrnt, rowDeflectFront, rowDeflectRear)
Range(Cells(rowRhd - 1, colDeflect), _
Cells(rowRhd + nbrDeflect, colDeflect + colSpeedMax)).ClearContents
Next
End Sub
Public Sub RhdSpeed(ByVal rowRhd As Integer)
Dim indSpeed As Integer, indCol As Integer
indCol = colRideHeight
For indSpeed = 0 To speedMax Step speedIncr
Cells(rowRhd - 1, indCol) = indSpeed ' Speed (km/h)
indCol = indCol + 1
Next
End Sub
Public Function RhdBuild() As Integer
Dim indPlace As Integer, indDeflect As Integer, indSpeed As Integer
Dim indRow As Integer, indCol As Integer, rowRhd As Integer ' Ride Height Deflection
For indPlace = indFrnt To indRear
rowRhd = IIf(indPlace = indFrnt, rowDeflectFront, rowDeflectRear)
RhdSpeed rowRhd
For indDeflect = 0 To nbrDeflect - 1
indRow = rowRhd + indDeflect
Cells(indRow, colDeflect) = indDeflect * deflectionDelta ' Deflection (mm)
indCol = colRideHeight
For indSpeed = 0 To speedMax Step speedIncr
Cells(indRow, indCol) = RhdExtra(indPlace, indDeflect, indSpeed)
indCol = indCol + 1
Next
Next
Next
RhdBuild = indCol - 1 ' Max of column of speed
End Function
' Extrapolation based on coeff
Public Function RhdExtra(ByVal indPlace As Integer, ByVal indDeflect As Integer, ByVal indSpeed As Integer) As Double
Const rhdAero = -0.5 * 1.2255
Const surface = 1 / 5235
Dim indGcFront As Integer, indGcRear As Integer
indGcFront = IIf(indDeflect < nbrGcFront, indDeflect, nbrGcFront - 1)
indGcRear = (indDeflect * groundClearanceIncr) \ groundClearanceIncr
RhdExtra = rhdAero * surface * arrCoef(indPlace, indGcFront, indGcRear) * indSpeed * indSpeed
End Function
' Draw the curve of the Ride Height Deflection both Front & Rear
Public Sub RhdDraw(ByVal indColMax As Integer)
Dim indPlace As Integer, rowRhd As Integer
For indPlace = indFrnt To indRear
rowRhd = IIf(indPlace = indFrnt, rowDeflectFront, rowDeflectRear)
' draw the curve
Next
End Sub |