% MotionGenesis file: MGStickSlipMassSpringDamperPulledBySpecifiedForceA.txt % Copyright (c) 2017-2021 Motion Genesis LLC. All rights reserved. % Purpose: Simulate mass-spring-damper on rough table. %------------------------------------------------------------------------------- NewtonianFrame N % Earth (ground). Particle B % Block that is connected by a spring/damper to N. B.SetMass( m = 1 kg ) %------------------------------------------------------------------------------- Variable x'' % B's horizontal displacement from No. Variable Fn % Resultant normal force on B. Variable Ff % Resultant friction force on B. Constant g = 9.8 m/s^2 % Earth's gravitational acceleration. Constant k = 400 N/m % Linear spring constant. Constant Ln = 4 m % Natural length of spring. Constant b = 4 N*s/m % Linear damper constant (zeta = 0.1). Constant muK = 0.4 noUnits % Coefficient of kinetic friction. Constant epsilonV = 1.0E-5 m/s % Represents a small sliding speed. Specified Fx = 20 * cos(t) % Specified horizontal force on B. %------------------------------------------------------------------------------- % Position, velocity, acceleration. B.Translate( No, x*Nx> ) %------------------------------------------------------------------------------- % Forces on B. B.AddForce( -m*g*Ny> ) % Gravity force. stretch = x - Ln % Spring stretch. B.AddForce( -(k*stretch + b*Dt(stretch))*Nx> ) % Spring/damper force. B.AddForce( Fn*Ny> + Ff*Nx> ) % Normal and friction forces. B.AddForce( Fx*Nx> ) % Specified force. %------------------------------------------------------------------------------- % Equations of motion via F = m*a. Dynamics[1] = Dot( Nx>, B.GetDynamics() ) Dynamics[2] = Dot( Ny>, B.GetDynamics() ) %------------------------------------------------------------------------------- % Equation governing Ff when B is sliding on N. % Herein we use the Continuous Friction Law to simulate both sticking and sliding. % This uses a small positive number for epsilonV to avoid divide-by-zero problems. % The advantage of the Continuous Friction Law is that it is easy to use and accurately % simulates both sticking and sliding. The disadvantage is that the Continuous Friction % law is slow (stiff) when simulating sticking. For better simulation speed, use the % Unified Friction Formulation in MGStickSlipMassSpringDamperPulledBySpecifiedForceB.txt. magVelocity = B.GetSpeed( N ) magVelocityPlusEpsilon = magVelocity + epsilonV Ff = Dot( -muK*Fn*B.GetVelocity(N) / magVelocityPlusEpsilon, Nx> ) %------------------------------------------------------------------------------- % Solve sliding equation of motion for x''. Solve( Dynamics = 0, x'', Fn ) %------------------------------------------------------------------------------- % Set initial values for variables (for subsequent ODE command). Input x = Input(Ln) m, x' = 0 m/s %------------------------------------------------------------------------------- % List output quantities from the ODE command. Output t sec, x m, x' m/s, x'' m/s^2, Ff Newton %------------------------------------------------------------------------------- % Set numerical integration parameters and solve ODEs. Input tFinal = 12 sec, tStep = 0.01 sec, absError = 1.0E-07 ODE() MGStickSlipMassSpringDamperPulledBySpecifiedForceA %------------------------------------------------------------------------------- Save MGStickSlipMassSpringDamperPulledBySpecifiedForceA.html Quit