LBNL - Review, Fix, and Verify Simulator Calculations - #172
Conversation
| $$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}^{(-)}} |
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.
|
ok thanks! @ecosang or @yun-dam can you please post a screenshot of the updated docs site content? @amcberkes let us know if the formula updates look good to you. I believe some related changes may have been recently made internally? |
|
@s2t2 yes we have made that change internally in March. |
|
@StS2 seems several synchronization issues here. How do you want to deal with this? I may close this PR if Google's repo already has this. During that time, I will work with @yun-dam to find the other potential issues. Any comment regarding the syncing process? do you want me to merge this PR #169 to open-source one? but at least, I want to modify the "docs" update. I can update it separately. |
|
@ecosang I would be inclined to merge this PR. We will include it in the content that needs to get synced, and process it in the same way. Will take a final look on Monday and probably merge if everything looks good. |


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 asIn Consultation With / Contributions By: Yun-Dam Ko @yun-dam