# Path: DiscEvolution/star.py
# class PhotoStar(SimpleStar):
#     def __init__(self, LX=1e30, Phi=0, **kwargs):
#         super().__init__(**kwargs)
#         self._L_X = LX
#         self._Phi = Phi
# 
#     @property
#     def L_X(self):
#         """X-ray Luminosity"""
#         return self._L_X
# 
#     @property
#     def Phi(self):
#         """EUV Photon Luminosity"""
#         return self._Phi


import numpy as np
import argparse
import json
import matplotlib.pyplot as plt
from DiscEvolution.constants import *
from DiscEvolution.star import PhotoStar
from scipy.signal import argrelmin
    from control_scripts import run_model
        if not self._Hole: #self._type=='Primordial':
            self.check_dt(disc, dt)

        # Determine mass loss
        dSigma = np.minimum(self.dSigmadt * dt, disc.Sigma_G)   # Limit mass loss to density of cell
        dSigma *= (disc.R < self._R_out)                        # Only apply mass loss inside disc outer edge

        # Apply, preserving the dust mass
        if hasattr(disc, 'Sigma_D'):
            Sigma_D = disc.Sigma_D                              # Save the dust density
        disc._Sigma -= dSigma
        if hasattr(disc, 'Sigma_D'):
            dusty = Sigma_D.sum(0)>0
            disc.dust_frac[:,dusty] = np.fmin(Sigma_D[:,dusty]/disc.Sigma[dusty],disc.dust_frac[:,dusty]/disc.dust_frac.sum(0)[dusty])
            disc.dust_frac[:] /= np.maximum(disc.dust_frac.sum(0), 1.0)           # Renormalise to 1 if it exceeds

        # Calculate actual mass loss given limit
        if dt>0:
            dM = 2*np.pi * disc.R * dSigma
            self._Mdot_true = np.trapz(dM,disc.R) / dt * AU**2 / Msun

    def get_Rhole(self, disc, external_photo=None):
        """Deal with calls when there is no hole"""
        if not self._Hole:
            print("No hole for which to get radius. Ignoring command and returning nans.")
            return np.nan, np.nan

        """Otherwise continue on to find hole
           First find outer edge of disc - hole must be inside this"""
        if external_photo:

# Path: DiscEvolution/star.py
# class PhotoStar(SimpleStar):
#     def __init__(self, LX=1e30, Phi=0, **kwargs):
#         super().__init__(**kwargs)
#         self._L_X = LX
#         self._Phi = Phi
# 
#     @property
#     def L_X(self):
#         """X-ray Luminosity"""
#         return self._L_X
# 
#     @property
#     def Phi(self):
#         """EUV Photon Luminosity"""
#         return self._Phi


# Path: DiscEvolution/internal_photo.py
import numpy as np
import argparse
import json
import matplotlib.pyplot as plt
from DiscEvolution.constants import *
from DiscEvolution.star import PhotoStar
from scipy.signal import argrelmin
    from control_scripts import run_model

        if not self._Hole: #self._type=='Primordial':
            self.check_dt(disc, dt)

        # Determine mass loss
        dSigma = np.minimum(self.dSigmadt * dt, disc.Sigma_G)   # Limit mass loss to density of cell
        dSigma *= (disc.R < self._R_out)                        # Only apply mass loss inside disc outer edge

        # Apply, preserving the dust mass
        if hasattr(disc, 'Sigma_D'):
            Sigma_D = disc.Sigma_D                              # Save the dust density
        disc._Sigma -= dSigma
        if hasattr(disc, 'Sigma_D'):
            dusty = Sigma_D.sum(0)>0
            disc.dust_frac[:,dusty] = np.fmin(Sigma_D[:,dusty]/disc.Sigma[dusty],disc.dust_frac[:,dusty]/disc.dust_frac.sum(0)[dusty])
            disc.dust_frac[:] /= np.maximum(disc.dust_frac.sum(0), 1.0)           # Renormalise to 1 if it exceeds

        # Calculate actual mass loss given limit
        if dt>0:
            dM = 2*np.pi * disc.R * dSigma
            self._Mdot_true = np.trapz(dM,disc.R) / dt * AU**2 / Msun

    def get_Rhole(self, disc, external_photo=None):
        """Deal with calls when there is no hole"""
        if not self._Hole:
            print("No hole for which to get radius. Ignoring command and returning nans.")
            return np.nan, np.nan

        """Otherwise continue on to find hole
           First find outer edge of disc - hole must be inside this"""
        if external_photo:

            self._R_out = external_photo._Rot      # If external photoevaporation is present, only consider radii inside its influence