Example #1
0
 def integrator(self, name_of_integrator):
     if self.__integrators is None:
         self.__integrators = Integrator.load_integrators()
     print(('Setting the integrator to %s' % name_of_integrator))
     # populate the parameters to the integrator
     if name_of_integrator in self.__integrators:
         self.__integrator = getattr(self.__integrators[name_of_integrator], name_of_integrator)()
         self.__integrator.CONST_G = self.CONST_G
         self.__integrator.t_end = self.__t_end
         self.__integrator.h = self.__h
         self.__integrator.t_start = self.__t_start
         self.__integrator.output_file = self.output_file
         self.__integrator.collision_output_file = self.collision_output_file
         self.__integrator.close_encounter_output_file = self.close_encounter_output_file
         self.__integrator.store_dt = self.__store_dt
         self.__integrator.buffer_len = self.__buffer_len
Example #2
0
    def initialize(self, config=None):
        # Initialize the integrator
        self.__integrators = Integrator.load_integrators()
        if self.__integrator is None:
            print('Use GaussRadau15 as the default integrator...')
            self.integrator = 'GaussRadau15'
            self.integrator.initialize()
            self.integrator.acceleration_method = 'ctypes'
        else:
            self.__integrator.CONST_G = self.CONST_G
            self.__integrator.t_end = self.__t_end
            self.__integrator.h = self.__h
            self.__integrator.t_start = self.__t_start
            self.__integrator.output_file = self.output_file
            self.__integrator.store_dt = self.__store_dt
            self.__integrator.buffer_len = self.__buffer_len


        if config is not None:
            # Gravitational parameter
            self.integrator.CONST_G = np.array(config['physical_params']['G'])

            # Integration parameters
            self.integrator = config['integration']['integrator']
            self.integrator.initialize()
            self.integrator.h = float(config['integration']['h'])
            if 'acc_method' in config['integration']:
                self.integrator.acceleration_method = config['integration']['acc_method']
            else:
                self.integrator.acceleration_method = 'ctypes'

            # Load sequence of object names
            if 'names' in config:
                names = config['names']
            else:
                names = None

            # Initial and final times
            if self.integrator.t_start == 0:
                self.integrator.t_start = float(config['integration']['t0'])
            if self.integrator.t_end == 0:
                self.integrator.t_end = float(config['integration']['tf'])
            self.integrator.active_integrator = config['integration']['integrator']
            DataIO.ic_populate(config['initial_conds'], self, names=names)