jmd-dk / concept

COsmological N-body CodE in PyThon
GNU General Public License v3.0
80 stars 27 forks source link

Is the Omega_cdm parameter actually important in the simulation? #6

Closed nihargupte-ph closed 3 years ago

nihargupte-ph commented 3 years ago

Hi! First of all great program, it was a breeze to install. I have one question/issue I would like to ask regarding the importance of Cosmology parameters in the simulation. I tried changing around Ωcdm, Ωb and H0 to see the variation in the simulation. However, after doing so and saving snapshots at many different times for each simulation I noticed that the simulations are very similar in their renders and even plotting them (using scatter) they are almost the same even with wildly different parameters. Is this expected behavior? For reference here are two screenshots of simulations at a=0.3877 with the first picture as parameters:

H0 = 67km/(sMpc) Ωcdm = 0.27 Ωb = 0.049

and the second:

H0 = 90km/(sMpc) Ωcdm = 0.46 Ωb = 0.049 a_begin = 0.05

render2D_a=0 387786

render2D_a=0 3877

jmd-dk commented 3 years ago

Thanks for trying out CONCEPT.

I think that's fine. Renders are not great for distinguishing cosmologies. Especially not with that low resolution. If you want to see a difference, comparing the power spectra of the two simulations is the way to go.

If pretty pictures is the end goal, I see the problem. By default, CONCEPT tries to enhance the contrast of each 2D render in order to obtain as nice a render as possible. In order to objectively compare two renders, you should deactivate this enhancement; just set the value of 'enhance' in render2D_options to False rather than True (see the example_params parameter file). Without enhancement I'm afraid the renders will generally look more dull. You can probably counteract this by slightly increasing the value of 'A_s' in the primordial_spectrum parameter.

Also, you may find it fun to play around with random_seed, giving it a value of 1 or 2 or 3, etc.

nihargupte-ph commented 3 years ago

Got it thank you, the random_seed part of your answer helps me a lot as well. I am also having another question and that is can I explicitly set the output times to a specific cosmic time (in Gyr) instead of the output_times in terms of the "a" variable. ie in

output_times = {
    'snapshot' : [0.7, 0.9, 1.0],
    'powerspec': [0.7, 0.9, 1.0],
    'render3D' : [0.7, 0.9, 1.0],
    'render2D' : [0.7, 0.9, 1.0],
}

I am working with the dynamical dark energy setting values of w0 to -1 or -.5 (or somewhere in between) and when I run the simulation the output times are different in Gyr. For reference here is my full parameter file:


# Non-parameter variable used to control the size of the simulation
_size = 64

random_seed = 1

# Input/output
initial_conditions = {
    'species': 'matter',
    'N'      : _size**3,
}
output_dirs = {
    'snapshot' : paths['output_dir'] + '/' + basename(paths['params']),
    'powerspec': ...,
    'render2D' : ...,
    'render3D' : ...,
}

output_times = {
    'snapshot' : [0.7, 0.9, 1.0],
    'powerspec': [0.7, 0.9, 1.0],
    'render3D' : [0.7, 0.9, 1.0],
    'render2D' : [0.7, 0.9, 1.0],
}

powerspec_select = {
    'matter': {'data': True, 'plot': False},
}
render2D_select = {
    'matter': {'data': False, 'image': True, 'terminal image': False},
}

# Numerical parameters
boxsize = 128*Mpc

# Cosmology
H0      = 67*km/(s*Mpc)
Ωcdm    = 0.27
Ωb      = 0.049
a_begin = 0.1

if _de != 'Lambda':
    class_params = {
        # Disable cosmological constant
        'Omega_Lambda': 0,
        # Dark energy fluid parameters
        'w0_fld' : -0.4044250522675218,
        'wa_fld' : 0,
        'cs2_fld': 0,
    }

# Physics
select_forces = {  # Forces and methods which act on each component
    'particles': {'gravity': ('p3m', 2*_size)},
    'fluid'    : {'gravity': 'pm'},
}
# Non-parameter helper variables which should
# be supplied as command-line parameters.
_de  = 'dynamical'  # Type of dark energy
_lin = ''        # Linear species to include

# Graphics
render2D_options = {
    'gridsize': {
        'matter': 3*_size,
    },
    'colormap': {
        'matter': 'inferno',
    },
    'enhance': {
        'all': False,
    },
}

So above if I change the w0_fld=-0.08789008148539856 the simulation will output a 10.31Gyr snapshot at a=1 and if I have w0_fld=-0.4044250522675218 the simulation will output 12.04 Gyr snapshot at a=1. Is this intentional behavior? Thank you!

jmd-dk commented 3 years ago

Yes, this is intended behavior. Having a = 1 just means "today", but the actual age of the universe today depend upon the cosmological parameters. Often you really do want to compare different cosmologies at the same a, even though this corresponds to different times. If you want to compare cosmologies at the same time/age (but then necessarily different a), you can specify the output times like so:

output_times = {
    't': {
        'snapshot' : [8*Gyr, 9*Gyr, 10*Gyr],
        'powerspec': ...,
        'render3D' : ...,
        'render2D' : ...,
   },
}

(Note that the ... is actually valid syntax, meaning "the same values as above"). You can also mix these cosmic times with scale factor values:

output_times = {
    't': {
        'snapshot' : [8*Gyr, 9*Gyr, 10*Gyr],
        'powerspec': ...,
        'render3D' : ...,
        'render2D' : ...,
   },
    'a': {
        'snapshot' : 1,
        'powerspec': ...,
        'render3D' : ...,
        'render2D' : ...,
    },
}
nihargupte-ph commented 3 years ago

Perfect, thank you, Jeppe. I am currently working on a project aiming to use machine-learning on N-body simulations. I will be sure to cite this very helpful code!