GTA

All Springer/NP/PCP Air Gun Discussion General => "Bob and Lloyds Workshop" => Topic started by: MartyMcFly on January 25, 2025, 10:15:45 PM

Title: Spring Piston Simulator Project
Post by: MartyMcFly on January 25, 2025, 10:15:45 PM
It’s been a while since I’ve been active on GTA, and I thought this might be a good time to re-engage with a project I’ve always been passionate about but lacked the time and expertise to fully explore. My interest began years ago when I read a book by the Cardews on the physics of spring-powered airguns. While it was fascinating, it left me wanting more. The spring-piston airgun market has seen little innovation for decades, likely due to the rise in popularity of PCPs. Additionally, there’s a lack of openly accessible, non-proprietary knowledge for inventors and hobbyists to build upon. I suspect that many of the designs still in use today were optimized through trial and error in the and late 80s and early 90s. While the mechanical principles behind springers are straightforward, the internal physics are complex, which leads me to believe there’s still room for meaningful optimization.

The ultimate goal of this thread is to motivate myself to write some code and better understand the trade-offs involved in designing spring-powered airguns. Although I’m not a trained engineer, I hope that with research and input from this forum, I can develop a model that closely approximates real-world performance. Ideally, this model will shed light on how various design choices affect the performance of springers.

For context, I’m not starting entirely from scratch. A pivotal paper published in 2015 by Domingo Tavella provides a solid foundation. While I won’t be replicating his work verbatim, I plan to use it as a guide. Dr. Tavella’s paper is thorough, but the lack of open-source code limits its practical application for DIY inventors. This gap forces hobbyists to rely on costly and time-consuming prototypes, effectively perpetuating the trial-and-error method of innovation.

Approach:

Tools:
The simulation will primarily be a one-dimensional (1D) model implemented in Python. There are three key reasons for this choice:


The simulation will rely on numerical integration of ordinary differential equations. Since the components in the system interact and influence one another, the only feasible approach is to simulate all components simultaneously. Initially, the model will be constructed to simulate the dynamics of an Air Arms TX200 Mk3. That said, it will be trivial to change the dimensional and spring characteristics to match other types of rifles for validating against other designs.

Questions:
There are many questions that interest me and I don't how close we can come in answering them in a simple 1D simulation, nevertheless I'd like to explore the following:

I hope that this project will not only educate me, but also engage others to think about novel solutions and experiments. Maybe the commercial age of springers is past us, with no new springer designs coming to market, but that doesn't mean that we can't try to improve on these wonderful machines ourselves. Moreover, I'm tremendously encouraged by the continued work of tuners and especially the lone innovators in England, folks like Tony Leach, for pushing the envelope of what is possible with a little grit and imagination. I hope this project encourages others to push the limits of springer design and performance.

PS. I hope to keep this thread active as much as possible, but I do have a job and family, so pauses in progress should be expected. That said, don't let that stop YOU from contributing ideas/solutions if you are willing and able.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: subscriber on January 25, 2025, 10:34:44 PM
Marty,

This sounds like quite an undertaking.  I think that power hungry Yanks are not interested in 5 FPE springers, nor in 25+ FPE springers because they are too bouncy.  Hence the gravitation towards PCPs.

I appreciate the simplicity of springers and the challenge of shooting them well, but if you could invent a non-bouncy 10 to 15 FPE springer you will have a winner.  But only if you can do it cheaply.  This may require copying and simplifying the dual opposing piston systems.  Or piston with counterweight systems.  The latter may sound like wasted parts, but plumbing the airflow is much easier with only one piston.

I have not come here to distract from your mission.  If you want an academic or lab understanding, rather than jumping to a marketable product, more power to you.  Perhaps decent lab work would be a better foundation for a better product - as it should be. 

Perhaps springers with a sled approach are better than dual pistol or dual mass ones.  All I know is that over sophistication often increase the weight of the air rifle; as does making it produce more than 20 FPE.   I would be most interested in a "recoilless" springer than weights 7 lb and is 40" long.  It can have any power level from 7 to 15 FPE - if it is light and compact enough.  Peak cocking force should not exceed 30 lb - half of that would be better, but can proportionate to power.  And spring twang should be subdued...  If you can improve efficiency, the above should be easy :)
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 01:31:12 AM
subscriber, I'm glad you found this thread. I hope a few more regulars like you come along for the journey too. That said, I can say confidently we share very similar ideas of what makes an ideal springer. I outgrew my power-hungry fantasies a number of years ago and I would like nothing better than a mid-level springer that is smooth to shoot, doesn't weight a ton, and is efficient at translating elbow power into FPE.

I think that opposing pistons are great from a novelty perspective. They are admirable works of art which, when calibrated and well maintained, give great performance. Unfortunately, they add a level of complexity and mass that makes them impractical for all around use and affordability. I believe there is probably a good halfway point that lies between a simple design and some sort of dummy piston or sled design that gets us 80% of the way with 20% of the price and complexity.

Anyways, my hope is that we can take various designs and show how close they are to their peak efficiency, and if they are far away figure out how to get them there. Thanks for your input and I look forward to your future feedback.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 02:26:31 PM
Starting with some basics...

The heart of a springer is of course the spring! Therefore, before we can get anywhere we need to determine the characteristics of the spring in our simulation. The most important information we need is the length of the spring and the spring's constant 'k' (stiffness coefficient). We can plug this information into Hooke's Law, which provides the amount of force a spring produces given a certain level of deflection. Spring k gives the amount of force (Newtons) the spring pushes or pulls per meter. 

I did a google search and according to some UK forums the TX200 has a 200mm spring with a k = 8.923x10^3 Newtons/meter.  I suspect that this is for the 12 FPE version and not the FAC. I don't have a way to test the force generated by my FAC spring (yet), but there is a formula which we can use to derive spring k if we know the material and the spring's dimensions. So, I took the following measurements:

Rest Length = 225mm (0.225 meters)
Outer diameter (OD) = 20.78mm (0.02078 meters)
Inner diameter (ID) = 14.24mm (0.01424 meters)
Wire diameter (WD) = 3.2mm (0.0032 meters)
Mean coil diameter (MCD) - there are two ways of computing this, so I will take the average of the two methods for the time being:
Coil count = 29
Active Coil count = 29 -2 = 27 (subtract 2 for the collapsed ends)
Spring mass = 100.5g
Spring Modus of Rigidity (material dependent) - I don't know the exact material of the spring so I'll experiment with the following common ones. Note: 1 GPa = 10^9 Pascal. This is about 145,039 psi.

The formula to determine k:
Spring k = (modulus_rigidity * WD^4) / (8 * MCD^3 * AC). If we plug in the modus of rigidity for Music Wire we get about 7,361 N/m. This seems less than the Spring k noted in the UK forum (8,923 N/m), but it is in the ballpark. I suspect that either the longer length of the spring or its pre-load allows for a less rigid spring to be used in the FAC TX200. Of course, the internet figure could also be wrong. We won't know for sure until we do further testing.

But let's move on to Hooke's Law, which states: F = -kx This simply states that the (spring k) multiplied by the displacement of the spring (i.e. compression or extension) will generate some amount of force at said displacement distance. It's easy to see that the more we compress or stretch a spring from its rest length the more force it will generate.

Quick example. If we compress our spring by 100mm it will be pushing back by:
F = -kx --> -(7,361) x (0.1) = -736.1 Newtons (the negative sign tells us that its pushing in the opposite direction of the displacement or compression).
It should be noted that spring pre-load will naturally increase the amount of Force pushing back in addition to any compression we add via cocking.

Ok, so now we have some spring basics down. I'll see you on the next post.

-Marty

 


Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 03:07:57 PM
On to more measurements!

In addition to spring data, we need to gather more information about the internal dimensions of the TX200 Mk3 FAC. Knowing the dimensions will allow us to compute how much air is being compressed and what are the distances over which the parts travel. A quick google search returned the following:

I don't know if these measures are accurate, so I will have to take my TX200 apart to confirm. Additionally, we need to know how much spring pre-load is present, how big is the diameter of the transfer port, how long is the transfer port, and how long is the barrel (the TX has a shroud so its not obvious).

If anyone has measured these things on their own rifle, please feel free to share your measurements.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on January 26, 2025, 06:01:49 PM
Marty, Nice to see someone revisiting airgun basic physics. Not sure if that is your plan, but I always thought it would be valuable if someone could code the analysis in the Tavella paper.

Several years ago I did some testing on the shot cycle of a Crosman Titan (gas ram). The cycle timing can be measured, including pellet motion, But the thermodynamics (Pressure, Temperature) are much more elusive.

If you are planning to do a lot of testing, I would suggest using a basic low cost springer so that any planned or unplanned irreversible modifications don't hurt as much.

Looking forward to this thread
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 06:16:29 PM
Marty, Nice to see someone revisiting airgun basic physics. Not sure if that is your plan, but I always thought it would valuable if someone could code the analysis in the Tavella paper.

Several years ago I did some testing on the shot cycle of a Crosman Titan (gas ram). The cycle timing can be measured, including pellet motion, But the thermodynamics (Pressure, Temperature) are much more elusive.

If you are planning to do a lot of testing, I would suggest using a basic low cost springer so that any planned or unplanned irreversible modifications don't hurt as much.

Looking forward to this thread

Stan/WhatUPSBox - Indeed, I think I remember you doing some accelerometer readings on the Titan. I don't have one (either same rifle or accelerometer), but I'm sure some of the data you captured will be useful in correlating with the output of the simulation.

Regarding Tavella's paper, I plan to implement as much of it as I can manage. I'm not aiming for 100% replication, but if I can get 80% there I'm sure others will be able to improve and add to it.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 06:32:11 PM
On to more measurements!

In addition to spring data, we need to gather more information about the internal dimensions of the TX200 Mk3 FAC. Knowing the dimensions will allow us to compute how much air is being compressed and what are the distances over which the parts travel. A quick google search returned the following:
  • Piston Diameter = 25mm
  • Stroke Length = 96mm
  • Piston Mass = 220g
  • Piston Washers/Weights = 28g

I don't know if these measures are accurate, so I will have to take my TX200 apart to confirm. Additionally, we need to know how much spring pre-load is present, how big is the diameter of the transfer port, how long is the transfer port, and how long is the barrel (the TX has a shroud so its not obvious).

If anyone has measured these things on their own rifle, please feel free to share your measurements.

-Marty

OK, so I did some of my own measurements on the piston. They came out slightly different from the internet search, this could be the result of differences in production runs or measurement errors. I still need to measure a few more things but here is what I got so far:


-Marty
Title: Re: Spring Piston Simulator Project
Post by: subscriber on January 26, 2025, 07:40:27 PM
Apart from spring rate, there is dynamic hysteresis to consider: If you slowly compress a spring with a load cell and displacement measure, then slowly allow the spring to expand, the force in the spring at each incremental length will be less while expanding than at the same spring length, while compressing it.  This is known as hysteresis.  To complicate the matter, we care about how efficiently the spring can generate force while expanding rapidly

Measurment system friction adds load to the loadcell while compressing the spring, and subtracts from the loadcell reading while the spring is expanding; because the friction is reversed.  Yes, we also care about system friction is a given airgun design; but it is what is happening inside the spring's material that I am emphasizing. 

The spring has some internal damping inherent in the material, so dynamic hysteresis more pertinent than measure force while the spring is allowed to expand slowly.  Think of it as crystalline matrix inertia.  Or friction between crystals is probably more accurate, except that it is worse at high speed.  The opposite of static and dynamic surface friction.  Rubber has very poor dynamic hysteresis; or a lot of damping, if you like.  In the case of a spring piston airgun, the damping we want on the spring is to reduce the twang.    Different spring materials have different crystal matrix friction or inertia.

