cmuchancel commited on
Commit
0bc6c8d
·
verified ·
1 Parent(s): 902b9c5

Document deterministic theory, LLM grounding and validation limits

Browse files
Files changed (1) hide show
  1. README.md +58 -14
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
- This HW3 app calculates heat transfer from identical straight rectangular fins with adiabatic tips. Python calculations are the numerical source of truth. The local LLM only explains supplied results; it does not calculate the table values.
17
 
18
- ## Inputs and outputs
 
 
19
 
20
- Enter the number of fins; ambient and base temperatures in °C; fin length, width, and thickness in meters; convection coefficient `h` in W/m²-K; and thermal conductivity `k` in W/m-K. Inputs must be finite, fin count and dimensions must be positive, `h` and `k` must be positive, and base temperature must exceed ambient temperature. The intended fin count is a positive integer.
21
 
22
- The table shows cross-sectional area (m²), perimeter (m), base excess temperature (°C), fin parameter `m` (1/m), dimensionless `mL`, heat transfer per fin (W), and total array heat transfer (W).
 
 
 
 
 
 
 
 
 
23
 
24
- The formulas are `A_c = w*t`, `P = 2*(w+t)`, `theta_b = Tb-T∞`, `m = sqrt(h*P/(k*A_c))`, `q_fin = sqrt(h*P*k*A_c)*theta_b*tanh(m*L)`, and `q_total = N*q_fin`.
25
 
26
- ## Assumptions
27
 
28
- Steady-state, one-dimensional conduction; adiabatic tips; constant `h`, `k`, ambient temperature, and base temperature; uniform rectangular cross-section; identical fins; perfect thermal contact at the base; negligible radiation; and no fin-to-fin interaction.
29
 
30
- ## Explanation model and GenAI acknowledgment
 
 
 
 
 
 
31
 
32
- The app uses [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B), pinned to revision `c1899de289a04d12100db370d81485cdf75e47ca`, locally on CPU in float32. It preserves the notebook’s two few-shot examples, disabled thinking, greedy decoding, and 96-token generation limit.
33
 
34
- Generative AI produces the explanation. The system prompt requests exactly two short sentences, at most 35 words, copying supplied numbers without recalculation, invented causes, or design recommendations. These are instructions to the model, not guarantees; verify the prose against the deterministic table.
35
 
36
- ## Limitations and runtime
37
 
38
- This is an idealized classroom calculation of heat transfer from the fins only. It does not add heat transfer from an exposed base or account for effects outside the stated assumptions. Generated prose can be inaccurate or incomplete.
39
 
40
- Designed for CPU Basic. Float32 model weights require roughly 2.4 GB before runtime overhead. The initial model download and CPU generation can be slow. The model loads once at startup, and the interface allows one calculation-and-explanation request at a time.
41
 
42
- The implementation and interface follow the supplied working notebook and professor starter style.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.