Public Sub end_button_Click()
Unload userform1
End Sub
Public Sub ok_Click()
Dim mr As Variant, m As Variant, m0 As Variant, lam As Variant, a2 As Variant
'to get the input values from the userform
strke = Val(stroke.Text)
d = Val(dia.Text)
conrod_length = Val(l.Text)
cg_conrod = Val(l_dash.Text)
pist_mass = Val(pmass.Text)
conrod_mass = Val(conmass.Text)
crankpin_mass = Val(crank_mass.Text)
mr = (pist_mass * (conrod_length - cg_conrod) / conrod_length) + crankpin_mass
m = (cg_conrod * conrod_mass / conrod_length) + pist_mass
r = strke / 2
lam = r / conrod_length
a1 = 1
a2 = lam + ((1 / 4) * (lam) ^ 3) + ((15 / 128) * (lam) ^ 5)
cr_m1 = Val(crank_mass1)
cr_r1 = Val(crank_rad1)
cw_m1 = Val(counter_mass1)
cw_r1 = Val(counter_rad1)
cr_m2 = Val(crank_mass2)
cr_r2 = Val(crank_rad2)
cw_m2 = Val(counter_mass2)
cw_r2 = Val(counter_rad2)
eqm1 = (cr_m1 * cr_r1) - (cw_m1 * cw_r1)
eqm2 = (cr_m2 * cr_r2) - (cw_m2 * cw_r2)
m0 = (eqm1 + eqm2)
'the loop
Dim k As Variant
For f = 2 To Selection.CurrentRegion.Rows.Count - 1
Set i = Worksheets("input").Cells(f, 1)
Set k = Worksheets("input").Cells(f, 2)
y = rad(i)
p = k * 0.1
Cells(f, 16).Select
Selection.Value = p
a = Area(d)
fz = p * a
Cells(f, 17).Select
Selection.Value = fz
fzm = Forcezm(r, mr, m0, y, m, a1, a2)
Cells(f, 18).Select
Selection.Value = fzm
fym = Forceym(r, mr, mo, y, m)
Cells(f, 19).Select
Selection.Value = fym
vp = vprmf(r, m, y)
Cells(f, 20).Select
Selection.Value = vp
vs = vsrmf(r, m, a2, y)
Cells(f, 21).Select
Selection.Value = vs
trf = vp + vs
Cells(f, 22).Select
Selection.Value = trf
rf = trf - fz
Cells(f, 23).Select
Selection.Value = rf
fn = pistonst(rf, lam, y)
Cells(f, 24).Select
Selection.Value = fn
Next f
End Sub
Function Area(d As Variant) As Variant
pi = 22 / 7
Area = (pi * (d ^ 2)) / 4
End Function
Function Forcezm(r As Variant, mr As Variant, m0 As Variant, y As Variant, m As Variant, a1 As Variant, a2 As Variant) As Variant
pi = 22 / 7
rpm = Val(speed.Text)
Forcezm = r * (((2 * pi * rpm) / 60) ^ 2) * (((mr * m0) * 0.001 * Cos(y)) + (m * 0.001 * a1 * Cos(y)) + (m * 0.001 * a2 * (Cos(2 * y))))
End Function
Function Forceym(r As Variant, mr As Variant, m0 As Variant, y As Variant, m As Variant) As Variant
pi = 22 / 7
rpm = Val(speed.Text)
Forceym = r * (((2 * pi * rpm) / 60) ^ 2) * ((mr + m0) * 0.001 * Sin(y))
End Function
Function rad(i As Variant) As Variant
pi = 22 / 7
rad = (i * pi) / 180
End Function
Function Pre(p As Variant) As Variant
Pre = p * 0.1
End Function
Function vprmf(r As Variant, m As Variant, y As Variant) As Variant
pi = 22 / 7
rpm = Val(speed.Text)
vprmf = r * (((2 * pi * rpm) / 60) ^ 2) * m * 0.001 * Cos(y)
End Function
Function vsrmf(r As Variant, m As Variant, a2 As Variant, y As Variant) As Variant
pi = 22 / 7
rpm = Val(speed.Text)
vsrmf = r * (((2 * pi * rpm) / 60) ^ 2) * m * 0.001 * a2 * (Cos(2 * y))
End Function
Function pistonst(rf As Variant, lam As Variant, y As Variant) As Variant
pistonst = (rf * lam * Sin(y)) / ((1 - (lam * lam) * ((Sin(y)) ^ 2)) ^ 0.5)
End Function
Bookmarks