I have seen a number of posts about people reducing their spring length a coil or two to reduce power and harshness on their airgun, only to find the power remaining the same, while cocking effort and harshness were reduced.  I suspect that system friction and or crystal matrix restitution suffer when a spring is over compressed or over stressed.  Cutting a coil of a spring reduced the preload, while increasing the spring rate.  Perhaps the strange plateau in pellet FPE is because of an increase in spring restitution efficiency when compressed to a given overall length. 

When a longer spring is almost coil bound the spring and its material may be "unhappy".   Giving the coils more room by cutting it shorter seems to fix that, despite the shorter spring having a higher rate.  A higher rate spring does not only load up faster in compression; it unloads faster in extension.  This begs the question; would a similar effect exist for adding or removing spacer length, without altering the spring?
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 08:42:07 PM
subscriber, thanks for the info on hysteresis. I’m not planning to model that behavior yet,  but I do think it will make initial calibration trickier. The expected impact is a 1-5% of loss of power for metal springs. I may include a fudge factor for this since I don’t  how know to model it, yet.

As to why a cut spring can create the same power, I think this can also occur due to choke conditions in the TP. If the spring is over powered choke may limit the transfer of energy to the pellet. But I don’t know for sure and it’s something that would be worth investigating. It may also do with the non-linearity of the piston drag and speed of gas compression under different loads…

-Marty
Title: Re: Spring Piston Simulator Project
Post by: subscriber on January 26, 2025, 09:05:00 PM
Marty,

Too much spring may increase piston bounce, possibly related to TP volume.  TP flow area comes into the equation after the pellet starts moving rapidly.
Title: Re: Spring Piston Simulator Project
Post by: rsterne on January 26, 2025, 11:32:46 PM
Many years ago, I downloaded this file below, which deals with a lot of what your are interested in.... I hope it may be of some assistance....

I have another one in Excel,, but it is too large to attach.... I will try zipping it....

Bob
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 11:33:53 PM
Some more thoughts on simulating the spring:

Tavella's paper mentions that he takes a finite element approach to simulating the spring. Basically, he breaks-up the spring into multiple segments each with its own number of coils and mass. He does this to account more accurately for deflection at the end of the stroke. He states that unless this is done the kinetic energy is overestimated, resulting in higher output in the simulations than experienced in real life. Fortunately, as mentioned previously there is also the phenomena of spring hysteresis, which lowers the kinetic energy that the spring gives back on decompression. Therefore, for the initial version of my simulation I will take a simpler approach than Tavella. I will assume that the spring is without mass and that the mass is concentrated at the end of the spring, namely in the piston assembly. This means that I will assume that most of the power overestimation is cancelled out by spring hysteresis. This may or may not be true in real life, but for the moment it should be a good enough simplification to get us to a semi-working model, which can be improved once we start computing some forces.

All that being said, the spring's mass is still important and most of the spring simulation approaches I've read take a third of the spring's mass and add it to the total mass of the piston assembly, which is what I will do (at least initially).

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 26, 2025, 11:35:53 PM
Many years ago, I downloaded this file below, which deals with a lot of what your are interested in.... I hope it may be of some assistance....

I have another one in Excel,, but it is too large to attach.... I will try zipping it....

Bob

Thank you, Bob! I have not read his paper on PCPs, I will definitely take peak.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: rsterne on January 26, 2025, 11:40:09 PM
Here is my attempt to attach the other one....

Bob
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 27, 2025, 11:59:27 AM
Here is my attempt to attach the other one....

Bob

Thanks for sharing the spreadsheet. Given the limitations of excel, the person that put this together did a great job doing the integration steps manually. This will be useful in cross checking the initial results from the python simulation. What I'd like to do different then this spreadsheet is make the code object oriented so it's easy to add more advanced friction models or change things like spring models or even add piston bounce. Additionally, I want to be able to easily compare changing a single or multiple variables in order to isolate the exact impact of certain tweaks.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 27, 2025, 05:42:36 PM
Setting up a program skeleton...

The following is just some boiler plate code. It doesn't compute anything but instead serves to provide a layout of where the different pieces will exist. Names of variables and functions will probably change as the sim evolves.

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp

class SpringAirgunSimulation:
    def __init__(self):

        # --- Mass measurements ---
        self.spring_mass         = xxx           # kg
        self.piston_mass         = xxx           # kg
        self.piston_weights_mass = xxx      # kg

        # Effective piston assembly mass: 1/3 of spring + piston + weights
        self.pistonAssembly_mass = (1/3)*self.spring_mass + self.piston_mass + self.piston_weights_mass

        self.pellet_mass = xxx     # kg
        self.rifle_mass = xxx       # kg

        # --- Geometry & Dimensions ---
        self.spring_length = xxx   # m
        self.spring_preload = xxx  # m
        self.spring_cocking = xxx  # m

        # Total spring deflection
        self.spring_deflection = self.spring_cocking + self.spring_preload

        self.pellet_caliber = xxx  # m
        self.pellet_head_area = np.pi*(self.pellet_caliber/2)**2

        self.piston_diameter = xxx       # m
        self.piston_radius   = self.piston_diameter / 2 # m
        self.piston_head_area = np.pi * self.piston_radius**2 # m^2

        # Initial "chamber" length set to cocking distance
        self.chamber_length = self.spring_cocking
        self.chamber_volume = np.pi * self.piston_radius**2 * self.chamber_length

        self.transferPort_diameter = xxx # m
        self.transferPort_length = xxx  # m
        self.barrel_length = xxx  # m

        # --- Physical constants & properties ---
        self.spring_k = xxx                    # N/m
        self.ambient_pressure = 101325 # Pa
        self.ambient_temp = 293            # K
        self.gamma  = 1.4                      # Heat index
        self.R = 287.05                          # J/(kg·K)
        self.gravity = 9.801                    # m/s^2

    # --- Spring Model ---
    def SpringForce(self, spring_x):

    # --- Friction Models ---
    def BoreFriction(self, pellet_x):
    def PistonFriction(self, piston_x):
    def PelletDeformation(self, pellet_x):

   
    # ----------------------------------------------------------------------
    #  ODE System - 2nd order equations
    # ----------------------------------------------------------------------
    def system_equations(self, t, y):

    # ----------------------------------------------------------------------
    #  Simulation block
    # ----------------------------------------------------------------------
    def simulate(self, time_span, time_steps):

    # ----------------------------------------------------------------------
    #  Graphing simulation data
    # ----------------------------------------------------------------------
    def plot_results(self, solution):

-Marty
Title: Re: Spring Piston Simulator Project
Post by: rsterne on January 27, 2025, 06:27:14 PM
I thought that spreadsheet included piston bounce, but it's been years since I looked at it....

Bob
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 27, 2025, 07:04:58 PM
I thought that spreadsheet included piston bounce, but it's been years since I looked at it....

Bob

I didn't look in detail at the spreadsheet logic, I assumed it didn't because there is no variable for restitution force for the piston seal, which I think it necessary to model a bounce properly. That said, the spring velocity does go negative on the graph, which at first looked like a bounce but that could be just the spring oscillation and slowdown from the friction dampening. I'll have to look at it in more detail to say for sure.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: WobblyHand on January 27, 2025, 08:11:44 PM
Don't know if this helps or not, but there's CFD available in FreeCAD, as well as FEA (called the FEM workbench) and there's a CFDoF workbench.  I've used the FEM workbench, and have been able to get CFDoF to run some examples, including supersonic airflow.  The latter (CFDoF) is a lot harder to me to understand and to get running.  I've yet to get one of my CFDoF models to simulate.

I used to program in Python (and NumPy & SciPy) extensively, to design and run radar simulations, from physics models through signal processing.  Can't say I was a Python expert, but I used the tools to get the job done, for designing automotive radars.  It's great to see some active Python programming!
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 28, 2025, 12:10:09 AM
Don't know if this helps or not, but there's CFD available in FreeCAD, as well as FEA (called the FEM workbench) and there's a CFDoF workbench.  I've used the FEM workbench, and have been able to get CFDoF to run some examples, including supersonic airflow.  The latter (CFDoF) is a lot harder to me to understand and to get running.  I've yet to get one of my CFDoF models to simulate.

I used to program in Python (and NumPy & SciPy) extensively, to design and run radar simulations, from physics models through signal processing.  Can't say I was a Python expert, but I used the tools to get the job done, for designing automotive radars.  It's great to see some active Python programming!

Thanks Bruce! I’m a FreeCAD user too, just haven’t done any CFD work in it. I think that the FreeCAD implementation is actually based on OpenFoam, but I have no experience with that software. It’s definitely something to look into in the future, especially for the transfer port modeling. For now I’m starting with the basics, I’d like to see how close Python (in the hands of a hobbyist) can get us and still keep it simple to run by anyone.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 31, 2025, 10:24:40 PM
Clarifying the framework/approach…

Next, we need to put some more substance around the simulation framework. As said before I’d like to start with the basics and incrementally improve the simulation’s depth by adding details of various system dynamics. I also mentioned that this simulation will simultaneously model all the components of the system and show how they interact with each other.  So, let's start by clarifying what we mean by components and what we will need to model.

Oh, but wait! Before we can jump ahead, we should remember that all physics models need to adhere to the basic principle that energy can neither be created nor destroyed. Essentially, we want to ensure that what goes in, MUST come out, (like those burritos from last night 😃). What comes out can be in another form (ex. motion goes in while heat comes out), but we must maintain an energy balance. In our case, we can capture a springer’s main performance characteristics by describing where and how much energy is generated, where it is sunk/dissipated, and where it is transferred.


We can start with the simplest equation:

    1. Input Energy = Output Energy
 
This can be expanded into:

    2. (Spring Energy) + (Gas Energy) = (Pellet Energy) + (Dissipated Heat Energy) + (Friction Energy) + (Recoil Energy)
 
Lasty, we can rearrange the above equation, so we get the Pellet Energy on the left side:

   3. Pellet Energy = (Spring Energy) + (Gas Energy) - (Recoil Energy) – (Dissipated Heat Energy) – (Friction Energy)
 

Moving on…

In equation #2 we see six major system components. These components span several areas (or physical parts) and can be broken down further but for the moment we just want the big picture.  The components all simultaneously affect each other, not only in one instant of time, but also across time. Said differently, the pellet energy at time t is not only dependent on the total energy allocations in the system at time t, but also dependent on the total energy allocations that existed just before time t (i.e., t-1). In essence, the simulation will compute the state of the system at time 0.01, save the output, then use that output as the starting point for computing the change in energy at time 0.02 and so forth. It's sort of like stop motion animation; you make a little change, take a picture, then make another change and take another picture, until you get hungry for burritos again ;) If you remember high school calculus you should recall that this is the idea behind integration.

Lastly, you may have noticed that I'm not going to simulate cocking action. The reason is because this is an event that does not happen during the firing cycle of the gun. In the grand scheme of things cocking is a remote event (in time) and not important in describing the internal ballistics of an airgun when the trigger is pulled. This is not to say that cocking effort is not important, just that it's not essential to the simulation.

Thanks for reading, more to come!
-Marty



 

 
Title: Re: Spring Piston Simulator Project
Post by: subscriber on January 31, 2025, 10:47:37 PM
When the energy that comes out is less than what went in, it needs to be accounted for as inefficiency - at some point anyway.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on January 31, 2025, 11:50:12 PM
When the energy that comes out is less than what went in, it needs to be accounted for as inefficiency - at some point anyway.

Right; said inefficiency will be captured by (Dissipated Heat Energy) + (Friction Energy) + (Recoil Energy). But if and only if, the simulation is properly calibrated, and we identify/model all of the energy sinks.

That said, if the model shows a higher energy output than real-world experiments then the possible explanations are:
1. We messed up modeling the physical laws
2. We didn't accurately measure frictional forces
3. Our dimensional or material property measurements are off
4. The numerical integrator is unstable due to stiffness or some such programming limitation

