# Comparing two versions of the same hydrodynamic code and their error

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?

• 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? – dmckee --- ex-moderator kitten Nov 8 '15 at 1:27
• 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. – mathdummy Nov 8 '15 at 1:37
• 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 – tpg2114 Nov 8 '15 at 1:40
• 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. – Winther Nov 8 '15 at 1:46

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.