Naveshin Jawaheer

15 Reputation

One Badge

2 years, 318 days

MaplePrimes Activity


These are replies submitted by

@tomleslie Thanks for your help. For some reason when I run it, the same error Error, (in plots/odeplot) input is not a valid dsolve/numeric solution) still pops up. All I have changed is the mass values. I ahve attached the code below. Also for some reason, why is the code for the plot in text mdoe rather than math mode? 

Thanks for your time and thanks 

restart:

(x[1],y[1]):= l[1]*~(sin,-cos)(theta(t));
(x[2],y[2]):= l[2]*~(-sin,cos)(theta(t));
(x[4],y[4]):= (x[1],y[1])+~l[4]*~(-sin,cos)((theta+phi)(t));
(x[3],y[3]):= (x[2],y[2])+~l[3]*~(sin,-cos)((theta-psi)(t));
R:= table([seq](k= [x[k],y[k]], k= 1..4));
dR:= diff~(R, t);

l[1]*sin(theta(t)), -l[1]*cos(theta(t))

 

-l[2]*sin(theta(t)), l[2]*cos(theta(t))

 

l[1]*sin(theta(t))-l[4]*sin(theta(t)+phi(t)), -l[1]*cos(theta(t))+l[4]*cos(theta(t)+phi(t))

 

-l[2]*sin(theta(t))-l[3]*sin(-theta(t)+psi(t)), l[2]*cos(theta(t))-l[3]*cos(-theta(t)+psi(t))

 

table( [( 1 ) = [l[1]*sin(theta(t)), -l[1]*cos(theta(t))], ( 2 ) = [-l[2]*sin(theta(t)), l[2]*cos(theta(t))], ( 3 ) = [-l[2]*sin(theta(t))-l[3]*sin(-theta(t)+psi(t)), l[2]*cos(theta(t))-l[3]*cos(-theta(t)+psi(t))], ( 4 ) = [l[1]*sin(theta(t))-l[4]*sin(theta(t)+phi(t)), -l[1]*cos(theta(t))+l[4]*cos(theta(t)+phi(t))] ] )

 

table( [( 1 ) = [l[1]*(diff(theta(t), t))*cos(theta(t)), l[1]*(diff(theta(t), t))*sin(theta(t))], ( 2 ) = [-l[2]*(diff(theta(t), t))*cos(theta(t)), -l[2]*(diff(theta(t), t))*sin(theta(t))], ( 3 ) = [-l[2]*(diff(theta(t), t))*cos(theta(t))-l[3]*(-(diff(theta(t), t))+diff(psi(t), t))*cos(-theta(t)+psi(t)), -l[2]*(diff(theta(t), t))*sin(theta(t))+l[3]*(-(diff(theta(t), t))+diff(psi(t), t))*sin(-theta(t)+psi(t))], ( 4 ) = [l[1]*(diff(theta(t), t))*cos(theta(t))-l[4]*(diff(theta(t), t)+diff(phi(t), t))*cos(theta(t)+phi(t)), l[1]*(diff(theta(t), t))*sin(theta(t))-l[4]*(diff(theta(t), t)+diff(phi(t), t))*sin(theta(t)+phi(t))] ] )

(1)

F:= [theta, phi, psi](t):
V:= [l[1], l[2], l[3], l[4], m[1], m[2], diff(F, t)[], (cos,sin)(psi(t)), g]:

T:= combine(simplify(collect(m[1]/2*inner(dR[4]$2)+m[2]/2*inner(dR[3]$2), V)), trig);

-(diff(theta(t), t))^2*l[1]*l[4]*m[1]*cos(phi(t))-(diff(theta(t), t))^2*l[2]*l[3]*m[2]*cos(psi(t))+(1/2)*(diff(theta(t), t))^2*m[1]*l[1]^2+(1/2)*(diff(theta(t), t))^2*m[2]*l[2]^2+(1/2)*m[1]*l[4]^2*(diff(phi(t), t))^2+(1/2)*m[1]*l[4]^2*(diff(theta(t), t))^2+(1/2)*m[2]*l[3]^2*(diff(psi(t), t))^2+(1/2)*m[2]*l[3]^2*(diff(theta(t), t))^2+m[1]*l[4]^2*(diff(theta(t), t))*(diff(phi(t), t))-m[2]*l[3]^2*(diff(theta(t), t))*(diff(psi(t), t))-(diff(theta(t), t))*(diff(phi(t), t))*l[1]*l[4]*m[1]*cos(phi(t))+(diff(theta(t), t))*(diff(psi(t), t))*l[2]*l[3]*m[2]*cos(psi(t))

