A double-deck high-speed train, designed by architecture and system iterations#

The leading power car of the trainset, along the platform and under the overhead contact line

The high-speed train showcase of design3d is a double-deck trainset inspired by the Alstom TGV M: two power cars and nine trailers, 202 m long, running on 60E1 rails along a platform, under the overhead contact line of a high-speed line. It is designed the way a system architect works: the architecture allocates to each system an envelope, interfaces and a mass budget; each system is designed in its envelope and reports the issues it cannot solve; the architecture changes its parameters, allocates again, and the systems are designed again, until they all fit.

It was written by a coding agent, Claude Code with the Claude Opus 5.5 model, driven by its designer in 78 prompts over three days, about 9 hours of active conversation. What the agent wrote is not a model of one trainset: it is a design program, made of an architecture loop and of sizing algorithms for each system, that designs the trainset again from its parameters. This post tells how, and gives the prompts to do it again.

Open the 3D view of the trainset, or the architecture of a trailer with its envelopes. The code is in scripts/showcases/high_speed_train.

The setup#

design3d is a Python CAD modeler made to design 3D models from code: the agent writes Python, runs it, reads the checks it prints, and iterates. The agent showed a commented diff before each commit. The designer reviewed the model in the 3D viewer and steered the design.

The showcase reused the pattern of an earlier car showcase, where a first prompt had asked for “a car.py that assembles subassemblies (classes) instantiated from the architecture parameters”, with a recursive product tree and constraints checked at each build.

In numbers:

Conversation

78 prompts over 3 days, about 9 hours of active conversation (pauses over 10 minutes excluded)

Result

about 7,100 lines of Python (a main script and 11 modules)

Inputs

composition, gauge and decks, smallest curve radius, maximum axle load, traction needs, comfort requirements

Iterations

the architecture converges in 4 to 5 iterations, at each run

Checks

constraints checked at each run, and the masses compared with published figures

A design program, not a drawing#

The agent did not search for a geometry that happens to pass the checks, prompt after prompt. It wrote the algorithms a system architect and the system engineers would follow: allocate the envelopes, interfaces and mass budgets, design each system in its envelope, collect the design issues, change the architecture parameters that resolve them, and start again until every system fits. The traction chain is sized from the performance requirements, the air conditioning from a heat balance, the staircase from the rules of stair design, the clearances from the smallest curve.

These algorithms run again at each execution. Changing the number of trailers, the curve radius, the axle load limit or the traction needs is changing an input and running the script: the architecture is allocated again, the systems are designed again, and the loop resolves the new conflicts by itself.

Step by step#

The founding prompt#

The first prompt set the whole method, and asked for a plan and questions before any code:

Taking the car showcase as an example, make a high-speed train showcase after a TGV M trainset (bogies between the cars, two decks) for the dimensions and the general architecture. Write an architecture-oriented file in two steps: allocation of volumes and design interfaces to and between the systems; design of the systems in their constrained volume, respecting the interfaces. If a problem arises at the design level, report it back to iterate on the interfaces and the volumes. Keep the integrator’s view: do not detail the inside of the systems when it has no value for the assembly. Model the carbody quite finely (think about its manufacturing and deduce the parts to design). The design of the systems can have several levels of detail (functional reasoning, 2D, coarse 3D, then detailed 3D). Make a plan of how you intend to do it and ask me questions on the approach before implementing.

The agent proposed envelopes, interfaces, allocations and design issues as the core objects, an iteration loop, a gauge module, and a carbody built from aluminium extrusions, and asked six questions. The answers chose a complete trainset with less detail rather than one detailed car, a maximum number of iterations, a 17 t axle load limit, and “Russian doll” levels of detail that can be refined later.

The architecture loop, on purpose#

The initial values of some architecture parameters are deliberately tight, so that the loop has something to solve at each run:

Issue reported by a system

Architecture parameter changed

The trailer bogies need a higher carbody support

support height 1,060 → 1,100 mm

The transformer needs a longer space between the power car bogies

bogie spacing 9.80 → 10.05 m

The air conditioning no longer fits over the bogie

upper floor 2,320 → 2,340 mm

The gangway platform follows

headroom 1,780 → 1,760 mm

The last line was not planned: a cascade found by the loop itself.

An intermediate trailer with its architecture envelopes

The architecture of an intermediate trailer: the envelopes allocated to the carbody, the bogie, the door and staircase, the air conditioning and the gangway, around the systems designed inside them.#

Realism, asked for by the designer#

Many prompts were short corrections from a look at the 3D view: use the real 60E1 rail and wheel profiles; give the power car the same section as the trailers for the aerodynamics, with a recessed flat roof for the pantograph; add bogie fairings; cut the windows into the skin; merge the side panels by boolean union; put the belt rail inside the skin rather than in it.

Some revealed real design problems:

The lowered pantograph hits the fairing.

The pan head was 1,950 mm wide in a 1,240 mm recess. Instead of moving the geometry, the agent bounded the envelope of the pantograph by the recess and added an architecture rule that widens the recess (to 2,010 mm) when the pantograph asks for it. Most corrections ended this way: a rule or a check in the architecture, rather than a patch of the geometry, so that the same error cannot come back.

The raised pantograph under the contact wire

The raised pantograph of the rear power car, its working height given by the contact wire through an interface, above the recess widened for the lowered pan head.#

Systems sized from their needs#

Is there a way to give a mass to a volume other than volume times density? I am thinking of the electrical equipment. I want a summary electrical design from the high level traction needs, giving the dimensions and masses to integrate, and the power car designed to accommodate them.

