Intro
This is a small library meant to facilitate investigation of the Circular Restricted 3 Body Problem (CR3BP)
Usage
The library consists of a System dataclass representing a 3 body system,
a couple of functions which encode the equations of motion of the CR3BP, and
a function for setting initial conditions to get onto a periodic trajectory
around the collinear Lagrange points. Below we'll explain the System class
as well as the functions.
System class
You can either use one of the provided 3 body systems (Sun-Earth, Earth-Moon, Sun-Jupiter)
from cr3bp import EarthMoon
Or you can create your own system as follows:
from cr3bp import System
mass_primary = 2 # should be in kg
mass_secondary = 1 # should be in kg
distance = 100 # should be in m
MySystem = System(mass_primary, mass_secondary, distance)
System API
Properties
mass_primary - kg
mass_seconary - kg
l - m
G - 6.67408e-11 m^3 / (kg s^2) (this is constant across all Systems)
mu
theta_dot - radians/sec
total_mass - kg
seconds - number of seconds in a non-dimensional second (s*)
s - alias for seconds
conversion_vector - provides the vector [l, l, l, l/s, l/s, l/s] for converting dimensionless state to dimensional state
L1
L2
L3
L4
L5
All of the L* functions return dimensionless values. L1-3 return a float, L4 and L5 return a tuple with x and y values (but they just return (0.5, +/- sqrt(3)/2) for all systems). L1-3 perform a root-finding calculation so it's best not to use them in a performance sensitive loop - store the returned value and use that
Functions
convert_to_dimensional_state(state)
Accepts a dimensionless 6-element state vector and returns a 6-element state vector with dimensions added in
x_eqn
This is used for calculating the location of the collinear Lagrange points. It returns a function that bakes in the mu value of the system and which can then be used for plotting or root finding.
Other functions
-
DimensionalEOMs(t, X, system=EarthMoon)
This function encodes the EOMs for the CR3BP using dimensional values (meters, seconds, etc.). It is meant to be used with a numerical integrator from scipy. For example:scipy.integrate.solve_ivp(cr3bp.DimensionalEOMs, [0, 3600*24], IC, args=[cr3bp.SunEarth], atol=1e-6, rtol=1e-12)
In this case we are starting from some initial conditionIC(a 6 element state vector) and integrating for 1 day using the SunEarth system with a tolerance down to the micrometer level (atol=1e-6) -
EOMConstructor(mu, STM=False)
This encodes the EOMs in dimensionless form but it's a little different fromDimensionalEOMsin that it takes amuvalue and returns a function that can be used with numerical integrators. This just makes it a little smoother to use the numerical integrators since you specify the system when creating the EOMs as opposed to passing it in every time the EOMs are evaluated. The returned function can either integrate the State Transition Matrix or not. If integrating the STM, the returned function will expected a 42-element state vector, if not it will expect a 6-element one. Use this function like this:
EM = cr3bp.EarthMoon
eoms = cr3bp.EOMConstructor(EM.mu)
# We set the absolute tolerance to be at the micrometer level and keep the rtol small enough so that the atol dominates. rtol cannot be set lower than machine precision, so there may be some precision issues.
solution = scipy.integrate.solve_ivp(eoms, [0, 3600*24 / EM.seconds], IC, atol=0.000001/EM.l, rtol=2.3e-14)
initial_velocity(initial_position: tuple[float, float], lpoint: float, mu: float) -> tuple[float, float]:
This function takes a dimensionless initial position consisting of an x and y position relative to the system barycenter, the dimensionless value of the collinear Lagrange point around which one wants to oscillate, and the mu of the system and returns the necessary initial x and y velocity to get onto an oscillatory trajectory around the Lagrange point. Sample usage:
# IC (Initial Conditions) represents x, y, z, xdot, ydot, zdot
IC = [EM.L1 + 100/EM.l, 0, 0, 0, 0, 0]
IC[3:5] = cr3bp.initial_velocity(IC[:2], EM.L1, EM.mu)
Metadata
Release files for cr3bp 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cr3bp-0.2.1.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cr3bp-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.8 kB
Release files / cr3bp-0.2.1.tar.gz
| Download URL | cr3bp-0.2.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf7484f38e7e9fb30510e92b496149389ab87a56a722b3409032e2ce0d9628aa
|
|
BLAKE2b-256 checksum How to use checksums |
5dfff154c5a9addbf776b7f9ae5ac03ed8045d9ad92ab385cd3f2594a1389314
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Release files / cr3bp-0.2.1-py3-none-any.whl
| Download URL | cr3bp-0.2.1-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3cc8dcf14cc457c8a0cd429cc98fd0e570e77374cb0680b84c486843abc439ed
|
|
BLAKE2b-256 checksum How to use checksums |
15d766db9c82d705a403d410de9d497e12e1dd72d50c2ac2860685d9f517dc2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Security for cr3bp 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.