My expectations are that the frictional force calibrations won't be spot on, but they should be close. Assuming everything else is correct, this will result in a couple of percentage points in difference between the real world and the model. The biggest challenge would be missing or misunderstanding an important phenomenon occurring within. For example, the impact of the transfer port on the viscosity, mass flow, pressure or heat dissipation is a big question.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: subscriber on February 01, 2025, 12:12:16 AM
Jolly good!
Title: Re: Spring Piston Simulator Project
Post by: mpbby on February 01, 2025, 02:21:43 PM
I am not capable of technical thinking as you do.   So, maybe this is a kind of off topic post, and you judge if it should be considered.   

Since 2013, when, power-hungry, I bought a Diana 350 T06 .22, I am facing the challenging learning curve of springers in general.  Until I have learned to do a simple scope test about ‘still  holding zero?’, scopes were always a nightmare to the troubleshooting detective.

Well, scopes apart, no matter the springer, I ended thinking we are always dealing with an equation to minimize – inconsistency; where each factor brings its own contribution.

As I understand, for a given springer, when you squeeze the trigger the piston start to move and, at some point, the pellet start to move.  We have a smaller recoil from the very beginning, and the ‘big’ recoil at the ending of the piston curse. 

So, I think that some skilled person analyzing the barrel path after squeezing the trigger would be useful to all springers shooters.

The idea would be to attach a laser device to the barrel of any springer and do a slow motion recording of the laser dot.  I don’t have a slow motion recording device and the profile to execute it systematically.  The distance to the paper target should be convenient to clearly see/record the laser dot path.  ES and pellet weight should be considered.  Making some math, we could know at what point of the recorded path the pellet went out of the barrel. 

For instance, changing modes of holding, resting, squeezing, would show the modes we need to – consistently “minimize” form and length of the barrel path, in order to choose the combination the shooter has to try to repeat at each round.
 
In the whole context of the springer world, I hope you consider this idea useful.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 01, 2025, 07:50:49 PM
Some new code and graphs...

Ok, it's time to start computing things. The below code is an update of the boiler plate code I posted previously. The key changes include filling in some placeholder measurements, most which are not utilized yet. The second, important change is adding logic to simulate a simple spring+mass system. This serves as the first stepping stone and is a demonstration of what happens with a spring if it is not confined inside of an airgun.

The setup is a spring that is immobilized on on side (lets say the left side) and has a piston assembly attached on the right side. The spring is compressed to about half its length and released for 15 milliseconds. As the simulation is run the resulting change in position, velocity and acceleration are gstored and then raphed at the end.

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp

class SpringAirgunSimulation:
    def __init__(self):

        # --- Mass measurements ---
        self.spring_mass         = 0.1050  # kg TX200 Mk3 FAC spring
        self.piston_mass         = 0.2215  # kg
        self.piston_weights_mass = 0.0231  # kg

        # Effective piston assembly mass: 1/3 of spring + piston + weights
        self.pistonAssembly_mass = (1/3) * self.spring_mass + self.piston_mass + self.piston_weights_mass

        self.pellet_mass = 5.469028e-4  # kg
        self.rifle_mass = 0             # kg - needs to be measured

        # --- Geometry & Dimensions ---
        self.spring_length = 0.2250     # m
        self.spring_preload = 0.0025    # m - possibly more, needs to be measured
        self.spring_cocking = 0.0960    # m - needs to be verified

        # Total spring deflection
        self.spring_deflection = self.spring_cocking + self.spring_preload

        self.pellet_caliber = 0.0045  # m
        self.pellet_head_area = np.pi*(self.pellet_caliber/2)**2

        self.piston_diameter = 0.025    # m
        self.piston_radius   = self.piston_diameter / 2 # m
        self.piston_head_area = np.pi * self.piston_radius**2 # m^2

        # Initial "chamber" length set to cocking distance
        self.chamber_length = self.spring_cocking
        self.chamber_volume = np.pi * self.piston_radius**2 * self.chamber_length

        self.transferPort_diameter = 0.0036 # m - possibly as large as 3.75mm
        self.transferPort_length = 0.00987  # m - possibly smaller at 9.8mm
        self.barrel_length = 0.335  # m

        # --- Physical constants & properties ---
        self.spring_k = 77.2e3         # N/m - Assumed the spring is made of Chrome
        self.ambient_pressure = 101325 # Pa
        self.ambient_temp = 293        # K
        self.gamma  = 1.4              # Heat index
        self.R = 287.05                # J/(kg·K)
        self.gravity = 9.801           # m/s^2

    # ----------------------------------------------------------------------
    #  Spring Force Model
    # ----------------------------------------------------------------------
    def SpringForce(self, spring_x):
        """
        Computes the spring force based on Hooke's Law.
        Args:
            spring_x (float): Current spring displacement from equilibrium.
        Returns:
            float: Spring force in Newtons.
        """
        return self.spring_k * (self.spring_deflection - spring_x)
   
    # --- Friction Models ---
    def BoreFriction(self, pellet_x):
        return
    def PistonFriction(self, piston_x):
        return
    def PelletDeformation(self, pellet_x):
        return
   

    # ----------------------------------------------------------------------
    #  ODE System - 2nd order equations
    # ----------------------------------------------------------------------
    def system_equations(self, t, y):
        """
        Defines the dynamics of the spring-mass (piston + spring) system by computing how the
        system's displacement and velocity change over time (these are the time derivatives of x and v).
        Args:
            t (float): current time
            y (list): y[0] is the current spring displacement, y[1] is the current spring velocity
        Returns:
            list: Two elements, the first is the spring velocity (dx/dt = velocity),
            the second is the spring acceleration (dv/dt = acceleration). Both are the time derivatives of x and v,
            in other words how fast x and v are changing.
        Notes:
            The solve_ivp solver internally keeps track of x(t) and v(t) at every time step.
            When it integrates the system_equations function it stores the results in solution.t and solution.y
            solution.t stores the time steps of the integration.
            solution.y has two elements, y[0], which stores the spring displacements 'x', and y[1],
            which stores the velocity, each is stored at some time t
            The solver needs acceleration information to compute how the velocity changes over time, so it can
            compute the next v it will pass as y[1] in the next iteration of the integration.
        """
        spring_x, spring_v = y
        F = self.SpringForce(spring_x)
        dvdt = F / self.pistonAssembly_mass
        # Note: dvdt is not stored in the solution, but it is easily recomputed if we know x and v.
        return [spring_v, dvdt]

    # ----------------------------------------------------------------------
    #  Simulation block
    # ----------------------------------------------------------------------
    def simulate(self, time_span, time_steps):
        t_eval = np.linspace(time_span[0], time_span[1], time_steps)
        sol = solve_ivp(fun=self.system_equations,
                        t_span=time_span,
                        y0=[0.0, 0.0],  # Initial displacement and velocity
                        t_eval=t_eval,
                        method='RK45')
        return sol


    # ----------------------------------------------------------------------
    #  Graphing simulation data
    # ----------------------------------------------------------------------
    def plot_results(self, solution):
        t = solution.t * 1000  # Convert time to milliseconds
        x = solution.y[0] # Extract the spring positions
        v = solution.y[1] # Extract the pistonAssembly velocity
   
        # Compute spring energy and acceleration
        spring_energy = 0.5 * self.spring_k * (self.spring_deflection - x)**2
        piston_acceleration = self.SpringForce(x) / self.pistonAssembly_mass
   
        plt.figure(figsize=(10, 8 ))
   
        # Energy plot
        plt.subplot(3, 1, 1)
        plt.plot(t, spring_energy)
        plt.ylabel('Energy (J)')
        plt.title('Spring Energy')
        plt.grid(True)
   
        # Velocity plot
        plt.subplot(3, 1, 2)
        plt.plot(t, v)
        plt.ylabel('Velocity (m/s)')
        plt.title('Piston Velocity')
        plt.grid(True)
   
        # Acceleration plot
        plt.subplot(3, 1, 3)
        plt.plot(t, piston_acceleration)
        plt.xlabel('Time (ms)')
        plt.ylabel('Acceleration (m/s²)')
        plt.title('Piston Acceleration')
        plt.grid(True)
   
        plt.tight_layout()
        plt.show()
   
   
if __name__ == "__main__":
    model = SpringAirgunSimulation()
    solution = model.simulate(time_span=(0, 0.015), time_steps=15000)
    model.plot_results(solution)




Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 01, 2025, 08:04:35 PM
You will note in the three graphs that the spring energy oscillates over time. It goes from more than 300 Joules to zero and back up. Never stopping. Shouldn't it decrease gradually and stop at zero? A similar thing happens in the graphs for velocity and acceleration, they all oscillate back and forth.

Although this is not exactly what happens inside of a springer, it is correct for a spring whose right side is not confined or limited to a certain travel distance, and which does not experience friction nor an opposing force (like compressed air pushing back). In essence there is nothing in this simple simulation to slow and dissipate the energy of the spring, so it boings (oscillates) back and forth forever (see Newtons laws for an explanation). We will fix this in the near future, but the first basic step is done. We've setup a simple spring, which will provide the power for our simulated airgun.

See you at the next post!
-Marty

Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 01, 2025, 08:16:20 PM
mpbby, a few years back I heard of a device that attaches to a rifle and measures the vibration and positional changes of the gun itself. The device recorded this data and was meant to help people improve their shooting form. Unfortunately, I think these types of solutions have a small market vs. the price it costs to create theme. Doing the laser setup that you suggested is beyond my technical abilities, but it sounds doable and would be a cool thing to have.

-Marty

Title: Re: Spring Piston Simulator Project
Post by: mikeyb on February 02, 2025, 01:01:08 AM
You will note in the three graphs that the spring energy oscillates over time. It goes from more than 300 Joules to zero and back up. Never stopping. Shouldn't it decrease gradually and stop at zero? A similar thing happens in the graphs for velocity and acceleration, they all oscillate back and forth.

Although this is not exactly what happens inside of a springer, it is correct for a spring whose right side is not confined or limited to a certain travel distance, and which does not experience friction nor an opposing force (like compressed air pushing back). In essence there is nothing in this simple simulation to slow and dissipate the energy of the spring, so it boings (oscillates) back and forth forever (see Newtons laws for an explanation). We will fix this in the near future, but the first basic step is done. We've setup a simple spring, which will provide the power for our simulated airgun.

See you at the next post!
-Marty

Your model is currently an undamped https://en.wikipedia.org/wiki/Damping (https://en.wikipedia.org/wiki/Damping) oscillating system with reasonable "ballpark" values. A good start. As stated you need to add some losses due to friction and drag.
FYI that spreadsheet sim looks pretty close to the numbers I get. Piston velocity going negative IS a small bounce off the compressed air. I think this happens frequently but is NOT a big problem to solve.

Question...

Quote
Pellet Energy = (Spring Energy) + (Gas Energy) - (Recoil Energy) – (Dissipated Heat Energy) – (Friction Energy)

I don't understand the +(Gas Energy) term? Can you explain where it comes from?


Spring Energy (J)

is the total and only system energy at the start T="0" of the shot event.

The rifle converts the stored potential energy in the spring to kinetic energy in the piston-mass. The piston kinetic energy is converted back to potential energy in the compressed air (another lossy spring until pellet exits the muzzle). The potential energy stored in the compressed air is converted back to the kinetic energy of the pellet.

There will be losses from:

