fix typo in tf_simulator dt3, nt3 calculation#172
Open
ecosang wants to merge 1 commit into
Open
Conversation
Contributor
Author
ecosang
commented
Jul 25, 2026
| $$T_{i,j} = \frac{\sum_{\text{neighbors}} T_{\text{neighbor}} + | ||
| \frac{Q_x}{z k} + \frac{k_{\text{mass}} \delta_x^2}{z^2 k} | ||
| T_{\text{mass},i,j}+\frac{q_\text{lwx}}{zk} + t_0 T_{i,j}^{(-)}} | ||
| T_{\text{mass},i,j}+\frac{q_\text{lwx}\, \delta_x}{k} + t_0 T_{i,j}^{(-)}} |
Contributor
Author
There was a problem hiding this comment.
@s2t2 I have this typo in the docstring. the code is fine. This is the only issue. But I updated the docstring a bit more comprehensive.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Below is the PR message using LaTeX equations, grounded in the key equations from
_get_interior_cv_temp_estimate. Copy everything between the horizontal rules into your GitHub PR description (GitHub renders$...$and$$...$$LaTeX in Markdown).Fix: Duplicate specific-heat factor in the thermal storage term of
TFSimulatorSummary
The tensorized energy-balance update in$c$ twice in the thermal storage (energy-accumulation) term, producing a $c^2$ factor instead of $c$ . This over-weights the storage term by a factor of $\sim c$ (≈ 1000 for building air), corrupting the transient temperature response. This PR removes the duplicate multiplication in both the numerator and the denominator.
tf_simulator.pymultiplies the specific heat capacityReference: the base interior-node equation
The scalar reference implementation in$u = v = \delta_x$ ) and uniform conductivity ($k_1 = k_2 = k_3 = k_4 = k$ ), the balance is:
_get_interior_cv_temp_estimatedocuments the correct interior-CV energy balance. With uniform spacing (The right-hand side is the energy storage term. It derives from the time derivative of internal energy$E = m c T = \rho,(uvz),c,T$ :
The specific heat$c$ appears exactly once. A units check confirms it, and shows it is consistent with the conduction coefficient $\tfrac{k A_n}{\delta_x}$ :
Solving for$T_{i,j}$ (matching the documented closed form) gives:
Tensorized form and the storage coefficient
TFSimulatoruses the volumetric (non-normalized) form of the same balance. Define the storage coefficient:so the tensor update is (schematically, with$N_0, D_0$ the conduction/convection/mass/$Q_{\text{lwx}}$ terms that do not contain $c$ ):
The bug replaces$S$ with $c,S = \dfrac{\rho c^2 U V z}{\Delta t}$ in both numerator and denominator.
Why the$c^2$ error does not cancel
Because$N_0$ and $D_0$ do not contain $c$ , the erroneous factor does not cancel:
For building air$c \approx 1000$ , the storage term dominates and drives:
i.e. each CV barely updates per iteration — the transient response is slowed by$\sim c$ . (The converged steady state is still correct, since there $T = T^{(-)}$ , but the dynamics and per-step behavior are wrong.)
The bug in code
Denominator —
_get_denominator:Numerator —
_get_numerator:The fix
Remove the second$\dfrac{\rho c, U V z}{\Delta t}$ (and $\times T^{(-)}$ in the numerator):
tf.math.multiply(..., t_heat_capacity)in both functions so the storage term equalsVerification
_get_interior_cv_temp_estimateand the docstring ofupdate_temperature_estimates, which already stated the storage term as