Beispiel #1
0
    def solve(self, show_progress=False):
        """ Solve the system

        Notes
        -----
        Pre-stepping functions are those that need to be called before
        the integrator is called. 

        Similarly, post step functions are those that are called after
        the stepping within the integrator.

        """
        self.count = 0
        maxval = int((self.tf - self.t) / self.dt + 1)
        bar = PBar(maxval, show=show_progress)

        while self.t < self.tf:
            self.t += self.dt
            self.count += 1

            # update the particles explicitly

            self.particles.update()

            # perform any pre step functions

            for func in self.pre_step_functions:
                func.eval(self, self.count)

            # perform the integration

            logger.info("Time %f, time step %f " % (self.t, self.dt))

            self.integrator.integrate(self.dt)

            # perform any post step functions

            for func in self.post_step_functions:
                func.eval(self, self.count)

            # dump output

            if self.count % self.pfreq == 0:
                self.dump_output(*self.print_properties)

            bar.update()

            if self.execute_commands is not None:
                if self.count % self.command_interval == 0:
                    self.execute_commands(self)

        bar.finish()
Beispiel #2
0
    def solve(self, show_progress=False):
        """ Solve the system

        Notes
        -----
        Pre-stepping functions are those that need to be called before
        the integrator is called. 

        Similarly, post step functions are those that are called after
        the stepping within the integrator.

        """
        self.count = 0
        maxval = int((self.tf - self.t) / self.dt + 1)
        bar = PBar(maxval, show=show_progress)

        while self.t < self.tf:
            self.t += self.dt
            self.count += 1

            #update the particles explicitly

            self.particles.update()

            # perform any pre step functions

            for func in self.pre_step_functions:
                func.eval(self, self.count)

            # perform the integration

            logger.info("Time %f, time step %f " % (self.t, self.dt))

            self.integrator.integrate(self.dt)

            # perform any post step functions

            for func in self.post_step_functions:
                func.eval(self, self.count)

            # dump output

            if self.count % self.pfreq == 0:
                self.dump_output(*self.print_properties)

            bar.update()

            if self.execute_commands is not None:
                if self.count % self.command_interval == 0:
                    self.execute_commands(self)

        bar.finish()
Beispiel #3
0
    def solve(self, show_progress=False):
        """ Solve the system

        Notes
        -----
        Pre-stepping functions are those that need to be called before
        the integrator is called. 

        Similarly, post step functions are those that are called after
        the stepping within the integrator.

        """
        dt = self.dt

        bt = (self.tf - self.t)/1000.0
        bcount = 0.0
        bar = PBar(1001, show=show_progress)

        self.dump_output(dt, *self.print_properties)

        # set the time for the integrator
        self.integrator.time = self.t

        while self.t < self.tf:
            self.t += dt
            self.count += 1

            # update the particles explicitly
            self.particles.update()

            # perform any pre step functions
            for func in self.pre_step_functions:
                func.eval(self)

            # compute the local time step
            if not self.with_cl:
                dt = self.time_step_function.compute_time_step(self)

            # compute the global time step
            dt = self.compute_global_time_step(dt)
            
            logger.info("Time %f, time step %f, rank  %d"%(self.t, dt,
                                                           self.rank))
            # perform the integration and update the time
            self.integrator.integrate(dt)
            self.integrator.time += dt

            # update the time for all arrays
            self.update_particle_time()

            # perform any post step functions            
            for func in self.post_step_functions:
                func.eval(self)

            # dump output
            if self.count % self.pfreq == 0:
                self.dump_output(dt, *self.print_properties)

            bcount += self.dt/bt
            while bcount > 0:
                bar.update()
                bcount -= 1
        
            if self.execute_commands is not None:
                if self.count % self.command_interval == 0:
                    self.execute_commands(self)

        bar.finish()