Commit c2cdc579 authored by Laura Ketzer's avatar Laura Ketzer
Browse files

fixed issue #12

parent 86d4dc2b
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"# Planet Classes\n",
"#sys.path.append('platypos_package/')\n",
"from platypos_package.Planet_class_LoFo14 import planet_LoFo14"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'star_id': 'V1298Tau',\n",
" 'mass_star': 1.101,\n",
" 'radius_star': 1.345,\n",
" 'age': 23.0,\n",
" 'Lbol': 3.5753520000000005e+33,\n",
" 'Lx_age': 1.3e+30,\n",
" 'Lx_sat_info': None,\n",
" 'distance': 0.1,\n",
" 'metallicity': 'solarZ',\n",
" 'flux': 92.59500937302329,\n",
" 'has_evolved': False,\n",
" 'planet_id': 'dummy',\n",
" 'planet_info': 'Case 2 - obs. planet with radius, but no mass measurement',\n",
" 'core_mass': 5.0,\n",
" 'radius': 6.0,\n",
" 'core_radius': 1.4953487812212205,\n",
" 'fenv': 9.03435088013424,\n",
" 'mass': 5.496580355746687}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# (David et al. 2019, Chandra observation)\n",
"L_bol, mass_star, radius_star = 0.934, 1.101, 1.345 # solar units\n",
"age_star = 23. # Myr\n",
"Lx_age = Lx_chandra = 1.3e30 # erg/s in energy band: (0.1-2.4 keV)\n",
"Lx_age_error = 1.4e29\n",
"# use dictionary to store star-parameters\n",
"star_V1298Tau = {'star_id': 'V1298Tau', 'mass': mass_star, 'radius': radius_star, 'age': age_star, 'L_bol': L_bol, 'Lx_age': Lx_age}\n",
"Lx_1Gyr, Lx_5Gyr = 2.10*10**28, 1.65*10**27\n",
"track = {\"t_start\": star_V1298Tau[\"age\"], \"t_sat\": 100., \"t_curr\": 1000., \"t_5Gyr\": 5000., \"Lx_max\": Lx_age, \n",
" \"Lx_curr\": Lx_1Gyr, \"Lx_5Gyr\": Lx_5Gyr, \"dt_drop\": 0., \"Lx_drop_factor\": 0.}\n",
"\n",
"planet = {\"core_mass\": 5.0, \"radius\": 6.0, \"distance\": 0.1, \"metallicity\": \"solarZ\"}\n",
"\n",
"pl = planet_LoFo14(star_V1298Tau, planet)\n",
"pl.__dict__"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"folder_id = \"dummy\"\n",
"path_save = os.getcwd() + \"/\" + folder_id +\"/\"\n",
"if not os.path.exists(path_save):\n",
" os.makedirs(path_save)\n",
"else:\n",
" print(\"exists\")\n",
"\n",
"pl.evolve_forward(4500, 0.1, 0.1, \"yes\", \"yes\", track, path_save, folder_id)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
  • If you stop the kernel and clean the output you won't follow these unecessary changes.

