+ Reply to Thread
Results 1 to 3 of 3

Is there a way to speed up the calculation process?

  1. #1
    Registered User
    Join Date
    08-28-2015
    Location
    Colorado
    MS-Off Ver
    2013
    Posts
    25

    Is there a way to speed up the calculation process?

    I am currently working on a file that performs various calculations using multiple functions.

    There are 8600+ rows and it takes about 45 minutes for all of the calculations to execute. Is there a way to make this process faster?

    An example file containing the code and several lines of data is attached.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Is there a way to speed up the calculation process?

    When I first opened this, I thought it looked familiar. Searching through your past threads, and I see that I have looked at this spreadsheet before.

    First thing I had to do was run through a few iterations (repeatedly press F9) to clear the errors from the sheet.

    Having recognized the sheet, I knew I did not want to try to reverse engineer the circular references again, so I assumed the sheet was structured correctly.

    Then I started looking at the UDFs. I notice that all of them have application.volatile in them, which can slow things down. A quick look at the code suggested to me that they did not need to be volatile, so I removed the volatile statements from them. This seemed to improve calculation times a little, but not dramatically. I also have no idea if the calculations are correct or not, so could not tell if removing the application.volatile had an adverse effect on the accuracy of the calculation. As good practice, I would determine if these need to be volatile or not. If they do not need to be volatile, then remove the application.volatile statement. If they do need to be volatile, figure out how to code the procedures so they won't need to be volatile.

    The next thing I did was to check if there are numeric algorithms (involving loops which can be very slow if the algorithm requires many iterations to converge). I found what looks like a bisection algorithm in function WetBulb() and what looks like a brute force algorithm in function Tinput2cfm1(). I put a Stop statement after the For counter=1 to 1000..Next counter loops in Wetbulb as well as after the Do While..Loops in Tinput...() so that it would enter debug mode at those points in those procedures. I observe that the brute force loops in Tinput...() are consistently taking about 70 iterations to terminate. Even worse, I observe that the bisection loops in WetBulb() are often (well over half of the function calls) taking all 1000 iterations before terminating. When these loops did terminate normally, they were taking about 50 iterations.

    This looks to me like a major bottleneck. I would probably proceed by trying to figure out why the bisection loop is not terminating normally. I have not looked in more detail, since I don't understand the engineering behind these calculations and didn't want to get lost in things I don't understand. If you can get this part of the procedure to terminate in 50 iterations rather than 1000, that should improve your calculation times.

    Then I might ask myself if bisection is the best algorithm here, or if I could possibly use a Newton-Raphson type algorithm that would normally converge in fewer iterations. I might also ask myself if brute force is really the only suitable algorithm for Tinput...().

    I don't expect you will ever get 8600 copies of this calculation to calculate near instantaneously. But debugging/improving those two procedures should dramatically improve calculation times.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    08-28-2015
    Location
    Colorado
    MS-Off Ver
    2013
    Posts
    25

    Re: Is there a way to speed up the calculation process?

    Wow, thank you for the information. This is my second attempt at this calculator. I've finally been able to get it to work.

    I was told the original calculator would take several hours to process, so 45 minutes isn't too bad. I will certainly look into your suggestions.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to speed up formula calculation process
    By snuffnchess in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-04-2015, 12:19 PM
  2. [SOLVED] Need Help to speed-up the process using Macros
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 63
    Last Post: 01-22-2013, 10:29 AM
  3. Replies: 5
    Last Post: 03-15-2012, 01:20 AM
  4. Need to speed up process...
    By y34r1ght in forum Excel General
    Replies: 13
    Last Post: 01-10-2007, 06:17 PM
  5. VB code - To Speed up process
    By test1986 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2006, 11:22 AM
  6. [SOLVED] Speed up Program Process
    By maperalia in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-26-2006, 04:00 PM
  7. [SOLVED] Speed up the process
    By Ali Baba in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-03-2005, 02:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1