MGBeamOnTwoCablesDynamicsViaKaneLagrangeAugmentConstraints.html  (MotionGenesis input/output).
   (1) %    File: MGBeamOnTwoCablesDynamicsViaKaneLagrangeAugmentConstraints.txt
   (2) % Problem: Dynamics of a beam supported by two cables.
   (3) %--------------------------------------------------------------------
   (4) NewtonianFrame N         % Ceiling with Nx> horizontally right, Ny> vertically down
   (5) RigidBody      B         % Beam with Bx> pointing from Bo to Bc and Bz> = Nz>.
   (6) Point          Nc( N )   % Point of N attached to cable C.
   (7) Point          Bc( B )   % Point of B attached to cable C.
   (8) %--------------------------------------------------------------------
   (9) Constant  LN = 6 m       % Distance between No and NC.
   (10) Constant  LB = 4 m       % Distance between Bo and BC.
   (11) Constant  LA = 2.7 m     % Length of cable A (connects Bo to No).
   (12) Constant  LC = 3.7 m     % Length of cable C (connects BC to NC).
   (13) Constant  g = 9.8 m/s^2  % Earth's gravitational acceleration.
   (14) Constant  b = 230 N*s/m  % Aerodynamic damping constant.
   (15) B.SetMass( m = 120 kg )
   (16) B.SetInertia( Bcm, Izz = m*LB^2/12, 0, Izz )
-> (17) Izz = 0.08333333*m*LB^2

   (18) %--------------------------------------------------------------------
   (19) Variable  x'', y''       % Nx> and Ny> measures of Bo's position vector from No.
   (20) Variable  q''            % Angle from Nx> to Bx> with positive sense +Nz>.
   (21) Variable  TA, TC         % Tensions in cables A and C.
   (22) %--------------------------------------------------------------------
   (23) %   Rotational kinematics relating  Bx>, By>, Bz>  to  Nx>, Ny>, Nz>.
   (24) B.RotateZ( N,  q )
-> (25) B_N = [cos(q), sin(q), 0;  -sin(q), cos(q), 0;  0, 0, 1]
-> (26) w_B_N> = q'*Bz>
-> (27) alf_B_N> = q''*Bz>

   (28) %--------------------------------------------------------------------
   (29) %   Translational kinematics.
   (30) Bo.Translate( No,  x*Nx> + y*Ny> )
-> (31) p_No_Bo> = x*Nx> + y*Ny>
-> (32) v_Bo_N> = x'*Nx> + y'*Ny>
-> (33) a_Bo_N> = x''*Nx> + y''*Ny>

   (34) Bcm.Translate( Bo,  0.5*LB*Bx> )
-> (35) p_Bo_Bcm> = 0.5*LB*Bx>
-> (36) v_Bcm_N> = 0.5*LB*q'*By> + x'*Nx> + y'*Ny>
-> (37) a_Bcm_N> = -0.5*LB*q'^2*Bx> + 0.5*LB*q''*By> + x''*Nx> + y''*Ny>

   (38) BC.SetPosition( Bo,  LB*Bx> )
-> (39) p_Bo_Bc> = LB*Bx>

   (40) NC.SetPosition( No,  LN*Nx> )
-> (41) p_No_Nc> = LN*Nx>

   (42) %--------------------------------------------------------------------
   (43) %   Constraint relating cable lengths to magnitudes of position vectors.
   (44) LengthConstraint[1] = LA^2 - Bo.GetDistanceSquared( No )
-> (45) LengthConstraint[1] = LA^2 - x^2 - y^2

   (46) LengthConstraint[2] = LC^2 - Bc.GetDistanceSquared( Nc )
-> (47) LengthConstraint[2] = LC^2 + 2*LB*cos(q)*(LN-x) - LB^2 - y^2 - 2*LB*y*sin(q)
        - (LN-x)^2

   (48) %--------------------------------------------------------------------
   (49) %   Forces on beam.
   (50) unitVectorBoToNo> = No.GetPositionVector(Bo) / LA
