Пример #1
0
from interface import NearestNeighbor
from amuse.units import units, nbody_system
from amuse.ext import plummer
from amuse.io import text

number_of_particles = 1000
mass_per_particle = 1 | units.MSun

convert_nbody = nbody_system.nbody_to_si(
    number_of_particles * mass_per_particle, 1.0 | units.parsec)
uc = plummer.MakePlummerModel(number_of_particles, convert_nbody)
particles = uc.result

nn = NearestNeighbor()
nn.particles.add_particles(particles)
print "number of particles:", len(nn.particles)

nn.find_nearest_neighbors()

local_particles = nn.particles.copy()

for p in local_particles:
    delta = p.neighbor1.position - p.position
    p.distance_to_neighbor = delta.length()
    p.dx = delta.x
    p.dy = delta.y
    p.dz = delta.z

output = text.TableFormattedText("output.txt", set=local_particles)
output.attribute_names = ['x', 'y', 'z', 'dx', 'dy', 'dz']
output.attribute_types = [units.parsec] * 6
Пример #2
0
from interface import NearestNeighbor
from amuse.lab import *
from amuse.io import text

if __name__ == '__main__':
    number_of_particles = 1000
    particles = new_plummer_sphere(1000)

    code = NearestNeighbor()
    code.particles.add_particles(particles)

    code.run()

    local_particles = code.particles.copy()
    delta = local_particles.neighbor1.as_set().position - local_particles.position
   
    local_particles.dx = delta[...,0]
    local_particles.dy = delta[...,1]
    local_particles.dz = delta[...,2]

    output = text.TableFormattedText("output.txt", set = local_particles)
    output.attribute_names = ['x','y','z', 'dx', 'dy','dz']
    output.store()

Пример #3
0
from interface import NearestNeighbor
from amuse.lab import *
from amuse.io import text

if __name__ == '__main__':
    number_of_particles = 1000
    particles = new_plummer_sphere(1000)

    code = NearestNeighbor()
    code.set_maximum_number_of_particles(5000)
    code.commit_parameters
    code.particles.add_particles(particles)

    code.run()

    local_particles = code.particles.copy()
    delta = local_particles.neighbor1.position - local_particles.position

    local_particles.dx = delta[..., 0]
    local_particles.dy = delta[..., 1]
    local_particles.dz = delta[..., 2]

    output = text.TableFormattedText("output.txt", set=local_particles)
    output.attribute_names = ['x', 'y', 'z', 'dx', 'dy', 'dz']
    output.store()
Пример #4
0
from interface import NearestNeighbor
from amuse.lab import *
from amuse.io import text

if __name__ == '__main__':
    number_of_particles = 1000
    particles = new_plummer_sphere(1000)

    code = NearestNeighbor()
    code.particles.add_particles(particles)

    code.run()

    local_particles = code.particles.copy()
    delta = local_particles.neighbor1.as_set(
    ).position - local_particles.position

    local_particles.dx = delta[..., 0]
    local_particles.dy = delta[..., 1]
    local_particles.dz = delta[..., 2]

    output = text.TableFormattedText("output.txt", set=local_particles)
    output.attribute_names = ['x', 'y', 'z', 'dx', 'dy', 'dz']
    output.store()
Пример #5
0
from interface import NearestNeighbor
from amuse.lab import *
from amuse.io import text

if __name__ == '__main__':
    number_of_particles = 1000
    particles = new_plummer_sphere(1000)

    code = NearestNeighbor()
    code.set_maximum_number_of_particles(5000)
    code.commit_parameters
    code.particles.add_particles(particles)

    code.run()

    local_particles = code.particles.copy()
    delta = local_particles.neighbor1.as_set().position - local_particles.position
   
    local_particles.dx = delta[...,0]
    local_particles.dy = delta[...,1]
    local_particles.dz = delta[...,2]

    output = text.TableFormattedText("output.txt", set = local_particles)
    output.attribute_names = ['x','y','z', 'dx', 'dy','dz']
    output.store()

Пример #6
0
from interface import NearestNeighbor
from amuse.units import units, nbody_system
from amuse.ext import plummer
from amuse.io import text

number_of_particles = 1000
mass_per_particle = 1 | units.MSun

convert_nbody = nbody_system.nbody_to_si(number_of_particles * mass_per_particle, 1.0 | units.parsec)
uc = plummer.MakePlummerModel(number_of_particles, convert_nbody)
particles = uc.result

nn = NearestNeighbor()
nn.particles.add_particles(particles)
print "number of particles:", len(nn.particles)

nn.find_nearest_neighbors()

local_particles = nn.particles.copy()

for p in local_particles:
    delta =  p.neighbor1.position - p.position
    p.distance_to_neighbor = delta.length()
    p.dx = delta.x
    p.dy = delta.y
    p.dz = delta.z
    


output = text.TableFormattedText("output.txt", set = local_particles)
output.attribute_names = ['x','y','z', 'dx', 'dy','dz']