def setup_magnetospheric_accretion(self, mdot, rtrunc, fspot,
                                       xwav_min=0.001, xwav_max=0.01):
        '''
        Set up the model for magnetospheric accretion

        Parameters
        ----------
        mdot : float
            The accretion rate onto the star in cgs
        rtrunc : float
            The magnetospheric truncation radius of the disk in cgs
        fspot : float
            The spot coverage fraction. Photons will be emitted uniformly from
            the star, the coverage fraction ``fspot`` will determine the
            spectrum of the hot spot emission (smaller covering fractions will
            lead to a hotter spectrum).

        Notes
        -----
        This method only takes into account the hot spot and X-ray emission
        from the stellar surface. To simulate the viscous accretion luminosity
        in the disk, add an :class:`~hyperion.densities.AlphaDisk` to the
        model using :meth:`~hyperion.model.AnalyticalYSOModel.add_alpha_disk`
        and set the accretion rate or luminosity accordingly.
        '''

        # For convenience
        lstar = self.star.sources['star'].luminosity

        if self.star.mass is None:
            raise Exception("Stellar mass is not set")

        # Find the luminosity dissipated in the shock
        lshock = G * self.star.mass * mdot * (1 / self.star.radius - 1 / rtrunc)

        # Hot spot parameters
        fluxratio = 0.5 * lshock / lstar / fspot
        teff = (lstar / (4. * pi * self.star.radius ** 2 * sigma)) ** 0.25  # Kelvin
        tshock = teff * (1 + fluxratio) ** 0.25  # Kelvin

        # Set the hot spot source
        self.star.sources['uv'] = SphericalSource(name='uv',
                                                  radius=self.star.radius)
        self.star.sources['uv'].luminosity = lshock / 2. + lstar * fspot
        self.star.sources['uv'].temperature = tshock

        # X-rays from 0.1 to 10nm
        wav = np.logspace(np.log10(xwav_min), np.log10(xwav_max), 100)[::-1]
        nu = c * 1.e4 / wav
        fnu = np.repeat(1., nu.shape)

        # Set the X-ray source
        self.star.sources['xray'] = SphericalSource(name='xray',
                                                    radius=self.star.radius)
        self.star.sources['xray'].luminosity = lshock / 2.
        self.star.sources['xray'].spectrum = (nu, fnu)

        # Reduce the total luminosity from the original source
        self.star.sources['star'].luminosity *= 1 - fspot

    # OUTPUT
dataset/ETHPy150Open hyperion-rt/hyperion/hyperion/model/analytical_yso_model.py/AnalyticalYSOModel.setup_magnetospheric_accretion/original