(2)

U:= collect(simplify(expand(g*m[1]*y[4] + g*m[2]*y[3])), V);

-g*m[1]*l[1]*cos(theta(t))+g*m[2]*l[2]*cos(theta(t))+(-g*cos(theta(t))*cos(psi(t))-g*sin(theta(t))*sin(psi(t)))*m[2]*l[3]+g*(cos(theta(t))*cos(phi(t))-sin(theta(t))*sin(phi(t)))*m[1]*l[4]

(3)

L:= simplify(collect(T-U, V));

(1/2)*(-2*cos(phi(t))*l[1]*l[4]*m[1]-2*cos(psi(t))*l[2]*l[3]*m[2]+(l[1]^2+l[4]^2)*m[1]+m[2]*(l[2]^2+l[3]^2))*(diff(theta(t), t))^2+(1/2)*(-2*l[4]*m[1]*(cos(phi(t))*l[1]-l[4])*(diff(phi(t), t))+2*(diff(psi(t), t))*l[3]*m[2]*(cos(psi(t))*l[2]-l[3]))*(diff(theta(t), t))+(1/2)*m[1]*l[4]^2*(diff(phi(t), t))^2+(1/2)*m[2]*l[3]^2*(diff(psi(t), t))^2-g*((cos(phi(t))*l[4]*m[1]-cos(psi(t))*l[3]*m[2]-l[1]*m[1]+l[2]*m[2])*cos(theta(t))-sin(theta(t))*(sin(phi(t))*l[4]*m[1]+sin(psi(t))*l[3]*m[2]))

(4)

Eul:= remove(has, VariationalCalculus:-EulerLagrange(L, t, F), K[1]);

{sin(phi(t))*l[1]*l[4]*m[1]*(diff(theta(t), t))^2-g*(-sin(phi(t))*l[4]*m[1]*cos(theta(t))-sin(theta(t))*cos(phi(t))*l[4]*m[1])+l[4]*m[1]*(cos(phi(t))*l[1]-l[4])*(diff(diff(theta(t), t), t))-m[1]*l[4]^2*(diff(diff(phi(t), t), t)), sin(psi(t))*l[2]*l[3]*m[2]*(diff(theta(t), t))^2-g*(sin(psi(t))*l[3]*m[2]*cos(theta(t))-sin(theta(t))*cos(psi(t))*l[3]*m[2])-l[3]*m[2]*(cos(psi(t))*l[2]-l[3])*(diff(diff(theta(t), t), t))-m[2]*l[3]^2*(diff(diff(psi(t), t), t)), -g*(-(cos(phi(t))*l[4]*m[1]-cos(psi(t))*l[3]*m[2]-l[1]*m[1]+l[2]*m[2])*sin(theta(t))-cos(theta(t))*(sin(phi(t))*l[4]*m[1]+sin(psi(t))*l[3]*m[2]))-(2*(diff(phi(t), t))*sin(phi(t))*l[1]*l[4]*m[1]+2*(diff(psi(t), t))*sin(psi(t))*l[2]*l[3]*m[2])*(diff(theta(t), t))-(-2*cos(phi(t))*l[1]*l[4]*m[1]-2*cos(psi(t))*l[2]*l[3]*m[2]+(l[1]^2+l[4]^2)*m[1]+m[2]*(l[2]^2+l[3]^2))*(diff(diff(theta(t), t), t))-l[4]*m[1]*(diff(phi(t), t))^2*sin(phi(t))*l[1]+l[4]*m[1]*(cos(phi(t))*l[1]-l[4])*(diff(diff(phi(t), t), t))-(diff(diff(psi(t), t), t))*l[3]*m[2]*(cos(psi(t))*l[2]-l[3])+(diff(psi(t), t))^2*l[3]*m[2]*sin(psi(t))*l[2]}

(5)

INITS:=
    phi(0) = Pi/4, psi(0) = Pi/4, theta(0) = (3*Pi)/4,
    D(phi)(0) = 0, D(psi)(0) = 0, D(theta)(0) = 0
:

PARAM:= [g = 9.8, l[1] = 10, l[2] = 100, l[3] = 100, l[4] = 21, m[1] = 35000, m[2] = 350]:

sys:= eval(Eul, PARAM)[]:

sol:= dsolve([sys, INITS], numeric):

