Add American V8 preset, carb fuel transport, and adaptive desktop audio
This commit is contained in:
@@ -15,8 +15,8 @@ void check(bool b, const std::string &s) {
|
||||
void near(double a, double b, double tol, const char *s) {
|
||||
check(std::isfinite(a) && std::abs(a - b) <= tol, s);
|
||||
}
|
||||
void set(Pipe1D &p, int i, float pressure, float rho, float u = 0, float air = 1) {
|
||||
p.cells[i] = {rho, rho * u, pressure / pipe_gm1 + .5f * rho * u * u, air};
|
||||
void set(Pipe1D &p, int i, float pressure, float rho, float u = 0, float air = 1, float fuel = 0) {
|
||||
p.cells[i] = {rho, rho * u, pressure / pipe_gm1 + .5f * rho * u * u, air, fuel};
|
||||
}
|
||||
void lossless(Pipe1D &p) {
|
||||
p.damping_multiplier = 0;
|
||||
@@ -499,7 +499,8 @@ int main() {
|
||||
for (int k = 0; k < 2; k++) {
|
||||
lossless(p[k]);
|
||||
for (int i = 0; i < 40; i++)
|
||||
set(p[k], i, k ? 100000 : 120000, 1.2f, 0, k ? .9f : .1f);
|
||||
set(p[k], i, k ? 100000 : 120000, 1.2f, 0, k ? .9f : .1f,
|
||||
k ? .02f : .05f);
|
||||
}
|
||||
auto air_mass = [&] {
|
||||
double sum = 0;
|
||||
@@ -508,7 +509,15 @@ int main() {
|
||||
sum += q.cell_mass(i) * q.cells[i].air;
|
||||
return sum;
|
||||
};
|
||||
auto fuel_mass = [&] {
|
||||
double sum = 0;
|
||||
for (auto &q : p)
|
||||
for (int i = 0; i < 40; i++)
|
||||
sum += q.cell_mass(i) * q.cells[i].fuel;
|
||||
return sum;
|
||||
};
|
||||
double before = air_mass();
|
||||
double fuel_before = fuel_mass();
|
||||
BoundarySystem b(p);
|
||||
b.add_closed_end(0, true);
|
||||
b.add_closed_end(1, false);
|
||||
@@ -517,6 +526,7 @@ int main() {
|
||||
for (int i = 0; i < 3000; i++)
|
||||
solver.step(1.f / 44100);
|
||||
near(air_mass(), before, before * 4e-5, "species created at shared face");
|
||||
near(fuel_mass(), fuel_before, fuel_before * 4e-5, "fuel species created at shared face");
|
||||
});
|
||||
test("unsupported unequal junction rejected", [] {
|
||||
std::vector<Pipe1D> p;
|
||||
|
||||
Reference in New Issue
Block a user