Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

L.M. Arthur, A.M. Decker, Cambridge, MA, 2025-2026

This code is a work in progress, and is not yet ready for use. It is being developed for research purposes in the MIT Laboratory for Nuclear Security and Policy.

Get started

pytrajlib is a library written in a combination of C and Python whose purpose is to simulate trajectories of missiles with ballistic and maneuvering reentry vehicles and determine their accuracy. Accuracy limits arise from errors that can be broadly categorized into guidance errors (estimates of the current missile state) or control (maneuverability) limitations. pytrajlib's key output is the distribution of miss distances. Samples of this distribution are obtained by Monte-Carlo sampling of error factors and trajectories.

Installation

pytrajlib is pip-installable, though we recommend using a packaging manager such as uv. To install, run

pip install pytrajlib

Quickstart

pytrajlib can be run as a command-line tool to facilitate use in larger scripts or other programming languages. For a list of commands, try

pytrajlib --help

To quickly get started, run

pytrajlib --num-runs 10 --num-processes 2

The primary outputs of interest are the impact data and the impact scatter plot, which shows the impact locations with downrange and crossrange components. These plots are created by default and saved by default to output/rv-maneuv/impact_plot.png along with detailed trajectory and reentry guidance information about the first run in CSV files.

To examine the first trajectory's characteristics, use the --plot-trajectory flag

pytrajlib --num-runs 10 --num-processes 2 --plot-trajectory

You can also use pytrajlib like any other Python package from a Python file or notebook:

import pytrajlib as ptl

impact_df = ptl.run(num_runs=10, num_processes=2, plot_trajectory=True)
print(impact_df)

Pytrajlib supports two primary reentry vehicle (RV) types: ballistic and maneuverable.

Maneuverable RVs are the default. A ballistic RV can be specified with the --rv-maneuv 0 flag:

# maneuverable (default)
pytrajlib --rv-maneuv 1


# ballistic without accurate positioning updates
pytrajlib --rv-maneuv 0 --gnss-nav 0

Detailed usage

All simulation and vehicle configs can be changed using a configuration .json file. Run the modified simulation with

pytrajlib --config path-to-your-config.json

The default configuration is

