summaryrefslogtreecommitdiff
path: root/764/CH4/EX4.4.b/solution4_4.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /764/CH4/EX4.4.b/solution4_4.sce
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '764/CH4/EX4.4.b/solution4_4.sce')
-rwxr-xr-x764/CH4/EX4.4.b/solution4_4.sce73
1 files changed, 73 insertions, 0 deletions
diff --git a/764/CH4/EX4.4.b/solution4_4.sce b/764/CH4/EX4.4.b/solution4_4.sce
new file mode 100755
index 000000000..dd24a6e23
--- /dev/null
+++ b/764/CH4/EX4.4.b/solution4_4.sce
@@ -0,0 +1,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)
+