0

I want to know the worst case for a crank rod application. Sketch The force Ft in the connecting rod is given by:

Equation

And I want to know its maximum.

I tried to solve it either on Wolfram Alpha or with SymPy. See the following code :

import sympy as sym
# import numpy as np
r, l, A = sym.symbols('r, l, A', positive = 'True')
B= sym.asin(r/l*sym.sin(A))
f = sym.simplify(sym.sin(A+B)/sym.cos(B))
df=sym.simplify(sym.diff(f,A))
sln=sym.solveset(df,A, sym.Interval(0, sym.pi))

it gives me, that

Complement(ConditionSet(_R, Eq((-l + r*sin(_R))**2*(l + r*sin(_R))**2*(l**4*cos(_R + asin(r*sin(_R)/l))**2 - 2*l**2*r**2*sin(_R)**2*cos(_R + asin(r*sin(_R)/l))**2 + 2*l**2*r**2*sin(_R)*sin(_R + asin(r*sin(_R)/l))*cos(_R)*cos(_R + asin(r*sin(_R)/l)) - l**2*r**2*cos(_R)**2*cos(_R + asin(r*sin(_R)/l))**2 + r**4*sin(_R)**4*cos(_R + asin(r*sin(_R)/l))**2 - 2*r**4*sin(_R)**3*sin(_R + asin(r*sin(_R)/l))*cos(_R)*cos(_R + asin(r*sin(_R)/l)) + r**4*sin(_R)**2*sin(_R + asin(r*sin(_R)/l))**2*cos(_R)**2 + r**4*sin(_R)**2*cos(_R)**2*cos(_R + asin(r*sin(_R)/l))**2), 0), Interval(0, pi)), Union(Intersection({0}, ImageSet(Lambda(_n, -I*(I*(2*_n*pi + arg(sqrt(-2*l**2 - 2*l*sqrt(l - r)*sqrt(l + r) + r**2))) + log(Abs(sqrt(-2*l*sqrt(l - r)*sqrt(l + r)/r**2 + (-2*l**2 + r**2)/r**2))))), Interval(0, pi))), Intersection({0}, ImageSet(Lambda(_n, -I*(I*(2*_n*pi + arg(sqrt(-2*l**2 + 2*l*sqrt(l - r)*sqrt(l + r) + r**2))) + log(Abs(sqrt(2*l*sqrt(l - r)*sqrt(l + r)/r**2 + (-2*l**2 + r**2)/r**2))))), Interval(0, pi))), Intersection({0}, ImageSet(Lambda(_n, -I*(I*(2*_n*pi + arg(-sqrt(-2*l**2 - 2*l*sqrt(l - r)*sqrt(l + r) + r**2))) + log(Abs(sqrt(-2*l*sqrt(l - r)*sqrt(l + r)/r**2 + (-2*l**2 + r**2)/r**2))))), Interval(0, pi))), Intersection({0}, ImageSet(Lambda(_n, -I*(I*(2*_n*pi + arg(-sqrt(-2*l**2 + 2*l*sqrt(l - r)*sqrt(l + r) + r**2))) + log(Abs(sqrt(2*l*sqrt(l - r)*sqrt(l + r)/r**2 - (2*l**2 - r**2)/r**2))))), Interval(0, pi)))))

I don't know what is _n and Lambda ?

Could you please help me ?

talonmies
72.8k35 gold badges204 silver badges297 bronze badges
asked Apr 18, 2024 at 8:13
0

1 Answer 1

0
from sympy import *
r, l, A, L, t = sym.symbols('r, l, A, L, t', positive = 'True')
B= sym.asin(r/l*sym.sin(A))
f = sym.simplify(sym.sin(A+B)/sym.cos(B))
df=sym.simplify(sym.diff(f,A))
# replace r/l with L and expand trig funcs and rewrite in terms of tan
# and then replace tan(A/2)**2 with x
eq=df.subs(r,l*L).factor().expand(trig=True).rewrite(tan).subs(tan(A/2)**2,x)
# take the numerator and factor - it gives 3 factors
z = list(ordered(eq.as_numer_denom()[0].factor().args))
print(solve(z[0].base,x)) # (x + 1)**42
print(solve(z[1].base,x)) # (-4*L**2*x + x**2 + 2*x + 1)**19
# remove radicals from z[2]
from sympy.solvers.solvers import unrad
u = unrad(z[2],x)[0] # there is no change of var
# extend z with the new x-containing factors
z[-1:]=collect(u.factor(),L).as_independent(x)[1].args
print(solve(z[2].base,x))

This gives the 3 trivial solutions for x which is defined as tan(A/2)**2. It is left as an exercise to show that none of them is a valid solution.

[-1]
[2*L**2 - 2*L*sqrt(L**2 - 1) - 1, 2*L**2 + 2*L*sqrt(L**2 - 1) - 1]
[-1]

z[3] is quadratic in L**2 and is a 6th order polynomial in x.

numerical solutions

It will be easy to get solutions for a given L:

>>> [i.n(3) for i in real_roots(z[-1].subs(L,S.Half))] # r/l = L in [0,1]
[-2.99, -0.335, 0.450, 2.22]

And now solve those for A given the above definition. Since unrad was used, one should check the roots in the original equation, however, to see that they are valid.

implicit symbolic solutions

Let's get the implicit solutions and check them.

>>> Lsol = [sqrt(i) for i in solve(z[-1],L**2)]
# check that numerators of eq are zero when these solutions are used
>>> check = [eq.subs(L,li).simplify().as_numer_denom()[0] for li in Lsol]
# simplify under assumptions that sqrt args combine
>>> [powsimp(i,force=1).subs(x,t).factor(deep=1) for i in check]
[t + Abs(t - 1) - 1, t + Abs(t - 1) - 1]

So it looks like the implicit relationships will be valid as long as t = tan(A/2)**2 is in [0,1].

explicit symbolic solutions

Instead of rewriting in terms of tan it is possible to write in terms of cos:

>>> unrad(df.as_numer_denom()[0].expand(trig=1).subs(sin(A)**2,1-cos(A)**2).subs(cos(A),x).subs(r,l*L))[0].subs(x**2,y).factor()
-l*(L - 1)*(L + 1)*(L**2*y - L**2 + 1)**2*(L**4*y**3 - 3*L**4*y**2 + 3*L**4*y - L**4 + L**2*y**2 - 2*L**2*y + L**2 - y)
>>> _.as_independent(y)[1]
(L**2*y - L**2 + 1)**2*(L**4*y**3 - 3*L**4*y**2 + 3*L**4*y - L**4 + L**2*y**2 - 2*L**2*y + L**2 - y)

Only the last two factors depend on y = cos(A)**2 and it is cubic in y so an explicit solution can be found; only positive values should be selected for y.

answered Apr 20, 2024 at 1:14
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, it took me time to undestand all the parts but now I have the solution of A for all r/l

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.