Example #1
0
File: gd.py Project: Ingwar/amuse
 def set_state():
     """
     Update the current state of a particle. The *minimal* information of a stellar
     dynamics particle (mass, radius, position and velocity) is updated.
     """
     function = LegacyFunctionSpecification()
     function.can_handle_array = True
     function.addParameter('index_of_the_particle', dtype='int32', direction=function.IN,
         description = "Index of the particle for which the state is to be updated. This index must have been returned by an earlier call to :meth:`new_particle`")
     function.addParameter('mass', dtype='float64', direction=function.IN, description = "The new mass of the particle")
     function.addParameter('x', dtype='float64', direction=function.IN, description = "The new position vector of the particle")
     function.addParameter('y', dtype='float64', direction=function.IN, description = "The new position vector of the particle")
     function.addParameter('z', dtype='float64', direction=function.IN, description = "The new position vector of the particle")
     function.addParameter('vx', dtype='float64', direction=function.IN, description = "The new velocity vector of the particle")
     function.addParameter('vy', dtype='float64', direction=function.IN, description = "The new velocity vector of the particle")
     function.addParameter('vz', dtype='float64', direction=function.IN, description = "The new velocity vector of the particle")
     function.addParameter('radius', dtype='float64', direction=function.IN, description = "The new radius of the particle", default = 0)
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         particle was found in the model and the information was set
     -1 - ERROR
         particle could not be found
     -2 - ERROR
         code does not support updating of a particle
     -3 - ERROR
         not yet implemented
     """
     return function
Example #2
0
File: gd.py Project: Ingwar/amuse
 def set_acceleration():
     """
     Update the acceleration of a particle.
     *Defined for symetry with the get_acceleration function.*
     *Should be removed if physaccily unsound*
     *Maybe moved to snapshot support functionality*
     """
     function = LegacyFunctionSpecification()
     function.addParameter('index_of_the_particle', dtype='int32', direction=function.IN,
         description = "Index of the particle for which the state is to be updated. This index must have been returned by an earlier call to :meth:`new_particle`")
     function.addParameter('ax', dtype='float64', direction=function.IN, description = "The new acceleration vector of the particle")
     function.addParameter('ay', dtype='float64', direction=function.IN, description = "The new acceleration vector of the particle")
     function.addParameter('az', dtype='float64', direction=function.IN, description = "The new acceleration vector of the particle")
     function.result_type = 'int32'
     function.can_handle_array = True
     function.result_doc = """
     0 - OK
         particle was found in the model and the information was set
     -1 - ERROR
         particle could not be found
     -2 - ERROR
         code does not support updating of a particle
     -3 - ERROR
         not yet implemented
     """
     return function
Example #3
0
File: gd.py Project: Ingwar/amuse
 def get_state():
     """
     Retrieve the current state of a particle. The *minimal* information of a stellar
     dynamics particle (mass, radius, position and velocity) is returned.
     """
     function = LegacyFunctionSpecification()
     function.can_handle_array = True
     function.addParameter('index_of_the_particle', dtype='int32', direction=function.IN,
         description = "Index of the particle to get the state from. This index must have been returned by an earlier call to :meth:`new_particle`")
     function.addParameter('mass', dtype='float64', direction=function.OUT, description = "The current mass of the particle")
     function.addParameter('x', dtype='float64', direction=function.OUT, description = "The current position vector of the particle")
     function.addParameter('y', dtype='float64', direction=function.OUT, description = "The current position vector of the particle")
     function.addParameter('z', dtype='float64', direction=function.OUT, description = "The current position vector of the particle")
     function.addParameter('vx', dtype='float64', direction=function.OUT, description = "The current velocity vector of the particle")
     function.addParameter('vy', dtype='float64', direction=function.OUT, description = "The current velocity vector of the particle")
     function.addParameter('vz', dtype='float64', direction=function.OUT, description = "The current velocity vector of the particle")
     function.addParameter('radius', dtype='float64', direction=function.OUT, description = "The current radius of the particle")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         particle was removed from the model
     -1 - ERROR
         particle could not be found
     """
     return function
