I was looking at your thermal conductivity calculations and I noticed something: You've been doing the geometric mean which is a particularly expensive calculation.
Now I know you do some precaching already, so forgive me if you already do this, and if you do, you can ignore and close this ticket, but my suggestion is to do some memoization to save a lot of time every frame trading calculations for a little more space complexity.
Here's the idea: When you calculate the geometric mean, you are doing the calculation ((TC_i * TC_k)^(1/2)) * 1000 which always has the same result, regardless of the temperature or time involved for each pair of elements <i, k>. There is only ever reason then to do this calculation once, period, especially since a square root is very costly, even if you approximate it.
Now, if we precache the results into a 2D array, GeoMean[i,k], we can replace this part of your 5 Thermal Conductivity formulas with this array and save a lot of time every frame:
q_StS = dTemp * dTime * GeoMean[i,k]
q_StL = dTemp * dTime * GeoMean[i,k]
q_GtL = dTemp * dTime * GeoMean[i,k]
q_StG = dTemp * dTime * GeoMean[i,k] * 25
q_LtL = dTemp * dTime * GeoMean[i,k] * 625
I'll leave it up to you if the space complexity is worth it to do the same for the TC average for ducts and pipes, TC lowest, or TC building times TC cells. I believe cell to cell happen most often, and could provide the greatest benefit, even though the others might have some benefit.
code inspection.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now