A 63/20 kV substation on real plots, designed by a coding agent#
The substation showcase of design3d is an outdoor 63/20 kV substation designed on three real plots of the Loire and Rhône (France), read from OpenStreetMap. Everything in it is computed: the clearances in air come from the insulation levels of IEC 61936-1, the post insulators are sized for the pollution of the site, each bay is laid out by iterations on its clearances, the transformers are sized from their rating, and the whole is placed on the plot with the largest margin, its terminal towers at the real towers of the incoming lines.
It was written by a coding agent, Claude Code with the Claude Opus 5.5 model, driven by its designer in 22 prompts over two evenings, about 2.5 hours of active conversation. What the agent wrote is not a model of one substation: it is a design program, made of sizing and layout algorithms, that designs the substation again for any plot, voltage or rating given as input. This post tells how, and gives the prompts to do it again.
Open the 3D view of the substation of l’Horme, or browse all the 3D views. The code is in scripts/showcases/substation.
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. Nothing is drawn by hand, and every geometric question (does this conductor keep its clearance from that post? is this part inside the fence?) is answered by computation.
The agent showed a commented diff before each commit, one commit per design step. The designer reviewed each step in the 3D viewer and steered the design.
In numbers:
Conversation |
22 prompts, 2 sessions, about 2.5 hours of active conversation (pauses over 10 minutes excluded) |
Result |
about 5,100 lines of Python (a main script and 11 modules), 3 GeoJSON plots, 7 commits |
Inputs |
the plot (GeoJSON from OpenStreetMap) and its incoming lines, voltages, transformer rating, short-circuit current, pollution class, altitude |
Checks |
126 constraints checked at each run |
Run |
the whole script, with its 3 substations, runs in about 2 minutes |
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 an engineer would follow: derive the clearances from the voltages, size the insulators by iterations on their profile, move the parameter that resolves each violated clearance until the bay converges, choose the order of the bays by cost, search the placement with the largest margin. These algorithms run again at each execution, from the inputs.
Changing the plot, the voltage or the pollution of the site is changing an input and running the script: the insulators, the bays, the transformer and the layout are designed again, and the 126 constraints are checked again. This is how the same program designs the three substations of this post, on three very different plots.
Step by step#
Choosing the showcase#
The first prompt did not name the substation. It asked for ideas:
Propose ideas for an energy showcase that would involve design with architecture, pre-sizing and geometric calculations.
The agent proposed seven: a wind turbine (its own favorite), a dam, a solar tower, a PV farm, a tidal turbine, a small modular reactor, and an HV/MV substation. The designer picked the substation, precisely because it has a layout: many apparatuses whose positions are constrained by clearances, on a plot of limited size. The agent then detailed it as a 63/20 kV air insulated substation with two 36 MVA transformers, a 20 kA short-circuit current and 12 MV feeders, with three levels of design (topology, bays, layout), the sizing laws to use and the geometric checks to make.
A real plot as an input#
Identify a plot on OSM of a substation that could match, to get a realistic footprint. This polygon should be an input of the calculation.
This prompt anchored the whole showcase in reality. The agent queried the 63/20 kV substations of OpenStreetMap, picked the one of Sury-le-Comtal (4,445 m²) for its clean outline, saved it as GeoJSON with its ODbL attribution, and wrote a small module projecting it to local meters and loading it as a design3d polygon. From then on, the plot was a constraint like any other.
The inputs: the three plots read from OpenStreetMap, with the real incoming lines and their last towers (the two other plots came in a later step).#
Clearances and insulators#
The first step implemented the insulation coordination: the nominal voltages give the insulation levels of IEC 60038 and IEC 61936-1, from which derive the clearances in air (630 mm phase to earth at 72.5 kV), the height of live parts over the walkways, and the clearance to the fence, which leaves inside the plot the area where live parts may stand.
The post insulators are then designed for these levels and for the pollution of the site. The required creepage distance is not computed by a formula: it is measured on the 2D profile whose revolution builds the insulator, and the number and spacing of the sheds are found by iterations. The result, 12 sheds 56 mm apart for an 817 mm tall insulator, is close to a commercial C4-325 post (770 mm).
Step 1: the 24 kV and 72.5 kV post insulators, built by revolution of their 2D profiles, whose length between the flanges is the creepage distance: 12 sheds for 72.5 kV.#
A bay laid out by its clearances#
The line bay is where the method shows best. Every live and earthed part (busbars, disconnectors, circuit breaker, instrument transformers, gantry) is reduced to capsules around 3D line segments, and every clearance is checked by computation. The algorithm starts from deliberately tight parameters and, at each iteration, changes the one architecture parameter that resolves each violated clearance:
Violation found |
Parameter changed |
|---|---|
A riser 381 mm from a busbar, 630 mm required |
busbars raised by 200 mm steps, from 4.25 to 5.25 m |
Open disconnector blades too close to the next phase |
phase spacing from 1.13 to 1.28 m |
Outer phases too close to the gantry posts |
lateral margin increased, bay width 4.62 m |
The bay converges in 6 iterations, with 27 checks passing, at every run. The agent also caught one of its own errors on the way: heights must be measured from the low point of the conductor, not of its capsule, otherwise the instrument transformers came out 16 cm too low.
Step 2: the line bay, from the busbars to the gantry, laid out by iterations on its clearances.#
Outside the fence: the overhead line#
Could you add a high voltage tower?
A short prompt, a whole module: the sag of the line over its ruling span (7.93 m for 300 m spans), the phase spacing of EN 50341, a 19.7 m lattice tower of 148 members with its earth wire peak placed for a 30° shielding angle, and its crossarms grown in 7 iterations until the jumpers keep their clearance from the members. The slack span to the gantry of the substation sags 0.77 m.
Step 3: the terminal tower of the overhead line, and the slack span to the gantry of the substation.#
The transformer, sized from its rating#
The 36 MVA transformer is sized like a real one: 65.6 V per turn, a stepped core of 8 steps with a fill factor of 0.941 (the optimum, found with scipy, is 0.942), a winding height found by bisection to get a short-circuit impedance of 17 %, the no-load and load losses, ONAN cooling by 8 radiators, 16.6 m³ of oil, 48.7 t, and the retention pit that holds the oil.
Step 4: the 36 MVA transformer in its retention pit, with its radiators, conservator and bushings, beside its active part (core and windings) sized from the rating.#
The layout, chosen by cost#
The layout makes the bays agree on the parameters of the busbars running through them, chooses their order along the busbars by cost over all the permutations (firewalls between neighboring transformers, staggered towers, MV cables), adds the MV building, the road and the cable trenches, and searches the placement with the largest margin on the plot.
Step 5: the layout on the plot of Sury-le-Comtal, seen from above: the line bay, the busbars, the two transformer bays, the MV building and the road, with the terminal tower outside the fence.#
Three plots, real lines#
Find two other plots, a more cramped one and an odd-shaped one, and run the calculation three times. Identify the incoming lines to place the towers correctly.
This is where the design program proves itself. The agent added le Grand Verger (2,047 m², two lines arriving 56° apart) and l’Horme (3,206 m², three lines, 90 % of its convex hull) as new inputs, and the program now places the terminal towers at the real last towers of the lines, read from OpenStreetMap. Doing so, it found that Sury-le-Comtal has only one incoming line, and removed the second line it had assumed. The angled lines needed new design features (fitting lengths, jumpers offset outwards), and the agent admitted that its 35° limit on the line deviation was arbitrary: it became a 45° parameter, without which le Grand Verger had no solution. Once generalized this way, the program designs the three substations in one run, and would design a fourth from a new GeoJSON file.
Step 6: the cramped plot of le Grand Verger, with its two lines arriving 56° apart.#
What the designer saw#
The gantries of Grand Verger are outside the fence.
Typed while the agent was working, from a look at the 3D view. The design checked the live parts against the fence, but not the earthed structures, such as the posts of the gantries. A constraint on the hull of the structures was added to the placement, so that no part, live or earthed, can stand outside the fence on any plot.
Flexible conductors#
Shouldn’t we use sweeps for the electric cables?
The flexible conductors (downleads, slack spans, jumpers) are now sweeps of their circular section along smooth B-spline curves interpolating the points computed by the design, the same points used for the clearance checks: they follow the layout wherever the program places the apparatuses.
Step 7: the flexible conductors (downleads, slack spans, jumpers) are sweeps of their section along B-spline curves.#
Who did what#
The agent wrote the design program: it chose and applied the standards, turned them into sizing and layout algorithms, and reported honestly what it had assumed (the line on Sury-le-Comtal, the 35° limit). The designer chose the subject, asked for real inputs (a real plot, then the real lines), looked at the result, and spotted what the checks did not cover. The result belongs to the code, not to the conversation: anyone can run it again with other inputs.
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 system.
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 withhelp()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 withVolumeModel.babylonjs()and exports a STEP file. Before each commit, show me a commented diff.Propose ideas of [domain] systems I could design in Python with design3d, combining an architecture, a pre-sizing from physical laws and geometric calculations. For the one I pick, detail the inputs, the sizing laws with their standards, the geometric checks, the modules and a step-by-step plan. Ask me your questions before writing code.
Find a real site on OpenStreetMap whose footprint fits this [system], save its polygon as GeoJSON with its attribution, and make it an input of the calculation: project it to local meters and load it as a design3d
ClosedPolygon2D.Step 1: implement the governing standards (insulation levels and clearances). Size the first component by iterations, measuring the requirement on the geometry itself: the creepage distance is the length of the 2D profile that a design3d
RevolvedProfilerevolves. Print the iteration log.Step 2: design one functional unit (a bay). Reduce every live and earthed part to capsules around 3D line segments, check every clearance by computation, and on each violation change the one architecture parameter that resolves it, until convergence. Report which violation moved which parameter.
Add the interfacing equipment outside the fence (terminal tower and overhead line), sized from the sag and phase spacing rules, and checked with the same clearance model.
Size the main component (the transformer) from its rating: core, windings for the target impedance, losses, cooling, oil, masses. Then build its geometry.
Do the layout: make the units agree on their shared parameters, choose their order by a cost function, add the auxiliary works, and place everything on the plot with the largest margin. Check that every part, live or earthed, stays inside the fence.
Run the same design on two more real plots, a cramped one and an odd-shaped one, and place the towers at the real incoming lines from OpenStreetMap. Report the margins, and the assumptions that had to become parameters.
Model the flexible conductors as design3d
Sweepof their section along B-spline curves interpolating the points used by the clearance checks.Make every assumption an input or a parameter of the specification, so that I can run the design again on another site.
Between these prompts, look at the 3D view: the most useful corrections of this showcase came from it.