The traction chain is now sized from the performance requirements: maximum speed, accelerations, running resistance and adhesion give 7.3 MW at the wheel rim (7.8 MW for the real TGV M), and technology ratios give the dimensions and masses of the motors, converters, transformer and auxiliary converter. The transformer sized this way is the one asking for a longer space between the bogies. Later, asking “why is our power car empty next to the TGV M?” led to the missing equipment and more realistic ratios.

The leading power car with its equipment, body hidden

The leading power car with its body hidden: the traction equipment sized from the performance requirements (converters, auxiliary converter, cabinets), the transformer under the floor and the motors in the bogies.#

The air conditioning is sized by the heat balance of a trailer (26.2 kW of cooling, a 786 kg unit), the ventilation grilles of the power car by the airflow its losses need (2.05 m² instead of 1.26 m²).

The staircase, eight times#

The L-shaped staircase that climbs from the doors to the upper deck, over the bogie, took the most iterations. The method was given in one prompt: design the steps first, then the structure on them, and hand the floor the cut-out it needs. The designer then redirected it eight times: against a side wall, straight, the door steps designed first with the threshold as the first step, the staircase driving the position of the doors, split at a lowered gangway platform with at most 3 or 4 risers, and finally a straight flight ending with a quarter turn, as on the TGV Duplex, which gave back 0.66 m of platform. The steps follow the Blondel rule: 11 risers of 178 mm for a 274 mm going.

Cutaway of the door end of a trailer with its staircase

The door end of a trailer, side wall and roof hidden: the door steps, the staircase with its quarter turn up to the upper deck, the vestibule and the gangway platform.#

Clearances from the smallest curve#

To set the margin between the wheels of the bogie and the car, take an assumption of maximum curvature for this kind of train, deduce the maximum steering angle of the bogie, and the limit of the car with a 20 mm margin (parameter). From this, deduce the space between the cars, and reduce it as much as possible with a parametrized margin.

A 150 m radius gives a 3.6° steering angle: the end zones of the cars went from 2.40 to 2.14 m, and the gap between the cars from 0.60 to 0.23 m.

A bogie between two trailers

A bogie shared by two trailers, its fairings hidden: the ends of the cars are as close to the wheels as the smallest curve allows.#

The mass budget, held honestly#

The 17 t axle load is checked at each run. When the bogie fairings were added, the axle load reached exactly 17.0 t; when it was exceeded, the agent was asked to list the parts to lighten first, and a massive 450 kg underframe became a welded frame. When the nose was split in two to hide a Scharfenberg coupler, the 480 kg coupler made the power car 45 kg too heavy: the agent refused to adjust masses to make the check pass, and offered options. The designer chose a lighter transformer technology (1.9 kg/kVA).

Compare the carbody values with the information you could find.

The power car without its bogies weighs 49.9 t, against about 50 t published for the TGV M, and the trainset 408 t against 413.5 t in service.

Who did what#

The agent wrote the design program: the architecture loop, the sizing of the systems, and the rules and checks that fix the root causes of the collisions; it also said when the design did not respect a constraint. The designer set the method in the first prompt, gave the engineering judgment (real profiles, the TGV Duplex staircase, the curve radius assumption, the transformer technology), and looked at the model: almost every geometric error was first seen in the 3D view, then turned into a rule or a check of the program, which applies at every run, whatever the parameters.

The prompts to do it again#

Here are the prompts of this conversation, condensed, to design a similar system with a coding agent and design3d installed from PyPI. Replace the bracketed parts with your own product.

  1. In a new folder under git, create a Python virtual environment and install design3d from PyPI (pip install design3d). Learn its API from the documentation (https://design3d.app) and with help() on the classes you use. Write the design as a Python package of modules called by one main script, which prints the checks of the design, opens the 3D views with VolumeModel.babylonjs() and exports a STEP file. Before each commit, show me a commented diff.

  2. Design a [product, after a reference model] with design3d. Write an architecture-oriented script in two steps: (a) allocate envelopes, interfaces and mass budgets to each system; (b) design each system inside its envelope, and report the design issues back to the architecture, which resolves them and iterates, up to a maximum number of iterations. Keep an integrator’s view, and model the structure from its manufacturing process. Allow nested levels of detail (functional, coarse 3D, detailed 3D). Propose a plan and ask me your questions before implementing.

  3. [Your answers.] Implement it, cite your reference data, start from deliberately tight parameters so that the iterations show, and print the checks against the published figures.

  4. Use the real standard profiles for [the interface parts], and add the environment ([track, platform, overhead line]). Parametrize [the mechanism] by its working height, given by the environment through an interface, and show it in its two states.

  5. [A defect seen in the 3D view: a gap, a collision.] Find the root cause. If the architecture could not see it, bound the envelope or add a resolution rule and a check, rather than patching the geometry.

  6. When a budget is exceeded, list the coarse parts to redesign first, heaviest first, with the expected saving.

  7. Add a summary sizing of [subsystem] from the high level needs (performance, loads), with technology ratios giving dimensions and masses, and design the host so that it accommodates them.

  8. Design [the interior element]: first the elements in contact with the user, then the structure on them, then hand the cut-outs to the neighboring parts. Let it drive the position of [the doors]. Size [the air conditioning] from a parametrized heat balance and give it the volume it needs.

  9. Derive the clearances from a worst case assumption ([the smallest curve radius gives the steering angle]), with parametrized margins, and tighten the layout to the minimum.

  10. List the parts by increasing mass, and compare the totals with the published figures you can find. Do not adjust masses to make a constraint pass: offer me options.

  11. Change [an input: the number of cars, the curve radius] and run the design again: check that the architecture loop converges and report what changed.

Between these prompts, look at the 3D view: it is where most corrections of this showcase started.