Illustrated Guide to Writing a Finite Difference Code for Heat Equation

2023 eesc w3400 n.w
1 / 26
Embed
Share

Explore the step-by-step process of writing a Finite Difference code for solving dynamic heat conduction problems, also known as the diffusion equation. Follow along as we find the temperature distribution for a small problem using a structured grid, initial and boundary conditions, and interior equations involving multiple points.

  • Finite Difference Method
  • Heat Equation
  • Computational Science
  • Coding
  • Dynamic Heat Conduction

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. 2023 EESC W3400 Lec 22: Writing a FD code illustrated with 1D+time heat flow equation Computational Earth Science Bill Menke, Instructor Emily Glazer, Teaching Assistant TR 2:40 3:55

  2. Today Finite Difference Method for Solving Dynamic Heat Conduction Problem a.k.a. the Diffusion Equation

  3. Today I will lead you through writing a FD code assuming small problem that doesn t need sparse matrices

  4. Goal: Find temperature, ? ?,? for ???? ? = 0 0 ? source ? ?,? ? = 0 ???? ? = 0 ? ?? ?? ?2? satisfied in the interior ??2= ?

  5. Finite Difference grid ? ?? 1 0 ? 0 ? ?? 1 ? ?? ?? ?2? satisfied in the interior ??2= ?

  6. initial condition 0 ? 1 ? ?,? = 0 = 0 ?

  7. boundary condition 1 ? ? = 0, ? ? ???? = 0 0 ? ? 1 ? ? = ????, ? ? ???? = 0

  8. interior ?2? ?? ?? ??2 = ? ? ?,? ? ?,? ? ? ? ? ?,? ? 2? ?,? ? + ? ? + ?,? ? x2 ?? ?,? ? x2? ? ?,? ? + = ? ?,? 1 1 ?? ?,? 2 x2? ?,? ? x2? ? + ?,? + ? = ? ?,?

  9. interior ?2? ?? ?? ??2 = ? ? ?,? ? ?,? ? ? ? ? ?,? ? 2? ?,? ? + ? ? + ?,? ? x2 ?? ?,? ? x2? ? ?,? ? + = ? ?,? 1 1 ?? ?,? 2 x2? ?,? ? x2? ? + ?,? + ? = ? ?,?

  10. interior 1 1 2 x2? ?,? ? x2? ? ?,? ? ?? ?,? + ?+ x2? ? ?,? + ? = ? ?,?

  11. interior ? ?? 1 0 ? 0 every interior equation involves 4 points ? ?? 1 1 1 2 x2? ?,? ? x2? ? ?,? ? ? ?? ?,? + ?+ x2? ? ?,? + ? = ? ?,?

  12. Step 1: define x axis 0 ? 2 ? ? = ?? 1 ?

  13. Step 2: define t axis 0 ? 2 ? ? = ?? 1 ?

  14. Step 3: make tables to unwrap temperature matrix to vector ?0 ?? ?? 1 ?00 ?0,?? 1 ???,?? ? = ? = ??? 1,0 ??? 1,?? 1 ? = ?? ??

  15. Step 3: make tables to unwrap temperature matrix to vector ?0 ?? ?? 1 ?00 ?0,?? 1 ???,?? ? = ? = ??? 1,0 ??? 1,?? 1

  16. Step 3: make tables to unwrap temperature matrix to vector ?0 ?? ?? 1 ?00 ?0,?? 1 ???,?? ? = ? = ??? 1,0 ??? 1,?? 1

  17. Steps 4, 5, 6 and 7: set up ? and ??? for ?? = ??? ? initial condition ? left boundary condition ? rt boundary condition ? interior equation ? ???

  18. Step 4: initial conditions ? initial condition ? ???

  19. Step 5: boundary conditions ? left boundary condition ? rt boundary condition ? ???

  20. Steps 6: construct source ? Gaussian in ? impulsive in ? ? ? ???

  21. Step 7: interior equation ? interior equation ? ???

  22. Step 8: solve equation ?? = ???for ? ???

  23. Step 9: construct ? given ? ?0 ?? ?? 1 ?00 ?0,?? 1 ???,?? ? = ? = ??? 1,0 ??? 1,?? 1

  24. Step 10: plot ?

  25. trick is to build code incrementally step-by-step and test steps along the way

  26. bring up jupyter lab and load stub

Related


More Related Content