Consider the movement of the material point on the surface of the cone.
var('t')
var('a g')
xy_wsp = [('x','x'),('y','y'),('z','z')]
uv_wsp = [('r','r'),('phi','\phi'),('z','z')]
for v,lv in uv_wsp+xy_wsp:
var("%s"%v,latex_name=r'%s'%lv)
vars()[v.capitalize()] = function(v.capitalize())(t)
var("%sdd"%v,latex_name=r'\ddot %s'%lv)
var("%sd"%v,latex_name=r'\dot %s'%lv)
var("d%s"%v,latex_name=r'\delta %s'%lv)
xy = [vars()[v] for v,lv in xy_wsp]
uv = [vars()[v] for v,lv in uv_wsp]
to_fun=dict()
for v,lv in xy_wsp+uv_wsp:
to_fun[vars()[v]]=vars()[v.capitalize()]
to_fun[vars()[v+"d"]]=vars()[v.capitalize()].diff()
to_fun[vars()[v+"dd"]]=vars()[v.capitalize()].diff(2)
to_var = dict((v,k) for k,v in to_fun.items())
dAlemb = (X.diff(t,2))*dx +(Y.diff(t,2))*dy+ (Z.diff(t,2)+g)*dz
f = x^2 + y^2 - tan(a)^2*z^2
dxy = [vars()['d'+repr(zm)] for zm in xy]
constr =sum([dzm*f.diff(zm) for zm,dzm in zip(xy,dxy)])
show(f)
show(constr)
f.solve(z)
dAlemb_xy = dAlemb.subs(constr.solve(dz)[0]).subs(f.solve(z)[1])
show(dAlemb_xy.subs(to_var).coeff(dx))
show(dAlemb_xy.subs(to_var).coeff(dy))
Let's solve the problem in cylindrical coordinates. Because these coordinates are not consistent with constraints, but the cone has a particularly simple form in them. Therefore, we will have to perform the step of removing the dependent virtual offsets after moving to the cylindrical coordinate system.
x2u = {x:r*cos(phi),y:r*sin(phi),z:z}
for w in xy:
vars()['d'+repr(w)+'_polar']=sum([w.subs(x2u).diff(w2)*vars()['d'+repr(w2)] for w2 in uv])
show(dx_polar)
show(dy_polar)
show(dz_polar)
First, we write the d'Alembert's rule in cylindrical coordinates:
dAlemb = (x.subs(x2u).subs(to_fun).diff(t,2))*dx_polar + \
(y.subs(x2u).subs(to_fun).diff(t,2))*dy_polar+\
(z.subs(x2u).subs(to_fun).diff(t,2)+g)*dz_polar
dAlemb = dAlemb.subs(to_var)
show(dAlemb)
f_uv = f.subs(x2u).trig_simplify()
duv = [vars()['d'+repr(zm)] for zm in uv]
constr =sum([dzm*f_uv.diff(zm) for zm,dzm in zip(uv,duv)])
show(constr.solve(dz)[0])
dAlemb.subs( constr.solve(dz)[0] )
zdd_rdd = (f_uv.solve(z)[1]).subs(to_fun).diff(t,2).subs(to_var)
zdd_rdd
dAlemb_uv = dAlemb.subs( constr.solve(dz)[0] ).subs(f_uv.solve(z)[1]).subs(zdd_rdd)
r1 = dAlemb_uv.coeff(dr)
r2 = dAlemb_uv.coeff(dphi)
show(r1)
show( r2)
table([rown.trig_simplify() for rown in solve([r1,r2],[rdd,phidd])[0]])
\newpage