{
  # run parameters
  "run": {
    "run_name": "rv-maneuv", # Run identifier used for output folders and artifacts.
    "num_runs": 200, # Number of simulation runs to execute.
    "num_runs_optimizer": 50, # Number of Monte Carlo runs used by the boost and reentry optimizers.
    "num_trials_optimizer": 100, # Number of optimization trials per optimizer run.
    "time_step_boost": 0.001, # Time step used during the boost phase, in seconds.
    "time_step_lambert": 0.0001, # Time step used during Lambert maneuver, in seconds.
    "time_step_midcourse": 1.0, # Time step used during the midcourse phase, in seconds.
    "time_step_reentry": 0.0001, # Time step used during the reentry phase, in seconds.
    "traj_output": 1, # Write trajectory output logs for the first run with 1, and disable with 0.
    "range": 10000000, # Downrange distance in meters; supersedes the aimpoint.
    "x_aim": null, # Target aimpoint x-coordinate in meters.
    "y_aim": null, # Target aimpoint y-coordinate in meters.
    "z_aim": null, # Target aimpoint z-coordinate in meters.
    "integrator": 1, # Integrator selection; 0 is modified Euler-Maruyama, 1 is SRA3.
    "random_seed": -1, # Random seed used to initialize stochastic simulation inputs.
    "atm_path": null, # Path to the atmospheric profiles file used by the simulation.
    "optimize_boost": 0, # Optimize t_des_final and theta_long when set to 1.
    "optimize_reentry": 0 # Optimize reentry maneuver parameters (max_deflection_angle, gearing_ratio, nav_gain_0, nav_gain_1, K_q, K_pp, K_delta_p, K_delta_d) when set to 1.
  },
  # flight parameters
  "flight": {
    "grav_error": 1, # Enable the gravitational error model.
    "ballistic_drag": 0, # Use simplified drag; 1 enables it and 0 disables it.
    "atm_model": 2, # Atmospheric model selection; 0 is exponential, 1 adds perturbations, 2 is EarthGram, 3 is mean EarthGram.
    "gnss_nav": 1, # Enable GNSS position updates during exoatmospheric flight.
    "rv_maneuv": 1, # Reentry vehicle maneuverability mode; 1 uses realistic maneuverability, 2 uses idealized maneuverability.
    "perfect_boost": 0, # Set to 1 for a perfect boost phase and 0 for a realistic boost phase.
    "t_vert_boost": 10, # Vertical boost time, in seconds.
    "deflection_time": 0.02, # Actuator deflection time, in seconds.
    "actuator_force": 100, # Maximum actuator force in kN.
    "actuator_resolution": 0.01 # Actuator resolution in degrees.
  },
  # optimized parameters
  "optimized": {
    "theta_long": 0.6715065960788051, # Thrust angle from x axis in x-y plane.
    "theta_lat": 0.0, # Thrust angle above x-y plane.
    "t_des_final": 2986.6467267274857, # Desired final time for the boost phase, in seconds.
    "gearing_ratio": 18.902565748694002, # Actuator gearing ratio. Higher gearing ratios correspond to increased max force and decreased max speed.
    "max_deflection_angle": 5.005158800904358, # Maximum deflection angle allowed for the reentry vehicle in degrees.
    "nav_gain_0": 17.16392199274926, # Navigation gain at surface used by the reentry guidance law.
    "nav_gain_1": 1.8450079089106168, # Navigation gain at reentry used by the reentry guidance law.
    "K_q": 9.93839564932045, # Pitch-rate feedback gain.
    "K_pp": 12.011089458530302, # Proportional restoring angle of attack gain.
    "K_delta_p": 0.2397109503235244, # Proportional deflection gain.
    "K_delta_d": 12.81326407331284 # Derivative deflection gain.
  },
  # error parameters
  "error": {
    "initial_x_error": 0.0, # Initial x-position error.
    "initial_pos_error": 0.1, # Initial position error magnitude.
    "initial_vel_error": 0.001, # Initial velocity error magnitude.
    "initial_angle_error": 1e-06, # Initial angle error magnitude.
    "acc_scale_stability": 1e-06, # Accelerometer scale-factor stability.
    "gyro_bias_stability": 1e-08, # Gyroscope bias stability.
    "gyro_noise": 1e-08, # Gyroscope noise level.
    "gnss_noise": 0.1, # GNSS measurement noise level.
    "gnss_freq": 1.0, # GNSS update frequency in Hz.
    "roll_gyro_error_factor": 0.0, # Roll gyroscope error scaling factor.
    "burn_time_error": 0.1 # Burn time error magnitude in seconds.
  },
  # The vehicle parameters must be set in the json config. There is no command line support for modifying them.
  "vehicle": {
    # The default booster is based on the MMIII booster with three stages and a 
    # total burn time of 188 seconds.
    "booster": {
      "name": "MMIII",
      "area": 2.2698,
      "bus_mass": 100.0,
      "c_d_0": 0.15, # drag coefficient
      "stages": [
        {
          "wet_mass": 23230.0, # total mass of stage including fuel
          "fuel_mass": 20780.0,
          "isp0": 2619.27, # Isp * 9.81
          "burn_time": 61.0
        },
        {
          "wet_mass": 7270.0,
          "fuel_mass": 6240.0,
          "isp0": 2815.47,
          "burn_time": 66.0
        },
        {
          "wet_mass": 3710.0,
          "fuel_mass": 3306.0,
          "isp0": 2795.85,
          "burn_time": 61.0
        }
      ]
    },
    # The default reentry vehicle is based on SWERVE
    "rv": {
      "name": "SWERVE",
      "maneuverability_flag": 1,
      "rv_mass": 450.0,
      # Reference length is the tip to base length (m)
      "rv_length": 2.75,
      # Reference radius is the base radius (m)
      "rv_radius": 0.277,
      "half_angle": 0.0916, # Cone half angle in radians (5.5 degrees)
      "flap_area": 0.04, # flap area in square meters
      "x_flap": -2.65, # x-coordinate of the flap hinge in meters
      "x_com": -1.65, # x-coordinate of the center of mass in meters
      "Iyy": 290.0, # Moment of inertia around pitch/yaw axis
      "aerodynamics": {
        # If tabulated aerodynamic coefficients are present, then they will be used
        # to calculate the true state of the vehicle and the linear approximations will be 
        # used to calculate the guidance computer's estimated state of the vehicle.
        "c_d_0": 0.018, # Drag coefficient at zero angle of attack
        "c_d_alpha": 0.487, # Drag coefficient derivative per radian angle of attack
        "c_l_alpha": 1.988, # Lift coefficient derivative per radian angle of attack
        "c_m_alpha": -0.111, # Moment coefficient derivative per radian angle of attack
        "c_m_q": -0.429, # Moment coefficient derivative per radian/s angular velocity
        "c_m_delta": 0.059, # Moment coefficient derivative per radian flap deflection extent
        # Tabulated aerodynamic coefficients with angle of attack
        "alpha_deg_table": [
            0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8,5.0,5.2,5.4,5.6,5.8,6.0,6.2,6.4,6.6,6.8,7.0,7.2,7.4,7.6,7.8,8.0,8.2,8.4,8.6,8.8,9.0,9.2,9.4,9.6,9.8,10.0
        ],
        "c_d_table": [
            0.018,0.0181,0.0182,0.0183,0.0185,0.0188,0.0192,0.0196,0.0201,0.0205,0.0212,0.0219,0.0226,0.0234,0.0243,0.0252,0.0262,0.0273,0.0284,0.0296,0.0309,0.0322,0.0337,0.0351,0.0367,0.0383,0.0399,0.0417,0.0436,0.0455,0.0474,0.0494,0.0515,0.0538,0.0559,0.0583,0.0607,0.0632,0.0657,0.0684,0.0711,0.074,0.0769,0.0797,0.0828,0.0861,0.0893,0.0925,0.096,0.0994,0.1031
        ],
        "c_l_table": [
            0.0,0.006,0.012,0.018,0.024,0.03,0.036,0.042,0.048,0.055,0.061,0.067,0.073,0.08,0.086,0.092,0.099,0.105,0.112,0.118,0.125,0.131,0.138,0.144,0.151,0.157,0.164,0.171,0.177,0.184,0.191,0.198,0.205,0.212,0.219,0.226,0.234,0.241,0.249,0.256,0.264,0.272,0.28,0.288,0.296,0.304,0.313,0.321,0.329,0.338,0.347
        ],
        "c_m_table": [
            0.0,-0.0002,-0.0003,-0.0005,-0.0008,-0.001,-0.0012,-0.0014,-0.0016,-0.0018,-0.0021,-0.0023,-0.0026,-0.0029,-0.0032,-0.0035,-0.0038,-0.0041,-0.0043,-0.0047,-0.005,-0.0054,-0.0057,-0.0061,-0.0065,-0.0069,-0.0072,-0.0076,-0.0079,-0.0084,-0.0088,-0.0093,-0.0098,-0.0101,-0.0106,-0.011,-0.0115,-0.012,-0.0126,-0.013,-0.0135,-0.014,-0.0146,-0.0152,-0.0157,-0.0164,-0.0169,-0.0175,-0.0181,-0.0187,-0.0194
        ],
        "c_m_q_table": [
            -0.118,-0.119,-0.12,-0.121,-0.121,-0.122,-0.123,-0.124,-0.125,-0.125,-0.126,-0.127,-0.128,-0.129,-0.129,-0.13,-0.131,-0.131,-0.132,-0.133,-0.134,-0.135,-0.136,-0.136,-0.137,-0.138,-0.138,-0.14,-0.141,-0.143,-0.145,-0.147,-0.149,-0.151,-0.153,-0.155,-0.158,-0.16,-0.163,-0.165,-0.167,-0.17,-0.172,-0.175,-0.177,-0.18,-0.182,-0.185,-0.187,-0.19,-0.193
        ]
      }
    }
  }
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrajlib-1.0.0a42.tar.gz (272.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytrajlib-1.0.0a42-cp313-cp313-win_amd64.whl (325.3 kB view details)

Uploaded CPython 3.13Windows x86-64

pytrajlib-1.0.0a42-cp313-cp313-win32.whl (322.2 kB view details)

Uploaded CPython 3.13Windows x86

pytrajlib-1.0.0a42-cp313-cp313-musllinux_1_2_x86_64.whl (390.4 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pytrajlib-1.0.0a42-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (390.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pytrajlib-1.0.0a42-cp313-cp313-macosx_11_0_arm64.whl (324.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file pytrajlib-1.0.0a42.tar.gz.

File metadata

  • Download URL: pytrajlib-1.0.0a42.tar.gz
  • Upload date:
  • Size: 272.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pytrajlib-1.0.0a42.tar.gz
Algorithm Hash digest
SHA256 8db843bc98527e0073e02a230a2fd9e7deaf1f045f55187738d4649254648d84
MD5 996793a75ad80d22dc04cdad338feafc
BLAKE2b-256 8b4625e7e647df6140e797c0381f9c00ee1fd3e8c854b4c88dbdbcd80e0db3f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a42.tar.gz:

Publisher: build_wheels.yml on lmarthur/pytrajlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytrajlib-1.0.0a42-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pytrajlib-1.0.0a42-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 91115e7d400bc35880ccad3bea35ea5337ab2dea84d82df25da9bf50d48b3c97
MD5 f20780baeb773ee7e6c9a967a7e13735
BLAKE2b-256 97434617e3a1ee7482be3912b6624bae8b4b91b76724d901de647511f6076048

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a42-cp313-cp313-win_amd64.whl:

Publisher: build_wheels.yml on lmarthur/pytrajlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytrajlib-1.0.0a42-cp313-cp313-win32.whl.

File metadata

  • Download URL: pytrajlib-1.0.0a42-cp313-cp313-win32.whl
  • Upload date:
  • Size: 322.2 kB
  • Tags: CPython 3.13, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pytrajlib-1.0.0a42-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 ff332824c47efb404f5c0a362830b346d4987eabd202af39f1b53b0d46ce501c
MD5 43c296117a8fdef4e28d16d7e58e5814
BLAKE2b-256 24f3dc54b2dc78ea2719d58f89e3d4fa9989c651c40e15c6b0bde9e5fad1b5a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a42-cp313-cp313-win32.whl:

Publisher: build_wheels.yml on lmarthur/pytrajlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytrajlib-1.0.0a42-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytrajlib-1.0.0a42-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9d6c822c9a03653d8259a9a0a16cd3bec8f7e00f70d3ac7328d28d6320cc8de8
MD5 54f5823251edf936f9ae43f9d93e4fc7
BLAKE2b-256 750e84500d70f73048527fc194fffd72926471067b7d732cdb8d2aae4edc1b0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a42-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: build_wheels.yml on lmarthur/pytrajlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytrajlib-1.0.0a42-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytrajlib-1.0.0a42-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6230e269b77b089da52a50426c8c10422e210baca39a34c6bd38de3edd851b07
MD5 bf3f2ba3d11cc62b19544e1f4c5f214a
BLAKE2b-256 ca6a7e1f0de36fc09a079c2ccf0085189d9b7b28a83c57de2ba96ba704b05b22

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a42-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build_wheels.yml on lmarthur/pytrajlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytrajlib-1.0.0a42-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytrajlib-1.0.0a42-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 727d1b0a0e9af114f6da69da4cca99ab6e836f8436d571fd7e78f7d9e74a90e5
MD5 8f7b54a2c6a3cfd0107021313ecd838a
BLAKE2b-256 4e99e13284e60e0d7bb630d952a4c8bded60fd31d112483966d99b5fc7942421

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a42-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build_wheels.yml on lmarthur/pytrajlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0a42 This release

6 files

1.0.0a27

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page