Add self-heating visualisation

This commit is contained in:
2025-12-02 03:11:28 +00:00
parent 0e270dee88
commit 02101fd4b9

View File

@@ -89,6 +89,68 @@ def display_thermal_chart() -> None:
)
def display_self_heating_panel() -> None:
"""Display self-heating demonstration panel."""
engine: PhysicsEngine = st.session_state.engine
history: SimulationHistory = st.session_state.history
thermal = engine.get_thermal_state()
electrical = engine.get_electrical_state()
# Calculate temperature rises
delta_t_jc = thermal.junction_temperature - thermal.case_temperature
delta_t_ca = thermal.case_temperature - thermal.chamber_temperature
col1, col2 = st.columns(2)
with col1:
st.markdown("#### Self-Heating Analysis")
# Display thermal resistance info
st.markdown(
f"""
| Parameter | Value |
|-----------|-------|
| Junction-Case Rise (ΔT_jc) | **{delta_t_jc:.2f} °C** |
| Case-Ambient Rise (ΔT_ca) | **{delta_t_ca:.2f} °C** |
| Power Dissipation | {electrical.power_dissipation * 1000:.1f} mW |
| θ_jc (junction-case) | 15 °C/W |
| θ_ca (case-ambient) | 5 °C/W |
"""
)
st.markdown(
"""
**Thermal Coupling:** The junction temperature rises above the case
temperature due to power dissipation. This is governed by:
`T_junction = T_case + P_diss × θ_jc`
Try increasing the load current or input voltage to see
self-heating effects!
"""
)
with col2:
st.markdown("#### Power Dissipation")
if len(history.time) < 2:
st.info("Start the simulation to see power data")
return
power_data = {
"Time (s)": list(history.time),
"Power (mW)": [p * 1000 for p in history.power_dissipation],
}
st.line_chart(
power_data,
x="Time (s)",
y="Power (mW)",
color="#2ca02c",
)
def display_current_state() -> None:
"""Display current simulation state metrics."""
engine: PhysicsEngine = st.session_state.engine
@@ -222,6 +284,10 @@ def main() -> None:
st.subheader("Temperature History")
display_thermal_chart()
# Self-heating demonstration
st.subheader("Self-Heating Demonstration")
display_self_heating_panel()
# Auto-refresh when running
if st.session_state.running:
step_simulation(steps=10)