TDC Simulator (Type VII Submarines)
Web simulator for the torpedo fire control computer (TDC) of Type VII submarines.
01 Problem and context
The torpedo data computer on Type VII submarines used mechanical gears to solve an interception problem: where the target will be when the torpedo arrives. Rebuilding it is straightforward given ideal inputs; the real challenge lies in faithfully replicating the authentic operational procedure, where target speed was timed visually through the periscope and distance was estimated using a stadimeter.
The Torpedo Data Computer aboard Type VII submarines solved an interception problem with gears: where will the target be by the time the torpedo gets there. This project rebuilds that calculation as a web application, with the trigonometric engine kept entirely separate from the interface. The hard part is not the algebra but respecting the procedure: target speed comes from timing how long the hull takes to cross the periscope, and range from a stadimeter reading, so the model receives the same imperfect inputs the crew had.
02 Solution
The trigonometric engine is completely decoupled from the UI: it solves the torpedo triangle via trajectory intersection and is exposed as an API, with dedicated endpoints for each procedural step to allow isolated testing of each instrument. On top, two views interface with the engine: brass dials replicating the authentic on-board workflow, and a plan-view diagram showing the vectors intersecting at the point of impact.
- Reconstructing the shipboard procedure: how the lead angle was obtained and which instruments fed the calculation.
- A Python engine that solves the fire triangle by trajectory intersection, with inputs validated through Pydantic.
- A FastAPI service with one endpoint per step of the procedure, so each instrument can be exercised on its own.
- A Next.js frontend with two views over the same engine: brass dials that replicate the real workflow, and a top-down plot with the vectors meeting at the impact point.
- Client deployed on Vercel, with the backend running as a standalone Python service.
03 Results
Verifiable figures in the repository and its documentation:
04 How it's built
Educational simulator for the TVhRe C/37 and S3 torpedo pre-setting computer used in Kriegsmarine Type VII submarines. A FastAPI backend implements the trigonometric engine that solves the firing triangle (deflection angle or Vorhaltwinkel) using a quadratic intercept equation, along with calculating speed via ship-length timing and distance via stadiometer. The Next.js frontend offers two switchable views: a realistic mode with brass dials and a technical mode with a 2D vector diagram.
05 Ethical decisions
- This is a 1940s weapons system, and it was treated as a piece of computing history rather than a product. Scope was deliberately limited to the geometry of the fire triangle and the measuring instruments: no tactics, no targets, and none of it has operational value today.
- The full mathematical model sits in plain view in the repository with its assumptions written out, so anyone can check what is simulated and what is left out.
06 Highlights
- Trigonometric engine that solves torpedo-target interception as a quadratic equation, handling degenerate and no-solution cases.
- REST API built with FastAPI and Pydantic validation with field-bounded ranges.
- Target speed calculation via ship-length timing and distance via masthead stadiometer, replicating periscope instruments.
- Dual interface in Next.js: realistic mode with period-style instrumentation dials and technical mode with a top-down vector diagram.
- README with comprehensive documentation of the mathematical model, endpoints, and deployment guides.
07 Limitations
There is no dataset and no validation against historical firing tables: the engine is checked against its own geometry, not against period records. The model assumes the target crosses perpendicular to the bearing line, the classic textbook case rather than the general one, so arbitrary target courses are out of scope. Both torpedoes run at a nominal 30 knots, which flattens the real difference between the steam G7a and the electric G7e. Maximum range, gyro angle, depth and spread are not modelled either.