Exemple #1
0
    def run(self,
            model,
            plasma,
            no_of_packets,
            no_of_virtual_packets=0,
            nthreads=1,
            last_run=False):
        """
        Run the montecarlo calculation

        Parameters
        ----------
        model : tardis.model.Radial1DModel
        plasma : tardis.plasma.BasePlasma
        no_of_packets : int
        no_of_virtual_packets : int
        nthreads : int
        last_run : bool

        Returns
        -------
        None
        """
        self._integrator = FormalIntegrator(model, plasma, self)
        self.time_of_simulation = self.calculate_time_of_simulation(model)
        self.volume = model.volume
        self._initialize_estimator_arrays(self.volume.shape[0],
                                          plasma.tau_sobolevs.shape)
        self._initialize_geometry_arrays(model)

        self._initialize_packets(model.t_inner.value, no_of_packets)

        montecarlo.montecarlo_radial1d(
            model,
            plasma,
            self,
            virtual_packet_flag=no_of_virtual_packets,
            nthreads=nthreads,
            last_run=last_run)
        # Workaround so that j_blue_estimator is in the right ordering
        # They are written as an array of dimension (no_of_shells, no_of_lines)
        # but python expects (no_of_lines, no_of_shells)
        self.j_blue_estimator = np.ascontiguousarray(
            self.j_blue_estimator.flatten().reshape(
                self.j_blue_estimator.shape, order='F'))
        self.Edotlu_estimator = np.ascontiguousarray(
            self.Edotlu_estimator.flatten().reshape(
                self.Edotlu_estimator.shape, order='F'))
Exemple #2
0
    def run(
        self,
        model,
        plasma,
        no_of_packets,
        no_of_virtual_packets=0,
        nthreads=1,
        last_run=False,
        iteration=0,
    ):
        """
        Run the montecarlo calculation

        Parameters
        ----------
        model : tardis.model.Radial1DModel
        plasma : tardis.plasma.BasePlasma
        no_of_packets : int
        no_of_virtual_packets : int
        nthreads : int
        last_run : bool

        Returns
        -------
        None
        """

        set_num_threads(nthreads)

        self._integrator = FormalIntegrator(model, plasma, self)
        self.time_of_simulation = self.calculate_time_of_simulation(model)
        self.volume = model.volume

        # Initializing estimator array
        self._initialize_estimator_arrays(plasma.tau_sobolevs.shape)

        self._initialize_geometry_arrays(model)

        self._initialize_packets(model.t_inner.value, no_of_packets, iteration)

        configuration_initialize(self, no_of_virtual_packets)
        montecarlo_radial1d(model, plasma, self)