Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

substitute variables into values

I am trying to use Sagemath for a mechanics problem, for which I am at first solving a DE symbolically and later on assign physical properties to the parameters and finally plot the result. (It's a 2nd order bending problem) There are quite some parameters that I have to use, some parameters have to be expressed by other parameters.

A1, A2, A3, A4, K, qz, qzc, l, E, I, A, al, dT, y = var('A1, A2, A3, A4, K, qz, qzc, l, E, I, A, al, dT, y')
eq1 = -A3-A4*K*l+A3*cos(K*l)+A4*sin(K*l)+((qzc*l^2)/(2*K^2)) == 0
eq2 = -A3*K^2*cos(K*l)-A4*K^2*sin(K*l)+(qzc/(K^2)) == 0
solutions = solve([eq1,eq2], A3, A4)
sol = solutions [0]
sol_A3 = sol[0].rhs()
sol_A4 = sol[1].rhs()
sol_A3

1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

sol_A4

1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

w2 = function('w2')(x)
w2 = -sol_A3 - sol_A4*K*x + sol_A3*cos(K*x) + sol_A4*sin(K*x) + (qzc*x^2)/(2*K^2)

From this point on I have to assign values to variables, and express variables by means of other variables.

E = 21*10^4
I = 349*10^4
A = 2120
l = 3000
al = 11*10^(-6)
qz = 15
dT = 100
kt = (A*E)/l
qzc = qz/(E*I)
K = sqrt((al*dT*A*kt*l)/((E*A+kt*l)*I))
w2_intermediate = -sol_A3 - sol_A4*K*x + sol_A3*cos(K*x) + sol_A4*sin(K*x) + (qzc*x^2)/(2*K^2)
w2_intermediate

-1/2000*sqrt(583/1745)*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc*x/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/32648*x^2 + 1/2*(2*K*l -      (K^2*l^2 + 2)*sin(K*l))*qzc*cos(1/1000*sqrt(583/1745)*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc*sin(1/1000*sqrt(583/1745)*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) - 1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

I don't know how to substitute the kt, qzc and the K's in this function.

substitute variables into values

I am trying to use Sagemath for a mechanics problem, for which I am at first solving a DE symbolically and later on assign physical properties to the parameters and finally plot the result. (It's a 2nd order bending problem) There are quite some parameters that I have to use, some parameters have to be expressed by in terms of other parameters.

A1, A2, A3, A4, K, qz, qzc, l, E, I, A, al, dT, y = var('A1, A2, A3, A4, K, qz, qzc, l, E, I, A, al, dT, y')
eq1 = -A3-A4*K*l+A3*cos(K*l)+A4*sin(K*l)+((qzc*l^2)/(2*K^2)) == 0
eq2 = -A3*K^2*cos(K*l)-A4*K^2*sin(K*l)+(qzc/(K^2)) == 0
solutions = solve([eq1,eq2], A3, A4)
sol = solutions [0]
sol_A3 = sol[0].rhs()
sol_A4 = sol[1].rhs()
sol_A3

1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

sol_A4

1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

w2 = function('w2')(x)
w2 = -sol_A3 - sol_A4*K*x + sol_A3*cos(K*x) + sol_A4*sin(K*x) + (qzc*x^2)/(2*K^2)

From this point on I have to assign values to variables, and express variables by means of other variables.

E = 21*10^4
I = 349*10^4
A = 2120
l = 3000
al = 11*10^(-6)
qz = 15
dT = 100
kt = (A*E)/l
qzc = qz/(E*I)
K = sqrt((al*dT*A*kt*l)/((E*A+kt*l)*I))
w2_intermediate = -sol_A3 - sol_A4*K*x + sol_A3*cos(K*x) + sol_A4*sin(K*x) + (qzc*x^2)/(2*K^2)
w2_intermediate

-1/2000*sqrt(583/1745)*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc*x/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/32648*x^2 + 1/2*(2*K*l -      (K^2*l^2 + 2)*sin(K*l))*qzc*cos(1/1000*sqrt(583/1745)*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc*sin(1/1000*sqrt(583/1745)*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) - 1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

I don't know how to substitute the kt, qzc and the K's in this function.

substitute variables into values

(Edit: I have recently started with Sagemath for an engineering course I am attending. I don't have access to Maple or Mathematica, so I wanted to give Sagemath a try. I am trying to combine info and examples from several sources but sadly I don't have any experience with Python)

I am trying to use Sagemath for a mechanics problem, for which I am at first solving a DE symbolically and later on assign physical properties to the parameters and finally plot the result. (It's a 2nd order bending problem) There are quite some parameters that I have to use, some parameters have to be expressed in terms of other parameters.

A1, A2, A3, A4, K, kt, qz, qzc, l, E, I, A, al, dT, y = var('A1, A2, A3, A4, K, kt, qz, qzc, l, E, I, A, al, dT, y')
eq1 = -A3-A4*K*l+A3*cos(K*l)+A4*sin(K*l)+((qzc*l^2)/(2*K^2)) == 0
eq2 = -A3*K^2*cos(K*l)-A4*K^2*sin(K*l)+(qzc/(K^2)) == 0
solutions = solve([eq1,eq2], A3, A4)
sol = solutions [0]
sol_A3 = sol[0].rhs()
sol_A4 = sol[1].rhs()
sol_A3

1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

sol_A4

1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

w2 = function('w2')(x)
w2 = -sol_A3 - sol_A4*K*x + sol_A3*cos(K*x) + sol_A4*sin(K*x) + (qzc*x^2)/(2*K^2)
w2

-1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*K*qzc*x/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc*cos(K*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc*sin(K*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) - 1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/2*qzc*x^2/K^2

From this point on I have want to assign values to variables, and express variables by means of other variables.

E = 21*10^4
I = 349*10^4
A = 2120
l = 3000
al = 11*10^(-6)
qz = 15
dT = 100
kt = (A*E)/l
qzc = qz/(E*I)
K = sqrt((al*dT*A*kt*l)/((E*A+kt*l)*I))
w2_intermediate = -sol_A3 - sol_A4*K*x + sol_A3*cos(K*x) + sol_A4*sin(K*x) + (qzc*x^2)/(2*K^2)
w2_intermediate

-1/2000*sqrt(583/1745)*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc*x/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/32648*x^2 + 1/2*(2*K*l -      (K^2*l^2 + 2)*sin(K*l))*qzc*cos(1/1000*sqrt(583/1745)*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) + 1/2*((K^2*l^2 + 2)*cos(K*l) - 2)*qzc*sin(1/1000*sqrt(583/1745)*x)/(K^5*l*cos(K*l) - K^4*sin(K*l)) - 1/2*(2*K*l - (K^2*l^2 + 2)*sin(K*l))*qzc/(K^5*l*cos(K*l) - K^4*sin(K*l))

I don't know how to substitute the kt, qzc and the K's in this function.