General testing
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using FluidSim.Components;
|
||||
using FluidSim.Interfaces;
|
||||
using FluidSim.Utils;
|
||||
using SFML.Graphics;
|
||||
using SFML.System;
|
||||
@@ -12,7 +11,7 @@ namespace FluidSim.Core
|
||||
private Solver solver;
|
||||
private Volume0D cavity;
|
||||
private Pipe1D neck;
|
||||
private Connection coupling;
|
||||
private PipeVolumeConnection coupling;
|
||||
private int stepCount;
|
||||
private double time;
|
||||
private double dt;
|
||||
@@ -38,12 +37,8 @@ namespace FluidSim.Core
|
||||
neck = new Pipe1D(neckLength, neckArea, sampleRate, forcedCellCount: 40);
|
||||
neck.SetUniformState(1.225, 0.0, ambientPressure);
|
||||
|
||||
coupling = new Connection(neck.PortA, cavity.Port)
|
||||
{
|
||||
Area = neckArea,
|
||||
DischargeCoefficient = 0.62,
|
||||
Gamma = 1.4
|
||||
};
|
||||
// Create the coupling between cavity and left end of the neck (PortA)
|
||||
coupling = new PipeVolumeConnection(cavity, neck, isPipeLeftEnd: true, orificeArea: neckArea);
|
||||
|
||||
solver = new Solver();
|
||||
solver.SetTimeStep(dt);
|
||||
@@ -51,8 +46,8 @@ namespace FluidSim.Core
|
||||
solver.AddPipe(neck);
|
||||
solver.AddConnection(coupling);
|
||||
|
||||
// Port A (left) = volume coupling, Port B (right) = open end
|
||||
solver.SetPipeBoundary(neck, isA: true, BoundaryType.VolumeCoupling);
|
||||
// Left boundary (PortA) is volume‑coupled via ghost cell, right boundary (PortB) is open end
|
||||
solver.SetPipeBoundary(neck, isA: true, BoundaryType.GhostCell);
|
||||
solver.SetPipeBoundary(neck, isA: false, BoundaryType.OpenEnd, ambientPressure);
|
||||
}
|
||||
|
||||
@@ -68,11 +63,11 @@ namespace FluidSim.Core
|
||||
if (stepCount % 20 == 0)
|
||||
{
|
||||
double pCav = cavity.Pressure;
|
||||
double mdotA = neck.PortA.MassFlowRate; // positive = into pipe (leaving cavity)
|
||||
// Mass flow rate is not directly available – we can compute from pressure difference or skip
|
||||
Console.WriteLine(
|
||||
$"t={time * 1e3:F2} ms step={stepCount} " +
|
||||
$"P_cav={pCav:F1} Pa, P_open={pOpen:F1} Pa, " +
|
||||
$"mdot_A={mdotA * 1e3:F4} g/s, audio={audio:F4}");
|
||||
$"audio={audio:F4}");
|
||||
}
|
||||
|
||||
return audio;
|
||||
@@ -100,7 +95,7 @@ namespace FluidSim.Core
|
||||
float dx = neckLenPx / (n - 1);
|
||||
float baseRadius = 20f;
|
||||
|
||||
Vertex[] vertices = new Vertex[n * 2];
|
||||
var vertices = new Vertex[n * 2];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
float x = neckStartX + i * dx;
|
||||
|
||||
Reference in New Issue
Block a user