Tutorial 2: Calculate and Compare
← Home · Tutorials · Previous: 1. Set up your design · Next: 3. Use your knowledge
The five heat sink designs from tutorial 1 have dimensions but no performance yet. In this tutorial you build a canvas in the Simulation Studio that works out each design's maximum temperature, mass and pressure drop, then chart them and see which designs meet the targets.
A canvas is a set of connected blocks: inputs on the left, a calculation in the middle, and a chart at the end. When an input changes, everything after it runs again.
Part 1: Build the calculation
What you'll build
| Block | Type | Setting |
|---|---|---|
| Heat sink designs | Data input | Schema Heat sink, the five designs, key all keys |
| Heat load | Parameter: Numerical | 40, unit W |
| Air speed | Parameter: Numerical | 2, unit m/s |
| Ambient temperature | Parameter: Numerical | 25, unit °C |
| Thermal performance | Calculation | The code below, with all four blocks above as upstream components |
The calculation code
A simple laminar-flow model of a plate-fin heat sink. It reads each upstream block by name from componentInputs and sets result.
import math
def num(v):
if isinstance(v, dict):
return v.get("value", next(iter(v.values())))
return v
def field(doc, path):
# "all keys" passes the whole design under "root"
node = doc["root"]
for part in path.split("."):
node = node[part]
return num(node)
q = num(componentInputs["Heat load"])
v_air = num(componentInputs["Air speed"])
t_amb = num(componentInputs["Ambient temperature"])
K_AIR, NU_AIR, MU_AIR, PR_AIR = 0.026, 1.6e-5, 1.85e-5, 0.71
MATERIALS = {"Aluminium 6063": (200.0, 2700.0), "Copper": (390.0, 8960.0)}
designs = []
for doc in componentInputs["Heat sink designs"].values():
n = int(field(doc, "geometry.fin_count"))
t = field(doc, "geometry.fin_thickness") / 1000
h_fin = field(doc, "geometry.fin_height") / 1000
w = field(doc, "geometry.base_width") / 1000
l = field(doc, "geometry.base_length") / 1000
tb = field(doc, "geometry.base_thickness") / 1000
k, rho = MATERIALS[field(doc, "material.material")]
# Laminar forced convection over plate fins
s = (w - n * t) / (n - 1)
h = 0.664 * K_AIR / l * math.sqrt(v_air * l / NU_AIR) * PR_AIR ** (1 / 3)
m = math.sqrt(2 * h / (k * t))
eta = math.tanh(m * h_fin) / (m * h_fin)
area = (n - 1) * s * l + eta * 2 * n * h_fin * l
r_total = 1 / (h * area) + tb / (k * w * l)
v_ch = v_air * w / ((n - 1) * s)
dh = 2 * s * h_fin / (s + h_fin)
designs.append({
"design": doc["document_name"],
"max_temperature": round(t_amb + q * r_total, 1),
"mass": round(rho * (w * l * tb + n * t * h_fin * l) * 1000, 1),
"pressure_drop": round(48 * MU_AIR * l * v_ch / dh**2, 2),
})
result = {"designs": designs}
The Output Schema (JSON) describes the shape of result:
{
"type": "object",
"properties": {
"designs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"design": {"type": "string"},
"max_temperature": {"type": "number"},
"mass": {"type": "number"},
"pressure_drop": {"type": "number"}
},
"required": ["design", "max_temperature", "mass", "pressure_drop"]
}
}
},
"required": ["designs"]
}
Step by step: what the video shows
-
Create the canvas
Click Simulation Studio in the sidebar, then New › New Canvas. Name it Heat sink performance and click Create. The empty canvas offers to let the Co-Engineer build it; here you build it by hand.
-
Bring in the designs
Open the Components list on the left and click Data input. Name it Heat sink designs, pick the Heat sink schema, and tick the five designs. Under Selected Keys, pick all keys: each whole design goes to the next block. Create stays greyed out until you pick a key.
-
Set the operating conditions
Click Parameter and create the three from the table, each with its Unit. Parameters are values you change on the canvas, without touching the designs.
-
Write the calculation
Click Calculation, name it Thermal performance, and paste the code and output schema from The calculation code above. Click Create.
-
Connect it
Open the calculation with its edit button and pick all four blocks under Upstream Components. Input units then lists each input and the unit it arrives in. Fill in a unit there if your code expects a different one, for example km/h: Protos converts the input before every run. Dashed arrows now show data flowing into the calculation.
-
Approve and run
Click the calculation to open its panel and click Approve & Run. A calculation only runs once you have checked its code; after that it re-runs by itself whenever an input changes. After about a minute it shows Completed, and Result lists max temperature, mass and pressure drop for each design.
Part 2: Compare the results
A chart makes the numbers easier to read. A Visualization block is a small piece of HTML that draws whatever its upstream block produces.
The chart code
Draws one bar chart per result, with the best design highlighted.
<div id="charts" style="display:grid;grid-template-columns:repeat(3,1fr);gap:24px;font:13px system-ui,sans-serif;color:#1f2937;padding:8px"></div>
<script>
var designs = componentInputs["Thermal performance"].designs;
var metrics = [
["max_temperature", "Max temperature", "°C"],
["mass", "Mass", "g"],
["pressure_drop", "Pressure drop", "Pa"]
];
var root = document.getElementById("charts");
metrics.forEach(function (m) {
var max = Math.max.apply(null, designs.map(function (d) { return d[m[0]]; }));
var best = Math.min.apply(null, designs.map(function (d) { return d[m[0]]; }));
var html = "<div><div style='font-weight:600;margin-bottom:10px'>" + m[1] + " (" + m[2] + ") · lower is better</div>";
designs.forEach(function (d) {
var v = d[m[0]];
var color = v === best ? "#0f766e" : "#94a3b8";
html += "<div style='display:flex;align-items:center;gap:8px;margin:6px 0'>" +
"<span style='width:72px'>" + d.design + "</span>" +
"<span style='flex:1;background:#f1f5f9;border-radius:3px'><span style='display:block;height:16px;border-radius:3px;background:" + color + ";width:" + (100 * v / max) + "%'></span></span>" +
"<span style='width:48px;text-align:right;font-variant-numeric:tabular-nums'>" + v + "</span></div>";
});
root.innerHTML += html + "</div>";
});
</script>
Step by step: what the video shows
-
Add the chart
Click Visualization in the Components list. Name it Design comparison, paste the chart code, set the output schema to
{"type": "object"}, and click Create. -
Connect it on the graph
Drag from the right edge of Thermal performance to the left edge of Design comparison. Then click Reset layout in the graph controls: the chart moves into the right-hand column, after the calculation. You can also switch to List view, click the chart's Edit component button, and pick Thermal performance under Upstream Components, as you did for the calculation.
-
Read the results
Open the Results tab. Lower is better for all three, and the best design in each chart is highlighted.
-
Change a condition
Back on Build, edit Air speed and change it to 3. The calculation and the chart run again by themselves, and every design runs cooler.
What the results show
At 2 m/s, checked against the Targets from tutorial 1 (at most 60 °C, 250 g and 5 Pa):
| Design | Max temperature (°C) | Mass (g) | Pressure drop (Pa) | Meets the targets? |
|---|---|---|---|---|
| Baseline | 56.0 | 183.6 | 1.99 | Yes |
| Tall fins | 47.5 | 232.2 | 1.77 | Yes |
| Dense fins | 44.6 | 216.0 | 6.05 | No: pressure drop |
| Light | 71.2 | 113.4 | 1.10 | No: too hot |
| Copper | 55.2 | 609.3 | 1.99 | No: too heavy |
Tall fins runs coolest of the designs that pass. Copper conducts heat better than aluminium, but at this size it barely helps and triples the mass.
Good to know
- The Co-Engineer can build the canvas for you. Describe what you want to calculate on the empty canvas, or click Create with Co-Engineer, and it drafts the blocks and code for you to review before anything runs.
- Start sequence runs the whole canvas from the start.
- To try many air speeds at once instead of one at a time, use a Parameter: Array; see Simulation Studio.
- Every block, panel and run state is described in Simulation Studio.
Next: 3. Use your knowledge: back the design up with a datasheet and test data, and let the Co-Engineer use them.