Steady-State Junction Temperature With and Without Heatsink
Math & Bit ManipulationAuto-graded · 17 test casesLast updated
Compute a component's junction temperature from power dissipation and series thermal resistances, both before and after adding a heatsink.
Steady-state junction temperature
An electronic component generates heat that flows outward through a chain of thermal resistances into the surrounding air. In steady state you can model this chain exactly like resistors in series:
- The dissipated power
power_w(in watts) plays the role of current, and is the same through every element. - Each thermal resistance (in °C per watt) plays the role of a resistor.
- Each element therefore drops the temperature by
power_w × resistance, and these drops stack on top of the ambient temperature.
You are given a junction-to-case resistance r_jc_c_per_w and a baseline case-to-ambient resistance r_ca_c_per_w. The ambient temperature is ambient_c. A heatsink is then fitted, which replaces the case-to-ambient path with a new resistance heatsink_r_ca_c_per_w; the junction-to-case resistance stays the same.
Write a function that returns a list of two numbers, in this order:
- The junction temperature with the original (no-heatsink) case-to-ambient resistance.
- The junction temperature with the heatsink resistance substituted in.
Both values are computed as ambient_c + power_w × (r_jc_c_per_w + r_ca), where r_ca is respectively the original or the heatsink value. No rounding is applied.
The resistances are added in series in all cases, even if the "heatsink" value is larger than the original (the arithmetic is unchanged).
Constraints
0 <= power_w <= 1000(may be a float)0 <= r_jc_c_per_w, r_ca_c_per_w, heatsink_r_ca_c_per_w <= 1000(may be floats)-100 <= ambient_c <= 1000(may be a float)- Return exactly two values, original first, heatsink second, with no rounding.
Examples
Example 1
Input: junction_temperatures(5, 2, 5, 25, 2)
Output: [60, 45]
Example 2
Input: junction_temperatures(1, 10, 4, 20, 1)
Output: [34, 31]
Example 3
Input: junction_temperatures(2.5, 3.2, 6.8, 30, 2.4)
Output: [55, 44]
Hints
Hint 1
Heat flow through the package and heatsink behaves like current through series resistors: the temperature drops add up.
Hint 2
The total temperature rise above ambient is power times the sum of the two resistances on the path.
Hint 3
Only the case-to-ambient resistance changes when the heatsink is added; the junction-to-case value is untouched.
Worked solution
Easy Try it yourself first — then compare your approach, complexity and edge cases.
Approach
In steady state the same heat flux power_w passes through every layer of the thermal path. Treat each thermal resistance like a resistor in series: the temperature drop across one element is power_w × resistance, and the total drop above ambient is power_w times the sum of the resistances.
- Original path: resistances are
r_jc_c_per_wandr_ca_c_per_w, soT_j = ambient_c + power_w × (r_jc_c_per_w + r_ca_c_per_w). - Heatsink path: only the case-to-ambient resistance changes, so
T_j = ambient_c + power_w × (r_jc_c_per_w + heatsink_r_ca_c_per_w).
Return the two results as a list, original first.
Why it is correct
The series-resistance analogy is exactly the statement that the thermal drops are additive along the path from junction to ambient. Since the same power flows through both resistances, summing them and multiplying by the power once yields the same total rise as applying the power to each element and adding. This holds for any values, including power_w = 0 (result equals ambient) and negative ambient temperatures.
Complexity
- Time: O(1) — two multiply-adds.
- Space: O(1) — aside from the two-element output list.
from typing import List
def junction_temperatures(power_w: float, r_jc_c_per_w: float, r_ca_c_per_w: float, ambient_c: float, heatsink_r_ca_c_per_w: float) -> List[float]:
original = ambient_c + power_w * (r_jc_c_per_w + r_ca_c_per_w)
with_heatsink = ambient_c + power_w * (r_jc_c_per_w + heatsink_r_ca_c_per_w)
return [original, with_heatsink]