# # 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)
# 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)
# Create the fluid. # This is a global sine wave along the x-direction, # moving with the speed "speed" along the x-direction, # the speed 0 along the y-direction and a random speed # in the z-direction. components = [] 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.
# Create the fluid. # This is a global sine wave along the x-direction, # moving with the speed "speed" along the x-direction, # the speed 0 along the y-direction and a random speed # in the z-direction. components = [] 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.
# 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 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)
# 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)
# 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)
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)
# 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')
# 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-2 halos', 'matter', N=N, mass=mass) particles.populate(asarray([0.1] * N) * boxsize, 'posx') particles.populate(asarray([0.25, 0.25, 0.75, 0.75]) * boxsize, 'posy') particles.populate(asarray([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, dtype=float), 'momy') particles.populate(zeros(N, dtype=float), 'momz') # Save snapshot save(particles, 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, N_fluidvars=3, w=w) 蟻 = 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) * 蟽, '蟽', multi_index) # Save snapshot save(component, 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)
# 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 close to homogeneous particles N_lin = 128 N = N_lin**3 mass = 蟻_mbar*boxsize**3/N component = Component('test particles', 'matter particles', N, mass=mass) posx = empty(N) posy = empty(N) posz = empty(N) 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)
# Create the fluid. # This is a global sine wave along the x-direction, # moving with the speed "speed" along the x-direction, # the speed 0 along the y-direction and a random speed # in the z-direction. components = [] 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.
# 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-2 halos', '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)
# 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 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)
# 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 close to homogeneous particles N_lin = 128 N = N_lin**3 mass = 媳_mbar * boxsize**3 / N component = Component('test particles', 'matter particles', N, mass=mass) posx = empty(N) posy = empty(N) posz = empty(N) 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)
# 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)
# 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. # 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)
# 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)
# 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)
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)