-> (51) unitVectorBoToNo> = -x/LA*Nx> - y/LA*Ny>

   (52) unitVectorBcToNc> = NC.GetPositionVector(Bc) / LC
-> (53) unitVectorBcToNc> = -LB/LC*Bx> + (LN-x)/LC*Nx> - y/LC*Ny>

   (54) Bo.AddForce( TA*unitVectorBoToNo> )
-> (55) Force_Bo> = -TA*x/LA*Nx> - TA*y/LA*Ny>

   (56) BC.AddForce( TC*unitVectorBcToNc> )
-> (57) Force_Bc> = -LB*TC/LC*Bx> + TC*(LN-x)/LC*Nx> - TC*y/LC*Ny>

   (58) Bcm.AddForce( m*g*Ny> - b * Bcm.GetVelocity(N) )
-> (59) Force_Bcm> = -0.5*b*LB*q'*By> - b*x'*Nx> + (m*g-b*y')*Ny>

   (60) %--------------------------------------------------------------------
   (61) %   Dynamics via Kane's augmented constraint method.
   (62) %   Constraints are not embedded -- instead they are augmented (later steps).
   (63) SetGeneralizedSpeeds( x', y', q' )
   (64) Dynamics = System.GetDynamicsKane()
-> (65) Dynamics[1] = TA*x/LA + 0.5*b*(2*x'-LB*sin(q)*q') + m*x'' - TC*(LN-x-
        LB*cos(q))/LC - 0.5*m*LB*cos(q)*q'^2 - 0.5*m*LB*sin(q)*q''

-> (66) Dynamics[2] = TA*y/LA + TC*(y+LB*sin(q))/LC + b*y' + 0.5*b*LB*cos(q)*q'
        + m*y'' + 0.5*m*LB*cos(q)*q'' - m*g - 0.5*m*LB*sin(q)*q'^2

-> (67) Dynamics[3] = 0.25*LB*(4*TC*(y*cos(q)+sin(q)*(LN-x))/LC+b*LB*q'-2*b*sin
        (q)*x'-2*cos(q)*(m*g-b*y')) + 0.5*m*LB*cos(q)*y'' + 0.25*(4*Izz+m*LB^2)*q''
        - 0.5*m*LB*sin(q)*x''

   (68) %--------------------------------------------------------------------
   (69) %   Integration parameters and initial values.
   (70) Input  tFinal = 9 sec, tStep = 0.02 sec,  absError = 1.0E-07
   (71) Input  x = 2 m,  x' = 0 m/s
   (72) %--------------------------------------------------------------------
   (73) %   Use length constraints to set initial values for y and q (with guess).
   (74) SolveSetInput( LengthConstraint = 0,   y = 3 m,  q = 15 deg )

->   %  INPUT has been assigned as follows:
->   %   y                         1.813835714721706       m
->   %   q                         27.67399398437716       deg

   (75) %--------------------------------------------------------------------
   (76) %   Differentiate length constraints to set initial values for y' and q' (with guess).
   (77) SolveSetInput( Dt(LengthConstraint) = 0,  y' = 0 m/s,  q' = 0 m/s )

->   %  INPUT has been assigned as follows:
->   %   y'                        0                       m/s
->   %   q'                        0                       m/s

   (78) %--------------------------------------------------------------------
   (79) %   Quantities to be output by ODE command.
   (80) Output  t sec,  x m,  y m,  q degrees,  TA Newtons,  TC Newtons
   (81) %--------------------------------------------------------------------
   (82) %   Append 2nd-derivative of length constraints to dynamics equations and integrate.
   (83) ODE( [Dynamics; DtDt(LengthConstraint)] = 0,  x'', y'', q'', TA, TC )  MGBeamOnTwoCablesDynamics

   (84) %--------------------------------------------------------------------
   (85) %   Save input and output responses.
Saved by Motion Genesis LLC.   Command names and syntax: Copyright (c) 2009-2019 Motion Genesis LLC. All rights reserved.