friction/drag = pellet, piston, spring (these are significant and cannot be ignored)
acoustic = sound, vibrations (likely small enough to be ignored at least during the initial "debug" of your simulation)
recoil = rifle motion (just remember that "work = force * distance" so if the rifle doesn't move there is no "work" done.)
heat = adiabatic heating of the compressed air (Nice thing about "springers" is that the event duration is short so much of the adiabatic heat in the quickly compressed air is recaptured as the air expands & cools behind the pellet. SOME heat is lost to the rifle parts and simulating that will be fun. I predict that percentage energy lost will be small and there will be no practical way to capture it. Suggest you ignore it during initial sim setup.)

Pellet Energy (J) = Spring Energy (J) - All_Significant_Combined_Losses (J)


Springers are a type of simple (yet not so simple) heat engine. Efficiency of ~30%-35% of the spring energy transferred to the pellet is where many springers work today. I doubt that can be significantly improved without making the "elegantly simple" springer engine so complicated it becomes impractical... too difficult and/or expensive to manufacture. I'd be delighted to be proven wrong.

I ran many simulations like this during the 1980s to model electrical, mechanical, and electro-mechanical systems. When properly "set-up" the results can be VERY close to actual measured performance. The work I did was NOT cutting edge in theory OR in computational power. Anyone in the airgun industry would have had access to BETTER models and computational resources and I'd be surprised if they weren't using computer simulations/modeling to improve springer performance by the 1990's.

I already went down this rabbit hole (springer simulation) a few years ago. Learned what I wanted to know and archived my files. May dig up the results to compare with yours when you get closer to a working model.

mpbby - Regarding the idea about characterizing rifle/barrel oscillations to attain better accuracy I think this could be simulated but the effort would be high and the results only good for ONE specific rifle. We all know how springer rifles can be pellet-picky with even the SAME MODELS preferring different pellets. IMO this means that rifle/barrel oscillations are also likely to vary from rifle to rifle (manufacturing variations) so simulating the event for one rifle would not really help predict barrel whip.

I'd personally like to see VERY HIGH SPEED x-ray video of a springer shot cycle including barrel harmonics. I think that would clear up a lot of the myths about how springers actually work. Something in the 10000-100000 frames-per-second range. Anything slower is pretty much useless.

Simulation exercises like this help people understand how & why a springer does what it does. For that reason alone the effort is worthwhile IMO.
Your results may not be what you currently expect. I suggest you "enjoy the journey":-)
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 02, 2025, 11:27:22 AM

mikeyb, glad you joined the conversation! You're another regular that I hoped would add to the topic. Just a few more regulars and we'll be able to fill a table at Olive Garden ;) Now, on to some of your comments/questions.

Your model is currently an undamped https://en.wikipedia.org/wiki/Damping oscillating system with reasonable "ballpark" values. A good start. As stated you need to add some losses due to friction and drag.
FYI that spreadsheet sim looks pretty close to the numbers I get. Piston velocity going negative IS a small bounce off the compressed air. I think this happens frequently but is NOT a big problem to solve.

Yes, the spring system is undampened. I wanted to ensure that I'm getting the classical sign-wave of spring oscillation before doing anything else. I also looked at the spreadsheet, but I can't decipher all of the inline 'if' formulas in it. Thats the bad part about excel, it's hard to debug and understand the formulas when they get long and complex. This is not to say that it can't be used to solve this problem. Just that, it's not very elegant and harder to get an understanding of how the physics matches with the formulas/code. Regarding piston bounce, I wanted to show that it's not only a function of being pushed back by the compressed air, but also a function of the spring extending past its natural length. This won't be the case once we put a limit on the extension length but it's easy to forget and its does occur if the spring-piston assembly has any room to move in the uncocked position. Furthermore, I think there are two types of piston bounce, the first is when the piston is pushed back by air before it hits the end of the compression chamber and the other is when it makes contact (slams). In the second case the bounce is determined by the piston seal's thickness and its Mohs/Rockwell scale. I suspect the bounce is less in the second case, but we don't know by how much.   

I don't understand the +(Gas Energy) term? Can you explain where it comes from?

I was trying to show how the system balance looks like during the shot cycle. During the simulation a portion of the energy will be stored in the Gas and another portion of this energy will also be transferred from the Gas to the back of the pellet. To be clear, when the simulation starts the energy of the Gas will essentially be zero due to ambient atmosphere and zero again at the end of the shot cycle since the volume will be zero.

I appreciate the reminder about the energy losses. The plan for this project is to go from idealized basics to something closer to real life. Therefore, I intend to add pieces as I go along and fine tune the realism. For example, in the beginning there won't be any heat loss but it is my intention to add it via dissipation into the chamber walls and maybe even the pellet and barrel. It might be small, but I want to know exactly what proportion is wasted. I don't think this is the case but imagine if we find that 15% of energy disappears into friction and conduction. Lets say that out of this its 5% into conduction and 10% into friction. That gives us specific areas to think about improving. Hobbyists could polish the barrel, shorten it, or lube their pellets. But manufacturers (assuming costs are low), could use a different material for the comp chamber and barrel. Field Target competitors could figure out what is the ideal temperature for their rifles, etc, etc, etc.

I'd personally like to see VERY HIGH SPEED x-ray video of a springer shot cycle including barrel harmonics. I think that would clear up a lot of the myths about how springers actually work. Something in the 10000-100000 frames-per-second range. Anything slower is pretty much useless.

I'd love to see this myself. A few years ago I even contemplated recreating the compression chamber of an air rifle in plexiglass/acrylic. Filming the action through the plexiglass in slow motion would not only confirm the timing of the piston dynamics but also allow for temperature extrapolation.

Anyways, sorry for being so long winded. I know this is basic stuff to you! Nevertheless, I appreciate your input and for taking the time visit this thread. I hope to take this project much further and build it on more concrete concepts than my TP Madness thread ;)

-Marty


 
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 02, 2025, 12:37:03 PM
Getting the friction goin' on... ;D

In the next update to the model I've added a friction function for the piston seal. This is a very simple friction model that will serve to show how the spring behaves when it is dampened. Also, I'm not going to post the full code because it is starting to get long, but I will attach it as a file for anyone that wants to look at it. In the code I'm subtracting the force of the friction from the force of the spring, resulting in a net force.

Please note that I ran the simulation for a longer period, and I exaggerated the scale of the friction force just for demo purposes. It will be modified later to match the piston's actual friction more closely. You should now see how the oscillations die down as the spring's energy is dissipated over time through friction.

-Marty

(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=471554;image)
Title: Re: Spring Piston Simulator Project
Post by: mpbby on February 02, 2025, 01:36:34 PM
mpbby, a few years back I heard of a device that attaches to a rifle and measures the vibration and positional changes of the gun itself. The device recorded this data and was meant to help people improve their shooting form. Unfortunately, I think these types of solutions have a small market vs. the price it costs to create theme. Doing the laser setup that you suggested is beyond my technical abilities, but it sounds doable and would be a cool thing to have.

-Marty

Thank you for answering Marty, you are a gentleman.
Title: Re: Spring Piston Simulator Project
Post by: mikeyb on February 03, 2025, 09:16:40 AM
You have a single spring-mass model working with some damping. Excellent.

I don't want to change your path with specific coding details because I'm hoping your model and results will be consistent with what I've seen. I do have some suggestions on how to proceed through your model to confirm it is working in stages. If you try to add too much function in at one time it "may" be difficult to find small errors or incorrect-assumptions. Been there, done that!

Just some suggestions:

Next add compressible air volume which should behave like a SECOND NON-LINEAR SPRING in front of the piston.

- Include volume of transfer port so that PEAK pressure (ignoring adiabatic heating for now) at piston contact can be confirmed by simple ideal gas volume calculation.
- Set boundry conditions for piston travel... it can't go through the end of the compression tube!
- PRETEND pellet is blocking the bore volume and CANNOT MOVE.

Now you should have a coupled two-spring single-mass model that will oscillate and decay depending on the piston friction value you choose.

At this stage you can check if the time/velocity/pressure numbers generated are consistent with reality.



After that you can allow the pellet to move down the bore and "connect" that expanding-volume-mass-acceleration back into the action of the piston.



Simulating pellet "release" timing is a tricky monkey since in real springers the pellet will "STICK" at the breech until pressure reaches some threshold value. This can be modeled as an IF/THEN condition, a high static friction transitioning to a low sliding friction, or a combination of the two.

Best wishes :-)




Question for mods (and sorry to Marty)...
Should this discussion be moved from here

GTA »
All Springer/NP/PCP Air Gun Discussion General »
"Bob and Lloyds Workshop" (Moderators: Rocker1, ezman604, amb5500c)

to maybe here??

GTA »
All Springer/NP/PCP Air Gun Discussion General »
Machine Shop Talk & AG Parts Machining »
Engineering- Research & Development (Moderators: Rocker1, Wayne52)
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 03, 2025, 10:18:22 AM
Thanks for the advice, Mike. I've gotten a bit ahead of what I've posted so far. Unfortunately, the code needs a lot of cleaning up and changes to make it more object oriented. That said, I've got simple gas compression dynamics incorporated and I have the pellet movement modelled too. Right now, the TP is considered part of the compression chamber, so that will eventually need to be separated out with boundaries and mass flows etc. (Probably the hardest part of this project...).

I have experimented with two ways of setting boundary conditions for piston travel. The first is checking when the piston is about to extend past the compression chamber (i.e. deflection length - preload) and then setting the spring velocity to zero. However, this doesn't seem like a clean solution as it causes problems with the solver/integration. The second solution I'm experimenting with is adding event handling to the solver. When the wall is hit it should save the system state, reset some of the vectors and then restart the integration for the bounce portion of the movement (assuming there is enough energy for bounce).

Regarding pellet sticking, at the moment I have a simple IF/ELSE condition where it won't let the pellet start moving until a certain amount of force is built-up. Again, this is not the most elegant solution because it causes integration errors, but some of it can be overcome by using a solver that can deal better with stiff problems. Eventually, I'd like to make this pellet friction model less linear and more dependent on velocity and pressure. No recoil dynamics have been attempted yet.

The figures I'm getting are plausible, between 850 and 1000 fps, depending on the spring and pellet variables I set. But I have not tested it vigorously against my TX200 because I still need to measure the exact pre-load and verify the stroke length when cocked. Getting the measurements on actual stroke length is a bit tricky because the rifle needs to be cocked while the stock is off.

I was aiming to clean the code up and continue the step-by-step posts, rather than just posting the spaghetti code I have right now. Anyways, thanks for your input, it helps me verify that I'm going in the right direction.

PS. Attached is some sample output. I don't trust the figures yet, but the shapes of the curves and the scales look plausible.
(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=471601;image)

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 09, 2025, 01:40:49 PM
Just an update for anyone still interested...

The latest iteration of the code is looking better and the output looks very encouraging. I took apart a TX200 and got some better measurements of stroke length and preload. While I was at it, I popped in a softer ARH spring and replaced the metal guide with a Delrin one. That said, this required some new measurements of the spring, which I've updated in the code. I also took multiple chrony measurements of three JSB .177 pellets (i.e., 7.97gr, 8.44gr and 10.3gr) to have as a good range of comparison points.

The model now incorporates the following frictions:

The simulation does very well up to the point that the pellet exits the barrel. I've only relied on friction numbers from various papers and the pellet mass given on the tins, yet the "ball-park" figures look really good. Maybe I got lucky!

Actual vs. Simulated
876 vs 883 (7.87 gr) = +0.80% difference
848 vs 841 (8.44 gr) =  -0.83% difference
751 vs 723 (10.3 gr) = -3.73% difference

The biggest difference is for the heavy pellet. I assume that it has to do with the stiction friction or skirt deformation. Unfortunately, there are many variables to go through and I haven't even touched simulating the transfer of air between the compression chamber and TP.

Now for the parts that aren't working so well...
If I let the sim run past the point of the first piston bounce the piston position given by the integrator gets messed up and shows the piston going through the spring extension limit. This is because the integration function has adaptive time stepping, which does not always capture the exact moment of max spring extensions. I'm not sure how to deal with this yet, but I'm working on some potential solutions.

Also, I noticed that lowering the adiabatic index slightly can actually yield better performance. It's a bit counterintuitive that heat dissipation would cause better performance, so I have to do more research on the mechanics of this phenomena. It could be due to velocity and pressure impulse changes caused by lower heat during critical moments of the piston stroke. This has got me very curious!

More work to be done for sure!

-Marty

 
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 09, 2025, 07:32:47 PM
What the frrrrriction is going on?

So, I've been playing around with the code as I try to make it more readable and organized. While doing that I got this idea to selectively turn-off the friction logic, just so I know what impact frictions are having on the velocity of the pellet. This will make isolation of each friction component easier in the future, especially when I get friction measurements off my TX200 as opposed to using figures that someone else came up with. Anyways, the impact was BIG!

