Add machine workshop, typed logic, mechanics and sensor-driven ECUs
This commit is contained in:
@@ -81,10 +81,15 @@ int main() {
|
||||
const auto small_intake_pulse=desktop::pressure_tint(104325),small_exhaust_pulse=desktop::pressure_tint(104325,true);
|
||||
require(vacuum_before.x==vacuum_after.x&&vacuum_before.y==vacuum_after.y&&vacuum_before.z==vacuum_after.z,
|
||||
"exhaust highlighting must not change the established underpressure palette");
|
||||
require(small_intake_pulse.x>.9f&&small_intake_pulse.y>.8f&&small_intake_pulse.z<.1f,
|
||||
"a small positive intake pulse must be visible as yellow");
|
||||
require(small_exhaust_pulse.x>.95f&&small_exhaust_pulse.y<.4f,
|
||||
"a small positive exhaust pulse must be visible as orange-red");
|
||||
require(small_intake_pulse.x>atm.x&&small_intake_pulse.y>=atm.y&&small_intake_pulse.z<=atm.z,
|
||||
"a positive intake pulse must move continuously toward warmer colors");
|
||||
require(small_exhaust_pulse.x>small_intake_pulse.x,
|
||||
"the same exhaust pulse must reach warmer colors sooner than intake");
|
||||
const auto near_atmosphere=desktop::pressure_tint(101325.1f),strong_intake=desktop::pressure_tint(251325);
|
||||
require(std::abs(near_atmosphere.x-atm.x)<.001f&&std::abs(near_atmosphere.y-atm.y)<.001f,
|
||||
"the positive pressure palette must remain continuous at atmosphere");
|
||||
require(strong_intake.x>.95f&&strong_intake.y<.9f&&strong_intake.z<.1f,
|
||||
"strong intake overpressure must reach warm colors");
|
||||
Ecu fast_actuator;
|
||||
for(int i=0;i<230;++i)fast_actuator.step(1.f/44100,1,5000);
|
||||
require(fast_actuator.throttle_opening()>.99f,"throttle actuator must settle within about 5 ms");
|
||||
@@ -140,6 +145,7 @@ int main() {
|
||||
for (int i = 8; i < 12; ++i) audio_ring.write(float(i), -float(i));
|
||||
require(audio_ring.read_interpolated(left, right, 1.0) == 4 && left[0] == 7.0f && left[3] == 10.0f,
|
||||
"ring must resume continuously after underrun and wraparound");
|
||||
audio_ring.discard();require(audio_ring.available_samples()==0,"Discard must remove old playback latency while stopped");for(int i=100;i<105;++i)audio_ring.write(float(i),-float(i));require(audio_ring.read_interpolated(left,right,1)==4&&left[0]==100&&left[3]==103,"A restarted consumer replayed discarded audio");
|
||||
SoundProcessor linear_source(44100, 1.0f);
|
||||
linear_source.process(0.0f);
|
||||
const float response = linear_source.process(0.01f);
|
||||
@@ -283,6 +289,17 @@ int main() {
|
||||
require(std::abs(profiled_pipe.cell_mass(1) - 1.225f * 0.002f * 0.2f) < 1e-8f &&
|
||||
std::abs(profiled_pipe.minimum_cell_length() - 0.1f) < 1e-8f,
|
||||
"profiled pipes must retain each cell's area and length for mass/CFL calculations");
|
||||
Pipe1D contraction{{.001f,.00005f,.001f},{.01f,.01f,.01f}};
|
||||
Pipe1D uniform_comparison{.001f,.03f,3};
|
||||
require(contraction.prepare_step()<uniform_comparison.prepare_step()*.1f&&std::abs(contraction.stable_timestep()-contraction.prepare_step())<1e-10f,
|
||||
"sharp contractions must limit CFL by face area relative to stored volume");
|
||||
for(auto method:{PipeSolver::Rusanov,PipeSolver::Hlle,PipeSolver::Hllc,PipeSolver::Muscl}){
|
||||
std::vector<Pipe1D> pipes;pipes.emplace_back(.001f,1.f,40);auto& pipe=pipes[0];pipe.solver=method;
|
||||
for(std::size_t i=0;i<pipe.cells.size();++i){auto& cell=pipe.cells[i];cell.rho=1.2f;cell.momentum=12;cell.energy=101325/pipe_gm1+60;cell.air=0;cell.fuel=0;cell.fuel_equivalent=i<10?.02f:0;}
|
||||
const auto marker_mass=[&]{double total=0;for(std::size_t i=0;i<pipe.cells.size();++i)total+=pipe.cell_mass(int(i))*pipe.cells[i].fuel_equivalent;return total;};const auto before=marker_mass();
|
||||
BoundarySystem boundaries(pipes);boundaries.add_connection(0,true,0,false);Solver transport(pipes,boundaries);for(int i=0;i<2000;++i)transport.step(1.f/44100);
|
||||
require(std::abs(marker_mass()-before)<before*.0005&&pipe.cells[25].fuel_equivalent>0,"Burned-fuel origin must survive conservative gas transport");
|
||||
}
|
||||
|
||||
Vehicle bike;
|
||||
bike.set_first_gear();
|
||||
|
||||
Reference in New Issue
Block a user