Example #4
0
File: gd.py Project: Ingwar/amuse
    def new_particle():
        """
        Define a new particle in the stellar dynamics code. The particle is initialized with the provided
        mass, radius, position and velocity. This function returns an index that can be used to refer
        to this particle.
        """
        function = LegacyFunctionSpecification()
        function.can_handle_array = True
        function.addParameter('index_of_the_particle', dtype='int32', direction=function.OUT, description =
            """
            An index assigned to the newly created particle.
            This index is supposed to be a local index for the code
            (and not valid in other instances of the code or in other codes)
            """
            )

        function.addParameter('mass', dtype='float64', direction=function.IN, description = "The mass of the particle")
        function.addParameter('x', dtype='float64', direction=function.IN, description = "The initial position vector of the particle")
        function.addParameter('y', dtype='float64', direction=function.IN, description = "The initial position vector of the particle")
        function.addParameter('z', dtype='float64', direction=function.IN, description = "The initial position vector of the particle")
        function.addParameter('vx', dtype='float64', direction=function.IN, description = "The initial velocity vector of the particle")
        function.addParameter('vy', dtype='float64', direction=function.IN, description = "The initial velocity vector of the particle")
        function.addParameter('vz', dtype='float64', direction=function.IN, description = "The initial velocity vector of the particle")
        function.addParameter('radius', dtype='float64', direction=function.IN, description = "The radius of the particle", default = 0)
        function.result_type = 'int32'
        function.result_doc = """ 0 - OK
            particle was created and added to the model
        -1 - ERROR
            particle could not be created"""
        return function
Example #5
0
 def get_time():
     """
     Returns the current model time.
     """
     function = LegacyFunctionSpecification() 
     function.addParameter('value', dtype='float64', direction=function.OUT) 
     function.result_type = 'i'
     return function
Example #6
0
 def evolve_model():
     """
     Evolve the model until the given end time (or just before).
     """
     function = LegacyFunctionSpecification() 
     function.addParameter('value', dtype='float64', direction=function.IN) 
     function.result_type = 'i'
     return function
Example #7
0
 def get_has_external_gravitational_potential():
     """
     Returns true if an external gravitational potential is enabled.
     """
     function = LegacyFunctionSpecification() 
     function.addParameter('value', dtype='int32', direction=function.OUT) 
     function.result_type = 'i'
     return function
Example #8
0
 def specification(self):
     specification = LegacyFunctionSpecification()
     specification.name ='test'
     specification.addParameter('one','d',specification.IN, 'first parameter')
     specification.result_type = 'i'
     specification.result_doc = 'an integer'
     specification.description = 'Example function'
     return specification
Example #9
0
 def initialize_grid():
     """
     Perform accounting before evolving the model. This method will
     be called after setting the parameters and filling the grid points but
     just before evolving the system
     """
     function = LegacyFunctionSpecification()  
     function.result_type = 'i'
     return function
Example #10
0
File: gd.py Project: Ingwar/amuse
 def evolve_model():
     """
     Evolve the model until the given time, or until a stopping condition is set.
     """
     function = LegacyFunctionSpecification()
     function.addParameter('time', dtype='float64', direction=function.IN,
         description = "Model time to evolve the code to. The model will be "
             "evolved until this time is reached exactly or just after.")
     function.result_type = 'int32'
     return function
Example #11
0
 def get_fiducial_radius():
   """
   CG02 model fiducial radius where the density amplitude and initial phase are measured
     R_0 in eqn(1--3) of CG02
   """
   function = LegacyFunctionSpecification()
   function.addParameter('fiducial_radius', dtype='float64', direction=function.OUT, unit=units.kpc,
                         description='CG02 model fiducial radius where the density amplitude and initial phase are measured')
   function.result_type = 'int32'
   return function
Example #12
0
 def test7(self):
     print "Testing __str__ of Legacy Function"
     specification = LegacyFunctionSpecification()
     specification.name ='test'
     specification.addParameter('one','f',specification.IN, 'first parameter, type: float')
     specification.addParameter('two','d',specification.OUT, 'second parameter, type double')
     specification.result_type = 'i'
     specification.result_doc = 'an integer'
     specification.description = 'Example function'
     self.assertEquals(str(specification),"function: int test(float one)\noutput: double two, int __result")
Example #13
0
 def get_spiral_density_amplitude():
   """
   CG02 model spiral arms density amplitude, measured at fiducial radius
     rho_0 in eqn(1--3) of CG02
   """
   function = LegacyFunctionSpecification()
   function.addParameter('spiral_density_amplitude', dtype='float64', 
                         direction=function.OUT, unit=2.32e7*units.MSun/units.kpc**3,
                         description='CG02 model spiral arms density amplitude, measured at fiducial radius')
   function.result_type = 'int32'
   return function
Example #14
0
File: mhd.py Project: Ingwar/amuse
 def set_grid_magnetic_field():
     function = LegacyFunctionSpecification()
     function.must_handle_array = True
     for x in ['i','j','k']:
         function.addParameter(x, dtype='i', direction=function.IN)
     for x in ['B1i', 'B2i', 'B3i']:
         function.addParameter(x, dtype='d', direction=function.IN)
     function.addParameter('index_of_grid', dtype='i', direction=function.IN, default = 1)
     function.addParameter('number_of_points', 'i', function.LENGTH)
     function.result_type = 'i'
     return function
Example #15
0
 def get_interpolated_gravitational_potential():
     """
     Return the interpolated gravitational potential.
     """
     function = LegacyFunctionSpecification()  
     function.can_handle_array = True
     for x in ['x','y','z']:
         function.addParameter(x, dtype='d', direction=function.IN)
     function.addParameter('potential', dtype='d', direction=function.OUT)
     function.result_type = 'i'
     return function
Example #16
0
 def set_grid_momentum_density():
     function = LegacyFunctionSpecification()
     function.must_handle_array = True
     for x in ['i','j','k']:
         function.addParameter(x, dtype='i', direction=function.IN)
     for x in ['rhovx', 'rhovy', 'rhovz',]:
         function.addParameter(x, dtype='d', direction=function.IN)
     function.addParameter('index_of_grid', dtype='i', direction=function.IN, default = 1)
     function.addParameter('number_of_points', 'i', function.LENGTH)
     function.result_type = 'i'
     return function
Example #17
0
 def get_scale_height():
   """
   CG02 model spiral arms scale height
     H in eqn(1) of CG02
   """
   function = LegacyFunctionSpecification()
   function.addParameter('scale_height', dtype='float64', 
                         direction=function.OUT, unit=units.kpc,
                         description='CG02 model spiral arms scale height')
   function.result_type = 'int32'
   return function
Example #18
0
 def get_spiral_model():
    """
    set model of spiral arms
    0 -- TWA (2D)
    1 -- Cox and Gomez (3D)
    2 -- Lepine (2D)
    """
    function = LegacyFunctionSpecification()
    function.addParameter('spiral_model', dtype='int32', direction=function.OUT,
                          description='model of spiral arms (default: 0; TWA 2D arms)')
    function.result_type = 'int32'
    return function
Example #19
0
 def get_potential():
     """
     Retrieves the gravitational potential on the given gridpoint (only
     for codes supporting an external gravitational potential).
     """
     function = LegacyFunctionSpecification()  
     function.must_handle_array = True
     for x in ['i','j','k']:
         function.addParameter(x, dtype='i', direction=function.IN)
     function.addParameter('potential', dtype='d', direction=function.OUT)
     function.addParameter('number_of_points', 'i', function.LENGTH)
     function.result_type = 'i'
     return function
