#NEWLINE# def test_sub_qdot2( ) : #NEWLINE# #INDENT# ( g , m , Px , Py , Pz , R , t ) = symbols ( 'g m Px Py Pz R t' ) #NEWLINE# q = dynamicsymbols ( 'q:5' ) #NEWLINE# qd = dynamicsymbols ( 'q:5' , level = 1 ) #NEWLINE# u = dynamicsymbols ( 'u:5' ) #NEWLINE# A = ReferenceFrame ( 'A' ) #NEWLINE# B_prime = A . orientnew ( 'B_prime' , 'Axis' , [ q [ 0 ] , A . z ] ) #NEWLINE# B = B_prime . orientnew ( 'B' , 'Axis' , [ ( ( pi / 2 ) - q [ 1 ] ) , B_prime . x ] ) #NEWLINE# C = B . orientnew ( 'C' , 'Axis' , [ q [ 2 ] , B . z ] ) #NEWLINE# pO = Point ( 'O' ) #NEWLINE# pO . set_vel ( A , 0 ) #NEWLINE# pR = pO . locatenew ( 'R' , ( ( q [ 3 ] * A . x ) + ( q [ 4 ] * A . y ) ) ) #NEWLINE# pR . set_vel ( A , pR . pos_from ( pO ) . diff ( t , A ) ) #NEWLINE# pR . set_vel ( B , 0 ) #NEWLINE# pC_hat = pR . locatenew ( 'C^' , 0 ) #NEWLINE# pC_hat . set_vel ( C , 0 ) #NEWLINE# pCs = pC_hat . locatenew ( 'C*' , ( R * B . y ) ) #NEWLINE# pCs . set_vel ( C , 0 ) #NEWLINE# pCs . set_vel ( B , 0 ) #NEWLINE# pCs . v2pt_theory ( pR , A , B ) #NEWLINE# pC_hat . v2pt_theory ( pCs , A , C ) #NEWLINE# R_C_hat = ( ( ( Px * A . x ) + ( Py * A . y ) ) + ( Pz * A . z ) ) #NEWLINE# R_Cs = ( ( ( - m ) * g ) * A . z ) #NEWLINE# forces = [ ( pC_hat , R_C_hat ) , ( pCs , R_Cs ) ] #NEWLINE# u_expr = [ ( C . ang_vel_in ( A ) & uv ) for uv in B ] #NEWLINE# u_expr += qd [ 3 : ] #NEWLINE# kde = [ ( ui - e ) for ( ui , e ) in zip ( u , u_expr ) ] #NEWLINE# km1 = KanesMethod ( A , q , u , kde ) #NEWLINE# with warnings . catch_warnings ( ) : #NEWLINE# #INDENT# warnings . filterwarnings ( 'ignore' , category = SymPyDeprecationWarning ) #NEWLINE# ( fr1 , _ ) = km1 . kanes_equations ( forces , [ ] ) #NEWLINE# #UNINDENT# u_indep = u [ : 3 ] #NEWLINE# u_dep = list ( ( set ( u ) - set ( u_indep ) ) ) #NEWLINE# vc = [ ( pC_hat . vel ( A ) & uv ) for uv in [ A . x , A . y ] ] #NEWLINE# km2 = KanesMethod ( A , q , u_indep , kde , u_dependent = u_dep , velocity_constraints = vc ) #NEWLINE# with warnings . catch_warnings ( ) : #NEWLINE# #INDENT# warnings . filterwarnings ( 'ignore' , category = SymPyDeprecationWarning ) #NEWLINE# ( fr2 , _ ) = km2 . kanes_equations ( forces , [ ] ) #NEWLINE# #UNINDENT# fr1_expected = Matrix ( [ ( ( ( ( - R ) * g ) * m ) * sin ( q [ 1 ] ) ) , ( ( ( - R ) * ( ( Px * cos ( q [ 0 ] ) ) + ( Py * sin ( q [ 0 ] ) ) ) ) * tan ( q [ 1 ] ) ) , ( R * ( ( Px * cos ( q [ 0 ] ) ) + ( Py * sin ( q [ 0 ] ) ) ) ) , Px , Py ] ) #NEWLINE# fr2_expected = Matrix ( [ ( ( ( ( - R ) * g ) * m ) * sin ( q [ 1 ] ) ) , 0 , 0 ] ) #NEWLINE# assert ( trigsimp ( fr1 . expand ( ) ) == trigsimp ( fr1_expected . expand ( ) ) ) #NEWLINE# assert ( trigsimp ( fr2 . expand ( ) ) == trigsimp ( fr2_expected . expand ( ) ) )