Known bad point (unphysical energy loss)

This commit is contained in:
max
2026-05-02 17:40:43 +02:00
parent 9fc45224af
commit 650b993c2b
6 changed files with 89 additions and 91 deletions

View File

@@ -55,14 +55,19 @@ namespace FluidSim.Core
bool isLeftBoundary,
out double massFlux, out double momFlux, out double energyFlux)
{
// mass flow from pipe to volume (positive = pipe → volume)
double mdot = MassFlow(pPipe, rhoPipe, pVol, rhoVol, conn);
// ----- Compute STAGNATION pressures -----
double pStagPipe = pPipe + 0.5 * rhoPipe * uPipe * uPipe;
double pStagVol = pVol + 0.5 * rhoVol * uVol * uVol; // uVol is always 0 for your volumes
// Mass flow driven by stagnation pressure difference (positive = pipe→volume)
double mdot = MassFlow(pStagPipe, rhoPipe, pStagVol, rhoVol, conn);
// Limit mass flow to the amount that can leave/enter the pipe cell
double maxMdot = rhoPipe * pipeArea * 343.0;
if (Math.Abs(mdot) > maxMdot) mdot = Math.Sign(mdot) * maxMdot;
bool flowLeavesPipe = mdot > 0;
bool flowLeavesPipe = mdot > 0; // pipe → volume
double uFace, pFace, rhoFace;
double massFluxPerArea;
@@ -83,7 +88,7 @@ namespace FluidSim.Core
{ uFace = uVol; pFace = pVol; rhoFace = rhoVol; }
}
// Total enthalpy of the injected fluid (corrected: mass flux × total enthalpy)
// Total enthalpy of the injected fluid
double specificEnthalpy = (1.4 / (1.4 - 1.0)) * pFace / Math.Max(rhoFace, 1e-12);
double totalEnthalpy = specificEnthalpy + 0.5 * uFace * uFace;