ast2000tools.relativity.RelativityExperiments

class ast2000tools.relativity.RelativityExperiments(seed, data_path=None, solution_path=None)

Bases: object

Represents a set of experiments with relativity taking place in your solar system.

This class is used to run various experiments with special and general relativity and observe the results.

Parameters
  • seed (int) – The seed to use when generating random solar system and experiment properties.

  • data_path (str, optional) – Specifies the path to the directory where output XML files should be stored (e.g. the MCAst data folder). By default, a folder called “XMLs” is created in the working directory.

  • solution_path (str, optional) – Specifies the path to the directory where output solution text files should be stored. By default, a folder called “Solutions” is created in the working directory.

Methods

antimatter_spaceship(planet_idx[, …])

An antimatter spaceship and an ordinary spaceship travel towards each other close to the speed of light, before annihilating and producing photons with identical wavelengths.

black_hole_descent(planet_idx[, …])

A spaceship is falling towards a black hole while exhanging light signals with a spacecraft near an orbiting planet.

black_hole_schedules(distance[, filename, …])

Two astronauts living in spaceships orbiting respectively close to and far from a black hole are sending each other messages about their schedule.

cosmic_pingpong(planet_idx[, filename_1, …])

Two spaceships are playing cosmic ping-pong with a laser beam.

crash_landing(planet_idx[, increase_height, …])

A spaceship’s failed landing attempt is observed from both the spaceship the surface of the planet.

gps(planet_idx[, angular_position, …])

Two GPS satellites are passing above an observer on the equator.

laser_chase(planet_idx[, increase_height, …])

A fast moving spaceship emits two successive laser beams, which are observed from the frame of reference of a planet and the spaceship.

lightning_strikes(planet_idx[, …])

A spaceship is struck by a yellow and a blue lightning bolt while traveling through the atmosphere of a planet.

more_lightning_strikes(planet_idx[, …])

The unfortunate spaceship flying through the atmosphere is this time struck by a green, a pink, a blue and a yellow lightning bolt.

neutron_decay(planet_idx[, increase_height, …])

A fast moving neutron disintegrates spontaneously, and a proton and an electron are seen to continue in the same direction.

spaceship_duel(planet_idx[, …])

Two spaceships are moving with equal speed relative to a planet, firing lasers at each other and exploding simultaneously in their frame of reference.

spaceship_race(planet_idx[, filename_1, …])

Three spaceships are traveling with different velocities with respect to a space station.

twin_paradox(planet_idx[, filename_1, …])

An astronaut is traveling at close to the speed of light to a distant planet and back again, while an observer remains at the home planet.

Attributes

data_path

The path to the directory where output XML files will be stored.

seed

The seed used to generate random solar system and experiment properties.

solution_path

The path to the directory where output solution files will be stored.

system

The randomized solar system where the experiments take place.

property seed

The seed used to generate random solar system and experiment properties.

Type

int

property data_path

The path to the directory where output XML files will be stored.

Type

str

property solution_path

The path to the directory where output solution files will be stored.

Type

str

property system

The randomized solar system where the experiments take place.

Type

SolarSystem

crash_landing(planet_idx, increase_height=False, filename_1='crash_landing_frame_1.xml', filename_2='crash_landing_frame_2.xml', number_of_video_frames=1000, write_solutions=False)

A spaceship’s failed landing attempt is observed from both the spaceship the surface of the planet.

Generates the XML files used in Exercise 2 in Part 2A of the lecture notes.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.001 planet radii to be used. Using True increases this to 1.1. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1000, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

lightning_strikes(planet_idx, increase_height=False, filename_1='lightning_strikes_frame_1.xml', filename_2='lightning_strikes_frame_2.xml', field_of_view=70, number_of_video_frames=1000, write_solutions=False)

A spaceship is struck by a yellow and a blue lightning bolt while traveling through the atmosphere of a planet.

Generates the XML files used in Exercise 3 in Part 2A of the lecture notes.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.01 planet radii to be used. Using True increases this to 1.1. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • field_of_view (float, optional) – The field of view of the camera, in degrees. Default is 70.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1000, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

spaceship_duel(planet_idx, increase_height=False, filename_1='spaceship_duel_frame_1.xml', filename_2='spaceship_duel_frame_2.xml', number_of_video_frames=400, write_solutions=False)

Two spaceships are moving with equal speed relative to a planet, firing lasers at each other and exploding simultaneously in their frame of reference.

Generates the XML files used in Exercise 4 in Part 2A of the lecture notes and Exercise 1 in Part 8 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.02 planet radii to be used. Using True increases this to 1.1. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename_1 (str, optional) – The filename to use for frame of reference 1. Default is “spaceship_duel_frame_1.xml”.

  • filename_2 (str, optional) – The filename to use for frame of reference 2. Default is “spaceship_duel_frame_2.xml”.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 400, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

cosmic_pingpong(planet_idx, filename_1='cosmic_pingpong_frame_1.xml', filename_2='cosmic_pingpong_frame_2.xml', filename_3='cosmic_pingpong_frame_3.xml', number_of_video_frames=1000, write_solutions=False)

Two spaceships are playing cosmic ping-pong with a laser beam.

Generates the XML files used in Exercise 5 in Part 2A of the lecture notes and Exercise 2 in Part 8 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • filename_3 (str, optional) – The filename to use for frame of reference 3.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1000, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

more_lightning_strikes(planet_idx, increase_height=False, filename_1='more_lightning_strikes_frame_1.xml', filename_2='more_lightning_strikes_frame_2.xml', field_of_view=70, number_of_video_frames=1000, write_solutions=False)

The unfortunate spaceship flying through the atmosphere is this time struck by a green, a pink, a blue and a yellow lightning bolt.

