summaryrefslogtreecommitdiff
path: root/764/CH4/EX4.4.b/solution4_4.sce
blob: dd24a6e2378536376db9b9a2dbc3ca6a087e78dc (plain)
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

//Function to calculate roots of a quadratic equation
function[r] = quadratic(a,b,c)
    //Calculate discriminant D
    D = (b^2)-(4 * a * c)
    r1 = ((-1 * b)+ sqrt(D))/(2 * a)
    r2 = ((-1 * b)- sqrt(D))/(2 * a)
    if(r1 > 0)
        r = r1
    else
        r = r2
    end
endfunction

//Function to round-up a value such that it is divisible by 5
function[v] = round_five(w)
    v = ceil(w)
    rem = pmodulo(v,5)
    if (rem ~= 0)
        v = v + (5 - rem)
    end
endfunction

//Obtain path of solution file
path = get_absolute_file_path('solution4_4.sce')
//Obtain path of data file
datapath = path + filesep() + 'data4_4.sci'
//Clear all
clc
//Execute the data file
exec(datapath)
//Permissible stresses (N/mm2)
//Compressive stress sigmac
sigmac = (2 * Syt)/fs
//Yield strength in shear of the material Ssy (N/mm2)
Ssy = (50/100)*Syt
//Shear stress tau
tau = Ssy/fs
//Tensile stress sigmat
sigmat = Syt/fs
//Calculate the load acting on the rods P (N)
P = (%pi/4)*((d^2) * sigmat)
//Calculate inside diameter of the socket d2 (mm)
//a,b,c are the coefficients of the resulting quadratic equation
//ax^2 + bx + c = 0  x=d2
a = (%pi/4)*sigmat
b = (-1)*(t * sigmat)
c = (-1)*(P)
d2 = quadratic(a, b, c)
d2 = round_five(d2)
//Calculate outside of socket d1 (mm)
//a,b,c are the coefficients of the resulting quadratic equation
//ax^2 + bx + c = 0  x=d1
a = (%pi/4)*(sigmat)
b = (-1)*(t * sigmat)
c = (((-1 * (%pi/4) * (d2^2))+(t * d2))*sigmat)-(P)
d1 = quadratic(a, b, c)
d1 = round_five(d1)
//Calculate daimeter of socket collar d4 (mm)
d4 = (P/(sigmac * t)) + d2
d4 = round_five(d4)
//Calculate dimensions of a and c (mm)
a = P/(2 * d2 * tau)
a = round_five(a)
c = P/(2 * (d4 - d2) * tau)
c = round_five(c)
//Print results
printf('\nLoad acting on rods(P) = %f N\n',P)
printf('\nInside diameter of socket(d2) = %f mm\n',d2)
printf('\nOutside diameter of socket(d1) = %f mm\n',d1)
printf('\nDiameter of socket collar(d4) = %f mm\n',d4)
printf('\na = %f mm\n\nc = %f mm\n',a,c)