Skip to content

Zheren1999/mass-spring-problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mass-spring problem

This code numerically solves the spring-mass system problem and determines the mass displacement, velocity, and acceleration for n time steps using the central difference method.

image

The central difference method is an explicit numerical method. This method is based on finite difference expressions in time for velocity and acceleration at a time t given by:

ken1

Numerical integration:

ken9

The procedure for a solution is then as follows:

Step1: determine displacement, velocity, and force at t=0

Step2: determine acceleration at t=0

ken3

Step3: determine displacement (i=-1)

ken4

Step4: determine displacement (i=1)

ken5

Step5: determine displacement (i=2)

ken6

Step6: determine acceleration (i=1)

ken7

Step7: determine velocity (i=1)

ken8

Use steps 5 through 7 repeatedly to obtain the displacement, acceleration, and velocity for all other time steps.

Numerical solution (Python)

Enter the number of steps and the amplitute of force when t=0

image

Plot the displacement, velocity and acceleration:

image

Releases

No releases published

Packages

No packages published

Languages