Introduced automatic sub stepping and pipe cell count
This commit is contained in:
@@ -19,15 +19,14 @@ namespace FluidSim.Core
|
||||
dt = 1.0 / sampleRate;
|
||||
|
||||
double V = 5.0 * Units.L;
|
||||
volA = new Volume0D(V, 1.1 * Units.atm, Units.Celsius(20), sampleRate);
|
||||
volA = new Volume0D(V, 2.0 * Units.atm, Units.Celsius(20), sampleRate);
|
||||
volB = new Volume0D(V, 1.0 * Units.atm, Units.Celsius(20), sampleRate);
|
||||
|
||||
double length = 150 * Units.mm;
|
||||
double diameter = 25 * Units.mm;
|
||||
double area = Units.AreaFromDiameter(25, Units.mm);
|
||||
int nCells = 10;
|
||||
|
||||
pipe = new Pipe1D(length, area, nCells, sampleRate);
|
||||
pipe = new Pipe1D(length, area, sampleRate);
|
||||
pipe.SetUniformState(volA.Density, 0.0, volA.Pressure);
|
||||
pipe.FrictionFactor = 0.02;
|
||||
|
||||
@@ -54,13 +53,30 @@ namespace FluidSim.Core
|
||||
|
||||
public static void Log()
|
||||
{
|
||||
if (stepCount <= 50 || stepCount % 200 == 0)
|
||||
bool logPipe = true;
|
||||
|
||||
if ((stepCount <= 10 || (stepCount <= 1000 && stepCount % 100 == 0)) || stepCount % 1000 == 0 && stepCount < 10000)
|
||||
{
|
||||
// Summary line
|
||||
Console.WriteLine(
|
||||
$"t = {time * 1e3:F3} ms Step {stepCount:D4}: " +
|
||||
$"PA = {volA.Pressure / 1e5:F6} bar, " +
|
||||
$"PB = {volB.Pressure / 1e5:F6} bar, " +
|
||||
$"FlowA = {pipe.PortA.MassFlowRate * 1e3:F2} g/s");
|
||||
|
||||
// Per‑cell state
|
||||
if (logPipe && stepCount <= 1000)
|
||||
{
|
||||
int n = pipe.GetCellCount();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
double rho = pipe.GetCellDensity(i);
|
||||
double p = pipe.GetCellPressure(i);
|
||||
double u = pipe.GetCellVelocity(i);
|
||||
Console.WriteLine(
|
||||
$" Cell {i,2}: ρ={rho,8:F4} kg/m³, p={p,10:F2} Pa, u={u,8:F3} m/s");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user