/JB5_avatar.webp

Polymer Mechanics and Machine Learning

About this site
I have a PhD in computational mechanics from MIT. This site is where I work through machine learning projects myself and write up what I learn — the theory, the dead ends, and the results. Everything here is educational; all code is open source under the MIT license and available on GitHub.

Hammer Throw: Generate Training Data

Training Data All machine learning algorithms require data for training the model. In this example, we can use physics calculations to generate a dataset with two input variables: velocity and angle, and one output variable: flight distance. The following Python code creates an input file named data_X.csv containing the input variables, and a results file with the flight distance. These files will be used in subsequent machine learning demonstrations. import math import numpy as np import csv def calc_distance(angle, velocity): # fixed input parameters g = 9.

Hammer Throw Distance Calculation when No Air Drag

Introduction Welcome to the first article in my series on calculating the distance a projectile will travel based on its initial velocity and angle. Using hammer throwing, an Olympic track and field sport, as an example, I will demonstrate these calculations. However, the principles apply equally well to baseball and other sports. Code Location You can find the code in this example in this file. For simplicity, I will focus solely on predicting the distance the hammer will fly, leaving the complete flight path for later discussion.

Physics Calculation of Hammer Throw Distance with Air Drag

Physics-Based Theory and Numerical Implementation The weight of the hammer ball is 7.26 kg, the material is steel and therefore the ball radius is given by $r = (3m/(4\pi \rho_s))^{1/3}$. The drag force from the air resistance is $F_d = \rho_a v^2 C_d A$, where $A$ is the cross-sectional area. In summary, Newton’s equation in the horizontal and vertical directions can be written in incremental form: $$ \displaystyle \Delta v_x = – \frac{F_d(v)}{m} \frac{v_x}{v} \Delta t$$ $$ \displaystyle \Delta v_y = – \left[ \frac{F_d(v)}{m} \frac{v_y}{v} + g \right] \Delta t$$

Calculate Pi Using Python

Background The purpose of this article is to demonstrate how JupyterLab can be used to solve numerical problems using Python. Code Location You can find the code in this example in this repo. My example here is not a machine learning problem, but instead focuses on how one can calculate an approximate value of Pi. You may want to know why you want to do this since you can always just type:

Install JupyterLab

Instructions The next step after installing Python is to install JupyterLab. This is free open-source web-based interactive development environment for Python coding. It is really cool, easy to install and use. All you have to do is to start Python and type the following commands: pip install --upgrade pip pip install jupyterlab Then start JupyterLab using the following command: jupyter lab. This will open a new browser window with JupyterLab. It will look something like in the following image.

Set Up Python For ML

Background You can use any computer language for learning, coding, and solving Machine Learning (ML) problems. The most common language to use is Python. The main reason for this is that there are many high quality libraries of ML algorithms already written and freely available for Python (e.g. PyTorch, TensorFlow, and Keras). This makes it really easy to get started and to try things out. One main design feature of Python is that the core language is relatively small, and additional features are added through external packages.