# This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particles N = 8 mass = ρ_mbar * boxsize**3 / N components = Component('GADGET halos', 'matter', N=N, mass=mass) d = 0.005 components.populate( np.array([0.25 - d] * 4 + [0.75 + d] * 4) * boxsize, 'posx') components.populate(np.array([0.25, 0.25, 0.75, 0.75] * 2) * boxsize, 'posy') components.populate(np.array([0.25, 0.75, 0.75, 0.25] * 2) * boxsize, 'posz') components.populate(zeros(N), 'momx') components.populate(zeros(N), 'momy') components.populate(zeros(N), 'momz') # Save snapshot save(components, initial_conditions)
# # You should have received a copy of the GNU General Public License # along with CO𝘕CEPT. If not, see http://www.gnu.org/licenses/ # # The author of CO𝘕CEPT can be contacted at dakin(at)phys.au.dk # The latest version of CO𝘕CEPT is available at # https://github.com/jmd-dk/concept/ # This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particle N = 1 mass = ρ_mbar*boxsize**3/N particles = Component('test particles', 'matter particles', N, mass=mass) particles.populate(np.array([0.75])*boxsize, 'posx') particles.populate(np.array([0.75])*boxsize, 'posy') particles.populate(np.array([0.75])*boxsize, 'posz') particles.populate(ones(N)*boxsize/(10*units.Gyr)*mass, 'momx') particles.populate(ones(N)*boxsize/(10*units.Gyr)*mass, 'momy') particles.populate(ones(N)*boxsize/(10*units.Gyr)*mass, 'momz') # Save snapshot save(particles, initial_conditions)
gridsize = 64 speed = a_begin**2 * boxsize / (0.5 * units.Gyr) N = gridsize # Number of particles N_fluidelements = gridsize**3 # Number of fluid elements Vcell = (boxsize / gridsize)**3 mass_tot = ρ_mbar * boxsize**3 mass_fluid_tot = mass_particles_tot = 0.5 * mass_tot mass_fluid = mass_fluid_tot / N_fluidelements # Mass of each fluid element mass_particles = mass_particles_tot / N # Mass of each particle component = Component('test fluid', 'matter', gridsize=gridsize) ϱ = empty([gridsize] * 3, dtype=float) for i in range(gridsize): ϱ[i, :, :] = 2 + sin(2 * π * i / gridsize) # Unitless ϱ /= sum(ϱ) # Normalize ϱ *= mass_fluid_tot / Vcell # Apply units component.populate(ϱ, 'ϱ') component.populate(ϱ * speed, 'J', 0) component.populate(zeros([gridsize] * 3, dtype=float), 'J', 1) component.populate(ϱ * speed * random_uniform(-1, 1), 'J', 2) components.append(component) # Create the particles. # These are N particles strewn uniformly over the x-axis, with a velocity # only in the x-direction. These should then remain equally spaced # in the x-direction throughout time, each following a specific fluid element. # The y-positions are given by a sine (in order to match # these against the fluid density profile) and the z-positions are random. component = Component('control particles', 'matter', N=N, mass=mass_particles) offset = 0.5 * boxsize A = 0.4 * boxsize component.populate(linspace(0, boxsize, N, endpoint=False), 'posx')
# This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from linear import random_uniform from species import Component from snapshot import save # Create a global sine wave along the x-direction, # traversing the box in the x-direction over 10 Gyr. # The y-velocity is 0 and the z-velocity is random. gridsize = 64 Vcell = (boxsize / gridsize)**3 speed = boxsize / (10 * units.Gyr) component = Component('test fluid', 'matter', gridsize=gridsize) ϱ = empty([gridsize] * 3, dtype=float) for i in range(gridsize): ϱ[i, :, :] = 2 + sin(2 * π * i / gridsize) # Unitless ϱ /= sum(ϱ) # Normalize ϱ *= ρ_mbar * gridsize**3 # Apply units component.populate(ϱ, 'ϱ') component.populate(ϱ * speed, 'J', 0) component.populate(zeros([gridsize] * 3, dtype=float), 'J', 1) component.populate(ϱ * speed * random_uniform(-1, 1), 'J', 2) # Save snapshot save(component, initial_conditions)
# This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create a global sine wave along the x-direction, # traversing the box in the x-direction over 10 Gyr. # The y-velocity is 0 and the z-velocity is random. gridsize = 64 Vcell = (boxsize/gridsize)**3 speed = boxsize/(10*units.Gyr) N = gridsize**3 component = Component('test fluid', 'matter fluid', gridsize) ϱ = empty([gridsize]*3) for i in range(gridsize): ϱ[i, :, :] = 2 + np.sin(2*π*i/gridsize) # Unitless ϱ /= sum(ϱ) # Normalize ϱ *= ϱ_mbar*gridsize**3 # Apply units component.populate(ϱ, 'ϱ' ) component.populate(ϱ*speed, 'J', 0) component.populate(zeros([gridsize]*3), 'J', 1) component.populate(ϱ*speed*(random()*2 - 1), 'J', 2) # Save snapshot save(component, initial_conditions)
from commons import * from species import Component from snapshot import save # Create stationary, homogeneous matter distribution, # perturbed with global, stationary sine wave along # the x-direction. w = user_params['_w'] ρ0 = user_params['_ρ0'] A = user_params['_A'] σ = user_params['_σ'] gridsize = 4 * 16 # Should be a multiple of 4 N = gridsize**3 component = Component('test fluid', 'matter fluid', gridsize, boltzmann_order=2) ρ = empty([gridsize] * 3) for i in range(gridsize): x = boxsize * i / gridsize ρ[i, :, :] = ρ0 + A * sin(x / boxsize * 2 * π) component.populate(ρ, 'ϱ') for multi_index in component.J.multi_indices: component.populate(zeros([gridsize] * 3), 'J', multi_index) for multi_index in component.ς.multi_indices: component.populate( ones([gridsize] * 3) * ρ * (1 + w) * σ, 'ς', multi_index) # Save snapshot save(component, initial_conditions)
gridsize = 64 speed = a_begin**2 * boxsize / (0.5 * units.Gyr) N = gridsize # Number of particles N_fluidelements = gridsize**3 # Number of fluid elements Vcell = (boxsize / gridsize)**3 mass_tot = ϱ_mbar * boxsize**3 mass_fluid_tot = mass_particles_tot = 0.5 * mass_tot mass_fluid = mass_fluid_tot / N_fluidelements # Mass of each fluid element mass_particles = mass_particles_tot / N # Mass of each particle component = Component('test fluid', 'matter fluid', gridsize) ϱ = empty([gridsize] * 3) for i in range(gridsize): ϱ[i, :, :] = 2 + np.sin(2 * π * i / gridsize) # Unitless ϱ /= sum(ϱ) # Normalize ϱ *= mass_fluid_tot / Vcell # Apply units component.populate(ϱ, 'ϱ') component.populate(ϱ * speed, 'J', 0) component.populate(zeros([gridsize] * 3), 'J', 1) component.populate(ϱ * speed * (random() * 2 - 1), 'J', 2) components.append(component) # Create the particles. # These are N particles strewn uniformly over the x-axis, with a velocity # only in the x-direction. These should then remain equally spaced # in the x-direction throughout time, each following a specific fluid element. # The y-positions are given by a sine (in order to match # these against the fluid density profile) and the z-positions are random. component = Component('control particles', 'matter particles', N, mass=mass_particles)
posx = zeros(N) posy = zeros(N) posz = zeros(N) momx = zeros(N) momy = zeros(N) momz = zeros(N) x = 0 count = 0 for i in range(Nx): for j in range(Ny): y = j/Ny*boxsize for k in range(Nz): z = k/Nz*boxsize posx[count] = x posy[count] = y posz[count] = z count += 1 if i < Nx - 1: x = binary_search(x, mass_unitless) # Instantiate particles particles = Component('control particles', 'matter particles', N, mass=mass) particles.populate(posx, 'posx') particles.populate(posy, 'posy') particles.populate(posz, 'posz') particles.populate(momx, 'momx') particles.populate(momy, 'momy') particles.populate(momz, 'momz') # Save snapshot save(particles, initial_conditions)
# # You should have received a copy of the GNU General Public License # along with CO𝘕CEPT. If not, see http://www.gnu.org/licenses/ # # The author of CO𝘕CEPT can be contacted at dakin(at)phys.au.dk # The latest version of CO𝘕CEPT is available at # https://github.com/jmd-dk/concept/ # This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particles N = 4 mass = ρ_mbar*boxsize**3/N particles = Component('GADGET halos', 'matter particles', N, mass=mass) particles.populate(np.array([0.1]*N)*boxsize, 'posx') particles.populate(np.array([0.25, 0.25, 0.75, 0.75])*boxsize, 'posy') particles.populate(np.array([0.25, 0.75, 0.75, 0.25])*boxsize, 'posz') particles.populate(ones(N)*100*units.km/units.s*mass, 'momx') particles.populate(zeros(N), 'momy') particles.populate(zeros(N), 'momz') # Save snapshot save(particles, initial_conditions)
# This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create homogeneous matter distribution perturbed # with a global sine wave along the x-direction. gridsize = 24 component = Component('matter', 'matter', gridsize=gridsize) x = (0.5 + arange(gridsize)) * boxsize / gridsize f = gridsize // 3 // 2 y = cos(f * π / boxsize * x + π / 4) ϱ = empty([gridsize] * 3, dtype=float) for i in range(gridsize): ϱ[i, :, :] = 2 + y[i] # Unitless ϱ /= sum(ϱ) # Normalize ϱ *= ρ_mbar * gridsize**3 # Apply units component.populate(ϱ, 'ϱ') for index in component.J.multi_indices: component.populate(zeros([gridsize] * 3, dtype=float), 'J', index) # Save snapshot save(component, output_dirs['snapshot'] + '/sine.hdf5')
# For the stationary tile test, increase the particle mass # in order to enhance any possible erroneous evolution. if subtest == 'tile': mass *= 10 # Distribute particles into multiple components posx = collections.defaultdict(list) posy = collections.defaultdict(list) posz = collections.defaultdict(list) for n, (x, y, z) in enumerate(pos): n %= ncomponents posx[n].append(x) posy[n].append(y) posz[n].append(z) components = [] for n in range(ncomponents): N = len(posx[n]) component = Component(f'component{n}', 'matter', N=N, mass=mass) component.populate(asarray(posx[n]), 'posx') component.populate(asarray(posy[n]), 'posy') component.populate(asarray(posz[n]), 'posz') component.populate(zeros(N), 'momx') component.populate(zeros(N), 'momy') component.populate(zeros(N), 'momz') components.append(component) # Save snapshot save(components, initial_conditions)
# The latest version of CO𝘕CEPT is available at # https://github.com/jmd-dk/concept/ # This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create a global sine wave along the x-direction, # traversing the box in the x-direction over 10 Gyr. # The y-velocity is 0 and the z-velocity is random. gridsize = 64 Vcell = (boxsize / gridsize)**3 speed = boxsize / (10 * units.Gyr) N = gridsize**3 component = Component('test fluid', 'matter fluid', gridsize) ϱ = empty([gridsize] * 3) for i in range(gridsize): ϱ[i, :, :] = 2 + np.sin(2 * π * i / gridsize) # Unitless ϱ /= sum(ϱ) # Normalize ϱ *= ρ_mbar * gridsize**3 # Apply units component.populate(ϱ, 'ϱ') component.populate(ϱ * speed, 'J', 0) component.populate(zeros([gridsize] * 3), 'J', 1) component.populate(ϱ * speed * (random() * 2 - 1), 'J', 2) # Save snapshot save(component, initial_conditions)
mass = π**2 / ((2 + 8 * sqrt(2)) * G_Newton) * distance**3 / T**2 # For the stationary tile test, increase the particle mass # in order to enhance any possible erroneous evolution. if subtest == 'tile': mass *= 10 # Distribute particles into multiple components posx = collections.defaultdict(list) posy = collections.defaultdict(list) posz = collections.defaultdict(list) for n, (x, y, z) in enumerate(pos): n %= ncomponents posx[n].append(x) posy[n].append(y) posz[n].append(z) components = [] for n in range(ncomponents): N = len(posx[n]) component = Component(f'component{n}', 'matter', N=N, mass=mass) component.populate(asarray(posx[n]), 'posx') component.populate(asarray(posy[n]), 'posy') component.populate(asarray(posz[n]), 'posz') component.populate(zeros(N, dtype=float), 'momx') component.populate(zeros(N, dtype=float), 'momy') component.populate(zeros(N, dtype=float), 'momz') components.append(component) # Save snapshot save(components, initial_conditions)
momx = zeros(N) momy = zeros(N) momz = zeros(N) count = 0 boxsize_over_N_lin = boxsize/N_lin for i in range(N_lin): X = i*boxsize_over_N_lin for j in range(N_lin): Y = j*boxsize_over_N_lin for k in range(N_lin): Z = k*boxsize_over_N_lin posx[count] = mod(random_gaussian(X, R_tophat), boxsize) posy[count] = mod(random_gaussian(Y, R_tophat), boxsize) posz[count] = mod(random_gaussian(Z, R_tophat), boxsize) count += 1 component.populate(posx, 'posx') component.populate(posy, 'posy') component.populate(posz, 'posz') component.populate(momx, 'momx') component.populate(momy, 'momy') component.populate(momz, 'momz') # Save snapshot save(component, initial_conditions) # Expand particle locations by a factor of 2 posx = component.posx posy = component.posy posz = component.posz for i in range(N): posx[i] *= 2
# This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create stationary, homogeneous matter distribution, # perturbed with global, stationary sine wave along # the x-direction. w = user_params['_w'] ρ0 = user_params['_ρ0'] A = user_params['_A'] σ = user_params['_σ'] gridsize = 4*16 # Should be a multiple of 4 N = gridsize**3 component = Component('test fluid', 'matter fluid', gridsize, boltzmann_order=2) ρ = empty([gridsize]*3) for i in range(gridsize): x = boxsize*i/gridsize ρ[i, :, :] = ρ0 + A*sin(x/boxsize*2*π) component.populate(ρ, 'ϱ') for multi_index in component.J.multi_indices: component.populate(zeros([gridsize]*3), 'J', multi_index) for multi_index in component.ς.multi_indices: component.populate(ones([gridsize]*3)*ρ*(1 + w)*σ, 'ς', multi_index) # Save snapshot save(component, initial_conditions)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CO𝘕CEPT. If not, see http://www.gnu.org/licenses/ # # The author of CO𝘕CEPT can be contacted at dakin(at)phys.au.dk # The latest version of CO𝘕CEPT is available at # https://github.com/jmd-dk/concept/ # This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particles N = 4 mass = ρ_mbar * boxsize**3 / N particles = Component('GADGET halos', 'matter particles', N, mass=mass) particles.populate(np.array([0.1] * N) * boxsize, 'posx') particles.populate(np.array([0.25, 0.25, 0.75, 0.75]) * boxsize, 'posy') particles.populate(np.array([0.25, 0.75, 0.75, 0.25]) * boxsize, 'posz') particles.populate(ones(N) * 100 * units.km / units.s * mass, 'momx') particles.populate(zeros(N), 'momy') particles.populate(zeros(N), 'momz') # Save snapshot save(particles, initial_conditions)
momx = zeros(N) momy = zeros(N) momz = zeros(N) count = 0 boxsize_over_N_lin = boxsize / N_lin for i in range(N_lin): X = i * boxsize_over_N_lin for j in range(N_lin): Y = j * boxsize_over_N_lin for k in range(N_lin): Z = k * boxsize_over_N_lin posx[count] = mod(random_gaussian(X, R_tophat), boxsize) posy[count] = mod(random_gaussian(Y, R_tophat), boxsize) posz[count] = mod(random_gaussian(Z, R_tophat), boxsize) count += 1 component.populate(posx, 'posx') component.populate(posy, 'posy') component.populate(posz, 'posz') component.populate(momx, 'momx') component.populate(momy, 'momy') component.populate(momz, 'momz') # Save snapshot save(component, initial_conditions) # Expand particle locations by a factor of 2 posx = component.posx posy = component.posy posz = component.posz for i in range(N): posx[i] *= 2
# This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particles N = 8 mass = ρ_mbar * boxsize**3 / N components = Component('GADGET halo', 'matter', N=N, mass=mass) d = 0.005 components.populate(asarray([0.25 - d] * 4 + [0.75 + d] * 4) * boxsize, 'posx') components.populate(asarray([0.25, 0.25, 0.75, 0.75] * 2) * boxsize, 'posy') components.populate(asarray([0.25, 0.75, 0.75, 0.25] * 2) * boxsize, 'posz') components.populate(zeros(N, dtype=float), 'momx') components.populate(zeros(N, dtype=float), 'momy') components.populate(zeros(N, dtype=float), 'momz') # Save snapshot save(components, initial_conditions)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with CO𝘕CEPT. If not, see http://www.gnu.org/licenses/ # # The author of CO𝘕CEPT can be contacted at dakin(at)phys.au.dk # The latest version of CO𝘕CEPT is available at # https://github.com/jmd-dk/concept/ # This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particle N = 1 mass = ρ_mbar * boxsize**3 / N particles = Component('test particles', 'matter particles', N, mass=mass) particles.populate(np.array([0.75]) * boxsize, 'posx') particles.populate(np.array([0.75]) * boxsize, 'posy') particles.populate(np.array([0.75]) * boxsize, 'posz') particles.populate(ones(N) * boxsize / (10 * units.Gyr) * mass, 'momx') particles.populate(ones(N) * boxsize / (10 * units.Gyr) * mass, 'momy') particles.populate(ones(N) * boxsize / (10 * units.Gyr) * mass, 'momz') # Save snapshot save(particles, initial_conditions)
# You should have received a copy of the GNU General Public License # along with CO𝘕CEPT. If not, see http://www.gnu.org/licenses/ # # The author of CO𝘕CEPT can be contacted at dakin(at)phys.au.dk # The latest version of CO𝘕CEPT is available at # https://github.com/jmd-dk/concept/ # This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particles N = 8 mass = ρ_mbar*boxsize**3/N components = Component('GADGET halos', 'matter particles', N, mass=mass) d = 0.005 components.populate(np.array([0.25 - d]*4 + [0.75 + d]*4)*boxsize, 'posx') components.populate(np.array([0.25, 0.25, 0.75, 0.75]*2) *boxsize, 'posy') components.populate(np.array([0.25, 0.75, 0.75, 0.25]*2) *boxsize, 'posz') components.populate(zeros(N), 'momx') components.populate(zeros(N), 'momy') components.populate(zeros(N), 'momz') # Save snapshot save(components, initial_conditions)
# This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particles. # It is important that no inter-particle separation exceeds boxsize/2 in # any direction, as the nearest particle image in all cases must be the # actual particle itself. N = 8 mass = ρ_mbar*boxsize**3/N component = Component('GADGET halo', 'matter', N=N, mass=mass) component.populate(asarray([0.26]*4 + [0.74]*4 )*boxsize, 'posx') component.populate(asarray([0.25, 0.25, 0.75, 0.75]*2)*boxsize, 'posy') component.populate(asarray([0.25, 0.75, 0.75, 0.25]*2)*boxsize, 'posz') component.populate(zeros(N, dtype=float), 'momx') component.populate(zeros(N, dtype=float), 'momy') component.populate(zeros(N, dtype=float), 'momz') # Save snapshot save(component, initial_conditions)
gridsize = 64 speed = a_begin**2*boxsize/(0.5*units.Gyr) N = gridsize # Number of particles N_fluidelements = gridsize**3 # Number of fluid elements Vcell = (boxsize/gridsize)**3 mass_tot = ρ_mbar*boxsize**3 mass_fluid_tot = mass_particles_tot = 0.5*mass_tot mass_fluid = mass_fluid_tot/N_fluidelements # Mass of each fluid element mass_particles = mass_particles_tot/N # Mass of each particle component = Component('test fluid', 'matter fluid', gridsize) ϱ = empty([gridsize]*3) for i in range(gridsize): ϱ[i, :, :] = 2 + np.sin(2*π*i/gridsize) # Unitless ϱ /= sum(ϱ) # Normalize ϱ *= mass_fluid_tot/Vcell # Apply units component.populate(ϱ, 'ϱ' ) component.populate(ϱ*speed, 'J', 0) component.populate(zeros([gridsize]*3), 'J', 1) component.populate(ϱ*speed*(random()*2 - 1), 'J', 2) components.append(component) # Create the particles. # These are N particles strewn uniformly over the x-axis, with a velocity # only in the x-direction. These should then remain equally spaced # in the x-direction throughout time, each following a specific fluid element. # The y-positions are given by a sine (in order to match # these against the fluid density profile) and the z-positions are random. component = Component('control particles', 'matter particles', N, mass=mass_particles) offset = 0.5*boxsize A = 0.4*boxsize component.populate(linspace(0, boxsize, N, endpoint=False), 'posx')
z = k / Nz * boxsize posx[count] = x posy[count] = y posz[count] = z # Make the momenta diverge from the point of lowest density if isclose(x, 0.75 * boxsize, abs_tol=boxsize / Nx): momx[count] -= 0.01 * mass * boxsize / (100 * units.Gyr) elif abs(x - 0.75 * boxsize) < 0.3 * boxsize: if x <= 0.75 * boxsize: fac = -0.5 * exp(-0.07 * (x - 0.75 * boxsize + 0.1 * boxsize)**2) else: fac = +0.5 * exp(-0.07 * (x - 0.75 * boxsize - 0.1 * boxsize)**2) momx[count] += fac * mass * boxsize / (100 * units.Gyr) count += 1 if i < Nx - 1: x = binary_search(x, mass_unitless) # Instantiate particles particles = Component('control particles', 'matter particles', N, mass=mass) particles.populate(posx, 'posx') particles.populate(posy, 'posy') particles.populate(posz, 'posz') particles.populate(momx, 'momx') particles.populate(momy, 'momy') particles.populate(momz, 'momz') # Save snapshot save(particles, initial_conditions)
# # The author of CO𝘕CEPT can be contacted at dakin(at)phys.au.dk # The latest version of CO𝘕CEPT is available at # https://github.com/jmd-dk/concept/ # This file has to be run in pure Python mode! # Imports from the CO𝘕CEPT code from commons import * from species import Component from snapshot import save # Create the particles. # It is important that no interparticle separation exceeds boxsize/2 in # any direction, as the nearest particle image in all cases must be the # actual particle itself. N = 8 mass = ρ_mbar*boxsize**3/N component = Component('GADGET halos', 'matter particles', N, mass=mass) component.populate(np.array([0.26]*4 + [0.74]*4)*boxsize, 'posx') component.populate(np.array([0.25, 0.25, 0.75, 0.75]*2)*boxsize, 'posy') component.populate(np.array([0.25, 0.75, 0.75, 0.25]*2)*boxsize, 'posz') component.populate(zeros(N), 'momx') component.populate(zeros(N), 'momy') component.populate(zeros(N), 'momz') # Save snapshot save(component, initial_conditions)