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

Clarifying the purpose of "poisson2d", choosing clear convergence criteria, adding tests #24

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

arunningcroc
Copy link
Member

@arunningcroc arunningcroc commented Jul 1, 2021

As discussed in #23, it would be good to have tests in order to be sure the codes converge correctly. Indeed, on adding a sensible check for the end result, I was able to make all the codes run with the exact same number of iterations. This seems like a pretty strong indication of algorithmic parity.

To get a sensible test, I changed the "source term", i.e. "rho", to an analytical form that also has a pen-and-paper solution. Then anyone can easily implement a function that checks whether the numerical solution is "close enough", for which I chose that the average absolute difference between the grid points of the analytical vs. numerical solution is less than 5.0e-3.

Other than that, this branch adds the modern Fortran version of @rouson and also separates the Fortran calculations in to functions and modules. Though I agree that it would be good to have a single file from which to run all the benchmarks, I wasn't sure what would be the best way to do it, so I left it out for now pending further discussion.

One interesting thing that happened is that what was previously called "optimized.f90" (I've now changed my fortran codes to traditional1.f90 and traditional2.f90) is somehow slower than the "naive.f90" version. Hence the name change: it's hardly optimized if it is slower in the end! Also, @rouson 's modern version blows both of mine out of the water in terms of performance (and prettiness :) ) showing that indeed utilizing modern features can cause performance speedups. For some reason, though, it doesn't converge for M=200, but does converge in the exact same number of iterations as the other codes for the M=100 and M=300 cases. Beats me.. if anyone has any ideas, I'll be glad to hear them.

I also added a numpy-vectorized Python code for fun.

There's now also a pdf giving a problem description (from which you can see the analytical source term and solution as well).

edit: also, the code that was pulled from me last time gave non-deterministic answers as per the comments of @certik . I didn't notice the later comments in the pull request. This shouldn't happen with these codes, either. If anyone can test, that would be great.

@arunningcroc arunningcroc changed the title Clarifying the purpose of this exercise, choosing clear convergence criteria Clarifying the purpose of "poisson2d", choosing clear convergence criteria, adding tests Jul 1, 2021
@certik
Copy link
Member

certik commented Jul 1, 2021

Thanks! Can you please also push in the latex source of the pdf?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants