[MMTK] (no subject)

konrad.hinsen@laposte.net konrad.hinsen at laposte.net
Tue Feb 21 09:50:50 CET 2006


On 21.02.2006, at 02:04, dpy99 wrote:

> I am now being frustrated to implement the ¡°Class ParticleScalar¡±  
> and the
> ¡°Class AtomicScalarField (system. grid_size, values)¡±.
> The problem is I don¡¯t know how to give the proper  
> ParticleProperties to the
> parameter ¡°value¡±, for example, want to make the energy (mass) as  
> the scalar value, and then how to initial the object  
> ParticleScalar, and implement the AtomicScaleField.

1) Getting your data into ParticleScalar objects

There are basically two approaches:
a) Calculations using built-in ParticleProperties objects that result  
in a ParticleScalar object
b) Creation of a ParticleScalar object whose values are then defined  
in a loop over all atoms.

Examples for a):

	masses = universe.masses()  # yields a ParticleScalar directly

	charges = universe.charges()  # requires a force field

	v = universe.velocities()
	m = universe.masses()
	kinetic_energy = 0.5*m*(v*v)

Example for b):

	# calculate distance from the center of the universe
	cm = universe.centerOfMass()
	d = ParticleScalar(universe)
	for atom in universe.atomList():
		d[atom] = (atom.position()-cm).length()


2) Constructing the scalar field

This is always the same, you just give the ParticleScalar as the last  
parameter.

Example: mass density

	mass_density = AtomicScalarField(universe, 0.5, universe.masses())

Konrad.
--
------------------------------------------------------------------------ 
-------
Konrad Hinsen
Laboratoire Leon Brillouin (CEA-CNRS), CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: konrad.hinsen at cea.fr
------------------------------------------------------------------------ 
-------





More information about the mmtk mailing list