示例#1
0
#
# 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)
示例#2
0

# 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)

示例#3
0
# 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.
示例#4
0
# 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.
示例#5
0
# 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)
示例#6
0
# 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)
示例#7
0
# 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)
示例#8
0
# 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)

示例#9
0
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)
示例#10
0
# 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')
示例#11
0
# 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)
示例#12
0
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)
示例#13
0
# 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)
示例#14
0
# 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)
示例#15
0
# 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.
示例#16
0
# 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)
示例#17
0
# 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)
示例#18
0
#
# 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)
示例#19
0
# 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)
示例#20
0
# 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)
示例#21
0
# 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)
示例#22
0
# 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)
示例#23
0
# 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)
示例#24
0
# 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)
示例#25
0
            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)
示例#26
0
#
# 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)