Based on an 8.44 gr pellet, turning off all frictions resulted in a velocity increase from 848 fps to 1,177 fps. I don't want to make permanent/concrete statements on which friction component is causing most of this because I'm not using my own friction coefficients, nevertheless that's nearly a 39% loss of power due to friction.

Does this mean that we can increase power or efficiency by that much? Nope, I doubt that very much even if we made the gun out of Teflon. But it sure puts things into perspective. Furthermore, at this juncture I don't know if this is "real world" accurate. I say this because I didn't come up with these friction models from scratch and there is a possibility that some of these friction plugs, where backed out to make the academic papers better match up with experimental data. In other words, it could be that the numbers only match-up because the friction coefficients mask the fact that the physics modelled (like in the transfer port) is not accurate.

-Marty

PS. Just to be clear, I don't think Dr. Tavella over-optimized his friction models, just that my code has taken the liberty of using coefficients from all over the place and I have a little bit of doubt of how accurate those coefficients and assumptions are.
Title: Re: Spring Piston Simulator Project
Post by: subscriber on February 10, 2025, 12:15:37 AM
I think that piston seal friction is very complex, because the higher the air pressure during compression, the more the synthetic seal lip is actuated outwards to minimize blowby.  So, just pushing the piston forwards at low speed without increasing air pressure probably is not representative.

Steel piston rings are also activated by air pressure pushing them out, but I suspect the coefficient of friction is lower and more constant.  Certainly, the contact are between rings and cylinder are probably more constant than a seal lip, where the contact patch elongates at higher air pressure to produce more friction.

A Teflon seal lip, or coating may be the answer.  Certainly, a Teflon based grease on the seal lip and compression tube bore should help, regardless of piston seal type.

I think that pellet friction is less significant, because while it might start high, it probably drops significantly after an inch or two of travel down the barrel; if not sooner.  The friction and holding force of the pellet in the breech cone (due to cone to cone interference) may be high, but acts over a very short travel; and energy is force x distance.  The short distance aspect suggests not very much (negative) energy transfer in the breech cone.

Reducing the holding force by using a shallower breech cone to reduce the above loss would be a mistake.  The holding force is what enables full air pressure to be reached before the pellet breaks free.  It is like holding a jet aircraft against the brakes as the engines spool up on a short runway.  Allowing the aircraft to move before the engines have developed full thrust "uses up" runway length, and is contraindicated.

Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 10, 2025, 10:07:33 AM
I think that piston seal friction is very complex, because the higher the air pressure during compression, the more the synthetic seal lip is actuated outwards to minimize blowby.  So, just pushing the piston forwards at low speed without increasing air pressure probably is not representative.

I'm totally in agreement with you on this. I'm working on converting the piston seal friction to be non-static and non-linear. First, I think there is some stiction just to get the piston going, second as the velocity and thus pressure increases the lip flares which initially increases the friction quickly, but it reaches some apex. Next when a piston bounce occurs the friction force in the opposite direction is smaller. Likely this will require three conditional statements and a capped exponential function.

I think that pellet friction is less significant, because while it might start high, it probably drops significantly after an inch or two of travel down the barrel; if not sooner.  The friction and holding force of the pellet in the breech cone (due to cone to cone interference) may be high, but acts over a very short travel; and energy is force x distance.  The short distance aspect suggests not very much (negative) energy transfer in the breech cone.

Regarding the pellet friction - To my surprise the sim is showing the opposite, pellet deformation is the biggest energy sink. On page 19 of Tavella's paper, he assumes that the pellet deformation friction is constant, which I assumed as well for initial simplicity. As you say this may not be a correct assumption, especially given that he got this figure from measuring the push required to get the pellet down the barrel and I doubt he was able to vary the velocity as he was making this measurement. BUT in its totality, as part of the entire simulation, this assumption is holding or offsetting something else.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 10, 2025, 10:59:15 AM
Coefficients are important...

In the previous post where I compared the simulation results vs. actual, I mentioned that the biggest error was occurring for the heavy 10.3gr pellet. Now I know why!

When I ran the previous simulations, I neglected to update the skirt friction coefficients. I simply used the same value for all three pellet types. Below are the corrected figures, which look even better:

Actual vs. Correct Sim
876 vs 870 (7.87 gr) = -0.68% difference
848 vs 841 (8.44 gr) = -0.83% difference
751 vs 741 (10.3 gr) = -1.33% difference

Note that using Tavella's friction coefficients shrank the error for the heavy pellet from -3.71% undershoot to only -1.33%. It also shrank the error for the light pellet. This is assuming an adiabatic index of 1.35, so allowing some heat loss.

-Marty

Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 10, 2025, 01:37:22 PM
The holding force is what enables full air pressure to be reached before the pellet breaks free. 
I think the pellet motion starts long before full pressure. George Schmermund's pressure transducer based data on a .22 CO2 barrel had motion start at about 232 psi. My Accelerometer based data for a .22 gas ram gun showed the pellet motion start as early in the pressure rise.
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 10, 2025, 02:02:51 PM
Nice work Marty.
It may be interesting to plot pressure vs. pellet position and or velocity. It would show the break free pressure as well as the rise and fall of the friction term as the pellet moves down the barrel.

I my head, the pellet/barrel interaction partitions more clearly into skirt effects and body/head effects. The skirt effects include the pressure term and cover friction including the rifling. I don't think you can separate that out. The body/head effects would be pressure independent (though velocity dependent) and may be dimensionally driven. You may be able to capture some of this in testing by pellet head size.
The pellet elastic (and actually plastic) deformation energy may need an FEM analysis. I don't think Tavella's suggestion of pushing a pellet down the barrel will capture the effect.

Like I said earlier, great work!
Title: Re: Spring Piston Simulator Project
Post by: subscriber on February 10, 2025, 05:52:14 PM
I think that if you had a test bed where could ramp the air pressure slowly,, the pellet would stat moving at lower pressure than in an actual air rifle.  This would be in part due to pellet inertia and friction.

As for pellet friction down the barrel, that should be a lot lower than while pellet is being swaged down into the bore.  After the rifling is fully engraved and the air pressure starts to drop due to the enlarging expansion volume, friction should drop off and remain near constant until the pellet reaches the choke.  Am aggressive choke probably uses up significant pellet energy.

As long as the air pressure is high enough to force hard contact between pellet  skirt and barrel, friction is likely to be significant.  If the barrel has constrictions in the diameter anywhere a long the length, friction there is likely to reduce efficiency.

A  soft or thin pellet skirt is likely to reduce breech cone pressure, but if the skirt balloons a lot it increases friction in part due to the length of skirt contact down the rest of the barrel.  Both breech cone pressure and barrel friction would be affected by the diameter of the skirt before the pellet is fired.  To some degree a more expandible pellet skirt will increase friction, as the air pressure in the skirt forces hard skirt to breech cone and barrel contact. 

This is a bit like drum brakes, where wheel rotation draws the brake shoes in on a wedge or pivot, making them self actuating to a significant degree.  Also the reason why drum brakes tend to lock the wheels and not allow them to start turning again when the brakes are released.  Although that may be problem associated with early designs, before vacuum brake boosters were common.

So, with a springer, either side of the point where the pellet starts to move, building air pressure feeds friction; and increasing friction feeds the build up of air pressure - until the piston stops moving forwards.  This is due to the very abrupt "crash" of the piston into the air ahead of itself, being stuffed into a tiny space.  Not what would happen if you fed air to the base of the pellet more gently and ramped the pressure slowly.  At least in the model in my head :)
Title: Re: Spring Piston Simulator Project
Post by: subscriber on February 10, 2025, 06:02:40 PM

I am not sure what the breech looks like on the CO2 airgun used by George, but any probe loaded PCP that pushes the pellet into the bore to some degree is not a good model for a spring piston airgun.  The latter have a breech cone that has the pellet finger loaded to just make contact with the cone.  A probe loaded PCP would be similar to deep seating the pellet in a springer's breech cone.  The PCP' air is pre-compressed and does not need a breech cone to build the air pressure on firing the way a spinger does.

At one time pellet loading tools were popular. All well and good for uniformity, but some people thought they were helping by overcoming the breech cone force, by deep seating pellets.  If they ran their pellets over a chrono and observed lower velocities, they might consider that the lost pellet energy went into slamming the piston harder.

The holding force is what enables full air pressure to be reached before the pellet breaks free. 
I think the pellet motion starts long before full pressure. George Schmermund's pressure transducer based data on a .22 CO2 barrel had motion start at about 232 psi. My Accelerometer based data for a .22 gas ram gun showed the pellet motion start as early in the pressure rise.
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 10, 2025, 07:57:26 PM
I don't think the pellet knows (or cares) what is causing the pressure on its rear end to rise. Once its fingernails can't cling to the barrel wall anymore, off it goes.  ;) Geometric tolerances and pellet material probable drive this, but it happened well before peak pressure.
I think I remember Lloyd did some of his high velocity tests with a pellet equivalent that was restrained until peak pressure was achieved.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 11, 2025, 08:03:24 PM
Nice work Marty.
It may be interesting to plot pressure vs. pellet position and or velocity. It would show the break free pressure as well as the rise and fall of the friction term as the pellet moves down the barrel.

I my head, the pellet/barrel interaction partitions more clearly into skirt effects and body/head effects. The skirt effects include the pressure term and cover friction including the rifling. I don't think you can separate that out. The body/head effects would be pressure independent (though velocity dependent) and may be dimensionally driven. You may be able to capture some of this in testing by pellet head size.
The pellet elastic (and actually plastic) deformation energy may need an FEM analysis. I don't think Tavella's suggestion of pushing a pellet down the barrel will capture the effect.

Like I said earlier, great work!

Thanks Stan! I’m working on adding some nicer graphs that should show the timings and positions a bit better. But I gotta work to pay for eggs first ;D, wish I had more time.

-Marty

Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 11, 2025, 10:17:51 PM
One interesting parameter that you may be able to extract from your analysis is the net force on the rifle. This would be the pressure times the compression head area minus the force between the aft end of the spring and the wall. This is in essence the acceleration of the unconstrained rifle. It is also what I attempted to measure with accelerometers in this graph. It shows the acceleration as a function of time and also includes (overlayed from a number of shots) the pellet position in the same timeframe. It is an external measurement beyond just muzzle velocity that one could compare to modeling results.
https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=176445.0;attach=360073;image
https://www.gatewaytoairguns.org/GTA/index.php?topic=176445.msg156155029#msg156155029
Title: Re: Spring Piston Simulator Project
Post by: ballisticboy on February 12, 2025, 10:49:23 AM
I wrote a program about 10 years ago which was able to predict the effects of changes to a spring gun, but not until it had been calibrated against known measured characteristics for the gun in its original state. There are just too many variables at work.

Take pellet release pressure, there is a difference in the release pressures depending on the rate of increase of the pressure. The pellet will move at a lower pressure for a slow increase in pressure than it does for a rapid increase. Also, the gas specific heat factor gamma will be different at the high temperatures and pressures in the rifle which will affect the speed of sound in the gas and thus the flow through the transfer port.

The friction coefficients for the various parts are all mostly unknown, and measuring them under the correct conditions is difficult. The pellet has a different friction coefficient when it is sliding than it does when stationery, and the pellet velocity also has an effect on the friction value. There is in addition the mechanical interactions as the pellet deposits lead in the barrel. Friction plays a major part in the gun efficiency and is difficult to get right. The most efficient spring gun I have come across was a 12 FPE rifle with a small diameter piston, sealed with O rings, which had an efficiency of just over 60% as measured by the pellet energy as a fraction of the available spring energy.

So you can get useful information from the models, but it takes a lot of effort to develop the model and to calibrate all the separate parts. The Cardew book is useful for the initial development.
Title: Re: Spring Piston Simulator Project
Post by: subscriber on February 12, 2025, 10:57:12 AM
Thanks, Miles

