Michelle,
I think the oscillation is unavoidable. The way to stop it is to set a tolerance such that when the algorithm solves to your tolerance criteria it stops and distributes the error in a manner to equalise the pressure. I am unfamiliar with whether that is possible in the programming language that you are using.
Regarding the constant:
The equation for flow though a restricting device such as a control valve takes the form:
C = Q * sqrt (P1-P2)/G))
Q = flow
C = constant which defines the flow characteristics of the valve at constant opening. ie. it is different if the valve is full open or half open etc.
G = specific gravity of the fluid
P1 = upstream pressure
P2 = downstream pressure.
In our case the fluid is air and I have assumed constant density which is not true as the pressure is constantly changing. We can go into more complexity in the algorithm if needed as strictly we should be using the equation for compressible flow. This party explains for you why my constant is not unitless.
C = Q * sqrt(2*G*T/(P1-P2)*(P1+P2))
T = temperature
This only holds for ranges of P2 up to 50% of P1 - but i depends on the accuracy we need.
Changing the "constant" with the car length is entirely acceptable (it is not a true constant) as the equation describes a specific system with defined characteristics. A different car is a different system with a different characteristic. For simple piping systems of known diameter, roughness and length and knowing the number of fittings etc we can effectively derive the constant from known tables of "fricton factors". For the control valve equation we are using here, the manufacturers probably determine the "constant" for each valve by direct measurement - maybe nowadays there are complex fluid dynamic models that can predict this?
As stated before though this constant is highly unlikely to be proportional to car length - a simple wide open valve in a line would be equivalent to many time its actual length of normal straight pipe. Each bend would contribute many factors of length. So I think the effect of length of the car within the normal range of rail vehicles can be neglected for your purposes. Would you like more information in this subject so that you feel more comfortable with this situation?
