Exemplo n.º 1
0
    def has_stopping_condition():
        """
        Return 1 if the stopping condition with
        the given index is supported by the code,
        0 otherwise.
        """
        function = LegacyFunctionSpecification()
        function.can_handle_array = True
        function.addParameter(
            'type',
            dtype='int32',
            direction=function.IN,
            description="The type index  of the stopping condition")
        function.addParameter(
            'result',
            dtype='int32',
            direction=function.OUT,
            description="1 if the stopping condition is supported")

        function.result_type = 'int32'
        function.result_doc = """
        0 - OK
        -1 - ERROR
        """
        return function
Exemplo n.º 2
0
 def deep_echo_string():
     function = LegacyFunctionSpecification()
     function.addParameter('string_in', dtype='string', direction=function.IN)
     function.addParameter('string_out', dtype='string', direction=function.OUT)
     function.result_type = 'int32'
     function.can_handle_array = True
     return function
Exemplo n.º 3
0
 def copy_over_interface():
     function = LegacyFunctionSpecification()
     function.addParameter('comm_identifier', dtype='int32', direction=function.IN)
     function.addParameter('encoded_interface', dtype='string', direction=function.IN)
     function.result_type = 'int32'
     function.can_handle_array = False
     return function
 def get_x():
     function = LegacyFunctionSpecification()
     function.addParameter('index', dtype='int32', direction=function.IN)
     function.addParameter('x', dtype='float64', direction=function.OUT)
     function.result_type = 'int32'
     function.can_handle_array = True
     return function
Exemplo n.º 5
0
 def echo_double():
     function = LegacyFunctionSpecification()
     function.addParameter('double_in', dtype='float64', direction=function.IN)
     function.addParameter('double_out', dtype='float64', direction=function.OUT)
     function.result_type = 'int32'
     function.can_handle_array = True
     function.id = 13
     return function
Exemplo n.º 6
0
 def echo_int():
     function = LegacyFunctionSpecification()
     function.addParameter('int_in', dtype='int32', direction=function.IN)
     function.addParameter('int_out', dtype='int32', direction=function.OUT)
     function.result_type = 'int32'
     function.can_handle_array = True
     function.id = 12
     return function
Exemplo n.º 7
0
 def set_mass():
     function = LegacyFunctionSpecification()
     function.addParameter('index_of_the_particle', dtype='int32', direction=function.IN)
     function.addParameter('mass', dtype='float64', direction=function.IN, description="The new mass of the particle")
     function.result_type = 'int32'
     function.can_handle_array = True
     function.id = 11
     return function
Exemplo n.º 8
0
 def get_mass():
     function = LegacyFunctionSpecification()
     function.addParameter('index_of_the_particle', dtype='int32', direction=function.IN)
     function.addParameter('mass', dtype='float64', direction=function.OUT)
     function.result_type = 'int32'
     function.can_handle_array = True
     function.id = 10
     return function
Exemplo n.º 9
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
Exemplo n.º 10
0
 def echo_strings():
     function = LegacyFunctionSpecification()
     function.addParameter('string_inout1', dtype='string', direction=function.INOUT)
     function.addParameter('string_inout2', dtype='string', direction=function.INOUT)
     function.result_type = 'int32'
     function.can_handle_array = True
     function.id = 15
     return function
Exemplo n.º 11
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
Exemplo n.º 12
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
Exemplo n.º 13
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
Exemplo n.º 14
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
Exemplo n.º 15
0
 def multiply_ints():
     function = LegacyFunctionSpecification()
     function.addParameter('int_in1', dtype='int32', direction=function.IN)
     function.addParameter('int_in2', dtype='int32', direction=function.IN)
     function.addParameter('int_out', dtype='int32', direction=function.OUT)
     function.result_type = 'int32'
     function.can_handle_array = True
     return function
Exemplo n.º 16
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
Exemplo n.º 17
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
Exemplo n.º 18
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
Exemplo n.º 19
0
 def echo_quantities_error():
     function = LegacyFunctionSpecification()
     function.addParameter('quantity_in', dtype='float64', direction=function.IN)
     function.addParameter('quantity_out', dtype='float64', direction=function.OUT)
     function.result_type = 'int32'
     function.must_handle_array = True
     function.has_units = True
     function.id = 25
     return function
Exemplo n.º 20
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")
Exemplo n.º 21
0
 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
Exemplo n.º 22
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
Exemplo n.º 23
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
Exemplo n.º 24
0
Arquivo: gd.py Projeto: 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
Exemplo n.º 25
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
Exemplo n.º 26
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
Exemplo n.º 27
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
Exemplo n.º 28
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
Exemplo n.º 29
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
Exemplo n.º 30
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
Exemplo n.º 31
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
Exemplo n.º 32
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
 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
 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
Exemplo n.º 35
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
 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
Exemplo n.º 37
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
Exemplo n.º 38
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 
Exemplo n.º 39
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
 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
Exemplo n.º 41
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
Exemplo n.º 42
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
 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
 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
Exemplo n.º 45
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
 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 