60 percent efficiency is very impressive.  Perhaps double the typical springer efficiency?

Can you remember the piston diameter of the efficient air rifle you mentioned? 

I wonder if smaller bore pistons experience less bounce at usefully high pressures...
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 12, 2025, 02:19:03 PM
I wrote a program about 10 years ago which was able to predict the effects of changes to a spring gun, but not until it had been calibrated against known measured characteristics for the gun in its original state. There are just too many variables at work.

Take pellet release pressure, there is a difference in the release pressures depending on the rate of increase of the pressure. The pellet will move at a lower pressure for a slow increase in pressure than it does for a rapid increase. Also, the gas specific heat factor gamma will be different at the high temperatures and pressures in the rifle which will affect the speed of sound in the gas and thus the flow through the transfer port.

The friction coefficients for the various parts are all mostly unknown, and measuring them under the correct conditions is difficult. The pellet has a different friction coefficient when it is sliding than it does when stationery, and the pellet velocity also has an effect on the friction value. There is in addition the mechanical interactions as the pellet deposits lead in the barrel. Friction plays a major part in the gun efficiency and is difficult to get right. The most efficient spring gun I have come across was a 12 FPE rifle with a small diameter piston, sealed with O rings, which had an efficiency of just over 60% as measured by the pellet energy as a fraction of the available spring energy.

So you can get useful information from the models, but it takes a lot of effort to develop the model and to calibrate all the separate parts. The Cardew book is useful for the initial development.

Miles, the current simulation is only calibrated to my TX200 in the sense that I took some quick spring and dimensional measurements. I have not calibrated any of the other frictions based on my rifle. I took the friction coefficients as given in Tavella's paper, which are based on a different gun. Either I got extremely lucky and Tavella's friction measurements are very close to my TX200 or his friction measurements don't vary too much from one rifle type to another. I sincerely hope that it is the latter, but future testing should confirm what is happening in real life.

That said, my long-term intent is to get some force gauges and to check how close my rifle matches the friction figures from the paper. Lastly, I am skeptical about the 60% efficiency of reduced piston size designs. The Tony Leach kits, which shrink the piston down to 22mm, are said to be up to 40% efficient. I'm in possession of one of these kits and intend to test the real-world performance. I'd love to get my hands on one of the titanium kits form the UK to compare too... If 60% efficiency is possible that would be outstanding.

-Marty

PS. Miles, If you happen to have access to the rifle that is 60% efficient it would be great if you could share the rifle's internal dimensions, spring measurements, etc. I can plug it into the sim and see what comes out.
Title: Re: Spring Piston Simulator Project
Post by: ballisticboy on February 12, 2025, 06:04:34 PM
The 60% efficiency gun was one of Tony Leach's development guns using, as I said, o rings and not parachute seals. It makes a large difference while they are sealing. I was running some early development numbers through the model for him at the time. I don't have any details of the gun any more. Jim Tyler was also carrying out experiments with a full length HW77 at the time and getting efficiencies of 40% with a conventional layout using different types of springs.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 12, 2025, 06:45:00 PM
The 60% efficiency gun was one of Tony Leach's development guns using, as I said, o rings and not parachute seals. It makes a large difference while they are sealing. I was running some early development numbers through the model for him at the time. I don't have any details of the gun any more. Jim Tyler was also carrying out experiments with a full length HW77 at the time and getting efficiencies of 40% with a conventional layout using different types of springs.

Thanks for the additional color. I love my TL kit and its one of the reasons why I decided to finally do this project. I'm very curious to see how the Tony Leach specs square up against the simulator, but I don't want to jump the gun. First, I want to be sure that the predictions I'm getting for the unmodified TX aren't a fluke. For the TL kit my best guess is that the faster compression due the lighter and reduced diameter piston is overcoming the loss from the additional piston mass.

I hope that Jim will chime in too. I've seen him around GTA a few times before, so I know he's lurking around :D

-Marty
Title: Re: Spring Piston Simulator Project
Post by: JPSAXNC on February 13, 2025, 07:58:09 AM
Something else to consider, there's often a restriction where the barrel is forced into the breech block, and then there's the choke. Both usually harder for the pellet to get through than the release at the breech.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 13, 2025, 10:33:38 AM
Something else to consider, there's often a restriction where the barrel is forced into the breech block, and then there's the choke. Both usually harder for the pellet to get through than the release at the breech.

Good points. I think the breech restriction can be largely captured by the pellet's initial stiction. I haven't given the choke much thought. Although choke does slow down the pellet, my guess is that it's probably by no more than 10-15 fps. Only way to know for sure would be to take a rifle and either cut off the barrel end or enlarge it. For now, these effects will be netted into the pellet stiction and deformation frictions. I might come back to them later for more detailed handling.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 13, 2025, 06:42:29 PM
Nice work Marty.
It may be interesting to plot pressure vs. pellet position and or velocity. It would show the break free pressure as well as the rise and fall of the friction term as the pellet moves down the barrel.

I my head, the pellet/barrel interaction partitions more clearly into skirt effects and body/head effects. The skirt effects include the pressure term and cover friction including the rifling. I don't think you can separate that out. The body/head effects would be pressure independent (though velocity dependent) and may be dimensionally driven. You may be able to capture some of this in testing by pellet head size.
The pellet elastic (and actually plastic) deformation energy may need an FEM analysis. I don't think Tavella's suggestion of pushing a pellet down the barrel will capture the effect.

Like I said earlier, great work!

Stan, here is the graph you were interested in. It shows that the pellet starts moving before max pressure is reached, but it's very hard to see due to the scaling so I added a vertical line to show exactly when this happens. I would be very cautious in accepting this data without further testing. The model has stiction friction on the pellet, but the force might be set too low and thus result in the pellet moving too early. The movement looks plausible, with the pellet taking off like a rocket near max pressure. Take this output with a grain of salt...

PS. I've been looking at the pellet acceleration graphs. The change in acceleration is incredible, which makes me think that most of the friction force would come not from the barrel lands or stiction, but from the pellet deforming due to the high Gs.

(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=472114;image)

-Marty
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 14, 2025, 02:53:05 PM
Marty, Thank you for posting the curve.
It was interesting to compare your model results to the test results I posted the link to.
In both cases the pellet passes through 200 mm pretty much towards the end of the pressure spike. In your model, it looks like it takes about 1.4 ms to get there. In my tests it was about 1.8 ms. I was shooting a .22, 14.7 gr pellet, so the slower start make sense. It is also a gas ram which has a different pressure rise curve. It may be that your friction model is not that far off. How does it compare to the bounding "no pellet friction" case?
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 15, 2025, 11:39:29 AM
Marty, Thank you for posting the curve.
It was interesting to compare your model results to the test results I posted the link to.
In both cases the pellet passes through 200 mm pretty much towards the end of the pressure spike. In your model, it looks like it takes about 1.4 ms to get there. In my tests it was about 1.8 ms. I was shooting a .22, 14.7 gr pellet, so the slower start make sense. It is also a gas ram which has a different pressure rise curve. It may be that your friction model is not that far off. How does it compare to the bounding "no pellet friction" case?

Stan, I'll see what I can do with getting additional data points. BTW, you just gave me an idea to add a gas ram option in the future. I'll have to do some research on how to implement it but I'm very curious as to how efficient gas rams are versus springers. I believe that gas rams accelerate the piston faster than a traditional spring which undoubtably results in their faster lock times. But what is less spoken about is that with faster lock times you get higher pressures and temperatures over a shorter time interval. To me that means there is a possibility that gas rams are more efficient than springers. I say 'possibility' because as I stated before I also believe that elastic deformation of the pellet is a large friction component, which means that faster acceleration may lead to more radial friction than you would get with a slower lock time.

This is just a thought, but maybe we can couple a gas ram with a transfer port and breech cone designed to spread out the pressure force on the pellet over a longer period of time (more like a PCP). I still need to verify this, but it's my assumption that most of a springer's pellet velocity is generated over a 2ms period near the max pressure point, which results in almost instantaneous acceleration and therefore higher deformation friction. If you can spread out the acceleration to 4ms we might be able to reduce the total friction and increase efficiency.

That said, we should not forget that this might also be achieved with clever pellet design and twist rates. Pellet deformation is not only driven by acceleration but also on the mechanical properties of the material it's made of and the centrifugal force from its spin. For example, a pure lead pellet will have a lower Young's modulus than an alloy pellet. This means that it compresses more during acceleration and thus creates more friction. Furthermore, the timing and magnitude of pellet spin can also have an impact on friction. Centrifugal expansion from pellet spin creates radial forces that add to elastic deformation friction. Therefore, it would make sense to have a twist only at the end of the barrel and to use materials that have high Young's modulus, or which have a very small contact area with the barrel. 

Anyways, these are just my musings. I hope I haven't put you guys to sleep.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 15, 2025, 04:11:29 PM
Marty,
I'm not sure what you mean by faster lock times.
George Schermund measured the Gas ram force in the Titan. He got 140 lbs preload and 213 lbs compressed 4 in. So the gas ram has a much flatter force curve than the metal spring's Kx with a smaller preload.
https://www.gatewaytoairguns.org/GTA/index.php?topic=176445.msg156015839#msg156015839
In my testing, at one point I compared the gas ram Titan against the spring driven Quest. The first was .22 and the latter .177 but overall they put out similar FPE.
https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=176445.0;attach=348841;image
In the image, the yellow traces are accelerometer measurements at the scope mount. Positive is forward. It shows the springer with a much higher initial rearward recoil (more negative) due to higher spring force and then falling off as Kx ( and eventually the seal friction and pressure rise) The gas ram has a much more constant recoil until the seal/pressure rise.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 15, 2025, 11:35:14 PM
Stan, by faster lock time I mean that the piston completes the full stroke in a shorter amount of time.

Yes, you are correct. The gas ram has a flatter force curve than a metal spring. Assuming that there is no dampening force acting on the spring, it will have its peak acceleration at the very beginning of its motion and slow down linearly. On the other hand, the gas ram applies its peak force across the entire travel, thus its acceleration (assuming no dampening) remains constant until its full extension. However, this difference results in the gas ram completing its full stroke faster than the metal spring, because on average the gas ram is accelerating more, even if the metal spring has a higher peak acceleration at the beginning. In fact, as you stated the metal spring's higher initial acceleration lines up well with the bigger rearward recoil. This also implies that in a springer the pellet might experience higher elastic deformation, at least initially.

Lastly, not taking into account the friction from the seal, the gas ram may generate more force over the same stroke length because it is sustaining the acceleration for longer (i.e. F=ma * t). I'd like to hedge this statement by saying that this is in theory only. Right now, we don't know the scale/impact of the friction from the ram seal nor whether choke conditions in the transfer port become a limiter before the peak air pressure is reached.

PS. If anyone knows the physics better, please jump in and correct me. I not a physics major, but I stayed in a Holiday Inn last year ;D

-Marty
Title: Re: Spring Piston Simulator Project
Post by: mikeyb on February 16, 2025, 09:53:04 AM

...add a gas ram option in the future. I'll have to do some research on how to implement it but I'm very curious as to how efficient gas rams are versus springers. I believe that gas rams accelerate the piston faster than a traditional spring which undoubtedly results in their faster lock times. But what is less spoken about is that with faster lock times you get higher pressures and temperatures over a shorter time interval. To me that means there is a possibility that gas rams are more efficient than springers. I say 'possibility' because as I stated before I also believe that elastic deformation of the pellet is a large friction component, which means that faster acceleration may lead to more radial friction than you would get with a slower lock time.

Shorter "lock time" is a myth you should be able to disprove once your gas spring simulation is running. My sim showed a gas spring WITH THE SAME STORED ENERGY as a coil spring has a slightly LONGER lock time. The gas spring is about 8%-10% SLOWER than the equivalent coil spring. The "perceived" quicker lock time may be due to the lack of lingering spring vibrations? The FORCE profiles are different with the gas spring "initial force" being LOWER and "end force" being HIGHER than a coil spring. This does lead to a larger perceived 2nd recoil force. Some confirmation of the hypothesis that gas springs kill more scopes.