Example #20
0
 def set_has_external_gravitational_potential():
     """
     When True enables the script to set and external gravitational
     potential. 
     
     note::
         Not every hydrodynamics code supports an external gravitational
         potential
     """
     function = LegacyFunctionSpecification() 
     function.addParameter('value', dtype='int32', direction=function.IN) 
     function.result_type = 'i'
     return function
Example #21
0
 def set_stopping_condition_timeout_parameter():
     """
     Set max computer time available (in seconds).
     """
     function = LegacyFunctionSpecification()  
     function.can_handle_array = False 
     function.addParameter('value', dtype='float64', direction=function.IN, description = "Available wallclock time in seconds")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - Value out of range
     """
     return function
Example #22
0
 def get_stopping_condition_timeout_parameter():
     """
     Retrieve max computer time available (in seconds).
     """
     function = LegacyFunctionSpecification()  
     function.can_handle_array = False 
     function.addParameter('value', dtype='float64', direction=function.OUT, description = "Current value of avaible wallclock time in seconds")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - ERROR
     """
     return function
Example #23
0
 def set_stopping_condition_number_of_steps_parameter():
     """
     Set max inner loop evaluations.
     """
     function = LegacyFunctionSpecification()
     function.can_handle_array = False
     function.addParameter('value', dtype='int32', direction=function.IN, description = "Available inner loop evaluations")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - Value out of range
     """
     return function
Example #24
0
 def get_stopping_condition_number_of_steps_parameter():
     """
     Retrieve max inner loop evaluations.
     """
     function = LegacyFunctionSpecification()  
     function.can_handle_array = False 
     function.addParameter('value', dtype='int32', direction=function.OUT, description = "Current number of avaible inner loop evaluations")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - ERROR
     """
     return function
Example #25
0
File: gd.py Project: Ingwar/amuse
    def synchronize_model():
        """
        After an evolve the particles may be at different simulation
        times. Synchronize the particles to a consistent stat
        at the current simulation time
        """
        function = LegacyFunctionSpecification()
        function.result_type = 'int32'
        function.result_doc = """
        0 - OK

        """
        return function
Example #26
0
 def get_stopping_condition_out_of_box_parameter():
     """
     Get size of box
     """
     function = LegacyFunctionSpecification()
     function.can_handle_array = False
     function.addParameter('value', dtype='float64', direction=function.OUT, description = "Size of box")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - Value out of range
     """
     return function
Example #27
0
 def set_stopping_condition_out_of_box_use_center_of_mass_parameter():
     """
     If True use the center of mass to determine the location of the box, if False use (0,0,0)
     """
     function = LegacyFunctionSpecification()
     function.can_handle_array = False
     function.addParameter('value', dtype='bool', direction=function.IN, description = "True if detection should use center of mass")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - Value out of range
     """
     return function
