SWIFTSIM / SWIFT

Modern astrophysics and cosmology particle-based code. Mirror of gitlab developments at https://gitlab.cosma.dur.ac.uk/swift/swiftsim
http://www.swiftsim.com
GNU Lesser General Public License v3.0
88 stars 58 forks source link

Precision problem when reading ICs #41

Closed rennehan closed 4 months ago

rennehan commented 9 months ago

Hi, I generated cosmological dark-matter-only ICs for Swift using Python (h5py + numpy).

Specifically, I'm using Python 3.9.12 (Miniconda + gcc 7.5.0), numpy 1.22.4, and h5py 3.6.0.

I wrote out my ICs with an initial starting scale factor of 0.008, using the above libraries.

When I tried to run Swift (with debugging checks), I had the following output near the very start of the run:

[0000] [00000.0] main: Using ParMETIS partitioning: [0000] [00000.0] main: initial partitioning: memory and edge balanced cells using particle weights [0000] [00000.0] main: repartitioning: edge and vertex task cost weights [0000] [00000.1] main: Internal unit system: U_M = 1.988410e+43 g. [0000] [00000.1] main: Internal unit system: U_L = 3.085678e+24 cm. [0000] [00000.2] main: Internal unit system: U_t = 3.085678e+19 s. [0000] [00000.2] main: Internal unit system: U_I = 1.000000e+00 A. [0000] [00000.2] main: Internal unit system: U_T = 1.000000e+00 K. [0000] [00000.2] phys_const_print: Gravitational constant = 4.300918e+01 [0000] [00000.2] phys_const_print: Speed of light = 2.997925e+05 [0000] [00000.2] phys_const_print: Planck constant = 1.079940e-99 [0000] [00000.2] phys_const_print: Boltzmann constant = 6.943482e-70 [0000] [00000.2] phys_const_print: Thomson cross-section = 6.986845e-74 [0000] [00000.2] phys_const_print: Electron-Volt = 8.057577e-66 [0000] [00000.2] phys_const_print: Vacuum permeability = 1.950089e-30 [0000] [00000.2] phys_const_print: Proton mass = 8.411856e-68 [0000] [00000.2] phys_const_print: Year = 1.022690e-12 [0000] [00000.2] phys_const_print: Parsec = 1.000000e-06 [0000] [00000.2] phys_const_print: Astronomical Unit = 4.848137e-12 [0000] [00000.2] phys_const_print: Earth radius = 2.067001e-16 [0000] [00000.2] phys_const_print: Solar mass = 1.000000e-10 [0000] [00000.2] phys_const_print: Solar luminosity = 5.940412e-01 [0000] [00000.2] phys_const_print: H_0 / h = 100 km/s/Mpc = 1.000000e+02 [0000] [00000.2] phys_const_print: T_CMB0 = 2.725500e+00 [0001] [00000.7] cosmology.c:cosmology_get_time_since_big_bang():207: Error a can't be smaller than a_begin [0004] [00000.7] cosmology.c:cosmology_get_time_since_big_bang():207: Error a can't be smaller than a_begin

I specified a_begin in the parameter file as 0.008.

This is a precision issue that can be avoided if I set a_begin = 0.07999999. I'm not sure why this is happening, but it should be reproducible.

JBorrow commented 9 months ago

If you upload an example IC and parameter file we could take a look, but this isn't enough information to reproduce the issue.

We do have a specific code for writing out SWIFT-compatible IC files, units and all: https://swiftsimio.readthedocs.io/en/latest/creating_initial_conditions/index.html