Please register or sign in to reply
......@@ -27,17 +27,17 @@ the density of the planet,
is the efficiency of the atmospheric escape with a value between 0 and 1, and K is a factor representing the impact of Roche lobe overflow (Erkaev et al. 2007)[^Erkaev-et-al-07], which can take on values of 1 for no Roche lobe influence and <1 for planets filling significant fractions of their Roche lobes.
**Stellar high-energy evolution** <br>
Most previous studies of exoplanet evaporation approximate the stellar XUV evolution by using the average activity level of stars in a specific mass bin for well-studied clusters of different ages, and approximating it with a broken power-law with a 100 Myr-long saturation regime. Observations and theoretical studies show, however, that stars spin down at a wider range of ages (see Barnes 2003[^Barnes-03], Matt et al. 2012[^Matt-et-al-12], Tu et al. 2015[^Tu-et-al-20], Garaffo et al. 2018[^Garaffo-et-al-2018]). In the context of exoplanet irradiation, this was explored in simulations by Tu et al. (2015)[^Tu-et-al-20] and Johnstone et al. (2015)[^Johnstone-et-al-2015]. Their studies show that the saturation timescales can range from ~10 to 300 Myr for solar-mass stars. Hence, a star that spins down quickly will follow a low-activity track, while a star that can maintain its rapid rotation will follow a high-activity track. This translates into significantly different irradiation levels for exoplanets, and thus the amount and strength of evaporation. Based on the findings by Tu et al. (2015), we generate a more realistic stellar activity evolution of the host star by adopting a simplified broken power-law model with varying saturation and spin-down time scales to approximate a low-, medium- and high-activity scenario for the host star. \vspace{0.5cm}
Most previous studies of exoplanet evaporation approximate the stellar XUV evolution by using the average activity level of stars in a specific mass bin for well-studied clusters of different ages, and approximating it with a broken power-law with a 100 Myr-long saturation regime. Observations and theoretical studies show, however, that stars spin down at a wider range of ages (see Barnes 2003[^Barnes-03], Matt et al. 2012[^Matt-et-al-12], Tu et al. 2015[^Tu-et-al-15], Garaffo et al. 2018[^Garaffo-et-al-2018]). In the context of exoplanet irradiation, this was explored in simulations by Tu et al. (2015)[^Tu-et-al-20] and Johnstone et al. (2015)[^Johnstone-et-al-2015]. Their studies show that the saturation timescales can range from ~10 to 300 Myr for solar-mass stars. Hence, a star that spins down quickly will follow a low-activity track, while a star that can maintain its rapid rotation will follow a high-activity track. This translates into significantly different irradiation levels for exoplanets, and thus the amount and strength of evaporation. Based on the findings by Tu et al. (2015), we generate a more realistic stellar activity evolution of the host star by adopting a broken power-law model with varying saturation and spin-down time scales to approximate a low-, medium- and high-activity scenario for the host star.
### Planet Model description: <br>
At the moment, the user can choose between two planet models.
1. *Planet with a rocky core and H/He envelope atop* <br>
We use the tabulated models of Lopez & Fortney (2014)[^Lopez-Fortney_2014], who calculate radii for low-mass planets with hydrogen-helium envelopes on top of Earth-like rocky cores, taking into account the cooling and thermal contraction of the atmospheres of such planets over time. Their simulations extend to young planetary ages, at which planets are expected to still be warm and possibly inflated. Simple analytical fits to their simulation results are provided, which we use to trace the thermal and photoevaporative evolution of the planetary radius over time.
We use the tabulated models of Lopez & Fortney (2014)[^Lopez-Fortney-14], who calculate radii for low-mass planets with hydrogen-helium envelopes on top of Earth-like rocky cores, taking into account the cooling and thermal contraction of the atmospheres of such planets over time. Their simulations extend to young planetary ages, at which planets are expected to still be warm and possibly inflated. Simple analytical fits to their simulation results are provided, which we use to trace the thermal and photoevaporative evolution of the planetary radius over time.
1. *Planet which follows the empirical mass-radius relationships observed for planets around older stars* <br>
(see Otegi et al. (2020)[^Otegi-et-al-2020], also Chen & Kipping (2017)[^Chen-Kipping_2017]) <br>
(see Otegi et al. (2020)[^Otegi-et-al-2020], also Chen & Kipping (2017)[^Chen-Kipping-2017]) <br>
These "mature" relationships show two regimes, one for small rocky planets up to radii of about 2 Earth radii and one for larger planets with volatile-rich envelopes. The scatter is low in the rocky planet regime and larger in the gaseous planet regime: as core vs. envelope fractions may vary, there is a broader range of observed masses at a given planetary radius for those larger planets.
1. *Giant planets with mass-radius relations computed using MESA* <br>
......@@ -49,8 +49,8 @@ To be implemented...
* **platypos_package**: contains the planet classes & all the necessary funtions to construct a planet and make it evolve
(LoF014 planet with rocky core & gaseous envelope OR planet based on mass-radius relation for mature planets (Ot20))
* **supplementary_files**: contains some extra files for plotting
Tu et al. (2015)[^Tu-et-al-20] model tracks for the X-ray luminosity evolution,
* **supplementary_files**: contains some extra files for plotting;
Tu et al. (2015)[^Tu-et-al-15] model tracks for the X-ray luminosity evolution,
Jackson et al. (2012)[^Jackson-et-al-12] sample of X-ray measurements in young clusters)
* **example_V1298Tau**: evolve the four young V1298 Tau planets as shown in "X-ray irradiation and evaporation of the four young planets around V1298 Tau"
......@@ -63,9 +63,9 @@ To be implemented...
[^Poppenhaeger-et-al-20]: [Poppenhaeger, Ketzer, Mallon 2020](https://arxiv.org/abs/2005.10240)
[^Erkaev-et-al-07]: [Erkaev et al. 2007](https://arxiv.org/abs/astro-ph/0612729)
[^Lopez-Fortney_2014]: [Lopez & Fortney 2014](https://arxiv.org/abs/1311.0329)
[^Lopez-Fortney-14]: [Lopez & Fortney 2014](https://arxiv.org/abs/1311.0329)
[^Jackson-et-al-12]: [Jackson et al. 2012](https://arxiv.org/abs/1111.0031)
[^Chen-Kipping_2017]: [Chen & Kipping 2017](https://arxiv.org/abs/1603.08614)
[^Chen-Kipping-2017]: [Chen & Kipping 2017](https://arxiv.org/abs/1603.08614)
[^Otegi-et-al-2020]: [Otegi et al. 2020](https://arxiv.org/abs/1911.04745)
[^Barnes-03]: [Barnes 2003](https://arxiv.org/abs/astro-ph/0303631)
[^Matt-et-al-12]: [Matt et al. 2012](https://arxiv.org/abs/1206.2354)
......
a,core_mass,fenv,mass,radius,metallicity,age
0.1,5.0,9.03435088013424,5.496580355746687,6.0,solarZ,23.0
\ No newline at end of file
This diff is collapsed.
a,core_mass,fenv,mass,radius,metallicity,track
0.1,5.0,0.0,5.0,1.4953487812212205,solarZ,dummy_track_23.0_100.0_4500_1.3e+30_0.0_0.0
\ No newline at end of file
star_id,mass_star,radius_star,age,Lbol,Lx_age
V1298Tau,1.101,1.345,23.0,0.934,1.3e+30
\ No newline at end of file
t_start,t_sat,t_curr,t_5Gyr,Lx_max,Lx_curr,Lx_5Gyr,dt_drop,Lx_drop_factor
23.0,100.0,1000.0,5000.0,1.3e+30,2.1e+28,1.65e+27,0.0,0.0
\ No newline at end of file
......@@ -17,7 +17,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -4,15 +4,15 @@ import sys
import astropy.units as u
from astropy import constants as const
from Lx_evo_and_flux import Lx_evo
from Lx_evo_and_flux import flux_at_planet_earth
from Lx_evo_and_flux import L_xuv_all
from Lx_evo_and_flux import flux_at_planet
import Planet_models_LoFo14 as plmoLoFo14
import Planet_model_Ot20 as plmoOt20
import Beta_K_functions as bk
from Mass_loss_rate_function import mass_loss_rate_forward_LO14
from Mass_loss_rate_function import mass_loss_rate_forward_Ot20
from platypos_package.Lx_evo_and_flux import Lx_evo
from platypos_package.Lx_evo_and_flux import flux_at_planet_earth
from platypos_package.Lx_evo_and_flux import L_xuv_all
from platypos_package.Lx_evo_and_flux import flux_at_planet
import platypos_package.Planet_models_LoFo14 as plmoLoFo14
import platypos_package.Planet_model_Ot20 as plmoOt20
import platypos_package.Beta_K_functions as bk
from platypos_package.Mass_loss_rate_function import mass_loss_rate_forward_LO14
from platypos_package.Mass_loss_rate_function import mass_loss_rate_forward_Ot20
  • That is much much better!!!! one little tip for this, PEP8 suggest to avoid suffixes like _package in the name of a package. It is one and it should be clear that it is one, so platypos should be enough.

Please register or sign in to reply
def mass_planet_RK4_forward_LO14(epsilon, K_on, beta_on, planet_object,
......
# mass loss rate function
import astropy.units as u
from astropy import constants as const
from Lx_evo_and_flux import Lx_evo
from Lx_evo_and_flux import flux_at_planet_earth
from Lx_evo_and_flux import L_xuv_all
from Lx_evo_and_flux import flux_at_planet
import Planet_models_LoFo14 as plmoLoFo14
import Planet_model_Ot20 as plmoOt20
import Beta_K_functions as bk
from platypos_package.Lx_evo_and_flux import Lx_evo
from platypos_package.Lx_evo_and_flux import flux_at_planet_earth
from platypos_package.Lx_evo_and_flux import L_xuv_all
from platypos_package.Lx_evo_and_flux import flux_at_planet
import platypos_package.Planet_models_LoFo14 as plmoLoFo14
import platypos_package.Planet_model_Ot20 as plmoOt20
import platypos_package.Beta_K_functions as bk
def mass_loss_rate_forward_LO14(t_, epsilon, K_on, beta_on,
......
......@@ -6,11 +6,11 @@ import scipy.optimize as optimize
import astropy.units as u
from astropy import constants as const
from Lx_evo_and_flux import Lx_evo
from Lx_evo_and_flux import flux_at_planet_earth
from Lx_evo_and_flux import L_xuv_all
from Lx_evo_and_flux import flux_at_planet
from Mass_evolution_function import mass_planet_RK4_forward_LO14
from platypos_package.Lx_evo_and_flux import Lx_evo
from platypos_package.Lx_evo_and_flux import flux_at_planet_earth
from platypos_package.Lx_evo_and_flux import L_xuv_all
from platypos_package.Lx_evo_and_flux import flux_at_planet
from platypos_package.Mass_evolution_function import mass_planet_RK4_forward_LO14
class planet_LoFo14():
......@@ -214,45 +214,44 @@ class planet_LoFo14():
# Next, create a file (e.g. planet_XXXX.txt) which contains the
# initial planet params
if not os.path.exists(path_for_saving+planet_folder_id+".txt"):
p = open(path_for_saving+planet_folder_id+".txt", "w")
planet_params = "a,core_mass,fenv,mass,radius,metallicity,age\n"\
+ str(self.distance) + "," + str(self.core_mass)\
+ "," + str(self.fenv) + "," + str(self.mass)\
+ "," + str(self.radius) + "," + self.metallicity\
+ "," + str(self.age)
p.write(planet_params)
p.close()
with open(path_for_saving+planet_folder_id+".txt", "w") as p:
planet_params = "a,core_mass,fenv,mass,radius,metallicity,age\n"\
+ str(self.distance) + "," + str(self.core_mass)\
+ "," + str(self.fenv) + "," + str(self.mass)\
+ "," + str(self.radius) + "," + self.metallicity\
+ "," + str(self.age)
p.write(planet_params)
p.close()
Please register or sign in to reply
# create a file (track_params_planet_....txt) which contains
# the track parameters
if not os.path.exists(path_for_saving + "track_params_"\
+ self.planet_id + ".txt"):
t = open(path_for_saving+"track_params_" +
self.planet_id+".txt", "w")
track_params = "t_start,t_sat,t_curr,t_5Gyr,Lx_max,Lx_curr,"\
+ "Lx_5Gyr,dt_drop,Lx_drop_factor\n"\
+ str(evo_track_dict["t_start"]) + ","\
+ str(evo_track_dict["t_sat"]) + "," \
+ str(evo_track_dict["t_curr"]) + ","\
+ str(evo_track_dict["t_5Gyr"]) + ","\
+ str(evo_track_dict["Lx_max"]) + ","\
+ str(evo_track_dict["Lx_curr"]) + ","\
+ str(evo_track_dict["Lx_5Gyr"]) + ","\
+ str(evo_track_dict["dt_drop"]) + ","\
+ str(evo_track_dict["Lx_drop_factor"])
t.write(track_params)
t.close()
with open(path_for_saving+"track_params_"+self.planet_id+".txt", "w") as t:
track_params = "t_start,t_sat,t_curr,t_5Gyr,Lx_max,Lx_curr,"\
+ "Lx_5Gyr,dt_drop,Lx_drop_factor\n"\
+ str(evo_track_dict["t_start"]) + ","\
+ str(evo_track_dict["t_sat"]) + "," \
+ str(evo_track_dict["t_curr"]) + ","\
+ str(evo_track_dict["t_5Gyr"]) + ","\
+ str(evo_track_dict["Lx_max"]) + ","\
+ str(evo_track_dict["Lx_curr"]) + ","\
+ str(evo_track_dict["Lx_5Gyr"]) + ","\
+ str(evo_track_dict["dt_drop"]) + ","\
+ str(evo_track_dict["Lx_drop_factor"])
t.write(track_params)
t.close()
Please register or sign in to reply
# create a file which contains the host star parameters
if not os.path.exists(path_for_saving+"host_star_properties.txt"):
s = open(path_for_saving+"host_star_properties.txt", "w")
star_params = "star_id,mass_star,radius_star,age,Lbol,Lx_age\n"\
+ self.star_id + "," + str(self.mass_star) + ","\
+ str(self.radius_star) + "," + str(self.age)\
+ "," + str(self.Lbol/const.L_sun.cgs.value)\
+ "," + str(self.Lx_age)
s.write(star_params)
s.close()
with open(path_for_saving+"host_star_properties.txt", "w") as s:
star_params = "star_id,mass_star,radius_star,age,Lbol,Lx_age\n"\
+ self.star_id + "," + str(self.mass_star) + ","\
+ str(self.radius_star) + "," + str(self.age)\
+ "," + str(self.Lbol/const.L_sun.cgs.value)\
+ "," + str(self.Lx_age)
s.write(star_params)
s.close()
  • this is not needed the with statement is there for this reason, it take care of it.

Please register or sign in to reply
# call mass_planet_RK4_forward_LO14 to start the integration
t, M, R, Lx = mass_planet_RK4_forward_LO14(
......@@ -271,21 +270,21 @@ class planet_LoFo14():
# create another file, which contains the final parameters only
if not os.path.exists(path_for_saving+\
self.planet_id+"_final.txt"):
p = open(path_for_saving+self.planet_id+"_final.txt", "w")
# get index of last valid entry in the radius array and access
# its value
index_of_last_entry = df["Radius"][df["Radius"].notna()].index[-1]
R_final = df["Radius"].loc[index_of_last_entry]
index_of_last_entry = df["Mass"][df["Mass"].notna()].index[-1]
M_final = df["Mass"].loc[index_of_last_entry]
f_env_final = ((M_final-self.core_mass)/M_final)*100 # %
planet_params = "a,core_mass,fenv,mass,radius,metallicity,track\n"\
+ str(self.distance) + "," + str(self.core_mass)\
+ "," + str(f_env_final) + "," + str(M_final)\
+ "," + str(R_final) + "," + self.metallicity\
+ "," + self.planet_id
p.write(planet_params)
p.close()
with open(path_for_saving+self.planet_id+"_final.txt", "w") as p:
  • don't forget PEP8:

    with open(path_for_saving + self.planet_id + "_final.txt", "w") as p:
Please register or sign in to reply
# get index of last valid entry in the radius array and access
# its value
index_of_last_entry = df["Radius"][df["Radius"].notna()].index[-1]
R_final = df["Radius"].loc[index_of_last_entry]
index_of_last_entry = df["Mass"][df["Mass"].notna()].index[-1]
M_final = df["Mass"].loc[index_of_last_entry]
f_env_final = ((M_final-self.core_mass)/M_final)*100 # %
planet_params = "a,core_mass,fenv,mass,radius,metallicity,track\n"\
+ str(self.distance) + "," + str(self.core_mass)\
+ "," + str(f_env_final) + "," + str(M_final)\
+ "," + str(R_final) + "," + self.metallicity\
+ "," + self.planet_id
p.write(planet_params)
p.close()
self.has_evolved = True # set evolved-flag to True
......@@ -306,7 +305,6 @@ class planet_LoFo14():
print("Planet has not been evolved & no result file exists.")
def evolve_backwards(self, t_final, initial_step_size, epsilon, K_on,
beta_on, evo_track_dict, path_for_saving):
def evolve_backwards(self):
raise NotImplementedError("Coming soon! :)")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment