A glitch in Jorrie’s Cosmo-Calculator?

  • I
  • Thread starter JimJCW
  • Start date
In summary: The other in main() if (s > 0.9999999 && s < 1.0000001) { z = 0; // the 'now' line, force z to zero } else { z = s - 1; // redshift s=z + 1
  • #71
JimJCW said:
I noticed that using version (1.2.0), I can’t duplicate your Dnow(z) in one run of the calculator; I had to calculate one or two values at a time.
Yes, it doesn't currently do linear intervals; this should be easy to add.

JimJCW said:
The Dv1.2.0(z) result shows a big improvement over the Jorrie 2022 result, but it still deviates systematically from Dcosmic(z).
I'm not really surprised at this deviation, steps to improve it include:
  • Check the precision of the physical constants and model values
  • Try midpoint instead of trapezium rule which always overestimates for a concave function.
  • Add error estimation/adaptive step size.
But these are all enhancements for 1.4.0.
 
Last edited:
Space news on Phys.org
  • #72
pbuk said:
I'm not really surprised at this deviation, steps to improve it include:
These calculators use different values for the constants* (and Cosmic doesn't take ## \Omega_R ## into account at all). It's not surprising they give different results with a regular pattern. Note that the "new Jorrie" site does not yet allow overriding the default values (again this is something that is easy to add but pointless until we are happy with ALL the calculations, not just ## D_{now} ##.

*e.g. ## H_0 ## Jorrie, pbuk 67.74 km/s/Mpc, cosmic 67.04, Gnedin 68.14.
 
  • #73
pbuk said:
These calculators use different values for the constants* (and Cosmic doesn't take ## \Omega_R ## into account at all). It's not surprising they give different results with a regular pattern. Note that the "new Jorrie" site does not yet allow overriding the default values (again this is something that is easy to add but pointless until we are happy with ALL the calculations, not just ## D_{now} ##.

*e.g. ## H_0 ## Jorrie, pbuk 67.74 km/s/Mpc, cosmic 67.04, Gnedin 68.14.

You are right; all other calculators I have tried do not include ΩR. That’s why I like and use Jorrie’s calculator. The effect of ΩR is significant only during early cosmological times (high z values) and it probably does not have any noticeable effects in our Dnow calculations.

All calculators I tried use H0, Ωm and ΩΛ as input parameters and I use H0 = 67.74 km/s/Mpc, Ωm = 0.309 and ΩΛ = 0.691 for all of them.
 
  • Informative
Likes pbuk
  • #74
JimJCW said:
You are right; all other calculators I have tried do not include ΩR. That’s why I like and use Jorrie’s calculator. The effect of ΩR is significant only during early cosmological times (high z values) and it probably does not have any noticeable effects in our Dnow calculations.
It would be easy enough to exclude it for better comparisons: then with the same constants the only thing that should be different is the integration algorithm.

JimJCW said:
All calculators I tried use H0, Ωm and ΩΛ as input parameters and I use H0 = 67.74 km/s/Mpc, Ωm = 0.309 and ΩΛ = 0.691 for all of them.
Ah OK. Is Ωm = 0.309 correct or is it Ωm = 0.3089 as per Jorrie's defaults?
 
Last edited:
  • #75
pbuk said:
Ah OK. Is Ωm = 0.309 correct or is it Ωm = 0.3089 as per Jorrie's defaults?
Keep in mind that the accuracy of our knowledge of the Omega's is far worse than the rounding contributions. It is good to chase mathematical integrity in algorithms, but is it worth it to get far ahead of the quality of the observations that we work with?
 
  • #76
Jorrie said:
is it worth it to get far ahead of the quality of the observations that we work with?
Not in actual use, but in testing it is important to determine whether differences in results arise from different models or poor integration methods.
 
  • #77
pbuk said:
Ah OK. Is Ωm = 0.309 correct or is it Ωm = 0.3089 as per Jorrie's defaults?

See discussion in StackExchange:

1653645616295.png


If we change zeq from 3370 to 999998 in the current version of the calculator (i.e., neglect the radiation energy density), Ωm,0 will change from 0.3089 to 0.309.

In the current version, changing zeq in the calculator does not change the calculated Dnow. When it is fixed, we can compare the calculated Dnow using large zeq values with that calculated with the cosmic calculator (no radiation energy term).
 
  • #78
Hi @Ibix,

In the figures included in Post #70, Dv1.2.0(z) by @pbuk shows a small, systematic deviation from Dcosmic(z) near z = 0. It is interesting to see whether this is caused by the omission of the radiation term ΩR,0 in the cosmic model. Your python version includes the radiation term and may provide information concerning this. Would you please post your result with more digits? (See Post #57)

z
Gnedin
Jorrie, 2022
ibix
ibix_2
cosmic
Toth
0.11.410041.40841.411.4095921.409608
0.091.272141.2706091.271.271741.271756
0.081.133541.1321061.131.1331891.133219
0.070.994260.9929310.9940.9939440.993964
0.060.854270.853050.8540.8540050.854024
0.050.71360.7124770.7130.7133770.713399
0.040.572250.5712250.5720.5720630.57209
0.030.430230.4292780.430.4300650.430062
0.020.287480.2866510.280.2873850.287382
0.010.144080.143360.1440.1440290.144017
000.000621000
-0.010.144740.145260.1450.1446980.144702
-0.020.290150.2905670.290.2900610.290057
-0.030.436230.4365360.4360.4360840.436097
-0.040.582950.5831610.5830.5827630.582789
-0.050.730320.7304330.730.7300940.730101
-0.060.878340.8783580.8780.8780720.878098
-0.071.026991.0269261.031.0266881.026715
-0.081.176311.1761241.181.1759411.175951
-0.091.326231.3259681.331.3258241.32584
-0.11.476791.4764161.481.4763321.476349
 
  • #79
Hi @JimJCW,

Yes, this is part of my plan for generating test data. I am away on a sailing trip at the moment so can't work on it for a while though.
 
  • #80
Hi @Jorrie, @pbuk, @lbix,

I think the cosmology calculator by The International Centre for Radio Astronomy Research, ICRAR, can be useful for testing in our calculator development. It is written in R language and can have ΩR as an input parameter. The inputs to this calculator for PLANCK 2015 Data are:

H0 = 67.74​
ΩΛ = 0.691​
ΩR = 0.0000916 [obtained from ΩR = Ωm / (zeq + 1)]​
Ωm = 1 - 0.691 - 0.0000916 = 0.3089​

I have some questions about some of the terms:

What is the difference between ‘The Comoving Radial Distance LoS to z’ and ‘The Comoving Radial Distance Tran to z’?​
What is Sigma8[0]?​
 
Last edited:
  • #81
JimJCW said:
Hi @Jorrie, @pbuk, @lbix,

I think the cosmology calculator by The International Centre for Radio Astronomy Research, ICRAR, can be useful for testing in our calculator development. It is written in R language and can have ΩR as an input parameter. ...

I have some questions about some of the terms:

What is the difference between ‘The Comoving Radial Distance LoS to z’ and ‘The Comoving Radial Distance Tran to z’?​
What is Sigma8[0]?​
You will find the definitions of comoving distances in Hogg
(arXiv:astro-ph/9905116v4 16 Dec 2000) section 5.

I have no clue about Sigma8[0]
 
  • #83
JimJCW said:
In the figures included in Post #70, Dv1.2.0(z) by @pbuk shows a small, systematic deviation from Dcosmic(z) near z = 0. It is interesting to see whether this is caused by the omission of the radiation term ΩR,0 in the cosmic model. Your python version includes the radiation term and may provide information concerning this. Would you please post your result with more digits? (See Post #57)
I have posted results from Ibix's Python program below with a LOT more digits. I have also written a much better integrator for my Javascript code* which I am pleased to say agrees almost to machine precision with Python's scipy.integration.quad here. I have posted these results (with differing digits shown in bold) as "pbuk g7k15" below. I may be able to get this into GitHub and the demo site over the weekend.

I have also run Ibix's code with the radiation parameters ## \Omega_{R0} ## and ## \Omega_R ## removed. You can see from the table below that it doesn't make much difference so there must be some other reason for the differences from the other calculators.

z
Gnedin
Jorrie, 2022
ibix
pbuk g7k15
ibix no ## \Omega_R ##
cosmic
Toth
0.11.410041.40841.4096995371674351.4096995371674351.4097071.4095921.409608
0.091.272141.2706091.27183645996174401.27183645996174381.2718421.271741.271756
0.081.133541.1321061.1332757881107791.1332757881107791.1332801.1331891.133219
0.070.994260.9929310.99401986048914960.99401986048914960.9940230.9939440.993964
0.060.854270.853050.85407121547408080.85407121547408070.8540740.8540050.854024
0.050.71360.7124770.71343259282539450.71343259282539450.7134340.7133770.713399
0.040.572250.5712250.57210693537856640.57210693537856640.5721080.5720630.57209
0.030.430230.4292780.43009739054182380.43009739054182370.4300980.4300650.430062
0.020.287480.2866510.28740731158840520.28740731158840520.2874080.2873850.287382
0.010.144080.143360.14404025873529720.14404025873529720.1440400.1440290.144017
000.00062100000
-0.010.144740.145260.14470948817285470.14470948817285470.1447090.1446980.144702
-0.020.290150.2905670.29008402052289970.29008402052289970.2900840.2900610.290057
-0.030.436230.4365360.436119202830953620.436119202830953570.4361190.4360840.436097
-0.040.582950.5831610.58281043202858960.58281043202858970.5828090.5827630.582789
-0.050.730320.7304330.73015289656704170.73015289656704190.7301510.7300940.730101
-0.060.878340.8783580.87814157705166910.87814157705166910.8781390.8780720.878098
-0.071.026991.0269261.02677124714768621.02677124714768621.0267681.0266881.026715
-0.081.176311.1761241.17603647476232801.17603647476232781.1760331.1759411.175951
-0.091.326231.3259681.32593162350803271.32593162350803251.3259271.3258241.32584
-0.11.476791.4764161.47645085445058591.47645085445058591.4764451.4763321.476349

* Given that scipy.integrate.quad simply links the venerable Fortran library QUADPACK in, I am quite pleased that my Gauss-Kronrod [7, 15] implementation seems to perform as well, on this problem at least. I need to make sure it handles the discontinuity at ## s = 0 ## well and add transformation for the integration to ## \infty ## before I put it into the 'new' LightCone7.
 
  • #84
Hi @pbuk,

Thanks for the results (Post #83) obtained with the python program by @Ibix. It is nice to know that when the ΩR term is included, pbuk g7k15 = version (1.2.0) = ibix. Please confirm that if ΩR = 0, pbuk g7k15 = ibix is also true.

When comparing the various results, what do you think about using the following assumptions?

The cosmic calculator works properly when ΩR = 0.​
The ICRAR calculator works properly when the ΩR term is included.​
 
  • #85
pbuk said:
I need to make sure it handles the discontinuity at ## s = 0 ## well and add transformation for the integration to ## \infty ## before I put it into the 'new' LightCone7.
I presume you meant "at ## z = 0 ##" ?
There is no real discontinuity at z = 0. One could just as well have had distances (and some other outputs) go negative for future times (negative z). The reason the original Lightcone team have chosen to keep things positive was for better resolution on the vertical graph axis, while keeping the graphs vertically compact.

Maybe we should start talking about Lightcone8 (or X) due to the major rework and so avoid confusion...?
 
  • #86
JimJCW said:
Please confirm that if ΩR = 0, pbuk g7k15 = ibix is also true.
Yes this is true: the calculations in pbuk g7k15, ibix and jorrie are in fact identical except for the numerical integration method summarised below
  • jorrie uses a simple fixed step method with the 'glitch' in the title of this thread.
  • ibix uses Python's scipy.integrate.quad which links the ancient, well-tested FORTRAN 77 code QUADPACK.
  • pbuk g7k15 (note this is not yet the version used on the website) uses a new JavaScript routine written from scratch. I believe that for infinite ranges this uses the same transformation and underlying algorithm as QUADPACK (15-point Gauss-Kronrod), although there are differences in the error estimation and hence adaptive step calculations, however for finite ranges QUADPACK uses a higher order (21 point) method: this does not seem to make any material difference.

JimJCW said:
When comparing the various results, what do you think about using the following assumptions?

The cosmic calculator works properly when ΩR = 0.​
The ICRAR calculator works properly when the ΩR term is included.​
I'm not sure, other calculators seem to include other parameters, for instance Ned Wright's includes this:

JavaScript:
// by Ned Wright
// 25 Jul 1999 - revised 2 Dec 2005
// Copyright Edward L. Wright, all rights reserved.

// ...

// correction for annihilations of particles not present now like e+/e-
// added 13-Aug-03 based on T_vs_t.f
  var lpz = Math.log((1+1.0*z))/Math.log(10.0);
  var dzage = 0;
  if (lpz >  7.500) dzage = 0.002 * (lpz -  7.500);
  if (lpz >  8.000) dzage = 0.014 * (lpz -  8.000) +  0.001;
  if (lpz >  8.500) dzage = 0.040 * (lpz -  8.500) +  0.008;
  if (lpz >  9.000) dzage = 0.020 * (lpz -  9.000) +  0.028;
  if (lpz >  9.500) dzage = 0.019 * (lpz -  9.500) +  0.039;
  if (lpz > 10.000) dzage = 0.048;
  if (lpz > 10.775) dzage = 0.035 * (lpz - 10.775) +  0.048;
  if (lpz > 11.851) dzage = 0.069 * (lpz - 11.851) +  0.086;
  if (lpz > 12.258) dzage = 0.461 * (lpz - 12.258) +  0.114;
  if (lpz > 12.382) dzage = 0.024 * (lpz - 12.382) +  0.171;
  if (lpz > 13.055) dzage = 0.013 * (lpz - 13.055) +  0.188;
  if (lpz > 14.081) dzage = 0.013 * (lpz - 14.081) +  0.201;
  if (lpz > 15.107) dzage = 0.214;
  zage = zage*Math.pow(10.0,dzage);

There is clearly a lot more to this than I realized at first: I'm just a humble coder :wink:
 
Last edited:
  • #87
Jorrie said:
I presume you meant "at ## z = 0 ##" ?
Well I meant at ## s = 0 ## because I was confusing the calculation of ## T_{now} = \int_{s=S}^\infty \frac{1}{sH(s)} ## with ## D_{hor} = \frac1S \int_{s=0}^S \frac{1}{H(s)} ## and thinking we had to compute ## \int_{s=0}^S \frac{1}{sH(s)} ## somewhere! So there is no discontinuity: that's good, my integrator doesn't handle discontinuities as well as QUADPACK.

Jorrie said:
Maybe we should start talking about Lightcone8 (or X) due to the major rework and so avoid confusion...?
Yes, a bit of housekeeping to do here.
 
  • #88
It may be interesting to compare Dnow vs z curves from different calculators for larger z values. The result is shown below:

1655119700106.png

This suggests that for large z values, the results from all these calculators are almost indistinguishable and the glitch discussed in this thread is very small. I am working on the comparison for small z values.

Note that DJorrie,2021 is the modified version discussed in Posts #15 and #17.
 
  • #89
In the following discussion, I assume that the ICRAR calculator works properly and use it as a reference for comparison.

1655205630253.png


1655205656099.png


These figures suggest that there exist real discrepancies among the three calculators. When we modify and/or rewrite Jorrie’s calculator, maybe we can use ICRAR calculator as a tool for testing.
 
  • #90
JimJCW said:
When we modify and/or rewrite Jorrie’s calculator, maybe we can use ICRAR calculator as a tool for testing.
It's already rewritten, now working here: https://light-cone-calc.github.io. There's not much point testing it against the ICRAR calculator though as that uses a more sophisticated model.
 
  • #91
pbuk said:
It's already rewritten, now working here: https://light-cone-calc.github.io. There's not much point testing it against the ICRAR calculator though as that uses a more sophisticated model.

Great! I can make more comparisons.

Please explain what you mean by “. . . the ICRAR calculator . . . uses a more sophisticated model”. Doesn’t it calculate the same Dnow?
 
  • #92
JimJCW said:
Please explain what you mean by “. . . the ICRAR calculator . . . uses a more sophisticated model”. Doesn’t it calculate the same Dnow?
Not exactly, there is a much more sophisticated treatment of dark energy. You can see the code (in R) if you go to https://cosmocalc.icrar.org/ and click the "R code" tab.
 
  • #93
pbuk said:
Not exactly, there is a much more sophisticated treatment of dark energy. You can see the code (in R) if you go to https://cosmocalc.icrar.org/ and click the "R code" tab.

How about comparing the cosmic model with your new version (setting ΩR = 0)? Similar discrepancy exists.
 
  • #94
JimJCW said:
How about comparing the cosmic model with your new version (setting ΩR = 0)? Similar discrepancy exists.
Rather than reverse engineer output I'd rather look at the implementations themselves. For instance the constants used in Jorrie's original model include these:
JavaScript:
// https://github.com/light-cone-calc/light-cone-calc/blob/main/src/model.ts
const physicalConstants = {
  rhoConst: 1.7885e9, // 3 / (8 pi G)
  secInGy: 3.1536e16, // s / Gyr
  tempNow: 2.725, // CMB temperature now
  convertToGyr: 1 / 978, // Convert km/s/Mpc -> Gyr^-1
};

whereas cosmic uses these

C++:
// https://github.com/joshkempner/Cosmic.NET/blob/main/Cosmic.NET/cosmo/Cosmo.cs
        private const double c = 2.99792458e5; // speed of light
        private const double G = 6.67259e-8;   // gravitational constant
        private const double KmPerMpc = 3.08567758e19;
        private const double TropicalYear = 3.1556926e7; // in seconds

Also, as noted in the code, I'm not sure about the calculation of ## \Omega_m ##
JavaScript:
//  s_eq: 1 + 3370, // Stretch when OmegaM=OmegaR
...

  //@TODO check this - should it be s_eq + 1 as the original, or as below
  // from Ibix?
  // const OmegaM = ((Omega - OmegaL) * s_eq) / (s_eq + 1); // Energy density of matter
  // const OmegaR = OmegaM / s_eq; // Energy density of radiation
  const OmegaM = ((Omega - OmegaL) * (s_eq + 1)) / (s_eq + 2); // Energy density of matter

A better place to discuss this is probably https://github.com/light-cone-calc/light-cone-calc/issues - in fact I've already noted the last point here https://github.com/light-cone-calc/light-cone-calc/issues/6.
 
  • #95
Pbuk, Jim and Ibix, thanks for your great work!
We have a local 4-day weekend starting tomorrow, so I will take a look good at your Lightcone8 version and also at the issue that you raised on Github and discuss it there.
 
  • Like
Likes berkeman and pbuk
  • #96
Yes, There is an error in my old Legacy js code, line 356
Ibix is correct, i.e.
// const OmegaM = ((Omega - OmegaL) * s_eq) / (s_eq + 1); // Energy density of matter

Tiny, tiny influence, considering the uncertainty on the z_eq value.

@pbuk, which one did you use in Lightcone8?
 
  • #97
Jorrie said:
Ibix is correct, i.e.
// const OmegaM = ((Omega - OmegaL) * s_eq) / (s_eq + 1); // Energy density of matter

Tiny, tiny influence, considering the uncertainty on the z_eq value.
Yes of course.

Jorrie said:
@pbuk, which one did you use in Lightcone8?
I used yours, but it's a quick fix.
 
  • #98
Jorrie said:
Tiny, tiny influence, considering the uncertainty on the z_eq value.
Tiny but important: this was the remaining part of the problem causing the offset at z = 0.

Code:
z: 0
Dnow: 3.552713678800501e-15
Dthen: 3.552713678800501e-15
Vnow: 2.460744627831758e-16
Vthen: 2.4607446278317573e-16
These values should all be 0 of course. Now fixed.
 
  • #99
pbuk said:
Code:
z: 0
Dnow: 3.552713678800501e-15
Dthen: 3.552713678800501e-15
Vnow: 2.460744627831758e-16
Vthen: 2.4607446278317573e-16
These values should all be 0 of course. Now fixed.
Great stuff! I will link https://light-cone-calc.github.io/ in my signature and you can do the same, if you so wish.
Maybe do a last edit to take some credit for the improvement?
 
  • #100
Hi @Jorrie, @pbuk,

When trying LightCone8, I noticed that if zlower = 0, a duplicated line is printed at z = 0. For example:

1655545085892.png
 
  • #101
JimJCW said:
Hi @Jorrie, @pbuk,

When trying LightCone8, I noticed that if zlower = 0, a duplicated line is printed at z = 0.
Thanks for that, it is an unintended side effect of fixing the range so it includes z = 0 instead of z = 1e-6 for instance. I'll fix the fix.
 
  • #102
Hi @Jorrie, @pbuk,

Let’s review the current situation of Jorrie’s calculator. First, LightCone8 updated by @pbuk has eliminated the glitch discussed in this thread (see Post #1):

1655861803812.png


ICRAR is an online calculator that includes ΩR,0 as an input parameter, just like LightCone8 (zeq = 3370). A comparison of the calculated Dnow’s using the two models is shown below:

1655861880350.png


The two results are almost indistinguishable. However, when their difference is plotted against z, the result shows,

1655861932658.png


The fact that ‘ICRAR - LightCone8’ is not a horizontal line near y = 0 suggests that there exists discrepancy between the two calculators. To look into this further, we note that ICRAR (ΩR=0), LightCone8 (ΩR=0), and cosmic (no ΩR) should give the same results, but they don’t:

1655862011899.png


The figure suggests that when ΩR=0, ICRAR and cosmic are consistent with each other, but not with LightCone8. The source of this discrepancy is unknown. It would be nice, though, to be able to identify it.

To summarize:

LightCone8 has removed the glitch discussed in this thread. However, it is noticed that there exist discrepancies between LightCone8 and some other online calculators, such as ICRAR and cosmic.​
 
  • #103
JimJCW said:
The figure suggests that when ΩR=0, ICRAR and cosmic are consistent with each other, but not with LightCone8. The source of this discrepancy is unknown. It would be nice, though, to be able to identify it.
My first suspicion is the values of certain constants, particularly the conversion factor from ## km\\s^{-1}\\Mpsc^{-1} ## to ## Gyr^{-1} ## which is a simple ## \frac 1 {978} ## in LightCone8 instead of something like ## \frac{365.2421897 \times 86400 \times 1000000 \pi}{96939420213600000} ##.

I've raised an issue and will look at it: https://github.com/light-cone-calc/light-cone-calc/issues/11
 
  • #104
I have commented on the Github issues page.
 
  • #105
Hi @Jorrie and @pbuk,

I noticed some discrepancies in results from LightCone8. Let’s use the following input values:

1656585579240.png


Equations in Tutorial, part III,

Ωm = (Ω - ΩΛ) Seq / (1 + Seq), where Seq = zeq + 1​
ΩR = Ωm / Seq

give,

Ωm = 0.308908363
ΩR = 0.000091637

These numbers are compared with output of LightCone8 below:

z
OmegaM
OmegaL
OmegaR
OmegaT
LightCone8
0​
0.309000000​
6.910000000
0.00009169139​
1.000091691​
From Equations
0​
0.308908363​
6.91​
0.000091637​
1​

Note that under Conversions in the output, LightCone8 gives,

1656585842082.png


Conclusion: The values of Ωm and ΩT calculated with LightCone8 are questionable.
 

Similar threads

Replies
100
Views
6K
Replies
19
Views
2K
Replies
18
Views
2K
Replies
4
Views
2K
Replies
0
Views
1K
Back
Top