Function Repository Resource:

LagrangePointData

Source Notebook

Compute properties for the Lagrange points of two orbiting astronomical bodies

Contributed by: Jeff Bryant

ResourceFunction["LagrangePointData"][{entity1, entity2},property]

compute the value of property assuming the current distance between entity1 and entity2.

ResourceFunction["LagrangePointData"][{entity1, entity2},date,property]

compute the value of property assuming a distance between entity1 and entity2 on the specified date.

Details and Options

Computations are done in a coordinate system that rotates with the two primary bodies as they orbit.
In the coordinate system used, the origin is at the center of mass of the system and the orbiting bodies orbit in the xy plane with the z‐axis perpendicular to that plane.
The positive x‐direction is in the direction of the smaller mass.
The positive y‐direction follows a right‐hand rule convention.
The gravitational effective potential includes terms for the masses of the two bodies in addition to a centripetal term due to the orbital motion.
The distance between the two bodies changes with time, scaling the numbers accordingly.
For a given date, the gravitational effective potential assumes a circular orbit of entity1 and entity2 using the distance on that date (a) as the distance between the bodies.
The following keys can be seen in the results:
qthe mass ratio, Msecondary/Mprimary
μthe reduced mass,Msecondary/(Mprimary + Msecondary)
athe distance between entity1 and entity2
ωthe angular velocity of the orbit
The "NondimensionalizedPotential" sub‐value of the "GravitationalEffectivePotentialData" property uses SI base units.
The property can be any of the following:
"ContourPlot"contour plot of the gravitational effective potential
"ContourPlot3D"3D contour plot of the gravitational effective potential
"Distances"dataset of distances between the bodies and the Lagrange points
"GravitationalEffectivePotentialData"association of data related to the gravitational effective potential
"Plot3D"3D surface plot of the gravitational effective potential
Options supported by LagrangePointData include:
"EmphasizeSecondaryMassRegion"Falsewhether or not to zoom into the area near the secondary mass
TargetUnitsAutomaticunits to use only when requesting distances
Additional options vary depending on the property requested ("ContourPlot" supports all the options of ContourPlot, etc.).
The potential (V) can be used to formulate the position and speed of a third body in the system using the following equations of motion: x''-2ωy'==-V/x, y''+2ωx'==-V/y.

Examples

Basic Examples (6) 

Compute data about the gravitational effective potential:

In[1]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "GravitationalEffectivePotentialData"]
Out[1]=

Find the gravitational effective potential at a specific 3D point:

In[2]:=
ResourceFunction[
   "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "GravitationalEffectivePotentialData"]["Potential"][
 Quantity[3.44*^8, "Meters"], Quantity[0, "Meters"], Quantity[0, "Meters"]]
Out[2]=

Create a contour plot of the gravitational effective potential:

In[3]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "ContourPlot"]
Out[3]=

Create a 3D surface plot of the gravitational effective potential:

In[4]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "Plot3D"]
Out[4]=

Create a 3D contour plot of the gravitational effective potential:

In[5]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "ContourPlot3D"]
Out[5]=

Compute the current distance between both bodies and the various Lagrange points:

In[6]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "Distances"]
Out[6]=

Compute the distance between both bodies and the various Lagrange points on a specified date:

In[7]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, DateObject[{2024, 7, 16, 0, 0, 0}, TimeZone -> "America/Chicago"], "Distances"]
Out[7]=

Scope (1) 

Create a contour plot with distances:

In[8]:=
Grid[{ResourceFunction[
   "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["MinorPlanet", "Pluto"], Entity["PlanetaryMoon", "Charon"]}, {"ContourPlot", "Distances"}, ImageSize -> 300, TargetUnits -> "Kilometers"]}]
Out[8]=

Options (3) 

Emphasize the area around the secondary mass as 2D contours:

In[9]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "ContourPlot", "EmphasizeSecondaryMassRegion" -> True]
Out[9]=

Emphasize the area around the secondary mass as a 3D surface:

In[10]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "Plot3D", "EmphasizeSecondaryMassRegion" -> True]
Out[10]=

Emphasize the area around the secondary mass as 3D contours:

In[11]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "ContourPlot3D", "EmphasizeSecondaryMassRegion" -> True]
Out[11]=

Specify the distance to the Lagrange points in specific units:

In[12]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "Distances", TargetUnits -> "Kilometers"]
Out[12]=

Plot the equipotential through a specific Lagrange point:

