Plotting SHM Graph using Python (Matplotlib | Numpy)
Programming is influencing all disciplines and helping scientiests discover in the field of Science and Mathematics with the help of technology. The concept of Simple Harmonic Motion is uded to create graph of waves using Python(Numpy | Matplotlib | Scipy) where the user can make changes to the amplitutde, initial phase and frequency of the wave. User can also add a decay or damping constant. User can also plot any SHM graphs using this program. As a demonstration spring simulation has been given in .py format.
In mechanics and physics, simple harmonic motion is a special type of periodic motion where the restoring force on the moving object is directly proportional to the object's displacement magnitude and acts towards the object's equilibrium position.
- SHM can be modeled as sin or cosine wave moving forward with time t
- Equation of SHM is: y = A sin(𝝎t+ 𝜽), we plot time t on X axis and correponding position on Y axis A = amplitude, 𝝎 = angular frequency, 𝜽 = initial phase
Fig. Simple Harmonic Motion
- Set size of each step and number of total steps
- Define a function (data_gen) will compute the value of the wave at each point in time t from 0 second in steps of 0.5s for a 1000 times
- Creating a set of arrays to store these values as required for plotting, one for X axis and different array for values of Y axis
- Program SHM-1.py is console based user defined program where user can change: frequency, apmlitude and intial phase
- Program SHM-2.py will plot a spring simulation
- Download the code and run(double click) the .py file to plot the graph
- Python
- Python Libraries:
Numpy
Matplotlib
Scipy
git clone https://github.com/qxresearch/Simple-Harmonic-Motion
📑 If you think this project has helped you learn something new you can give a star
📑 If you think it's a bad project do point out 'why' and spam the issue section 🚩
Any kind of contributions to qxreseach/Simple-Harmonic-Motion
are welcome. While creating an issue(for this project) use Request-Feature
Label.
- Fork the Project
- Commit your Changes
- Open a Pull Request
- Join Mozilla Group @qxresearch
- Join Telegram Group @qxresearch
- email me your GitHub id (subject: GitHub id @qxresearch)