A trained machine learning model for predicting the force due to contact between a deformable end cap and a taper
Project description
#Piston vs taper This is a library containing a pretrained machine learning model for predicting the force applied to a piston by a tapered transition-piece at the end of a pump-tube for a two-stage gas gun.
Provided that a given machine has an up-to-date instillation of pip
, the
library can be installed using
pip install piston-v-taper
If the library is updated, the update of the library can be installed using
pip install -U piston-v-taper
Usage
The library provides a PistonVTaper
class which can be imported as follows:
from piston_v_taper.model import PistonVTaper
After importing the class, a PistonVTaper
object can be instantiated as follows:
my_piston_v_taper_object = PistonVTaper()
Here, the variable my_piston_v_taper_object
can be named as the user desires.
The force applied to the piston during a given time-step f
can be determined by calling the
PistonVTaper.inc()
method and parsing in the position of the piston
past the start of the taper x
in mm, the velocity of the piston v
in mm/s,
and the size of the time increment dt
in s; that is:
f = my_piston_v_taper_object.inc(x, v, dt)
Note that the .inc
method predicts whether the piston is in contact with
the transition piece and updates the degree of plastic deformation that has occurred
in the end-cap. As such, the .inc
method should only be called once per time step,
otherwise the degree of plastic deformation of the end-cap will be increased multiple times
in a single time step.
Example
Here, we illustrate the usage of the PistonVTaper
class with an example script shown below.
The example script makes use of some artificial data for time, and position and velocity of the piston.
In a 1D computational code, the position and velocity of the piston the start of a given time step is typically known.
import numpy as np
import matplotlib.pyplot as plt
import piston_v_taper.plotting_config
import seaborn as sns
from piston_v_taper.model import PistonVTaper
N_HUES = 10
HALF_PERIODS = 12
OFF_SET = 0.3
def get_hue_order(val, n_hues):
return np.linspace(np.min(val), np.max(val), n_hues)
# Step 1: Create a PistonVTaper object
pist_v_taper = PistonVTaper()
# Step 2: Create some artificial loading data
t = np.linspace(0, 0.5, 10000)
x = 10 * (1 + np.sin(np.pi * HALF_PERIODS * t / t[-1] - np.pi / 2)) * (OFF_SET + t * (1 - OFF_SET)/t[-1]) / 2
v = np.gradient(x, t) # Velocity of piston
f = np.zeros(t.size) # Force applied to the piston from the taper (to be determined)
# Step 3: Loop through the loading data to determine the forces
for i in range(1, t.size):
dt = t[i] - t[i - 1]
# .inc (short for increment) method returns the force and determines the plastic dissipation of the cap.
# The plastic dissipation is stored inside the PistonVTaper object
f[i] = pist_v_taper.inc(x[i], v[i], dt)
# Step 4: Construct data frame for plotting
results = pd.DataFrame(data={
't (s)': t,
'x (mm)': x,
'v (mm/s)': v,
'F (N)': f,
})
# Step 5: Plot the results
sns.scatterplot(data=results, x='x (mm)', y='F (N)', hue='t (s)', palette='viridis', linewidth=0,
hue_order=get_hue_order(results['t (s)'], N_HUES), legend='brief')
plt.tight_layout()
plt.figure()
sns.scatterplot(data=results, x='t (s)', y='F (N)', hue='x (mm)', palette='viridis', linewidth=0,
hue_order=get_hue_order(results['x (mm)'], N_HUES), legend='brief')
plt.tight_layout()
plt.figure()
sns.scatterplot(data=results, x='t (s)', y='x (mm)', hue='F (N)', palette='viridis', linewidth=0,
hue_order=get_hue_order(results['F (N)'], N_HUES), legend='brief')
plt.tight_layout()
plt.show()
TODO include figures
Improvements and future work
It is clear that the machine learning model can be improved upon. In particular, some non-physical behaviour is observed:
- There are occasionally negative forces. It is possible that these could arise from the end-cap being wedged in the transition piece due to friction. However, since these negative forces are not observed in the data used to train the model (see below) it is apparent that this is an undesirable artifact of the machine learning model.
- The force curves contain significant discontinuous jumps. These are somewhat reasonable given the discontinuous nature of the underlying contact problem. However, again, this is slightly inconsistent with the data (see below).
I (Ben Alheit) have some ideas on how this may be improved, but I do not have the time to implement them. If someone is interested in contributing in this regard, please feel free to reach out using the email address provided.
Some notes of the development of the model
To train the machine learning model data is required. This is obtained by means of finite element simulations, which are outlined briefly in the subsection below. With the data in hand, a machine learning model was trained to produce the required force given the known input information. This is outlined briefly in the subsection that follows the Finite element simulation subsection.
For a more detailed description of the development see
Finite element simulation
Machine learning model
TODO include figures
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for piston_v_taper-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce57a592fc9d8f023dfd8d0db932f90fab5549e12de8fdf1be2adc52112f194b |
|
MD5 | ff4cda854d079183b6297137732d0120 |
|
BLAKE2b-256 | dbc9b192a1e13bbcba0d0826ad75fd72ed0678eaa6542f93b4806965c109018d |