In[13]:=
With[{entities = {Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}}, ResourceFunction[
  "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][entities, "ContourPlot3D", Contours -> {QuantityMagnitude[
     ResourceFunction[
       "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][entities, "GravitationalEffectivePotentialData"]["L1Potential"]]}]]
Out[13]=

Applications (4) 

Compute the distances of the bodies to the L1 point of the Earth-Moon system:

In[14]:=
ResourceFunction[
  "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "Distances", TargetUnits -> "Kilometers"]["L1"]
Out[14]=

Compute the distance of the Earth to the L1 point of the Earth-Moon system:

In[15]:=
ResourceFunction[
   "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "Distances", TargetUnits -> "Kilometers"]["L1"][Entity["Planet", "Earth"]]
Out[15]=

Compute the distance between the Moon and the L1 point of the Earth-Moon system:

In[16]:=
ResourceFunction[
   "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]}, "Distances", TargetUnits -> "Kilometers"]["L1"][Entity["PlanetaryMoon", "Moon"]]
Out[16]=

Compute the distance between Earth and the Moon:

In[17]:=
UnitConvert[
 AstroDistance[Entity["Planet", "Earth"], Entity["PlanetaryMoon", "Moon"]], "Kilometers"]
Out[17]=

Possible Issues (1) 

If the two bodies don't orbit each other, then computations are not applicable:

In[18]:=
ResourceFunction[
 "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Planet", "Earth"], Entity["Planet", "Mars"]}, "GravitationalEffectivePotentialData"]
Out[18]=

Neat Examples (4) 

Explore the Lagrange points of the Sun‐Jupiter system:

In[19]:=
{\[Omega], V, L1, L4, L5, cp} = Flatten[{{QuantityMagnitude[#[[1]]], #[[2]][x[t], y[t], z[t]], QuantityMagnitude[#[[3]]], QuantityMagnitude[#[[4]]], QuantityMagnitude[#[[5]]]} &@
        Lookup[#[[1]], {"\[Omega]", "NondimensionalizedPotential", "L1Position", "L4Position", "L5Position"}], #[[2]]} &@
     ResourceFunction[
      "LagrangePointData", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Entity["Star", "Sun"], Entity["Planet", "Jupiter"]}, {"GravitationalEffectivePotentialData", "ContourPlot"}], 1] /. z[t] -> 0;

Solve the equations of motion for a particle starting at the L1 point and moving in the -x‐direction and -y‐direction over a period of about 31 years (1,000,000,000 seconds):

In[20]:=
L1sols = NDSolve[{x''[t] - 2 \[Omega] y'[t] == -D[V, x[t]], y''[t] + 2 \[Omega] x'[t] == -D[V, y[t]], x'[0] == -5000., y'[0] == -300., x[0] == L1[[1]], y[0] == L1[[2]], z[0] == L1[[3]]}, {x, y}, {t, 0, 1000000000}];

Solve the equations of motion for particle starting near the L4 and L5 points with different initial velocities:

In[21]:=
L4sols = NDSolve[{x''[t] - 2 \[Omega] y'[t] == -D[V, x[t]], y''[t] + 2 \[Omega] x'[t] == -D[V, y[t]], x'[0] == -1000., y'[0] == -300., x[0] == L4[[1]], y[0] == L4[[2]] - 20000000000, z[0] == L4[[3]]}, {x, y}, {t, 0, 1000000000}];
In[22]:=
L5sols = NDSolve[{x''[t] - 2 \[Omega] y'[t] == -D[V, x[t]], y''[t] + 2 \[Omega] x'[t] == -D[V, y[t]], x'[0] == -1000., y'[0] == -300., x[0] == L5[[1]], y[0] == L5[[2]] - 20000000000, z[0] == L5[[3]]}, {x, y}, {t, 0, 1000000000}];
In[23]:=
L1path = ParametricPlot[Evaluate[{x[t], y[t]} /. L1sols], {t, 0, 1000000000},
    PlotStyle -> Darker[Red, .3]];
In[24]:=
L4path = ParametricPlot[Evaluate[{x[t], y[t]} /. L4sols], {t, 0, 1000000000},
    PlotStyle -> Blue];
In[25]:=
L5path = ParametricPlot[Evaluate[{x[t], y[t]} /. L5sols], {t, 0, 1000000000},
    PlotStyle -> Yellow];
In[26]:=
Show[{cp, L1path, L4path, L5path}, PlotRange -> All]
Out[26]=

The motion around L4 and L5 is stable if μ2>23/27.

Explore the space of possible orbits of a test particle starting near L4:

In[27]:=
Manipulate[
 Module[{sol, L4 = Most[L4]}, sol = NDSolve[{x''[t] - 2 \[Omega] y'[t] == -D[V, x[t]], y''[t] + 2 \[Omega] x'[t] == -D[V, y[t]], x'[0] == v0[[1]], y'[0] == v0[[2]], x[0] == L4[[1]] + \[Delta]xy[[1]], y[0] == L4[[2]] + \[Delta]xy[[2]]}, {x, y}, {t, 0, 10^T}];
  Show[{cp, ParametricPlot[Evaluate[({x[t], y[t]}) /. sol], {t, 0, 10^T}, PlotStyle -> Directive[Darker[Red, .3], Thickness[0.003]], Frame -> True, Axes -> False]}, PlotRangePadding -> 1*^12, Frame -> False, Axes -> False, Background -> GrayLevel[.95]]], Row[{Control[{{T, 10.2, "T"}, 3, 11}], "  ", Dynamic[Quantity[Round[10^T/3.28725`*^7, 0.1], "Years"]]}], Row[{Control[{{\[Delta]xy, {100, 100}}, 10^6 {-1, -1}, 10^6 {1, 1}}],
    "  ", Dynamic[Quantity[Round[\[Delta]xy, 0.1], "Meters"]]}], Row[{Control[{{v0, {575, -300}}, 10^4 {-1, -1}, 10^4 {1, 1}}], "  ", Dynamic[Quantity[Round[\[Delta]xy, 0.1], "Meters"/"Seconds"]]}], SynchronousUpdating -> False]
Out[27]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.2 – 27 October 2023
  • 1.0.1 – 27 September 2023
  • 1.0.0 – 22 September 2023

Source Metadata

License Information