I've tested airguns that are the same model where one has a coil spring and the other has an air spring. Except for the different force profiles FELT during the cocking cycle, the shot cycles seemed identical. If you handed me either rifle already cocked I could NOT feel any difference between the 2 different springs during the shot. Chronograph data and pellet group size at 30' (open sights, no scope) were the same. IMO there is NO REAL SIGNIFICANT PERFORMANCE ADVANTAGE to using a gas spring. The big difference is that it is EASIER for the manufacturer to charge more money for and "claim" better performance on a rifle that shoots the SAME as a properly lubed coil springer with a fitted spring guide. That being said, gas spring rifles do shoot well right out of the box... no rework/tuning needed. Except for the high rate of leaky Vortex AIR springs there is no real NEGATIVE performance from gas(N2) spring rifles.

Quote
This is just a thought, but maybe we can couple a gas ram with a transfer port and breech cone designed to spread out the pressure force on the pellet over a longer period of time (more like a PCP). I still need to verify this, but it's my assumption that most of a springer's pellet velocity is generated over a 2ms period near the max pressure point, which results in almost instantaneous acceleration and therefore higher deformation friction. If you can spread out the acceleration to 4ms we might be able to reduce the total friction and increase efficiency.

That said, we should not forget that this might also be achieved with clever pellet design and twist rates. Pellet deformation is not only driven by acceleration but also on the mechanical properties of the material it's made of and the centrifugal force from its spin. For example, a pure lead pellet will have a lower Young's modulus than an alloy pellet. This means that it compresses more during acceleration and thus creates more friction. Furthermore, the timing and magnitude of pellet spin can also have an impact on friction. Centrifugal expansion from pellet spin creates radial forces that add to elastic deformation friction. Therefore, it would make sense to have a twist only at the end of the barrel and to use materials that have high Young's modulus, or which have a very small contact area with the barrel. 

Anyways, these are just my musings. I hope I haven't put you guys to sleep.

-Marty

BTW ;-) It's the Holiday Inn Express www.youtube.com/watch?v=8dOHEw8izno
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 16, 2025, 01:09:23 PM
mikeyb, you're probably right about shorter "lock time" being a myth. We often make extrapolations based on how we perceive or feel the shot. To me the gas ram feels quicker/snappier, but this could all be an illusion of the recoil dynamics.  If/when I get the gas ram code incorporated, we will be able to get a better analytical comparison of the two power types. I hope there is someone on this forum that has the new Diana 34 EMS, it would be a great test platform for comparing the gas ram vs. metal spring due to its convertibility.

I will say this though, if we assume that the ram's seal friction is negligible (a big IF) then the gas ram does have some advantages in terms of potential efficiency gains relative to the metal spring. With the metal spring we have hysteresis, un-uniform coil deflection, and/or vibrations - all of which can bleed off energy. BUT all of this is just hypothesizing on my part, the effect of the ram's seal and the scale of the differences is the real determinant of efficiency gains/losses in real life.

One last thing, I previously mentioned that bringing the adiabatic index down from 1.4 to 1.35 resulted in better performance. I've played around with this number and the performance drops when we go below or above 1.35. This is a very interesting finding, because it means that having a little bit of a heat loss in the rifle can help performance, up to a point. My educated guess is that it's probably due to changes in the timing of the pressure impulse. (For those reading who are confused about the adiabatic index, it acts as a coefficient that approximates how heat is lost into the body of the rifle). For some reason, keeping the air slightly cooler has a positive impact on performance. Maybe this is due to the rifle going from a "pop" phase to a "blow" phase. These phases might be just myths - but there might be some trade-off between when the pellet becomes dislodged due to pressure vs. when it is being accelerated by the velocity of the air behind it.

To all: keep the critiques coming. It's very helpful to my understanding of what is and isn't a good model and how to interpret the output.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 16, 2025, 01:48:33 PM
Marty, Thank you for posting the curve.
It was interesting to compare your model results to the test results I posted the link to.
In both cases the pellet passes through 200 mm pretty much towards the end of the pressure spike. In your model, it looks like it takes about 1.4 ms to get there. In my tests it was about 1.8 ms. I was shooting a .22, 14.7 gr pellet, so the slower start make sense. It is also a gas ram which has a different pressure rise curve. It may be that your friction model is not that far off. How does it compare to the bounding "no pellet friction" case?

Stan, below is a comparison of the pellet stiction vs. no pellet stiction, all other frictions (i.e., seal and barrel frictions) were kept on. Unsurprisingly the pellet starts moving immediately, but this results in approximately a 10 fps velocity increase. The timing of pellet exits is about the same in both scenarios.

Pellet Position vs. Pressure (all frictions engaged)
(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=472212;image)

Pellet Position vs. Pressure (pellet stiction turned-off)
(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=472214;image)

Pellet Acceleration vs. Pressure (all frictions engaged)
(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=472216;image)

Pellet Acceleration vs. Pressure (pellet stiction turned-off)
(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=472218;image)

-Marty



Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 16, 2025, 03:56:40 PM
Correction, I showed the wrong graph for Pellet Acceleration vs. Pressure (pellet stiction turned-off).

