Exemple #1
0
def new_plummer_distribution(number_of_particles, 
        total_mass = 1.0|nbody_system.mass, 
        virial_radius = 1.0|nbody_system.length,
        mass_cutoff = 0.999,
        G = None,
        **keyword_arguments):           # optional arguments for UniformSphericalDistribution
    """
    Create a plummer model with the given number of particles. Returns a set 
    of particles with equal masses and positions distributed to fit a plummer 
    distribution model. Velocities are sampled using von Neumann's rejection 
    method (Aarseth et al. 1974), balancing the gravitational forces between 
    the particles.
    """
    particles = new_plummer_spatial_distribution(number_of_particles, total_mass=total_mass, 
        virial_radius=virial_radius, **keyword_arguments)
    
    if G is None:
        G = nbody_system.G if generic_unit_system.is_generic_unit(total_mass.unit) else constants.G
    velocity_unit = (G*total_mass/virial_radius).sqrt().unit.base_unit()
    plummer_radius = 0.1875 * numpy.pi * virial_radius
    
    escape_velocity = (1 + particles.position.lengths_squared()/plummer_radius**2)**(-0.25) | velocity_unit
    velocity = escape_velocity * sample_from_velocity_distribution(number_of_particles)
    velocity *= numpy.sqrt((G*total_mass*number_of_particles) / (2*virial_radius*velocity.length_squared()))
    particles.velocity = velocity.reshape((-1,1)) * random_direction(number_of_particles)
    return particles
Exemple #2
0
def new_plummer_distribution(number_of_particles, 
        total_mass = 1.0|nbody_system.mass, 
        virial_radius = 1.0|nbody_system.length,
        mass_cutoff = 0.999,
        G = None,
        **keyword_arguments):           # optional arguments for UniformSphericalDistribution
    """
    Create a plummer model with the given number of particles. Returns a set 
    of particles with equal masses and positions distributed to fit a plummer 
    distribution model. Velocities are sampled using von Neumann's rejection 
    method (Aarseth et al. 1974), balancing the gravitational forces between 
    the particles.
    """
    particles = new_plummer_spatial_distribution(number_of_particles, total_mass=total_mass, 
        virial_radius=virial_radius, **keyword_arguments)
    
    if G is None:
        G = nbody_system.G if generic_unit_system.is_generic_unit(total_mass.unit) else constants.G
    velocity_unit = (G*total_mass/virial_radius).sqrt().unit.base_unit()
    plummer_radius = 0.1875 * numpy.pi * virial_radius
    
    escape_velocity = (1 + particles.position.lengths_squared()/plummer_radius**2)**(-0.25) | velocity_unit
    velocity = escape_velocity * sample_from_velocity_distribution(number_of_particles)
    velocity *= numpy.sqrt((G*total_mass*number_of_particles) / (2*virial_radius*velocity.length_squared()))
    particles.velocity = velocity.reshape((-1,1)) * random_direction(number_of_particles)
    return particles
Exemple #3
0
def new_gas_plummer_distribution(
    number_of_particles,
    total_mass=1.0 | nbody_system.mass,
    virial_radius=1.0 | nbody_system.length,
    G=None,
    **keyword_arguments
):  # optional arguments for UniformSphericalDistribution
    """
    Create a plummer gas model with the given number of particles. Returns a set 
    of SPH particles with equal masses and positions distributed to fit a plummer 
    distribution model. Velocities are set to zero, and internal energies are set 
    to balance the gravitational forces between the gas particles.
    """
    particles = new_plummer_spatial_distribution(number_of_particles,
                                                 total_mass=total_mass,
                                                 virial_radius=virial_radius,
                                                 **keyword_arguments)

    if G is None:
        G = nbody_system.G if generic_unit_system.is_generic_unit(
            total_mass.unit) else constants.G
    velocity_unit = (G * total_mass / virial_radius).sqrt().unit.base_unit()
    particles.velocity = [0.0, 0.0, 0.0] | velocity_unit

    plummer_radius = 0.1875 * numpy.pi * virial_radius
    u_unit = (velocity_unit**2).base_unit()
    particles.u = (1 + particles.position.lengths_squared() /
                   plummer_radius**2)**(-0.5) | u_unit
    particles.u *= 0.25 * (G * total_mass**2 /
                           virial_radius) / particles.thermal_energy()
    return particles
Exemple #4
0
def new_gas_plummer_distribution(number_of_particles, 
        total_mass = 1.0|nbody_system.mass, 
        virial_radius = 1.0|nbody_system.length,
        G = None,
        **keyword_arguments):           # optional arguments for UniformSphericalDistribution
    """
    Create a plummer gas model with the given number of particles. Returns a set 
    of SPH particles with equal masses and positions distributed to fit a plummer 
    distribution model. Velocities are set to zero, and internal energies are set 
    to balance the gravitational forces between the gas particles.
    """
    particles = new_plummer_spatial_distribution(number_of_particles, total_mass=total_mass, 
        virial_radius=virial_radius, **keyword_arguments)
    
    if G is None:
        G = nbody_system.G if generic_unit_system.is_generic_unit(total_mass.unit) else constants.G
    velocity_unit = (G*total_mass/virial_radius).sqrt().unit.base_unit()
    particles.velocity = [0.0, 0.0, 0.0] | velocity_unit
    
    plummer_radius = 0.1875 * numpy.pi * virial_radius
    u_unit = (velocity_unit**2).base_unit()
    particles.u = (1 + particles.position.lengths_squared()/plummer_radius**2)**(-0.5) | u_unit
    particles.u *= 0.25 * (G*total_mass**2/virial_radius) / particles.thermal_energy()
    return particles