Particle attributes are defined in the amuse.datamodel.particle_attributes. These attributes can be accesed in two ways, on the particle(s) or as a function imported from the module. When accessed on the particles, the first parameter (usually called `particles`) must not be given.
To access these functions directly do:
from amuse.datamodel.particle_attributes import *
from amuse.lab import new_plummer_sphere
particles = new_plummer_sphere(100)
print kinetic_enery(particles)
To access these functions as an attribute do:
from amuse.lab import new_plummer_sphere
particles = new_plummer_sphere(100)
print particles.kinetic_energy()
Calculate lagrangian radii. Output is radii, mass fraction
>>> import numpy
>>> from amuse.ic.plummer import new_plummer_sphere
>>> numpy.random.seed(1234)
>>> parts=new_plummer_sphere(100)
>>> lr,mf=parts.LagrangianRadii()
>>> print lr[5]
0.856966667972 length
Calculates the minimum spanning tree Q parameter (Cartwright & Whitworth 2004) for a projection of the particle set.
Parameters: | distfunc – distfunc is the distance function which can be used to select |
---|
the projection plane.
find the particles bound to the cluster. Returns a subset of bound particles.
Parameters: |
|
---|
>>> from amuse.ic.plummer import new_plummer_model
>>> from amuse.units import nbody_system
>>> plum=new_plummer_model(100)
>>> print len(plum.bound_subset(G=nbody_system.G))
100
>>> plum[0].velocity*=100
>>> plum[0].position*=100
>>> print len(plum.bound_subset(G=nbody_system.G))
99
Returns the center of mass of the particles set. The center of mass is defined as the average of the positions of the particles, weighted by their masses.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.x = [-1.0, 1.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.center_of_mass()
quantity<[0.0, 0.0, 0.0] m>
Returns the center of mass velocity of the particles set. The center of mass velocity is defined as the average of the velocities of the particles, weighted by their masses.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.vx = [-1.0, 1.0] | units.ms
>>> particles.vy = [0.0, 0.0] | units.ms
>>> particles.vz = [0.0, 0.0] | units.ms
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.center_of_mass_velocity()
quantity<[0.0, 0.0, 0.0] m * s**-1>
return a list of connected component subsets of particles, connected if the distfunc is smaller than the threshold.
Parameters: |
|
---|
calculate position of the density centre, coreradius and coredensity
>>> import numpy
>>> from amuse.ic.plummer import new_plummer_sphere
>>> numpy.random.seed(1234)
>>> particles=new_plummer_sphere(100)
>>> pos,coreradius,coredens=particles.densitycentre_coreradius_coredens()
>>> print coreradius
0.404120092331 length
Returns the total potential energy of the particles in the particles set.
Parameters: | field_particles – the external field consists of these (i.e. potential energy is calculated relative to the field particles) |
---|
>>> from amuse.datamodel import Particles
>>> field_particles = Particles(2)
>>> field_particles.x = [0.0, 2.0] | units.m
>>> field_particles.y = [0.0, 0.0] | units.m
>>> field_particles.z = [0.0, 0.0] | units.m
>>> particles = Particles(3)
>>> particles.x = [1.0, 3.0, 4] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> distances_squared(particles, field_particles)
quantity<[[ 1. 1.], [ 9. 1.], [ 16. 4.]] m**2>
return closest particle to x,y,z position
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.x = [0.0, 2.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> print particles.find_closest_particle_to( -1 | units.m,0.| units.m,0.| units.m).x
0.0 m
returns the binaries in a particleset. binaries are selected according to a hardness criterion [hardness=10] This function returns the binaries as a list of i,j particles. Triple detection is not done.
>>> from amuse import datamodel
>>> m = [1,1,1] | units.MSun
>>> x = [-1,1,0] | units.AU
>>> y = [0,0,1000] | units.AU
>>> z = [0,0,0] | units.AU
>>> vx = [0,0,0] | units.kms
>>> vy = [1.,-1.,0] | units.kms
>>> vz = [0,0,0] | units.kms
>>> particles = datamodel.create_particle_set( mass=m,x=x,y=y,z=z,vx=vx,vy=vy,vz=vz )
>>> binaries = particles.get_binaries()
>>> print len(binaries)
1
Returns the total kinetic energy of the particles in the particles set.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.vx = [-1.0, 1.0] | units.ms
>>> particles.vy = [0.0, 0.0] | units.ms
>>> particles.vz = [0.0, 0.0] | units.ms
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.kinetic_energy()
quantity<1.0 m**2 * kg * s**-2>
Converse & Stahler 2008 Gini coefficient for cluster.
Parameters: |
|
---|
>>> import numpy
>>> from amuse.ic.plummer import new_plummer_model
>>> from amuse.units import nbody_system
>>> plum=new_plummer_model(100)
>>> a=numpy.argsort(plum.position.lengths_squared().number)
>>> plum.mass=0|nbody_system.mass
>>> plum[a[0]].mass=1|nbody_system.mass
>>> print plum.mass_segregation_Gini_coefficient()
1.0
Returns the total moment of inertia (about the Z axis) of the particle set.
Move the particle positions to the center of mass and move the particle velocity to the center of mass velocity.
Implemented as:
particles.position -= particles.center_of_mass()
particles.velocity -= particles.center_of_mass_velocity()
Uses Hop to find the density centre (core) of a particle distribution and stores the properties of this core on a particle: position, velocity, (core) radius and (core) density.
Particles are assigned weights that depend on the density (as determined by Hop) to a certain power. The default weighting power is 2, which is most commonly used. Set density_weighting_power to 1 in order to get the original weighting of Casertano & Hut (1985, ApJ, 298, 80).
Parameters: |
|
---|
Returns the potential energy of a particle.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.x = [0.0, 1.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles[1].potential()
quantity<-6.67428e-11 m**2 * s**-2>
Returns the specific kinetic energy of a particle.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.vx = [0.0, 1.0] | units.ms
>>> particles.vy = [0.0, 0.0] | units.ms
>>> particles.vz = [0.0, 0.0] | units.ms
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles[1].specific_kinetic_energy()
quantity<0.5 m**2 * s**-2>
Returns the potential of the particles in the particles set.
Parameters: |
|
---|
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.x = [0.0, 1.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.potential()
quantity<[-6.67428e-11, -6.67428e-11] m**2 * s**-2>
Returns the total potential energy of the particles in the particles set.
Parameters: |
|
---|
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.x = [0.0, 1.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.potential_energy()
quantity<-6.67428e-11 m**2 * kg * s**-2>
Returns the total potential energy of the particles in the particles set.
Parameters: |
|
---|
>>> from amuse.datamodel import Particles
>>> field_particles = Particles(2)
>>> field_particles.x = [0.0, 2.0] | units.m
>>> field_particles.y = [0.0, 0.0] | units.m
>>> field_particles.z = [0.0, 0.0] | units.m
>>> field_particles.mass = [1.0, 1.0] | units.kg
>>> particles = Particles(2)
>>> particles.x = [1.0, 3.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.potential_energy_in_field(field_particles)
quantity<-2.22476e-10 m**2 * kg * s**-2>
Scale the particles to a standard NBODY model with total mass=1, kinetic energy=0.25 and potential_energy=0.5 (or viridial_radius=1.0)
Parameters: |
|
---|
Returns the specific kinetic energy of a particle.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.vx = [1.0, 1.0] | units.ms
>>> particles.vy = [0.0, 0.0] | units.ms
>>> particles.vz = [0.0, 0.0] | units.ms
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.specific_kinetic_energy()
quantity<[0.5, 0.5] m**2 * s**-2>
Returns the total internal energy of the (gas) particles in the particles set.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.u = [0.5, 0.5] | units.ms**2
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.thermal_energy()
quantity<1.0 m**2 * kg * s**-2>
Returns the total angular momentum of the particles set.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.x = [-1.0, 1.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> particles.vx = [0.0, 0.0] | units.ms
>>> particles.vy = [-1.0, 1.0] | units.ms
>>> particles.vz = [0.0, 0.0] | units.ms
>>> particles.mass = [1.0, .5] | units.kg
>>> particles.total_angular_momentum()
quantity<[0.0, 0.0, 1.5] m**2 * kg * s**-1>
Returns the total mass of the particles set.
>>> from amuse.datamodel import Particles
>>> particles = Particles(3)
>>> particles.mass = [1.0, 2.0, 3.0] | units.kg
>>> particles.total_mass()
quantity<6.0 kg>
Returns the total momentum of the particles set.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.vx = [-1.0, 1.0] | units.ms
>>> particles.vy = [0.0, 0.0] | units.ms
>>> particles.vz = [0.0, 0.0] | units.ms
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.total_momentum()
quantity<[0.0, 0.0, 0.0] m * kg * s**-1>
Returns the total radius (maximum distance from center) of the particles set.
>>> from amuse.datamodel import Particles
>>> particles = Particles(3)
>>> particles.mass = [1.0, 2.0, 3.0] | units.kg
>>> particles.position = [0.0, 0.0, 0.0] | units.m
>>> particles.x = [0.0, 3.0, 6.0] | units.m
>>> particles.total_radius()
quantity<4.0 m>
Returns the total potential energy of the particles in the particles set.
Parameters: | field_particles – the external field consists of these (i.e. potential energy is calculated relative to the field particles) |
---|
>>> from amuse.datamodel import Particles
>>> field_particles = Particles(2)
>>> field_particles.vx = [0.0, 2.0] | units.m
>>> field_particles.vy = [0.0, 0.0] | units.m
>>> field_particles.vz = [0.0, 0.0] | units.m
>>> particles = Particles(3)
>>> particles.vx = [1.0, 3.0, 4] | units.m
>>> particles.vy = [0.0, 0.0] | units.m
>>> particles.vz = [0.0, 0.0] | units.m
>>> velocity_diff_squared(particles, field_particles)
quantity<[[ 1. 1.], [ 9. 1.], [ 16. 4.]] m**2>
Returns the virial radius of the particles set. The virial radius is the inverse of the average inverse distance between particles, weighted by their masses.
>>> from amuse.datamodel import Particles
>>> particles = Particles(2)
>>> particles.x = [-1.0, 1.0] | units.m
>>> particles.y = [0.0, 0.0] | units.m
>>> particles.z = [0.0, 0.0] | units.m
>>> particles.mass = [1.0, 1.0] | units.kg
>>> particles.virial_radius()
quantity<4.0 m>