def test_whfast_democraticheliocentric(self): current_function_name = inspect.stack()[0][3][5:] # Remove first 5 characters "test_" expected_json_filename, json_filename = common.setup(self.current_dirname, self.current_filename, current_function_name) initial_time, time_step, time_limit, historic_snapshot_period, recovery_snapshot_period = common.simulation_properties() consider_effects = posidonius.ConsiderEffects({ "tides": True, "rotational_flattening": True, "general_relativity": True, "disk": True, "wind": True, "evolution": True, }) general_relativity_implementation = "Kidder1995" # Assumes one central massive body #general_relativity_implementation = "Anderson1975" # Assumes one central massive body #general_relativity_implementation = "Newhall1983" # Considers all bodies universe = posidonius.Universe(initial_time, time_limit, time_step, recovery_snapshot_period, historic_snapshot_period, consider_effects) star_mass = 0.08 # Solar masses star_dissipation_factor_scale = 1.0 star_position = posidonius.Axes(0., 0., 0.) star_velocity = posidonius.Axes(0., 0., 0.) #star_evolution = posidonius.Baraffe1998(star_mass) # M-Dwarf (mass = 0.10) or SolarLike ConstantDissipation (mass = 1.0) #star_evolution = posidonius.Baraffe2015(star_mass) # mass = 0.01 .. 1.40 star_evolution = posidonius.Leconte2011(star_mass) # BrownDwarf (mass = 0.01 .. 0.08) #star_evolution = posidonius.BolmontMathis2016(star_mass) # SolarLike Evolving dissipation (mass = 0.40 .. 1.40) #star_evolution = posidonius.GalletBolmont2017(star_mass) # SolarLike Evolving dissipation (mass = 0.30 .. 1.40) #star_evolution = posidonius.LeconteChabrier2013(False) # Jupiter without dissipation of dynamical tides #star_evolution = posidonius.LeconteChabrier2013(True) # Jupiter with dissipation of dynamical tides #star_evolution = posidonius.NonEvolving() star = common.brown_dwarf(star_mass, star_dissipation_factor_scale, star_position, star_velocity, general_relativity_implementation, star_evolution) universe.add_particle(star) common.basic_configuration(universe) ############################################################################ #whfast_alternative_coordinates="Jacobi" whfast_alternative_coordinates="DemocraticHeliocentric" #whfast_alternative_coordinates="WHDS" #universe.write(json_filename, integrator="LeapFrog") #universe.write(json_filename, integrator="IAS15") universe.write(json_filename, integrator="WHFast", whfast_alternative_coordinates=whfast_alternative_coordinates) if not os.path.exists(expected_json_filename): shutil.copyfile(json_filename, expected_json_filename) self.assertTrue(filecmp.cmp(json_filename, expected_json_filename, shallow=False), "Generated JSON case is not equal to the expected one: {} {}".format(json_filename, expected_json_filename)) shutil.rmtree(os.path.dirname(json_filename))
def calculate_spin(angular_frequency, inclination, obliquity, position, velocity): """ Old version of calculate spin used in all cases in Bolmont et al 2015 except for cases 6, 6', 6'', 6''' and 7 """ if inclination == 0.: # No inclination, spin can already be calculated: x = angular_frequency * np.sin( obliquity) # zero if there is no obliquity y = 0. z = angular_frequency * np.cos(obliquity) else: # Calculation of orbital angular momentum (without mass and in AU^2/day) horb_x = position.y() * velocity.z() - position.z() * velocity.y() horb_y = position.z() * velocity.x() - position.x() * velocity.z() horb_z = position.x() * velocity.y() - position.y() * velocity.x() horbn = np.sqrt( np.power(horb_x, 2) + np.power(horb_y, 2) + np.power(horb_z, 2)) # Spin taking into consideration the inclination: x = angular_frequency * ( horb_x / (horbn * np.sin(inclination))) * np.sin(obliquity + inclination) y = angular_frequency * ( horb_y / (horbn * np.sin(inclination))) * np.sin(obliquity + inclination) z = angular_frequency * np.cos(obliquity + inclination) return posidonius.Axes(x, y, z)
def _posvel(star_mass, planet_mass, a): zeros = posidonius.Axes(0., 0., 0.) #////////// Specify initial position and velocity for a stable orbit #////// Keplerian orbital elements, in the `asteroidal' format of Mercury code #a = 0.018; # semi-major axis (in AU) e = 0.1 # eccentricity i = 5. * posidonius.constants.DEG2RAD # inclination (degrees) p = 0. * posidonius.constants.DEG2RAD # argument of pericentre (degrees) n = 0. * posidonius.constants.DEG2RAD # longitude of the ascending node (degrees) l = 0. * posidonius.constants.DEG2RAD # mean anomaly (degrees) p = (p + n) # Convert to longitude of perihelion !! q = a * (1.0 - e) # perihelion distance position, velocity = posidonius.calculate_cartesian_coordinates( planet_mass, q, e, i, p, n, l, masses=[star_mass], positions=[zeros], velocities=[zeros]) return position, velocity
def _spin(obliquity, rotation_period, star_mass, planet_mass, planet_position, planet_velocity): zeros = posidonius.Axes(0., 0., 0.) #////// Initialization of planetary spin angular_frequency = posidonius.constants.TWO_PI / (rotation_period / 24. ) # days^-1 keplerian_orbital_elements = posidonius.calculate_keplerian_orbital_elements( planet_mass, planet_position, planet_velocity, masses=[star_mass], positions=[zeros], velocities=[zeros]) inclination = keplerian_orbital_elements[3] spin = posidonius.calculate_spin(angular_frequency, inclination, obliquity) return spin
recovery_snapshot_period, historic_snapshot_period, consider_effects) star_mass = 0.08 # Solar masses star_radius_factor = 0.845649342247916 # [start correction] ------------------------------------------------------- # To reproduce Bolmont et al. 2015: # Mercury-T was using R_SUN of 4.67920694e-3 AU which is not the IAU accepted value # thus, to reproduce Mercury-T results the star radius factor should be slighly modified: star_radius_factor = star_radius_factor * (4.67920694e-3 / posidonius.constants.R_SUN) # [end correction] --------------------------------------------------------- star_radius = star_radius_factor * posidonius.constants.R_SUN star_radius_of_gyration = 4.41e-01 # Brown dwarf star_position = posidonius.Axes(0., 0., 0.) star_velocity = posidonius.Axes(0., 0., 0.) # Initialization of stellar spin star_rotation_period = 70.0 # hours star_angular_frequency = posidonius.constants.TWO_PI / ( star_rotation_period / 24.) # days^-1 star_spin = posidonius.Axes(0., 0., star_angular_frequency) star_tides_parameters = { "dissipation_factor_scale": 0.01, "dissipation_factor": 2.006 * 3.845764e4, "love_number": 0.307, } star_tides_model = posidonius.effects.tides.ConstantTimeLag( star_tides_parameters)