def to_model(self, merge_if_possible=True):
        '''
        Returns a Model instance of the current model

        The AnalyticalYSOModel class is dynamic in the sense that one can
        change the parameters relating to the density structure at any time.
        This method computes the Model instance corresponding to the current
        density structure and computes the optimal grid.

        Parameters
        ----------
        merge_if_possible : bool
            Whether to merge density arrays that have the same dust type
        '''

        if self.grid is None:
            raise Exception("The coordinate grid needs to be defined")

        # Initialize new Model instance
        m = Model()

        # Set up grid
        if isinstance(self.grid, collections.Mapping):
            m.grid = self._set_polar_grid_auto(**self.grid)
        else:
            m.grid = deepcopy(self.grid)

        # Copy over settings
        m.name = self.name
        m.conf = deepcopy(self.conf)
        m.sources = deepcopy(self.sources)
        m.binned_output = deepcopy(self.binned_output)
        m.peeled_output = deepcopy(self.peeled_output)

        m._minimum_temperature = deepcopy(self._minimum_temperature)
        m._minimum_specific_energy = deepcopy(self._minimum_specific_energy)

        m._monochromatic = self._monochromatic
        m._frequencies = self._frequencies

        # Easiest way to copy over all settings
        g = virtual_file()
        self.write_run_conf(g)
        m.read_run_conf(g)
        g.close()

        for i, disk in enumerate(self.disks):

            if disk.rmin >= disk.rmax:
                logger.warn("Disk rmin >= rmax, ignoring density contribution")
            elif disk.mass == 0.:
                logger.warn("Disk mass is zero, ignoring density contribution")
            else:

                if not disk.dust:
                    raise Exception("Disk %i dust not set" % (i + 1))
                m.add_density_grid(disk.density(m.grid), disk.dust,
                                   merge_if_possible=merge_if_possible)

        for i, envelope in enumerate(self.envelopes):

            if envelope.rmin >= envelope.rmax:
                logger.warn("Envelope rmin >= rmax, "
                            "ignoring density contribution")
            elif isinstance(envelope, UlrichEnvelope) and envelope.rho_0 == 0.:
                logger.warn("Ulrich envelope has zero density everywhere, "
                            "ignoring density contribution")
            elif isinstance(envelope, PowerLawEnvelope) and envelope.mass == 0.:
                logger.warn("Power-law envelope has zero density everywhere, "
                            "ignoring density contribution")
            else:

                if not envelope.dust:
                    raise Exception("Envelope dust not set")
                m.add_density_grid(envelope.density(m.grid), envelope.dust,
                                   merge_if_possible=merge_if_possible)

                if envelope.cavity is not None:
                    if envelope.cavity.theta_0 == 0.:
                        logger.warn("Cavity opening angle is zero, "
                                    "ignoring density contribution")
                    elif envelope.cavity.rho_0 == 0.:
                        logger.warn("Cavity density is zero, "
                                    "ignoring density contribution")
                    else:
                        if not envelope.cavity.dust:
                            raise Exception("Cavity dust not set")
                        m.add_density_grid(envelope.cavity.density(m.grid),
                                           envelope.cavity.dust,
                                           merge_if_possible=merge_if_possible)

        # AMBIENT MEDIUM

        for i, ambient in enumerate(self.ambients):

            if ambient.density == 0.:
                logger.warn("Ambient medium has zero density, "
                            "ignoring density contribution")
            else:

                if not ambient.dust:
                    raise Exception("Ambient medium dust not set")

                m.add_density_grid(ambient.density(m.grid),
                                   ambient.dust,
                                   merge_if_possible=merge_if_possible)

        # SOURCES

        # Star

        if self.star.sources['star'].luminosity > 0:
            if self.star.sources['star'] not in self.sources:
                m.add_source(self.star.sources['star'])

        # Accretion

        if 'uv' in self.star.sources and self.star.sources['uv'].luminosity > 0.:
            if self.star.sources['uv'] not in self.sources:
                m.add_source(self.star.sources['uv'])

        if 'xray' in self.star.sources and self.star.sources['xray'].luminosity > 0.:
            if self.star.sources['xray'] not in self.sources:
                m.add_source(self.star.sources['xray'])

        for i, disk in enumerate(self.disks):

            if isinstance(disk, AlphaDisk):
                if disk.rmax >= disk.rmin:
                    logger.warn("Disk rmin >= rmax, "
                                "ignoring accretion luminosity")
                elif disk.mass == 0.:
                    logger.warn("Disk mass is zero, "
                                "ignoring accretion luminosity")
                elif disk.lvisc == 0.:
                    logger.warn("Disk viscous luminosity is zero, "
                                "ignoring accretion luminosity")
                else:
                    m.add_map_source(luminosity=disk.lvisc, map=disk.accretion_luminosity(m.grid), name='accdisk%i' % i)

        return m
dataset/ETHPy150Open hyperion-rt/hyperion/hyperion/model/analytical_yso_model.py/AnalyticalYSOModel.to_model/swapped operands of `>=`