I want to get an expression i.t.o B but I get the given error, everything else works fine. Don't really know whats happening if you guys could help I would really apreciate. Literaly everything works until the last line of code. So you can like ignore the whole big batch of code you can just look at the last few lines.
#Tut 10 Question 3 Attempt Almost got there...
x = sym.Symbol("x")
L,a,P = sym.Symbol("L"),sym.Symbol("a"),sym.Symbol("P")
A,B,C,D,E,F = sym.Symbol("A"),sym.Symbol("B"),sym.Symbol("C"),sym.Symbol("D"),sym.Symbol("E"),sym.Symbol("F")
#LHS
print("LHS")
lV = (L-a)*(P) #Shear force remains constant throughout 0 < x < a
lM = sym.integrate(lV,x) + A
lM = lM.subs(A,0)
display(lM)
ltheta = sym.integrate(lM,x) + B
display(ltheta)
lv = sym.integrate(ltheta,x) + C
lv = lv.subs(C,0)
display(lv)
#RHS
print("RHS")
rV = (a)*(P) #Shear force remains constant throughout 0 < x < a
rM = sym.integrate(rV,x) + D
rM = rM.subs(D,0)
display(rM)
rtheta = sym.integrate(rM,x) + E
display(rtheta)
rv = sym.integrate(rtheta,x) + F
rv = rv.subs(F,0)
display(rv)
print("combined")
CombinedTheta = rtheta - ltheta
CombinedTheta = CombinedTheta.subs(x,a) #### Look at the Hints of the question thethaLHS = thetaRHS at x =a
display(CombinedTheta)
Combinedv = rv - lv
Combinedv = Combinedv.subs(x,a) #### Look at the Hints of the question vLHS = vRHS at x =a
display(Combinedv)
#now we will solve E i.t.o B
print("solving for E")
factorE = sym.solve(CombinedTheta,E)[0]
display(factorE)
#now we will solve B by plugging factorE into E of Combinedv
print("solving for B")
Combinedv = Combinedv.subs(E,factorE)
Equation = Combinedv
display(Equation)
FactorB = sym.solve(Equation,B)[0]
I have been doing that technique the whole time and don't understand why I'm not getting it.
Your equation has no solutions for almost all possible values of the parameters. Here it is:
In [10]: Equation
Out[10]:
4 ⎛ 2 ⎞
P⋅a 3 ⎛L⋅P P⋅a⎞ ⎜ L⋅P⋅a 3⎟
-B⋅a + ──── - a ⋅⎜─── - ───⎟ + a⋅⎜B + ────── - P⋅a ⎟
6 ⎝ 6 6 ⎠ ⎝ 2 ⎠
In [11]: solve(Equation, B)
Out[11]: []
In [12]: Equation.expand()
Out[12]:
3 4
L⋅P⋅a 2⋅P⋅a
────── - ──────
3 3
You can see that after expanding there is no B
in the equation so there is no value of B
that can make this equal to zero. The result from solve
here applies for "generic" values of the symbolic parameters L
, P
and a
and generically the expression above will not be equal to zero so there are no solutions for B
in this equation and solve
returns an empty list. Should the parameters take (degenerate) values such that the expression was equal to zero then any value of B
would be a solution in which case there wouldn't be anything useful for solve
to return either.