Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization error in Step 9 #78

Open
Bob-McCrory opened this issue Oct 19, 2020 · 1 comment
Open

Initialization error in Step 9 #78

Bob-McCrory opened this issue Oct 19, 2020 · 1 comment
Labels

Comments

@Bob-McCrory
Copy link

In the fourth code cell in 12_Step_9.ipynb, dy is set to 2 / (ny - 1). To be consistent with the y array, this should be 1 / (ny - 1).

Correcting this has several effects. First, convergence slows. With the current version, laplace2d() stops iterating at 1,133 steps; after applying the correction, it takes 2,043 steps. Second, the revision affects how close laplace2d() comes to the analytic solution. I use sum(p) as a rough comparison among different results from laplace2d(). The current version (2/(ny - 1)) produces a sum of 231.8 when iteration stops at 1,133 steps. The corrected initialization (1/(ny - 1)) produces 220.2 at 2,043 steps. Compare these with the analytic solution sum of 240.25.

I'm translating to Julia as I work through the Steps. My Julia versions of Step 9 come up with the same results as the revised Python version. In addition, it shows that if you iterate the Julia version of laplace2d() for 5,000 steps, you come up pretty close the analytic solution (sum of 239.5 vs. the 240.25 noted above).

Hope this helps. Thanks again for all your work on this. In addition, thank you for keeping it current.

On to Step 10!

@piyueh
Copy link
Member

piyueh commented Oct 19, 2020

@Bob-McCrory yeah, that looks like a bug.

In fact, if we assess errors using norms (like l1, l2, etc.), without changing other settings, we can immediately see using correct dy gives smaller errors.

  • dy = 2 / (ny - 1):
    • Max err: 0.10306838849795835
    • Min err: 0.0
    • l1-norm: 30.280230647022975
    • l2-norm: 1.306916099371858
    • L1-norm: 0.03150908496048176
    • L2-norm: 0.042158583850705096
    • sum(p): 231.8167538742652
  • dy = 1 / (ny - 1):
    • Max err: 0.03634411762565337
    • Min err: 0.0
    • l1-norm: 20.1998976443884
    • l2-norm: 0.7380661021668224
    • L1-norm: 0.021019664562318834
    • L2-norm: 0.02380858394086524
    • sum(p): 220.19339147832645

@piyueh piyueh added the bug label Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants