Commit 86d4dc2b authored by Laura Ketzer's avatar Laura Ketzer
Browse files

fix issue #11 & #15, don't use if ... pass, but if not; plus raise NotImplemented error

parent 7dfe8eb6
......@@ -148,6 +148,7 @@ class planet_LoFo14():
# print("Sth went wrong in solving for\
# the envelope mass fraction! Check!")
def Calculate_R_env(self):
""" Check Planet_models_LoFo14.py for details on input and
output parameters;
......@@ -160,17 +161,19 @@ class planet_LoFo14():
((self.age/1e3)/5)**(age_exponent[self.metallicity])
return R_env # in units of R_earth
def Calculate_planet_radius(self):
""" Check Planet_models_LoFo14.py for details"""
self.radius = self.core_radius + self.Calculate_R_env()
def set_name(self, t_final, initial_step_size,
epsilon, K_on, beta_on, evo_track_dict):
""" Function to set the right planet name based on the track specified.
This can then be used to check if a particular planet on a particular
track has already evolved (i.e. if outpufile exists). """
self.planet_id = 'planet_a'\
+ str(np.round(self.distance, 3)).replace('.', 'dot')\
+ str(np.round(self.distance, 3)).replace('.', 'dot')\
+ '_Mcore'\
+ str(np.round(self.core_mass, 3)).replace(".", "dot")\
+ '_fenv'\
......@@ -184,6 +187,7 @@ class planet_LoFo14():
+ str(evo_track_dict["dt_drop"]) + "_"\
+ str(evo_track_dict["Lx_drop_factor"])
def evolve_forward(self, t_final, initial_step_size, epsilon, K_on, beta_on,
evo_track_dict, path_for_saving, planet_folder_id):
""" Call this function to make the planet evolve. This also produces the
......@@ -209,9 +213,7 @@ class planet_LoFo14():
#print("Planet: ", self.planet_id+".txt")
# Next, create a file (e.g. planet_XXXX.txt) which contains the
# initial planet params
if os.path.exists(path_for_saving+planet_folder_id+".txt"):
pass
else:
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)\
......@@ -223,10 +225,8 @@ class planet_LoFo14():
# create a file (track_params_planet_....txt) which contains
# the track parameters
if os.path.exists(path_for_saving + "track_params_"\
if not os.path.exists(path_for_saving + "track_params_"\
+ self.planet_id + ".txt"):
pass
else:
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,"\
......@@ -244,9 +244,7 @@ class planet_LoFo14():
t.close()
# create a file which contains the host star parameters
if os.path.exists(path_for_saving+"host_star_properties.txt"):
pass
else:
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) + ","\
......@@ -271,10 +269,8 @@ class planet_LoFo14():
df.to_csv(path_for_saving+self.planet_id+".txt", index=None)
# create another file, which contains the final parameters only
if os.path.exists(path_for_saving+\
if not os.path.exists(path_for_saving+\
self.planet_id+"_final.txt"):
pass
else:
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
......@@ -293,6 +289,7 @@ class planet_LoFo14():
self.has_evolved = True # set evolved-flag to True
def read_results(self, file_path):
# planet exists, has been evolved and results can be read in
if self.has_evolved == True:
......@@ -308,7 +305,8 @@ class planet_LoFo14():
else:
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):
print("Not implemented yet.")
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