Open ariel-phet opened 7 years ago
@veillette not sure if you have any time to take a look at this issue, but you have been very helpful with model suggestions in the past. I get the feeling there are some poor assumptions we are making in this model with friction turned on.
Thoughts?
The html5 version fluid pressure and flow exhibits the same behavior as the flow tab of the Java version when one ticks off the friction.
In the flow tab, the model for Pipe.js makes a reference to frictionProperty
/**
* Gets the x-velocity of a particle, incorporating vertical effects.
* If this effect is ignored, then when there is a large slope in the pipe, particles closer to the edge move much faster (which is physically incorrect).
* @param {number} x position in meters
* @param {number} y position in meters
* @returns {number} the tweaked x-velocity
*/
getTweakedVx: function( x, y ) {
var fraction = this.getFractionToTop( x, y );
var speed = this.getSpeed( x );
var pre = this.getCrossSection( x - 1E-7 );// pipe cross section
var post = this.getCrossSection( x + 1E-7 );// pipe cross section
var x0 = pre.getX();
var y0 = Util.linear( 0, 1, pre.yBottom, pre.yTop, fraction );
var x1 = post.getX();
var y1 = Util.linear( 0, 1, post.yBottom, post.yTop, fraction );
var deltaX = ( x1 - x0 );
var deltaY = ( y1 - y0 );
var vx = ( deltaX / Math.sqrt( deltaX * deltaX + deltaY * deltaY ) ) * speed;
// If friction is enabled, then scale down quadratically (like a parabola) as you get further from the center of the pipe.
// But instead of reaching zero velocity at the edge of the pipe (which could cause particles to pile up indefinitely), extend the region
// a small epsilon past the (0..1) pipe range
if ( this.frictionProperty.value ) {
var epsilon = 0.2;
var fractionToTop = this.getFractionToTop( x, y );
var scaleFactor = this.lagrange( -epsilon, 0, 0.5, 1, 1 + epsilon, 0, fractionToTop );
return vx * scaleFactor;
}
else {
return vx;
}
}
Note the last if statement involving the frictionProperty.value. For reference here is what lagrange does
/**
* I was told that the fluid flow rate falls off quadratically, so use lagrange interpolation so that at the center of the pipe
* the velocity is full speed, and it falls off quadratically toward the sides.
* See http://stackoverflow.com/questions/2075013/best-way-to-find-quadratic-regression-curve-in-java
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @param {number} x3
* @param {number} y3
* @param {number} x
* @returns {number}
*/
lagrange: function( x1, y1, x2, y2, x3, y3, x ) {
return ( x - x2 ) * ( x - x3 ) / ( x1 - x2 ) / ( x1 - x3 ) * y1 +
( x - x1 ) * ( x - x3 ) / ( x2 - x1 ) / ( x2 - x3 ) * y2 +
( x - x1 ) * ( x - x2 ) / ( x3 - x1 ) / ( x3 - x2 ) * y3;
}
This is responsible for the velocity profile of the pipe.
As a result, currently, the simulation does not demonstrate the effect of a pressure drop as the user reported.
In essence, the user comment is correct, and the simulation does not capture correctly the physics when the "friction" is present.
In order to fix it in a robust way but that doesn't require the full CFD approach, I would need to give it more thought.
@veillette thanks for looking into that...if you come up with some thoughts, lets us know!
For a large pipe, a viscous fluid would be in a regime where the Reynolds number is high, This means that the propagation of water should follow a turbulent regime (as opposed to laminar for low Reynolds number).
Currently, the pressure indicator shows a change a pressure when moving along the y direction. The user reported that the pressure should also change along the horizontal direction to the pressure loss.
The pressure loss in laminar fluid is follows the Hagen Poisseuille equation. https://en.wikipedia.org/wiki/Hagen%E2%80%93Poiseuille_equation
For turbulent flow, the pressure loss follows the Darcy-Weisbach equation. https://en.wikipedia.org/wiki/Darcy%E2%80%93Weisbach_equation
In both cases, the change in pressure is relatively easy to incorporate for a given fluid, given the Darcy friction factor or the dynamic viscosity of the fluid.
In FlowModel, the function getFluidPressure
/**
* @param {number} x position in meters
* @param {number} y position in meters
* @returns {number} fluid pressure (in Pa) at the specified position
*/
getFluidPressure: function( x, y ) {
if ( x <= this.pipe.getMinX() || x >= this.pipe.getMaxX() ) {
return 0;
}
var crossSection = this.pipe.getCrossSection( x );
if ( y > crossSection.yBottom + 0.05 && y < crossSection.yTop - 0.05 ) {
var vSquared = this.pipe.getVelocity( x, y ).magnitudeSquared();
return getStandardAirPressure( 0 ) - y * Constants.EARTH_GRAVITY * this.fluidDensityProperty.value -
0.5 * this.fluidDensityProperty.value * vSquared;
}
return 0;
},
This can be easily generalized to add an additional x dependence of the pipe cross section when friction is turned on.
In principle this can all be done easily but there are additional concerns that would need to be addressed. The fluid density can change with the help of a slider. There are three text labels (gasoline, water and honey). These three liquids have very different viscosities, so changing the fluid density is indirectly changing the viscosity of the fluid. One would need to address this UI before moving forward.
In addition, one would need to add a horizontal ruler since the loss of pressure is along the horizontal direction.
In absence of viscosity, one is always in a laminar flow regime. However, turning on the friction, for this size of a pipe, the viscosity of the fluid , and speed of particles, the flow, the flow for some of the parameter should be in a turbulent regime. However the moving dots do not hint at any kind of turbulent flow.
For reference, the Reynolds number associated with a pipe is Re=density speed diameter/dynamic viscosity. If the Reynolds is less than 2000 it is in laminar flow, but above 4000 it is the turbulent regime.
For the default value of the sim (flow rate of 5000L/s), the Reynolds number is about 3000 for water.
With a flow rate of 1000L/s, then you enter the laminar flow, whereas for a flow rate of 10000L/s would be in the turbulent regime for water.
Unfortunately, your choice of parameters for dimensions and speed, make you straddle these two regimes. I would add that choosing dimensions, and speed, and viscosities such that you always fall withing the laminar regime (and therefore one can readily apply the appropriate Hagen-Poisseuille correction to the pressure as suggested by the user)
My humble opinion is that there are many considerations to add when thinking about friction and this would detract from the main goal of the simulation. However, an the email pointed tout, this could be a very interesting simulation on its own and it would be able to leverage much of the work already done here.
Assigning back to @ariel-phet and yes Ariel you are correct to point out that the flux meter is incorrect when the friction is turned on as well.
@zepumph mentioning you here but not assigning. When this sim is further along we will discuss with the team and see if we should consider removing "friction" from the sim, or choosing an appropriate regime to apply the proper equation.
A user reported the following for the Java sim:
Although I have thought of this friction as "friction between the walls and the fluid" that frictional force is also being transferred to the layers of fluid in contact with the boundary layers so we must be assuming some internal frictional forces. The user responded to the idea of "friction between the walls and the fluid" with the following:
.
In addition, I also just noticed that the "flux meter" flow rate does not change with friction on...this aspect also seems incorrect, since sections of the fluid are clearly moving more slowly.