3
$\begingroup$

I have two versions of a hydrodynamic code that has the same underlying physics; let's call them code A and B. However, code B is more optimized and more object oriented than A. I was trying to compare the numerical results of both codes and see if they seem compatible. The way I'm doing this is running both codes with the same initial parameters and calculating a particular hydrodynamic value X, which is in the order of magnitude of $10^6$. To compare both codes I'm essentially doing

X(A)−X(B)=ϵ where ϵ is some error. The test is giving $ϵ=10^{−2}$, which would mean that both codes spit out the same X for the first 8 digits.

How significant is this error? I'm using double precision for non-integers, would such a magnitude simply imply a cumulative round off error for the thousands of calculations involved in a hydro code? Or a fundamental difference I'm missing?

$\endgroup$
  • $\begingroup$ Before anythinng else let's ask a couple of dumb questions. (A) Are these code deterministic or Monte Carlo? (B) If Monte carlo, do they make an identical set of calls the PRNG, and if so are you at least using the same seed for both runs? (C) Do both codes have test suites for the core operations? Do they both pass? (D) Are the both compiled with the same math options and optimization levels? $\endgroup$ – dmckee --- ex-moderator kitten Nov 8 '15 at 1:27
  • $\begingroup$ They are deterministic codes. One of the codes was tested against the results of a previous fortran code, so the less optimized is more "trustworthy" in that it has been tested with an older code. Both of them are compiled in java and the values are double precision. $\endgroup$ – mathdummy Nov 8 '15 at 1:37
  • $\begingroup$ I'm on my phone right now so I can't write a full answer but I'm going to say that you are likely okay. If you don't get a better answer from me in the next day or so, ping me and I'll type up something $\endgroup$ – tpg2114 Nov 8 '15 at 1:40
  • 2
    $\begingroup$ Some standard tests like the Sod shock tube have known analytical solutions you can comapre to. Then you can compute the acctual error instead of comparing code-code. $\endgroup$ – Winther Nov 8 '15 at 1:46
0
$\begingroup$

The best way to see the accuracy of a hydrodynamics code is to test it against analytic solutions. As mentioned by Winther in the comments, the Sod shock tube is one of the most common tests for 1D hydro (the magnetohydrodynamic (MHD) analog of this is called the Brio-Wu shock tube)

For other tests (of any dimension, but without the analytic solution), what you are doing is fine (and is often done in professional, academic codes, e.g. this test suite from Athena mentions using the suite for your own comparisons).

Depending on the $L^p$ norm you are using there (seems to be $L^1$), I would think the difference is acceptable. The origin of the difference is likely from either an optimization flag or through the an algorithmic difference in the 'more OOP' code, but without more tests comparing the two, one couldn't say how much this is going to differ in other tests or in the 'thousands of calculations involved' in your simulations.

$\endgroup$
  • $\begingroup$ PS: Super sorry for the mega-long delay in answering this. Seems both tpg2114 & I forgot about it $\endgroup$ – Kyle Kanos Feb 2 '17 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.