+ Reply to Thread
Results 1 to 10 of 10

Macro to perform a complicated equation

  1. #1
    Registered User
    Join Date
    01-30-2015
    Location
    Durham, England
    MS-Off Ver
    Microsoft 2007
    Posts
    31

    Macro to perform a complicated equation

    Hello everyone, I am new to Excel Macros, I have some (limited) computing knowledge though. i am trying to use excel to perform the equation in the image below. This equation is meant to represent the heat distribution though insulation.
    descretizationequation.jpg
    where Dt is the time step= 0.065 and the superscript n represents the current time step.

    The image below shows the parameters to enter into this equation. (these can also be seen in the attached workbook)
    parameters.jpg
    I am not entirely sure how to get excel to calculate T at each time step for each layer.
    I have made a start on the coding, however the results show that temperature does not change with time when it should, please note that this coding is currently missing the final term in the equation as shown in the image below (I am doing it step by step), but in terms of the output there should still should be some changes in T with time.
    final part of equation.jpg
    Please see below for the coding I have started: and comments to help would be greatly appreciated.
    Best Wishes,
    Sarah

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by eocsur; 01-30-2015 at 11:07 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to perform a complicated equation

    Sarah - please add code tags to your post, as per forum rules, and post a workbook - pictures don't really help.

  3. #3
    Registered User
    Join Date
    01-30-2015
    Location
    Durham, England
    MS-Off Ver
    Microsoft 2007
    Posts
    31

    Re: Macro to perform a complicated equation

    I have now added notes to my coding and attached the file in which i am working on , is that what you meant?

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to perform a complicated equation

    No, code tags. Official message:Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  5. #5
    Registered User
    Join Date
    01-30-2015
    Location
    Durham, England
    MS-Off Ver
    Microsoft 2007
    Posts
    31

    Re: Macro to perform a complicated equation

    Ok I have done that now, thank you for your help Stephen

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to perform a complicated equation

    Thanks. I guess it would be helpful if you could give an illustration of the results you are expecting, or some explanation of the sheet. Presumably the code is supposed to be evaluating the formula?

  7. #7
    Registered User
    Join Date
    01-30-2015
    Location
    Durham, England
    MS-Off Ver
    Microsoft 2007
    Posts
    31

    Re: Macro to perform a complicated equation

    The code in this thread is analysing the data in the sheet.
    Each layer can be seen in the table in the centre of the sheet, each layer has different corresponding parameters (to be applied to the equation). Heat is applied in the hot chamber. The temperature is then measured at each layer simultaneously and measured with respect to temp.

    Columns (O-AA:11) represent the temperature of each layer of the insulation. (The order of layers seen top to bottom in the table is shown here from left to right)

    Initial condition is time=0, so the column starting at (A:11) is time since the beginning of the experiment.

    Cell(B:2) is how many seconds the experiment will run for (can be manipulated by the user)

    Cell(B:6) is how many time steps (0.0625) have passed since the start of the experiment.

    These are the results that this calculation should be looking to achieve (Approximately) However, the coding I have created is still missing the last term which will change the results. However, it is expected to peak then drop and then remain constant.
    resultscopy.jpg
    Last edited by eocsur; 01-30-2015 at 01:11 PM.

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to perform a complicated equation

    Is that the issue then - the lack of the final term - do you know how to incorporate it?

  9. #9
    Registered User
    Join Date
    01-30-2015
    Location
    Durham, England
    MS-Off Ver
    Microsoft 2007
    Posts
    31

    Re: Macro to perform a complicated equation

    I have now incorporated the final term (please see attached) and the final T is still incorrect. I wonder if the problem is in the Tn(j-1) where I am inputting the temperature of the previous layer?

    For example:
    Please Login or Register  to view this content.
    with layer 3 Cells(13 + i, 17)
    I am not sure that the temp of the previous layer is established by just starting a row 12 instead of 13 Cells(12 + i, 18)

    Any help on this is or if you think it is another problem would be great

    Sarah

  10. #10
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to perform a complicated equation

    Tricky to disentangle all that! I wonder about the T superscript n subscript j term (sorry, don't know if can write formulae here properly) - the last bit of the second row of your formulae. For eg aluminium it refers to cells(12+i,15), but should it be column 16 as we're looking at the same j?

    Otherwise, check obvious things, which you probably already have, such as no typos in cell addresses and brackets all ok.

    If/when we sort this out, there is probably scope to simplify your code a little with another loop.

+ 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. Please help - complicated equation plus plotting it
    By loto11 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 03-01-2013, 07:39 PM
  2. Replace Fill Down, Complicated Equation
    By thequiff in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-15-2012, 10:03 AM
  3. [SOLVED] Complicated IF statement that runs an equation on True
    By scrumpulate in forum Excel General
    Replies: 1
    Last Post: 04-20-2012, 04:24 PM
  4. Replies: 1
    Last Post: 05-15-2011, 07:00 PM
  5. Complicated If Equation
    By Brad Larsen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-22-2006, 05:29 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