Generates the XML files used in Exercise 6 in Part 2A of the lecture notes.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.01 planet radii to be used. Using True increases this to 1.1. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • field_of_view (float, optional) – The field of view of the camera, in degrees. Default is 70.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1000, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

twin_paradox(planet_idx, filename_1='twin_paradox_frame_1.xml', filename_2='twin_paradox_frame_2.xml', filename_3='twin_paradox_frame_3.xml', number_of_video_frames=1500)

An astronaut is traveling at close to the speed of light to a distant planet and back again, while an observer remains at the home planet.

Generates the XML files used in Exercise 8 in Part 2A of the lecture notes.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • filename_3 (str, optional) – The filename to use for frame of reference 3.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1500, but must be at least 100.

spaceship_race(planet_idx, filename_1='spaceship_race_frame_1.xml', filename_2='spaceship_race_frame_2.xml', filename_3='spaceship_race_frame_3.xml', number_of_video_frames=1500)

Three spaceships are traveling with different velocities with respect to a space station.

Generates the XML files used in Exercise 1 in Part 2B of the lecture notes and Exercise 4 in Part 8 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • filename_3 (str, optional) – The filename to use for frame of reference 3.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1500, but must be at least 100.

laser_chase(planet_idx, increase_height=False, filename_1='laser_chase_frame_1.xml', filename_2='laser_chase_frame_2.xml', number_of_video_frames=400, write_solutions=False)

A fast moving spaceship emits two successive laser beams, which are observed from the frame of reference of a planet and the spaceship.

Generates the XML files used in Exercise 3 in Part 2B of the lecture notes and Exercise 5 in Part 8 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.02 planet radii to be used. Using True increases this to 1.1. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 400, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

neutron_decay(planet_idx, increase_height=False, filename_1='neutron_decay_frame_1.xml', filename_2='neutron_decay_frame_2.xml', number_of_video_frames=1200, write_solutions=False)

A fast moving neutron disintegrates spontaneously, and a proton and an electron are seen to continue in the same direction.

Generates the XML files used in Exercise 4 in Part 2B of the lecture notes and Exercise 6 in Part 8 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.05 planet radii to be used. Using True increases this to 1.2. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1200, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

antimatter_spaceship(planet_idx, increase_height=False, filename_1='antimatter_spaceship_frame_1.xml', filename_2='antimatter_spaceship_frame_2.xml', number_of_video_frames=400, write_solutions=False)

An antimatter spaceship and an ordinary spaceship travel towards each other close to the speed of light, before annihilating and producing photons with identical wavelengths.

Generates the XML files used in Exercise 5 in Part 2B of the lecture notes and Exercise 7 in Part 8 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.015 planet radii to be used. Using True increases this to 1.1. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 400, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

black_hole_descent(planet_idx, number_of_light_signals=30, consider_light_travel=False, text_file_dir='.', filename_1='black_hole_descent_frame_1.xml', filename_2='black_hole_descent_frame_2.xml', write_solutions=False)

A spaceship is falling towards a black hole while exhanging light signals with a spacecraft near an orbiting planet.

Generates the XML and text files used in Exercise 5 in Part 2C and Exercise 2 in Part 2E of the lecture notes and Exercise 3 in Part 9 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • number_of_light_signals (int, optional) – The number of light signals sent out by the falling spaceship. Default is 30, but must be between 10 and 100.

  • consider_light_travel (bool, optional) – Whether to take into account the traveling time of light. If True, note that an extra label will be added to the inputted file names to avoid conflicts with existing files. Default is False.

  • text_file_dir (str, optional) – The path to the directory in which to generate text files containing the time intervals between successive light signals. If set to None, no text files will be generated. Default is to generate text files in the working directory.

  • filename_1 (str, optional) – The filename to use for frame of reference 1.

  • filename_2 (str, optional) – The filename to use for frame of reference 2.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

gps(planet_idx, angular_position=None, increase_height=False, filename='gps.xml', number_of_video_frames=1000, write_solutions=False)

Two GPS satellites are passing above an observer on the equator.

Generates the XML file used in Exercise 8 in Part 2C of the lecture notes and Exercise 5 in Part 9 of the project.

Parameters
  • planet_idx (int) – Index of the planet above which the experiment takes place.

  • angular_position (float, optional) – The angular position of the observer on the planet equator, measured in radians from the x-axis. By default, the observer is situated at a random angle in the range [pi/2, 3*pi/2].

  • increase_height (bool or float, optional) – Determines the height above the planet center where the experiment takes place. The default value (False) causes a predetermined height of 1.01 planet radii to be used. Using True increases this to 1.1. Optionally, a custom adjustment parameter between 0.5 and 5 can be provided. Try modifying this argument if the spaceships interfere with the surface of the planet.

  • filename (str, optional) – The filename to use for the XML file.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1000, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.

black_hole_schedules(distance, filename='black_hole_schedules.xml', number_of_video_frames=1000, write_solutions=False)

Two astronauts living in spaceships orbiting respectively close to and far from a black hole are sending each other messages about their schedule.

Generates the XML files used in Exercise 2 in Part 2C of the lecture notes.

Note

For each scheduled activity you will be asked to input an associated time and message.

Parameters
  • distance ({'close', 'far'}) – Whether the observer should be the one close to or far from the black hole.

  • filename (str, optional) – The base filename to use for the XML file. Note that an extra label will be added to the inputted file name to indicate whether the observer is close or far. Default is “black_hole_schedules.xml”.

  • number_of_video_frames (int, optional) – The number of video frames to use in the XML files. Can be reduced to reduce file size, but be aware that this might lead to errors. Default is 1000, but must be at least 100.

  • write_solutions (bool, optional) – Whether to write a text file containing the solutions associated with this experiment. Default is False.