Exemplo n.º 1
0
    """
    Compute the dynamical (i.e. free-fall) timescale of the particles set. This is 
    the time it would take for a pressureless homogeneous sphere of this size and
    average density to collapse. If 'mass_fraction' is supplied, only the inner 
    particles are considered in the computation of the size of the sphere. For 
    example, 'mass_fraction=0.95' ignores the positions of the outer particles 
    comprising 5% by mass (useful for density profiles with long tails).
    """
    if mass_fraction is None:
        total_radius = particles.total_radius()
    else:
        total_radius = particles.LagrangianRadii(mf=[mass_fraction], cm=particles.center_of_mass())[0][0]
    return numpy.pi * (total_radius**3 / (8.0 * G * particles.total_mass())).sqrt()


AbstractParticleSet.add_global_function_attribute("center_of_mass", center_of_mass)
AbstractParticleSet.add_global_function_attribute("center_of_mass_velocity", center_of_mass_velocity)
AbstractParticleSet.add_global_function_attribute("kinetic_energy", kinetic_energy)
AbstractParticleSet.add_global_function_attribute("potential_energy", potential_energy)
AbstractParticleSet.add_global_function_attribute("thermal_energy", thermal_energy)
AbstractParticleSet.add_global_function_attribute("virial_radius", virial_radius)
AbstractParticleSet.add_global_function_attribute("total_mass", total_mass)
AbstractParticleSet.add_global_function_attribute("total_radius", total_radius)
AbstractParticleSet.add_global_function_attribute("total_momentum", total_momentum)
AbstractParticleSet.add_global_function_attribute("total_angular_momentum", total_angular_momentum)
AbstractParticleSet.add_global_function_attribute("moment_of_inertia", moment_of_inertia)
AbstractParticleSet.add_global_function_attribute("dynamical_timescale", dynamical_timescale)

AbstractParticleSet.add_global_function_attribute("potential_energy_in_field", potential_energy_in_field)

AbstractParticleSet.add_global_vector_attribute("position", ["x","y","z"])
Exemplo n.º 2
0
    the time it would take for a pressureless homogeneous sphere of this size and
    average density to collapse. If 'mass_fraction' is supplied, only the inner 
    particles are considered in the computation of the size of the sphere. For 
    example, 'mass_fraction=0.95' ignores the positions of the outer particles 
    comprising 5% by mass (useful for density profiles with long tails).
    """
    if mass_fraction is None:
        total_radius = particles.total_radius()
    else:
        total_radius = particles.LagrangianRadii(
            mf=[mass_fraction], cm=particles.center_of_mass())[0][0]
    return numpy.pi * (total_radius**3 /
                       (8.0 * G * particles.total_mass())).sqrt()


AbstractParticleSet.add_global_function_attribute("center_of_mass",
                                                  center_of_mass)
AbstractParticleSet.add_global_function_attribute("center_of_mass_velocity",
                                                  center_of_mass_velocity)
AbstractParticleSet.add_global_function_attribute("kinetic_energy",
                                                  kinetic_energy)
AbstractParticleSet.add_global_function_attribute("potential_energy",
                                                  potential_energy)
AbstractParticleSet.add_global_function_attribute("thermal_energy",
                                                  thermal_energy)
AbstractParticleSet.add_global_function_attribute("virial_radius",
                                                  virial_radius)
AbstractParticleSet.add_global_function_attribute("total_mass", total_mass)
AbstractParticleSet.add_global_function_attribute("total_radius", total_radius)
AbstractParticleSet.add_global_function_attribute("total_momentum",
                                                  total_momentum)
AbstractParticleSet.add_global_function_attribute("total_angular_momentum",