Document deterministic theory, LLM grounding and validation limits
Browse files
README.md
CHANGED
|
@@ -13,30 +13,74 @@ short_description: Deterministic fin heat transfer with a local LLM explanation
|
|
| 13 |
|
| 14 |
# Fin array calculator and explainer
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Fin array calculator and explainer
|
| 15 |
|
| 16 |
+
HW3 deterministic engineering calculator adapted from the lecture starter. Python computes heat transfer from identical straight rectangular fins with adiabatic tips. A local LLM describes supplied results; it never supplies the numerical table values.
|
| 17 |
|
| 18 |
+
- [Working Colab notebook](https://colab.research.google.com/drive/1A4t177a62Nl6Tv6EcB-R_Ua7JIqQTGyh?usp=sharing)
|
| 19 |
+
- [Explanation model: Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B)
|
| 20 |
+
- Fixed explanation-model revision: `c1899de289a04d12100db370d81485cdf75e47ca`.
|
| 21 |
|
| 22 |
+
## Inputs and intended valid ranges
|
| 23 |
|
| 24 |
+
| Input | Units | Intended valid range |
|
| 25 |
+
|---|---|---|
|
| 26 |
+
| Number of fins, N | Count | Positive integer |
|
| 27 |
+
| Ambient temperature, T∞ | °C | Finite; below Tb |
|
| 28 |
+
| Base temperature, Tb | °C | Finite; above T∞ |
|
| 29 |
+
| Fin length, L | m | Finite and positive |
|
| 30 |
+
| Fin width, w | m | Finite and positive |
|
| 31 |
+
| Fin thickness, t | m | Finite and positive |
|
| 32 |
+
| Convection coefficient, h | W/m²-K | Finite and positive |
|
| 33 |
+
| Thermal conductivity, k | W/m-K | Finite and positive |
|
| 34 |
|
| 35 |
+
No application-specific upper bounds are enforced. The calculator covers heat transfer from the fins only, not any exposed base surface.
|
| 36 |
|
| 37 |
+
## Deterministic calculation and assumptions
|
| 38 |
|
| 39 |
+
The backend returns a structured dictionary with numerical results and assumption flags. It calculates:
|
| 40 |
|
| 41 |
+
- Cross-sectional area: `A_c = w*t` (m²).
|
| 42 |
+
- Perimeter: `P = 2*(w+t)` (m).
|
| 43 |
+
- Base excess temperature: `theta_b = Tb-T∞` (°C difference, numerically equal to K difference).
|
| 44 |
+
- Fin parameter: `m = sqrt(h*P/(k*A_c))` (1/m).
|
| 45 |
+
- Dimensionless length: `mL = m*L`.
|
| 46 |
+
- Heat transfer per fin: `q_fin = sqrt(h*P*k*A_c)*theta_b*tanh(mL)` (W).
|
| 47 |
+
- Total array heat transfer: `q_total = N*q_fin` (W).
|
| 48 |
|
| 49 |
+
Assumptions: steady-state, one-dimensional conduction; adiabatic tips; constant `h`, `k`, T∞, and Tb; uniform rectangular cross-section; identical fins; perfect thermal contact at the base; negligible radiation; and no fin-to-fin interaction. The calculation has no empirical training dataset.
|
| 50 |
|
| 51 |
+
## Interface and explanation
|
| 52 |
|
| 53 |
+
The notebook’s layout presents labeled inputs, assumptions, valid-input guidance, a **Calculated evidence — source of the results** table, and a **Generated explanation — verify against the table** textbox. Select **Calculate and explain** to update both panels.
|
| 54 |
|
| 55 |
+
The table displays rounded results; calculations use unrounded values. The LLM receives a formatted summary derived from the computed record: heat transfer per fin, fin count, total heat transfer, temperatures, `m`, and `mL`. It does not receive the complete assumption dictionary. Two fixed few-shot examples demonstrate the response style; they do not train the model or change its weights.
|
| 56 |
|
| 57 |
+
The system prompt requests exactly two short sentences, at most 35 words, copying supplied values without recalculation, invented causes, or design recommendations. The model uses greedy decoding, disabled thinking, and a 96-token output limit. The code adds a warning if generation reaches its limit without an end-of-sequence token. These settings do not guarantee factual accuracy or compliance with the sentence/word limit.
|
| 58 |
|
| 59 |
+
## Validation and known edge cases
|
| 60 |
+
|
| 61 |
+
The deterministic function checks finite inputs, positive count/dimensions/coefficients, an integer fin count, and Tb greater than T∞. Invalid inputs caught by `run_once` clear the results table and return a correction message.
|
| 62 |
+
|
| 63 |
+
The current callback converts fin count with `int(...)` before calling the backend. Fractional values passed directly to the callback can therefore be truncated instead of rejected, despite the intended integer requirement. The interface uses a whole-number widget. Extremely large finite inputs can exceed numerical limits; arbitrary extreme combinations and model-generation failures are not comprehensively handled.
|
| 64 |
+
|
| 65 |
+
## Verification
|
| 66 |
+
|
| 67 |
+
Live checks on September 30, 2026 produced:
|
| 68 |
+
|
| 69 |
+
| Case | Heat transfer per fin | Total array heat transfer |
|
| 70 |
+
|---|---|---|
|
| 71 |
+
| Default: N=10, T∞=25 °C, Tb=100 °C, L=0.05 m, w=0.03 m, t=0.002 m, h=25 W/m²-K, k=205 W/m-K | 5.424 W | 54.244 W |
|
| 72 |
+
| Same inputs with N=20 | 5.424 W | 108.487 W |
|
| 73 |
+
|
| 74 |
+
For both cases, generated explanations accurately copied the displayed heat-transfer values. Reversing base and ambient temperatures returned a correction message and an empty table. The notebook also contains passing positivity and fin-count scaling checks. These checks cover selected cases; they are not proof that every generated explanation is correct.
|
| 75 |
+
|
| 76 |
+
## Runtime and limitations
|
| 77 |
+
|
| 78 |
+
The Space runs on CPU Basic with Python 3.13, Transformers 5.14.1, PyTorch 2.10.0, and Gradio 6.28.0. Qwen loads once on CPU in float32. Its approximately 0.6-billion-parameter weights alone need roughly 2.4 GB, plus runtime overhead. Model download and CPU text generation can be slow. The interface allows one calculation-and-explanation request at a time.
|
| 79 |
+
|
| 80 |
+
Results apply only to the idealized assumptions above. They do not include tip convection, radiation, contact resistance, varying properties, exposed-base heat transfer, or fin interactions. The LLM can misstate or omit information; the deterministic table remains the numerical source of truth. This is a classroom demonstration, not a validated engineering design tool.
|
| 81 |
+
|
| 82 |
+
## Credits, license, and GenAI acknowledgment
|
| 83 |
+
|
| 84 |
+
The calculator and interface follow the professor’s lecture starter. Credit for the pretrained explanation model belongs to the Qwen team; its upstream repository declares Apache 2.0. That license applies to the upstream model, not automatically to all app materials or lecture code.
|
| 85 |
+
|
| 86 |
+
I used ChatGPT/Codex for help where needed, including adapting the code, preparing the Hugging Face deployment, testing the live app, and writing documentation. The running app also uses generative AI to produce the explanation panel. Numerical results come from the deterministic Python backend, not ChatGPT or Qwen.
|