Split View: 브라우저 탭에서 엔진을 조립해 돌려보기 — Combustion Lab 뜯어보기
브라우저 탭에서 엔진을 조립해 돌려보기 — Combustion Lab 뜯어보기
브라우저 탭 안에서 엔진이 돈다
Combustion Lab(combustionlab.net)이 최근 해커뉴스에 올라와 돌고 있다. 설치도 로그인도 없이 브라우저 탭 하나에서 내연기관을 조립하고 돌려보는 시뮬레이터다. 페이지 상단은 스스로를 이렇게 소개한다. "CRANK-ANGLE-RESOLVED ENGINE DYNAMICS · v2.0". 크랭크 각도 단위로 엔진 거동을 계산한다는 뜻이다.
구성부터 보자. 배열은 직렬(Inline)·V·복서(Boxer)·대향(Opposed) 중에서 고르고 실린더 수·보어·스트로크·압축비를 정한다. 점화 방식은 스파크(오토 사이클)와 압축착화(디젤) 중에서 선택하고, 혼합비 λ와 점화 진각을 조절한다. 흡기는 자연흡기·터보·슈퍼차저에 부스트와 스풀 RPM, 인터쿨러까지 있다. 밸브트레인은 캠 듀레이션과 흡기 닫힘·배기 열림, 레드라인을 잡는다.
엔진을 세웠으면 이제 돌린다. RPM·스로틀·애니메이션 속도를 실시간으로 움직이며 출력(kW/HP)과 토크(N·m/LB-FT)를 읽는다. 결과는 다섯 가지 모드로 본다. DYNO(다이노 곡선), P–V(압력-체적 선도), P–θ(압력-크랭크각), ENERGY(에너지 흐름), CROSS-SECTION(단면 애니메이션)이다. 데이터는 CSV로 내보낼 수 있고, 개념을 짚어주는 LEARN MODE도 있다.
그런데 도구가 스스로 붙여둔 단서가 오히려 인상적이다. "Trends are engineering-realistic; certify nothing with it." 경향은 공학적으로 그럴듯하지만 이걸로 뭘 인증하지는 말라는 것이다. 이 한 줄이 이 글에서 계속 돌아올 기준점이다.
네 번의 행정, 하나의 닫힌 곡선
이 도구가 담는 물리는 교과서 속 4행정 사이클이다. 흡입에서 공기와 연료가 들어오고, 압축에서 피스톤이 밀어 올리고, 폭발(팽창)에서 연소가 일을 만들고, 배기로 내보낸다. 이 네 단계를 크랭크 각도 θ로 매개해 한 스텝씩 계산한다.
P–V 선도 모드가 핵심을 잘 보여준다. 한 사이클을 압력-체적 평면에 그리면 닫힌 고리가 되고, 그 고리가 감싸는 넓이가 곧 한 사이클의 지시일(indicated work)이다. 압축비를 올리거나 점화 시점을 앞당기면 고리가 어떻게 부풀고 기울어지는지 눈으로 확인된다.
교과서의 이상적인 오토 사이클은 모서리가 날카로운 사각형에 가깝다. 실제 곡선은 그 모서리가 둥글게 뭉개진다. 연소가 한순간이 아니라 유한한 크랭크 각도 구간(Wiebe가 그리는 구간) 동안 진행되고, 그동안 내내 벽으로 열이 새어 나가기(Woschni) 때문이다. 이 도구의 값어치는 바로 그 "둥글어짐"을 파라미터로 만질 수 있다는 데 있다.
타이밍이 왜 노출되어 있는지도 여기서 드러난다. 점화 진각 몇 도, 밸브 여닫는 각도 몇 도가 곡선 전체를 바꾼다. 압축비·점화 진각·λ를 노킹 쪽으로 밀면 자기착화가 임박하고, 도구는 Livengood–Wu 적분으로 그 여유를 추정한다. 추상적인 사이클이 "만지면 반응하는" 대상이 되는 순간이다.
단일 영역 모델은 CFD가 아니다
여기서 정직해질 필요가 있다. Combustion Lab은 단일 영역(single-zone) 열역학 모델이다. 실린더 안 혼합기를 균일한 하나의 덩어리로 보고, 각 크랭크 각도에서 압력과 온도를 하나의 값으로 취급하며 에너지 균형을 푼다. 흔히 0차원(0D) 모델이라 부르는, 엔진 열역학 수업의 고전적인 출발점이다.
페이지가 열거하는 네 모델은 그 균형에 꽂아 넣는 경험식들이다.
- Wiebe: 연소가 크랭크 각도에 따라 얼마나 탔는지(연소 질량 분율)를 그리는 S자 곡선.
- Woschni: 실린더 벽으로 빠져나가는 대류 열전달.
- Chen–Flynn: 마찰 손실(FMEP). 지시일에서 빼야 실제 브레이크 토크가 나온다.
- Livengood–Wu: 노킹이 언제 시작되는지 추정하는 적분.
이 조합이 주는 것은 사이클 단위 에너지 수지와, 보어·스트로크·압축비·부스트·타이밍을 바꿨을 때의 믿을 만한 경향이다. 수십 년간 다듬어진 상관식들이라 답의 방향성은 꽤 신뢰할 만하다.
반대로 담지 못하는 것도 분명하다. 실린더 안 유동(텀블·스월), 화염면의 모양, 연료 분무, 상세한 배출가스 화학, 흡배기 음향은 단일 영역이 표현할 수 없다. 그건 다중 영역 모델이나 완전한 CFD의 영역이고, 계산량이 몇 자릿수 많아 브라우저 탭에 들어오지 않는다. 그래서 저 "certify nothing" 단서가 붙는다. 직관을 기르는 교육 도구지 설계를 인증하는 물건이 아니다. 그 선을 스스로 긋는 게 오히려 미덕이다.
실시간 물리를 브라우저에서 돌린다는 것
사이트는 어떤 언어와 프레임워크로 만들었는지 밝히지 않는다(공개된 GitHub도 보이지 않는다). 그러니 구현을 단정하지 말고, 이런 걸 브라우저에서 실시간으로 돌릴 때의 일반적인 모양만 짚어 보자.
크랭크 각도로 분해한다는 건 결국 작은 각도 스텝으로 상미분방정식을 전진 적분한다는 뜻이다. 4행정은 한 사이클이 720°이니, 예컨대 0.5° 간격이라면 실린더당 한 사이클에 1,440스텝이 필요하다. 화면에 보이는 매 사이클마다 수천 번의 산술 연산이 도는 셈이다.
여기서 물리 스텝과 렌더 루프를 분리하는 게 보통이다. 렌더는 requestAnimationFrame으로 돌리고, "애니메이션 속도" 컨트롤은 물리를 실제 시간보다 빠르거나 느리게 밟을 수 있음을 시사한다. 고정 스텝으로 적분하면 같은 입력이 같은 곡선을 내놓는 결정론적 실행이 되는데, CSV 내보내기가 의미를 가지려면 이 재현성이 필요하다. P–V·P–θ 그래프와 단면 애니메이션은 2D 캔버스로 값싸게 그린다.
WASM이 유리한 지점은 이 뜨거운 적분 루프다. Rust·C++·AssemblyScript 같은 걸 WebAssembly로 컴파일하면 JS JIT보다 예측 가능한 처리량을 얻는다. 다만 엔진 하나를 인터랙티브한 속도로 돌리는 정도라면 순수 JS로도 충분한 경우가 많다. 어느 쪽을 골랐는지는 확인할 수 없고, 둘 다 합리적인 선택이다.
중요한 건 이 구조가 주는 경험이다. 설치 없이 URL로 공유되고, 폰에서도 열리며, 파라미터를 바꾸는 즉시 결과가 반응한다. 압축비를 올리면 P–V 고리가 두꺼워지고 노킹 여유가 줄어드는 걸 그 자리에서 본다.
마무리 — 왜 이런 도구가 좋은가
Combustion Lab에서 가장 마음에 드는 건 두 가지다. 대학원 수준의 주제인 엔진 열역학을 탭 하나에서 만질 수 있게 만들었다는 것, 그리고 자기가 못 하는 일에 대해 정직하다는 것. 인터랙티브 시뮬레이터의 교육적 힘은 정확도가 아니라 "파라미터 → 결과"의 즉각적인 되먹임 고리에서 나온다. 숫자를 하나 바꾸고 곡선이 어떻게 움직이는지 보는 그 순간에 직관이 붙는다.
동시에 기억할 것도 있다. 이건 진실이 아니라 경향이고, 단일 영역 모델은 공간적인 모든 것을 숨긴다. 실제 터보를 고르거나 캠을 갈 때 쓰는 도구가 아니라, 왜 그런 선택이 곡선을 그렇게 바꾸는지 감을 잡는 도구다. 브라우저 안 인터랙티브 시뮬레이터가 저평가된 교육 수단인 이유가 바로 이 즉각성에 있다.
참고 자료
- Combustion Lab — Interactive Engine Dynamics Simulator — 이 글이 다룬 시뮬레이터.
- Combustion Engine Web-Based Simulator — Hacker News 토론
- ange-yaghi/engine-sim — 비교용. 브라우저가 아니라 네이티브(C++) 데스크톱 앱이고, 물리에서 소리를 합성하는 데 집중한 별개 프로젝트다.
Assembling and running an engine in a browser tab — a look at Combustion Lab
- Introduction — an engine that runs in a browser tab
- Four strokes, one closed loop
- A single-zone model is not CFD
- Running real-time physics in the browser
- Closing — why a tool like this is good
- References
Introduction — an engine that runs in a browser tab
Combustion Lab (combustionlab.net) has been making the rounds on Hacker News. It is a simulator that lets you assemble and run an internal combustion engine in a single browser tab, with no install and no login. The header describes itself plainly: "CRANK-ANGLE-RESOLVED ENGINE DYNAMICS · v2.0", meaning it computes engine behavior in steps of crankshaft angle.
Start with the build. Pick an architecture — Inline, V, Boxer, or Opposed — and set cylinder count, bore, stroke, and compression ratio. Choose spark ignition (Otto) or compression ignition (Diesel), then dial in the mixture ratio λ and spark advance. Induction can be naturally aspirated, turbocharged, or supercharged, with boost, spool RPM, and an intercooler option. The valvetrain exposes cam duration, intake close, exhaust open, and a redline.
Once the engine is built, you run it. Move RPM, throttle, and animation speed live while reading power (kW/HP) and torque (N·m/LB-FT). You read the results in five modes: DYNO (dyno curves), P–V (pressure-volume), P–θ (pressure-crank angle), ENERGY (energy flow), and CROSS-SECTION (an animated cutaway). Data exports to CSV, and there is a LEARN MODE that walks through the concepts.
The caveat the tool pins on itself is the honest part: "Trends are engineering-realistic; certify nothing with it." Trends are plausible; do not certify anything with it. That one line is the reference point this post keeps returning to.
Four strokes, one closed loop
The physics here is the textbook four-stroke cycle. Intake draws in air and fuel, compression squeezes it, combustion (expansion) does the work, and exhaust pushes it out. The tool marches through those four phases one step at a time, parametrized by crank angle θ.
The P–V mode shows the point of it all. Draw one cycle on a pressure-volume plane and you get a closed loop; the area that loop encloses is the indicated work for that cycle. Raise the compression ratio or advance the spark and you watch the loop swell and tilt.
The idealized Otto cycle in a textbook is close to a box with sharp corners. A real loop has those corners rounded off, because combustion takes a finite stretch of crank angle (the interval Wiebe describes) rather than an instant, and heat leaks to the walls (Woschni) the whole time. The value of a tool like this is that you can grab those roundings by their parameters.
That is also why the timing knobs are exposed. A few degrees of spark advance, a few degrees of valve timing, and the whole curve shifts. Push compression ratio, spark advance, and λ toward knock and auto-ignition looms; the tool estimates that margin with a Livengood–Wu integral. This is the moment an abstract cycle becomes something you can poke and watch respond.
A single-zone model is not CFD
Here it helps to be honest. Combustion Lab is a single-zone thermodynamic model. It treats the cylinder charge as one uniform blob, carries a single pressure and temperature at each crank angle, and solves an energy balance. This is the zero-dimensional (0D) model, the classic starting point of any engine-thermodynamics course.
The four models the page lists are empirical correlations plugged into that balance:
- Wiebe — an S-curve for how much of the charge has burned (mass fraction burned) versus crank angle.
- Woschni — the convective heat lost to the cylinder walls.
- Chen–Flynn — friction losses (FMEP), subtracted from indicated work to get brake torque.
- Livengood–Wu — the integral that estimates knock onset.
What this buys you is cycle-level energy accounting and believable trends as you vary bore, stroke, compression ratio, boost, and timing. These are decades-old correlations, so the direction of the answer is fairly trustworthy.
What it cannot capture is just as clear: in-cylinder flow (tumble and swirl), flame-front geometry, fuel spray, detailed emissions chemistry, and intake/exhaust acoustics. That is the territory of multi-zone models and full CFD, which cost orders of magnitude more compute and do not fit in a browser tab. Hence the "certify nothing" line. It is a tool for building intuition, not for signing off a design — and drawing that line itself is a virtue.
Running real-time physics in the browser
The site does not disclose what language or framework it is built with (no public GitHub is visible either), so rather than guess at the implementation, consider the general shape of running something like this live in a browser.
Resolving by crank angle means integrating an ODE forward in small angle steps. A four-stroke cycle spans 720°, so at, say, 0.5° per step you need 1,440 steps per cylinder per cycle — thousands of arithmetic operations behind every cycle you see on screen.
The usual move is to decouple the physics step from the render loop: render on requestAnimationFrame, while the "animation speed" control hints that the physics can be stepped faster or slower than wall-clock time. A fixed-step integration makes the run deterministic — the same inputs yield the same curve — which is exactly what a meaningful CSV export needs. The P–V and P–θ plots and the cutaway animation are cheap to draw on a 2D canvas.
Where WASM earns its keep is that hot integration loop. Compiling Rust, C++, or AssemblyScript to WebAssembly gives more predictable throughput than a JS JIT. That said, a single engine at interactive rates is often fine in plain JavaScript. I cannot confirm which they chose, and both are reasonable.
What matters is the experience the structure enables: no install, shareable by URL, works on a phone, and results react the instant you change a parameter. Raise the compression ratio and you see the P–V loop thicken and the knock margin shrink, right there.
Closing — why a tool like this is good
Two things stand out about Combustion Lab. It makes a graduate-level topic — engine thermodynamics — something you can touch in a tab, and it is honest about what it cannot do. The teaching power of an interactive simulator comes not from accuracy but from the immediate feedback loop between parameter and outcome. Intuition forms in the instant you change one number and watch the curve move.
At the same time, keep its nature in mind. These are trends, not truth, and a single-zone model hides everything spatial. It is not the tool for choosing an actual turbo or grinding a cam; it is the tool for feeling why those choices bend the curve the way they do. That immediacy is exactly why interactive in-browser simulators are underrated as teaching instruments.
References
- Combustion Lab — Interactive Engine Dynamics Simulator — the simulator discussed here.
- Combustion Engine Web-Based Simulator — Hacker News discussion
- ange-yaghi/engine-sim — for contrast: a separate, native (C++) desktop project focused on synthesizing sound from the simulation, not a browser tool.