Example #28
0
 def disable_stopping_condition():
     """
     Will disable the stopping if it is supported
     """
     function = LegacyFunctionSpecification()  
     function.can_handle_array = True 
     function.addParameter('type', dtype='int32', direction=function.IN, description = "The index of the stopping condition")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - ERROR
     """
     return function 
Example #29
0
 def get_grid_energy_density():
     """
     Retreives the energy densitity at the given grid-point
     """
     function = LegacyFunctionSpecification()
     function.must_handle_array = True
     for x in ['i','j','k']:
         function.addParameter(x, dtype='i', direction=function.IN)
     function.addParameter('index_of_grid', dtype='i', direction=function.IN, default = 1)
     for x in ['en',]:
         function.addParameter(x, dtype='d', direction=function.OUT)
     function.addParameter('number_of_points', 'i', function.LENGTH)
     function.result_type = 'i'
     return function
Example #30
0
 def test6(self):
     print "Testing description of Legacy Function with output parameter"
     specification = LegacyFunctionSpecification()
     specification.name ='test'
     specification.addParameter('one','d',specification.OUT, 'first parameter')
     specification.result_type = 'i'
     specification.result_doc = 'an integer'
     specification.description = 'Example function'
     
     x = create_definition.CreateDescriptionOfAFunctionSpecification()
     x.specification = specification
     x.start()
     self.assertTrue(x.out.string.find('int32 test(float64 * one)') > 0)
     self.assertTrue(x.out.string.find(':returns:') > 0)
Example #31
0
 def print_error_string():
     function = LegacyFunctionSpecification()
     function.addParameter('string_in', dtype='string', direction=function.IN)
     function.result_type = 'int32'
     function.can_handle_array = True
     return function
Example #32
0
 def set_tin():
     function = LegacyFunctionSpecification()
     function.addParameter('Tin', dtype='float64', direction=function.IN, unit=97781310.5721*units.yr)
     function.result_type = 'int32'
     return function
Example #33
0
 def get_nbt():
     function = LegacyFunctionSpecification()
     function.addParameter('nbt', dtype='float64', direction=function.OUT)
     function.result_type = 'int32'
     return function
Example #34
0
 def return_control():
     function = LegacyFunctionSpecification()
     function.result_type = 'int32'
     function.can_handle_array = False
     return function
Example #35
0
 def get_axis_ratio_bar():
     function = LegacyFunctionSpecification()
     function.addParameter('axis_ratio_bar', dtype='float64', direction=function.OUT)
     function.result_type = 'int32'
     return function
Example #36
0
 def get_omega_bar():
     function = LegacyFunctionSpecification()
     function.addParameter('omega_bar', dtype='float64', direction=function.OUT, unit=10.*units.km/(units.s*units.kpc))
     function.result_type = 'int32'
     return function
Example #37
0
 def get_mass_bar():
     function = LegacyFunctionSpecification()
     function.addParameter('mass_bar', dtype='float64', direction=function.OUT, unit=2.32e7*units.MSun)
     function.result_type = 'int32'
     return function
Example #38
0
 def get_caxis_bar():
     function = LegacyFunctionSpecification()
     function.addParameter('caxis_bar', dtype='float64', direction=function.OUT, unit=units.kpc)
     function.result_type = 'int32'
     return function
Example #39
0
 def get_bar_phase():
     function = LegacyFunctionSpecification()
     function.addParameter('bar_phase', dtype='float64', direction=function.OUT)  # unit=units.rad
     function.result_type = 'int32'
     return function
Example #40
0
 def sleep():
     function = LegacyFunctionSpecification()
     function.addParameter('number_of_seconds', dtype='float64', direction=function.IN)
     function.result_type = 'int32'
     function.can_handle_array = False
     return function
Example #41
0
 def set_flag():
     function = LegacyFunctionSpecification()
     function.addParameter('xflag', dtype='float64', direction=function.IN)
     function.result_type = 'int32'
     return function
Example #42
0
 def delete_particle():
     function = LegacyFunctionSpecification()
     function.addParameter('index_of_the_particle', dtype='int32', direction=function.IN)
     function.result_type = 'int32'
     function.can_handle_array = True
     return function
Example #43
0
 def get_stopping_condition_maximum_internal_energy_parameter():
     function = LegacyFunctionSpecification()
     function.addParameter('value', dtype='float64', direction=function.OUT)
     function.result_type = 'int32'
     return function
Example #44
0
 def set_stopping_condition_maximum_density_parameter():
     function = LegacyFunctionSpecification()
     function.addParameter('value', dtype='float64', direction=function.IN)
     function.result_type = 'int32'
     return function
Example #45
0
 def get_tgrowth():
     function = LegacyFunctionSpecification()
     function.addParameter('tgrowth_bar', dtype='float64', direction=function.OUT, unit=97781310.5721*units.yr)
     function.result_type = 'int32'
     return function