Exemplo n.º 47
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
Exemplo n.º 48
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
Exemplo n.º 49
0
 def test2(self):
     specification = LegacyFunctionSpecification()
     specification.name ='test'
     specification.addParameter('one','d',specification.IN, 'first parameter')
     specification.description = 'Example function'
     
     x = create_definition.CreateDescriptionOfAFunctionSpecification()
     x.specification = specification
     x.start()
     
     self.assertTrue(x.out.string.find('void test(float64 one)') > 0)
     self.assertTrue(x.out.string.find('Example function') >= 0)
     self.assertTrue(x.out.string.find(':param one:') > 0)
Exemplo n.º 50
0
    def test2(self):
        specification = LegacyFunctionSpecification()
        specification.name = 'test'
        specification.addParameter('one', 'd', specification.IN,
                                   'first parameter')
        specification.description = 'Example function'

        x = create_definition.CreateDescriptionOfAFunctionSpecification()
        x.specification = specification
        x.start()

        self.assertTrue(x.out.string.find('void test(float64 one)') > 0)
        self.assertTrue(x.out.string.find('Example function') >= 0)
        self.assertTrue(x.out.string.find(':param one:') > 0)
Exemplo n.º 51
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)
Exemplo n.º 52
0
Arquivo: gd.py Projeto: Ingwar/amuse
 def set_eps2():
     """
     Update the value of the squared smoothing parameter.
     """
     function = LegacyFunctionSpecification()
     function.addParameter('epsilon_squared', dtype='float64', direction=function.IN,
         description = "The new value of the smooting parameter, squared.")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         Current value of the smoothing parameter was set
     -1 - ERROR
         The code does not have support for a smoothing parameter
     """
     return function
Exemplo n.º 53
0
Arquivo: gd.py Projeto: Ingwar/amuse
 def get_begin_time():
     """
     Retrieve the model time to start the evolution at.
     """
     function = LegacyFunctionSpecification()
     function.addParameter('time', dtype='float64', direction=function.OUT,
         description = "The begin time", unit = nbody_system.time)
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         Current value of the time was retrieved
     -2 - ERROR
         The code does not have support for querying the begin time
     """
     return function
Exemplo n.º 54
0
Arquivo: gd.py Projeto: Ingwar/amuse
 def get_time_step():
     """
     Retrieve the model timestep.
     """
     function = LegacyFunctionSpecification()
     function.addParameter('time_step', dtype='float64', direction=function.OUT,
         description = "The current model timestep")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         Current value of the time step was retrieved
     -1 - ERROR
         The code does not have support for querying the time
     """
     return function
Exemplo n.º 55
0
Arquivo: gd.py Projeto: Ingwar/amuse
 def get_number_of_particles():
     """
     Retrieve the total number of particles define  d in the code
     """
     function = LegacyFunctionSpecification()
     function.addParameter('number_of_particles', dtype='int32', direction=function.OUT,
         description = "Count of the particles in the code")
     function.result_type = 'int32'
     function.result_doc = """
      0 - OK
         Count could be determined
      -1 - ERROR
         Unable to determine the count
     """
     return function
Exemplo n.º 56
0
 def test4(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'
     
     x = create_definition.CreateFortranStub()
     x.specification = specification
     x.start()
     
     self.assertTrue(x.out.string.find('FUNCTION test(one)') >= 0)
     self.assertTrue(x.out.string.find('END FUNCTION') > 0)
     self.assertTrue(x.out.string.find('DOUBLE PRECISION :: one') > 0)
Exemplo n.º 57
0
Arquivo: gd.py Projeto: Ingwar/amuse
 def get_potential_energy():
     """
     Retrieve the current potential energy of the model
     """
     function = LegacyFunctionSpecification()
     function.addParameter('potential_energy', dtype='float64', direction=function.OUT,
         description = "The potential energy of the model")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         Current value of the potential energy was set
     -1 - ERROR
         Kinetic potential could not be provided
     """
     return function
Exemplo n.º 58
0
 def is_stopping_condition_set():
     """
     Return 1 if the stopping condition with
     the given index is enabled,0 otherwise.    
     """
     function = LegacyFunctionSpecification()  
     function.can_handle_array = True 
     function.addParameter('type', dtype='int32', direction=function.IN, description = "The index of the stopping condition")
     function.addParameter('result', dtype='int32', direction=function.OUT, description = "1 if the stopping condition is enabled")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
     -1 - ERROR
     """
     return function 
Exemplo n.º 59
0
Arquivo: gd.py Projeto: Ingwar/amuse
 def set_begin_time():
     """
     Set the model time to start the evolution at. This is an offset for
     all further calculations in the code.
     """
     function = LegacyFunctionSpecification()
     function.addParameter('time', dtype='float64', direction=function.IN,
         description = "The model time to start at", unit = nbody_system.time)
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         Time value was changed
     -2 - ERROR
         The code does not support setting the begin time
     """
     return function
Exemplo n.º 60
0
Arquivo: gd.py Projeto: Ingwar/amuse
 def get_total_radius():
     """
     Return the radius of the sphere, centered on the center of mass that
     contains all the particles. *get_size?*
     """
     function = LegacyFunctionSpecification()
     function.addParameter('radius', dtype='float64', direction=function.OUT,
         description = "The maximum distance from a star to the center of mass of the model")
     function.result_type = 'int32'
     function.result_doc = """
     0 - OK
         Current value of the radius was retrieved
     -1 - ERROR
         The value could not be provided
     """
     return function