plots:-odeplot(
    sol, [t, diff(psi(t), t)], 1..3, numpoints= 1000,
    labels= ["times(sec)", "Psi’(deg/s)"],
    labeldirections= [horizontal, vertical], font= [TIMES, ROMAN, 20]
);
plots:-odeplot(
    sol, [t, diff(theta(t), t)], t= 1..3, numpoints= 1000,
    labels= ["time(sec)", "Theta’(deg/s)"],
    labeldirections= [horizontal, vertical], font = [TIMES, ROMAN, 20]);NULL

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

 

Download Naveshin.mw

@Carl Love Thanks for the help on the missing parenthesis. However for some reason it can be seen that I still have the issue with the dsolve part which gives me the error, Error, (in dsolve/numeric/process_input) system must be entered as a set/list of expressions/equations. The code with the update is below. Do you mind taking a look? 

 


 

restart

with(VariationalCalculus)``

with(plots)
with(linalg)

We will now declare our first equations

 

 

x[1] := l[1]*sin(theta(t))

y[1] := -l[1]*cos(theta(t))NULL

x[2] := -l[2]*sin(theta(t)); y[2] := l[2]*cos(theta(t))

x[4] := x[1]-l[4]*sin(theta(t)+phi(t)); y[4] := y[1]+l[4]*cos(theta(t)+phi(t)); x[3] := x[2]+l[3]*sin(theta(t)-psi(t)); y[3] := y[2]-l[3]*cos(theta(t)-psi(t))

R[1] := vector(2, [x[1], y[1]]); R[2] := vector(2, [x[2], y[2]]); R[4] := vector(2, [x[4], y[4]]); R[3] := vector(2, [x[3], y[3]])

`\`R`[1]*` ≔ map`(diff, R[1], t); `\`R`[2]*` ≔ map`(diff, R[2], t); `\`R`[4]*` ≔ map`(diff, R[4], t); `\`R`[3]*`≔map`(diff, R[3], t)

NULL

NULL

T := combine(simplify(collect((1/2)*m[1]*innerprod(`\`R`[4]*`,`*R[4]*`)+m[2]/2*
innerprod(\`R[3]\`,\`R[3]`), [l[1], l[2], l[3], l[4], m[1], m[2], diff(theta(t), t), diff(phi(t), t), diff(psi(t), t), cos(psi(t)), sin(psi(t))])), trig)

NULL

U := collect(simplify(expand(g*m[1]*y[4]+g*m[2]*y[3])), [l[1], l[2], l[3], l[4], m[1], m[2], diff(theta(t), t), diff(phi(t), t), diff(psi(t), t), cos(psi(t)), sin(psi(t)), g])

NULL

L := simplify(collect(T-U, [l[1], l[2], l[3], l[4], m[1], m[2], diff(theta(t), t), diff(phi(t), t), diff(psi(t), t), cos(psi(t)), sin(psi(t))]))

NULL

NULL

NULL

Eul := remove(has, EulerLagrange(L, t, [theta(t), phi(t), psi(t)]), K[1]); eq1 := op(select(has, Eul, (diff(psi(t), t))^2)); eq2 := op(select(has, remove(has, Eul, (diff(psi(t), t))^2), sin(psi(t)))); eq3 := op(remove(has, remove(has, Eul, (diff(psi(t), t))^2), sin(psi(t))))

NULL

NULL

INITS := {phi(0) = (1/4)*Pi, psi(0) = (1/4)*Pi, theta(0) = 3*Pi*(1/4), (D(phi))(0) = 0, (D(psi))(0) = 0, (D(theta))(0) = 0}

NULL

PARAM := [g = 9.8, l[1] = 10, l[2] = 100, l[3] = 100, l[4] = 21, m[1] = 1000, m[2] = 1]

NULL

Evaluating the general equation for motion with respect to our
parameters.

NULL

sys := (eval([eq1, eq2, eq3], PARAM))[]

NULLNULL

 

We use a numeric ODE solver to approximate the change in theta and
theta’ over time.

 

sol := dsolve([sys, INITS], numeric)

Error, (in dsolve/numeric/process_input) system must be entered as a set/list of expressions/equations

 

NULL

Plotting time vs angular velocity

 

odeplot(sol, [t, diff(psi(t), t)], 1 .. 3, numpoints = 1000, labels = ["times(sec)", "Psi’(deg/s)"]), labeldirections = [horizontal, vertical], font = [TIMES, ROMAN, 20]; odeplot(sol, [t, diff(theta(t), t)], t = 1 .. 3, numpoints = 1000, labels = ["time(sec)", "Theta’(deg/s)"], labeldirections = [horizontal, vertical], font = [TIMES, ROMAN, 20]); noffm := 23

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

NULL

NULL


 

Download test_2.mw

Page 1 of 1