- #1
PauloE
- 28
- 0
Hello everyone,
I'm attempting to come up with a way to calculate the most efficient 7 members truss layout using Scilab.
The assignment is to make a highway sign support.
Since this is my first programming language I do not know how to approach it in order to get the best layout. My professor doesn't require it for the assignment and expects us to change the coordinates of the joints manually and sort of brute force the best layout that way. My idea would be just for extra credit.
Is this possible given that I only know Scilab language at a beginner level?
What examples can I look at to know where to start?
Thank you all!
Here is the most "advanced" thing I've done with Scilab so far:
I'm attempting to come up with a way to calculate the most efficient 7 members truss layout using Scilab.
The assignment is to make a highway sign support.
- It has to be L shaped and the truss system is only for the top horizontal part.
- Two supports.
- The sign is hanging at the furthest joint.
Since this is my first programming language I do not know how to approach it in order to get the best layout. My professor doesn't require it for the assignment and expects us to change the coordinates of the joints manually and sort of brute force the best layout that way. My idea would be just for extra credit.
Homework Equations
Is this possible given that I only know Scilab language at a beginner level?
What examples can I look at to know where to start?
Thank you all!
The Attempt at a Solution
Here is the most "advanced" thing I've done with Scilab so far:
Code:
//Create matrix called "joints" that stores the values of the coordinates
//of Joints 1 (first row), 2 (second row) 3(third row)
//Declare my variables (some of them)
joints = [-3 6;-3 4;7 6]//after a semicolon a new row starts.
members = [1 2; 1 3; 2 3]
weight = 850
wind = 320
//Now we display the matrix
printf("\n\n")// We add some space to make the console look cleaner
printf("Coordinates of Joint 1 = x = %3.3f y = %3.3f \n", joints(1,1), joints(1,2))
printf("Coordinates of Joint 2 = x = %3.3f y = %3.3f \n", joints(2,1), joints(2,2))
printf("Coordinates of Joint 3 = x = %3.3f y = %3.3f \n", joints(3,1), joints(3,2))
//now we store the coordinates in variables to call them later.
j1x = joints(1,1)
j1y = joints(1,2)
j2x = joints(2,1)
j2y = joints(2,2)
j3x = joints(3,1)
j3y = joints(3,2)
//now we get the distances.
d13x = abs(j3x - j1x)
d12x = abs(j2x - j1x)
//now create a matrix from the equilibrium equations.
A = [1 0 0;
0 0 1;
0 0 d12x;]
disp(A, "Matrix A")
//matrix B
B = [wind;
weight;
weight*d13x]
disp(B, "Matrix B")
//Solve matrix
x=A\B
//display results
printf("\n Ax = %3.3fN\n Cx = %3.3fN\n Cy = %3.3fN\n\n",x(1,1), x(2,1), x(3,1))
//Calculate the distances between the joints to be used later on the unit vector.
d12 = sqrt( (j2x - j1x)^2 + (j2y - j1y)^2 );
d13 = sqrt( (j3x - j1x)^2 + (j3y - j1y)^2 );
d23 = sqrt( (j3x - j2x)^2 + (j3y - j2y)^2 );
//now we calculate unit vectors
e31x = (j1x - j3x) / d13 //x component of unit vector from 3 to 1
e31y = (j1y - j3y) / d13 //y component of unit vector from 3 to 1
e32x = (j2x - j3x) / d23 //x component of unit vector from 3 to 2
e32y = (j2y - j3y) / d23 //y component of unit vector from 3 to 2
e12x = (j2x - j1x) / d12 //x component of unit vector from 1 to 2
e12y = (j2y - j1y) / d12 //y component of unit vector from 1 to 2
//unit vectosr in either direction are the same
e13x = -e31x
e13y = -e31y
e23x = -e32x
e23y = -e32y
e21x = -e12x
e21y = -e12y
//Create Matrix A
//Coefficients
// T12 T13 T23 Ax Ay Bx
A = [e12x e13x 0 1 0 0;//JOINT 1 x forces
e12y e13x 0 0 1 0;//JOINT 1 y forces
e21x 0 e23x 0 0 1;//JOINT 2 x forces
e21y 0 e23y 0 0 0;//JOINT 2 y forces
0 e31x e32x 0 0 0;//JOINT 3 x forces
0 e31y e32y 0 0 0;//JOINT 3 y forces
]
//MATRIX M
B = [0;
0;
0;
0;
wind;
weight;]
x = A\B
//Now print the results
printf("\n\n T12 = %7.3f LB\n T13 = %7.3f LB\n T23 = %7.3f LB \n", x(1,1), x(2,1), x(3,1))
printf("\n\n Ax = %7.3f LB\n Ay = %7.3f LB\n Bx = %7.3f LB \n", x(4,1), x(5,1), x(6,1))