$$ \newcommand{\D}{\Delta} \newcommand{\d}{\delta} \newcommand{\O}{\Omega} \newcommand{\o}{\omega} \newcommand{\e}{\varepsilon} \newcommand{\dd}{\mathrm{d}} \newcommand{\pd}{\partial} \newcommand{\abs}[1]{\left\lvert#1\right\rvert} \newcommand{\tup}[1]{\left(#1\right)} \newcommand{\atup}[1]{\left\langle#1\right\rangle} \newcommand{\v}{\vec} \newcommand{\mc}{\mathcal} \newcommand{\L}{\mc{L}} $$
What is a very simple way to model a 1D inelastic collision as a closed system in the Lagrangian or Hamiltonian framework? By closed I mean total energy is conserved. I'd like to include some other component that absorbs the KE lost in the collision and I'm wondering how to do that.
Let's make the setup concrete. Consider two particles of unit mass with 1D positions $x_1, x_2$ and velocities $v_1, v_2$. A simple (and standard) way to model a collision between them is using a repulsive inverse-square potential. The Lagrangian for this system is $\L = T - U$, where the kinetic energy term is $T = \frac{1}{2}v_1^2 + \frac{1}{2}v_2^2$ and the potential energy term is
$$ U = \frac{k}{\abs{x_2-x_1}} $$
for some constant $k$.
However, to model the kind of elastic collision often presented where no force is felt on the particles except at the moment of collision (e.g. as given here), we can use a piecewise interaction energy so that the particles feel no force until they are within a particular distance $\e$ with each other, at which point the interaction kicks in. By making the interaction distance $\e$ arbitrarily small we approximate an instantaneous collision. Here is the potential energy term:
$$ U = \begin{cases} k\tup{\frac{1}{\abs{x_2-x_1}} - \frac{1}{\e}} & \abs{x_2 - x_1} < \e \\ 0 & \mathrm{otherwise} \end{cases} $$
(The inverse square potential is offset so that the PE is 0 when $\abs{x_2 - x_1} = \e$, making $U$ a continuous function of $x_1,x_2$. It doesn't really matter what the non-zero part of the potential function looks like, so long as it explodes to infinity as the particles approach each other.)
My question is, what would be a simple way to modify this setup so that we can approximate an inelastic collision with some arbitrary coefficient of restitution between 0 and 1, such that total energy is conserved? To be specific, let suppose there is another degree of freedom with position $y$ and velocity $w$. What additional potential energy term can we add to $U$ s.t. KE is sucked out of the two particles during their collision and added to this third DoF, either in the form of potential or kinetic energy?
edit: I replaced the potential $1/(x_2-x_1)^2$ with $1/\abs{x_2-x_1}$ everywhere, which is the correct inverse-square law potential.