Here the corrected one:
Pellet Acceleration vs. Pressure (pellet stiction turned-off)
(https://www.gatewaytoairguns.org/GTA/index.php?action=dlattach;topic=217436.0;attach=472224;image)


-Marty
Title: Re: Spring Piston Simulator Project
Post by: rgb1 on February 16, 2025, 07:56:55 PM
Marty, gamma changes thru the compression cycle. To get an appreciation
use this website......


         www.wolframalpha.com/


......enter in the box (for example)     "specific heat ratio  air  800F  1200psi"
The compute button is on the right.   Hope this helps.


                          Ron


Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 16, 2025, 09:20:11 PM
Marty, gamma changes thru the compression cycle. To get an appreciation
use this website......


         www.wolframalpha.com/


......enter in the box (for example)     "specific heat ratio  air  800F  1200psi"
The compute button is on the right.   Hope this helps.


                          Ron

Thanks Ron! The current code makes a few simplifications, which I intend to sharpen as I go along. This link is very helpful.

-Martyrs

Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 19, 2025, 07:19:33 PM
Not much in terms of analytical updates, but I did want to provide a brief update on the progress made with the code:


Thanks for visiting!
-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 20, 2025, 07:09:40 PM
Marty, gamma changes thru the compression cycle. To get an appreciation
use this website......


         www.wolframalpha.com/


......enter in the box (for example)     "specific heat ratio  air  800F  1200psi"
The compute button is on the right.   Hope this helps.


                          Ron

Ron, I've done some more research on gamma behavior. What I found is that the value of gamma falls as the temperature gets higher. Using Wolfram, the estimate is that it falls somewhere into the vicinity of 1.33 at peak compression and temperature. In my code I assumed that gamma was constant at 1.35 to account for heat sinking into the chamber walls. That said, I think this value comes close to what is probably the average gamma throughout the piston stroke, since we are starting with a value of 1.4 at ambient pressure/temperature and it will fall as we compress the air.

I'm experimenting with some codes that can vary the gamma based on the temperature, but I'm doubtful that it will make a big difference. I expect the most visible difference to be in the predicted temperature of the air. Since gamma is falling during compression, it will have a negative effect/feedback on the temperature, which in turn will also result in slightly lower peak compression.

One last thing to mention... The inner surface area of the compression chamber is shrinking during the piston stroke, which means that the conductive area for heat to sink into is also shrinking. This likely implies that although some heat is lost into the steel, there isn't enough time for the gun to absorb much of it.

-Marty

Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 23, 2025, 05:28:26 PM
Time for some updated graphs!

As mentioned in the prior post I've made some improvements to the code. The following simulation graphs incorporate the following improvements:

Notes:
Friction coefficients are still estimates from other papers, they need to be measured for accuracy given my rifle.
Friction model for rifling and pellet spin is simplified, it needs to be improved to better account for changes in pellet inertia due to spin.
Code that calculates energies for a gas ram needs to be added.
The transfer port is still treated as an extension of the compression chamber. This needs to become its own volume with transfer of gases.
There is no code to simulate rifle recoil at this point. It's still on the drawing board. :(

Current output:
Pellet weight 8.44gr
First piston bounce at: 8.99 ms
Piston slam at: 25.51 milliseconds
Pellet exited at: 10.28 ms, velocity: 254.41 m/s (834.68 ft/s)

-Marty

PS. The addition of the dynamic gamma rather than using a static 1.35 cost about 4 fps in terms of velocity. It's a small impact but still large enough to detect.
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 23, 2025, 09:52:27 PM
Nice.
Is the pellet friction model a linear function of pressure? Is there a stiction term?
Title: Re: Spring Piston Simulator Project
Post by: mikeyb on February 23, 2025, 10:12:15 PM
Some parameters look consistent, but IMO there is a problem with piston velocity.

After the piston bounces off the initial plug of air the spring eventually stops the piston rebound and sends the piston forward again. Plot is OK so far.
 
At some time well AFTER the pellet exits, my sim suggests ~15-20 ms after t=0, the piston comes to REST at the end of the comp tube.
You call it piston slam? Much of the system energy has dissipated by this time so the final piston stop is nowhere near as violent as a dry-fire.

The pellet is long gone so air pressure in front of piston is small.

The plot shows the piston velocity settles to 10 m/s.

I don't think this is correct. It should be 0 m/s.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 23, 2025, 11:42:34 PM
Some parameters look consistent, but IMO there is a problem with piston velocity.

After the piston bounces off the initial plug of air the spring eventually stops the piston rebound and sends the piston forward again. Plot is OK so far.
 
At some time well AFTER the pellet exits, my sim suggests ~15-20 ms after t=0, the piston comes to REST at the end of the comp tube.
You call it piston slam? Much of the system energy has dissipated by this time so the final piston stop is nowhere near as violent as a dry-fire.

The pellet is long gone so air pressure in front of piston is small.

The plot shows the piston velocity settles to 10 m/s.

I don't think this is correct. It should be 0 m/s.

You're right, the piston should stop around 25ms. Perhaps it's just a coincidence, but suspiciously it's coming out to be 9.8 m/s... Time to do some more debugging!

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 24, 2025, 12:10:31 AM
Nice.
Is the pellet friction model a linear function of pressure? Is there a stiction term?

Yes, to both. Working on a more advanced friction model which will increase the inertia as the pellet spins up.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 24, 2025, 12:50:44 AM
mikeyb, thanks for your sharp eyes! The piston graph was showing ~10ms (9.8 m/s) because that's the velocity the piston was traveling at just before slamming into the end of the compression chamber. The integration routine is doing adaptive time stepping so it doesn't register when I force the spring velocity to zero upon contact with the end of the comp chamber.

I'm not sure how I'm going to fix this yet. The proper but harder way is to try to stop the piston via a large deceleration force. This may ultimately result in another 'tiny' bounce and should depend on the elastic properties of the piston seal. The other solution is to pause and save the system state, reset the velocities and forces to zero, and then continue. I'd like to make it as realistic as possible, so I'm inclined to do the former, but it will require some more research on my part.

That said, for the moment you can interpret the piston velocity graph as going to zero at 25 milliseconds rather than staying at 10 m/s level. It does not impact the pellet velocity.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 24, 2025, 09:27:52 AM
Attached are the updated graphs using the 'pause and save' method to fix the issue with the piston not stopping at impact. Now, the piston velocity graph has a sharp drop in velocity at the end of the stroke. This is hopefully a temporary fix. That said, the air temperature drops a bit too much subsequent to piston stop. I doubt that the compression chamber walls can draw heat away that quickly, especially since I don't have the transfer port modelled yet. This can be fixed by putting a floor on the chamber heat at ambient temperature, but the proper way is to keep track of how hot the internal walls have gotten because at some point their ability to draw heat away from the air slows down and may even reverse. Oh boy, all of these little details are starting to add up!

-Marty
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 24, 2025, 01:50:48 PM
Nice.
Is the pellet friction model a linear function of pressure? Is there a stiction term?

Yes, to both. Working on a more advanced friction model which will increase the inertia as the pellet spins up.

-Marty

I was thinking that with the stiction term present, it should be visible int the force curves. Shouldn't the net force be zero until pellet launch?
On a related topic, it may be interesting to compare both in modelling and test how a slug compares to a skirted pellet. On first order, the slug friction model would not be pressure dependent.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 24, 2025, 04:02:56 PM
The net force is the pressure acting on the pellet minus the bore frictions, which are pellet elastic deformation, skirt friction and rifling friction. Pellet stiction is implemented differently and acts a little bit like a delay, it prevents the pellet from accelerating until about 30 Newtons of force is generated in pressure. Out of a peak ~220 Newtons about 120 Newtons is stolen by bore friction (not including stiction). I hope that helps.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on February 24, 2025, 05:08:57 PM
I was thinking net force is analogous to acceleration and should be zero until the pellet starts to move. Usually, stiction is higher than the subsequent sliding friction (at least for a while) and when it releases there would be a glitch in the curve.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 24, 2025, 08:00:46 PM
I was thinking net force is analogous to acceleration and should be zero until the pellet starts to move. Usually, stiction is higher than the subsequent sliding friction (at least for a while) and when it releases there would be a glitch in the curve.

There is a glitch in the acceleration curve (see reply #62). I'll put in more acceleration curves in the future. Moreover, the stiction is dominated by the deformation friction, because the deformation friction acts on the pellet longer.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on February 28, 2025, 11:43:11 PM
Trials and Tribble-ations

As noted previously the output of the simulation was showing a drastic drop in air temperature (way below ambient) after the initial spike. My first guess was that the code for heat transfer into the chamber walls was drawing heat away too quickly or that I was improperly keeping track of the walls' changing temperature. Although, that code may still need adjusting I found a simpler explanation for the temp drop. You see, when the compression chamber shrinks the total volume of air in the system initially shrinks too (thus temp spike), but as the pellet moves the volume behind it starts expanding. It's this fast volume expansion in the barrel that is causing the temperature to fall so much. Not only that, what I should have done is capped the volume expansion at the moment the pellet exits the barrel, because that's when the pressure equalizes with the outside. But I didn't do that and as a result the volume just kept expanding as the pellet went on its merry way to kiss the squirrel.

Thoughts on next steps beyond volume control

Currently, the volume of air is treated as a lumped sum of the compression chamber, the transfer port, and the area in the barrel behind the pellet. This is obviously a simplistic approach, but it works pretty well in getting us accurate figures for the pellet energy. That said, it does not allow us to closely study the impact of the transfer port on air temperature, piston bounce, or timing of pellet release. To fix that here is an outline of the approach I'm thinking about next:


I think the difficult part of this approach will be defining the air mass flow between compartments. This is typically where fancy-pants math like the Navier-Stokes equations and Computational Fluid Dynamics (CFD) comes in. Such math deals with the conservation of energy, momentum, and mass of a fluid/gas flow. Having said that, I'm not planning to mess with Navier-Stokes directly, but instead I plan to apply some empirically derived approximations for orifice discharge rates, which I hope will get us close enough to a real-world figures for each of the volumes.

Thanks for dropping by!
-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on March 09, 2025, 04:00:01 PM
Sunday, Sunday, Sunday!

You guessed it, its Sunday and I finally have some time to post. I haven't made much headway with the changes discussed in the previous post yet, but I did make some progress in other areas.

First, I added a graph that shows the temperature change in the compression chamber walls. As you can see, due to the speed of the compression stroke the temp increase is miniscule, in fact I had to go to the 6th decimal place to show it. So, although the air temperature gets pretty hot, most of it is not absorbed by the rifle. I guess that's a good thing, more heat = more power, in general.

Second, I improved the pellet friction code. The bore has three component frictions, which initially were done as follows:

The initial version was a bit of a messy implementation, it didn't do a proper energy balance between forward pellet movement and its angular movement.

The new version still breaks it up into three components but with the following changes:

I still want to improve the friction code further. Firstly, I don't like a constant deformation friction. It should vary based on the softness of the pellet and the acceleration. Second, I'd like to add a resisting force from the air that is being compressed in front of the pellet.

As a result of the changes I can now also keep track of the pellet's angular velocity (how fast its spinning). The spin might not be a huge part of the pellet's total energy, nevertheless the true energy of the pellet is a sum of the forward motion and spin, which we should keep track of to properly compute efficiency.

Attached are the latest graphs. Please note that I have not recalibrated the coefficients, so the numbers are a little off compared to the previous graphs. That will be done later once the math is in better shape.

-Marty

Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on March 23, 2025, 01:47:35 PM
Total Recall Recoil!

Time sure flies when you're working, said no body, ever! Finally, I've stolen sometime away from real life to provide an update post. Recently, I've been thinking about recoil and how to implement it. Why recoil? Well, I think it would be cool to know how recoil depends on the rifle's characteristics.

We can say confidently that recoil will largely be dependent on the mass of the rifle, the mass of the piston, the power of the spring, and the mass of the pellet. The larger the rifle's mass, the lower the recoil. On the opposite end, the higher the power or more massive the piston, the bigger the recoil. Furthermore, old man Newton told us a long time ago that every action has an equal and opposite reaction, and something about conservation of mass and energy. In other words, I've used more of Newtons laws to workout recoil.

That said, the key things I added to the simulator was tracking of momentum, specifically, tracking of pellet, piston, and rifle momentum. Keeping account of these quantities gets us recoil velocity and recoil energy.  I think the main take away is that the rifle's recoil velocity is mostly determined by the piston's velocity. Intuitively it makes sense, the piston assembly is the only thing with significant mass and velocity that is moving around in the rifle. Therefore, controlling the weight and velocity of the piston gives us a way to control recoil, IF we keep the rifle's mass constant. We could of course raise the mass of the rifle to reduce recoil, but who wants to carry around a Howitzer...

Anyways, getting back on track! What's the point of simulating recoil? Well, I hope that we can experiment with different piston designs (i.e. mass, stroke length, etc.) and be able to explain what kind of recoil impulse the rifle will have.

Attached is the new output with recoil graphs - hopefully they make sense!

-Marty
Title: Re: Spring Piston Simulator Project
Post by: JPSAXNC on March 24, 2025, 09:39:37 AM
I wonder about the idea that an action has an opposite and equal reaction. Because action requires energy so some energy must be lost in the action, leaving less energy for the reaction? Also the piston with more mass creating more recoil I agree with if the piston is moving fast, but what if the piston with more mass is moving slower?
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on March 24, 2025, 03:31:38 PM
I wonder about the idea that an action has an opposite and equal reaction. Because action requires energy so some energy must be lost in the action, leaving less energy for the reaction? Also the piston with more mass creating more recoil I agree with if the piston is moving fast, but what if the piston with more mass is moving slower?

Thanks for the question. You are correct, some energy is lost. The following is where most of the losses come from:

1. When initially compressing the spring, we lose some energy into heat and vibration of the spring.
2. When decompressing the spring some of the energy is lost again via the spring vibrating and twisting.
3. The piston seal creates friction, which turns some of the forward motion into heat.
4. Next the compressed air heats up and gives up some of its energy into the metal of the gun before it is transferred to the back of the pellet via pressure and air velocity.
5. When the air hits the pellet skirt it deforms under pressure, which absorbs some energy in the form of heat again.
6. Next the pellet acting against the lands of the barrel causes friction and is absorbed into the metal as heat.
7. Lastly, some of the pellet's energy is imparted into the column of air in the barrel, which is expelled when the pellet leaves the barrel.

So even though the pellet provides an equal and opposite reaction to the airgun, some of this energy never makes it to the pellet because it is dissipated into those energy sinks. That said, I think it's worth clearing up a few things about recoil. Felt recoil has a lot to do with mass and acceleration. Two guns of the same power might be giving off the same energy via recoil, but we will typically experience worse recoil from the lighter gun. This is due to the fact that the heavier gun is accelerated into the shoulder at a slower velocity, which means that the energy transfer is taking place over a longer period of time and feels less jarring.

Lastly, slowing down the piston (not too much) will result in less felt recoil because of the time component mentioned above. But when we do that, it impacts accuracy because the shot cycle gets longer. We also allow heat more time to dissipate into the metal (rather than keeping pressure high), which wastes some energy again.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on March 24, 2025, 08:23:37 PM
Recoil is interesting.
If using the artillery hold approach, then the range of unconstrained motion may be relevant (for example I got ~8mm in the past). This should be influenced by the mass ratio and piston stroke length.
If using a tight grip, then the force-time curve is of interest. In this case differences between spring and gas ram should show up.

Great work.
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on March 29, 2025, 07:14:31 PM
Recoil is interesting.
If using the artillery hold approach, then the range of unconstrained motion may be relevant (for example I got ~8mm in the past). This should be influenced by the mass ratio and piston stroke length.
If using a tight grip, then the force-time curve is of interest. In this case differences between spring and gas ram should show up.

Great work.

I haven't thought that far ahead yet. The approach right now is that the rifle is suspended in air and there are no other forces acting against it.

-Marty
Title: Re: Spring Piston Simulator Project
Post by: MartyMcFly on March 30, 2025, 04:21:53 PM
Failure is not an option! Perhaps we can make it a feature?

This weekend has not been productive. As noted previously, the simulation treats the compression chamber, the TP, and the area behind the pellet as one volume. So today, I tried to tackle the issue of splitting up the compression volume into three parts, with mass flow occurring from one volume to the next.

The results were not pretty. First, the code wouldn't stop running, it went into an infinite loop. I know that the problems are coming from the mass flow calculations. As the volumes are changing throughout the stroke the sim is running into cases where the derivatives are either exploding in size or we're getting divide by zero problems.

I've set some floors on how small the compression chamber can get to avoid those divide by zero errors, this allowed the code to run and terminate. But now the simulation terminates too early and the output is garbage. I think that the second problem is that I'm not handling the reversal in upstream pressure (when piston bounces) correctly. Unfortunately, figuring out what is going wrong is starting to look daunting as the amount of new code added is significant and it is all linked together.

I was getting a bit too excited about moving to the next step, only to be reminded how feeble my efforts have been. I will continue to work on this problem, but it might take a few steps back before I can make the next step forward.

PS. I found that GTAs forum software censors the word s.u.c.k. It's kind of funny, because with the reverse pressure its appropriate for this conversation.  ;D

-Marty
 
Title: Re: Spring Piston Simulator Project
Post by: WhatUPSbox? on March 30, 2025, 05:10:45 PM


PS. I found that GTAs forum software censors the word s.u.c.k. It's kind of funny, because with the reverse pressure its appropriate for this conversation.  ;D

-Marty

Funny, my wife is on a couple of Facebook gardening groups. She tells me that if they use the word Hoe, it gets banned.  ???
Title: Re: Spring Piston Simulator Project
Post by: subscriber on April 05, 2025, 06:31:41 AM
I wonder about the idea that an action has an opposite and equal reaction. Because action requires energy so some energy must be lost in the action, leaving less energy for the reaction? Also the piston with more mass creating more recoil I agree with if the piston is moving fast, but what if the piston with more mass is moving slower?

The spring and piston have the same momentum as the rifle.   The rifle is heavy and moves much slower than the lighter piston.  But kinetic energy = 1/2 x mass x V x V    .   So the piston has much more energy than the rifle because it has proportionately more velocity.  If this principle did not exist, firing a centerfire rifle or shotgun would impart so much energy to you that you would not be keen to repeat the action.

The pellet has so little momentum by comparison you can almost ignore it.  In any event, the pellet gets some of the energy from the spring.  Usually closer to a 1/4 than 1/2 of the input energy due to inefficiency in converting spring energy to air pressure to pellet velocity.