As far as the "how" of the design angle;
At this point in history, there is such a wealth of successful firearms of nearly every design type at nearly every power level. That means that an educated guess can be made for factors like bolt weight, unlocking timing, and gas piston volume, that will at least get you close where you need to be with very little math involved. For razor's edge design problems like the MP7, there was probably some basic math done to obtain a starting point for the dynamics of the system, but internal ballistics is still such a dark science due to the difficulty in measuring important values that I bet a ton of prototypes and adjustments were needed before that gun was reliable (it supposedly is, at least for 6000 rounds between armory trips
)
Some of your system constraints are:
-Returning energy of the bolt assy being high enough to strip a round into the chamber (lower limit on spring force, bolt mass, and bolt over travel
-Cyclic speed being low enough for the mag to keep up (lower limit on bolt mass and bolt over travel)
-Recoil speed being high enough to reliably reach the end of motion (upper limit on bolt mass and spring force)
-Unlocking timing (lower limit on reciprocating mass for recoil actions and blowbacks, upper limit on locked-travel for recoil actions, and lower limit on distance of gas port to chamber in the case of gas-ops)
-Force & distance required for cycle (fixed in the case of recoil & blowbacks, but defines a lower limit for piston head area, with piston head travel set by whatever is needed to obtain the recoil velocity)
-And then finally you have your structural requirements, which will limit how much force you can put on a gas piston of such and such dimensions before it buckles, bolt lug stresses, receiver battering, and cam surface galling
There's so many variables involved at the end of the day, that "educated guesses" based on what we've found to work is the only efficient way to narrow the unknowns down to something than can be hashed out through testing of a prototype. If the only unknown is the gas port size, it's easy to work your way up until the thing runs
. For something like a funky-length AR build where you have at least half a dozen variables like bolt/buffer mass, spring strength, gas tube length, a range of ammunition pressure curves, and also gas port size --it can be an exercise in frustration.
Part of the reason recoil and blowback designs are easier to design (thus, were invented first) is because cartridge selection cements many of the variables needed to define the system. But you do typically end up with a narrower band of what works in terms of ammunition, and the designs won't scale as well.
TCB