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.0a41.tar.gz (270.5 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.0a41-cp313-cp313-win_amd64.whl (323.5 kB view details)

Uploaded CPython 3.13Windows x86-64

pytrajlib-1.0.0a41-cp313-cp313-win32.whl (320.4 kB view details)

Uploaded CPython 3.13Windows x86

pytrajlib-1.0.0a41-cp313-cp313-musllinux_1_2_x86_64.whl (388.7 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pytrajlib-1.0.0a41-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (388.9 kB view details)

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

pytrajlib-1.0.0a41-cp313-cp313-macosx_11_0_arm64.whl (323.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pytrajlib-1.0.0a41.tar.gz
  • Upload date:
  • Size: 270.5 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.0a41.tar.gz
Algorithm Hash digest
SHA256 89702b7212f7633b46a8b5bba29664f2b28bfc9d3ffe0f2fd4fe8b44c241ac4f
MD5 00f6ca9f46a718242df02bf4c798a3f7
BLAKE2b-256 25d74d990aa964ce3a846a5de698fd72662ac44a56c89692409cee8a82c62135

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a41.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.0a41-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pytrajlib-1.0.0a41-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e83ab831a03ad47a459a5466bf1f3990e8268c8f417cdb3c5dfd1837928339f3
MD5 f7892d01d95ee4b50f28ddb652a2c2e1
BLAKE2b-256 9960d95ecdcf17d75de616d20930304b8bc27329cdbc98e7e619dc9c0db52814

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a41-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.0a41-cp313-cp313-win32.whl.

File metadata

  • Download URL: pytrajlib-1.0.0a41-cp313-cp313-win32.whl
  • Upload date:
  • Size: 320.4 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.0a41-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 f1de28967d88b0912c0e232d3493c8f68ff40d1f57658cc220ad36bce3c037e4
MD5 057e51fb7a49375e92ede617210110af
BLAKE2b-256 47dfb778f6f481678ddc56d4afc03877aa6bfa00d8ec17ea625724cdf2d6a291

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a41-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.0a41-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pytrajlib-1.0.0a41-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cda6b1f6e8db419c648c6b500d6008638d8b238aae66b8949302a1a74d85deb9
MD5 76cd27c8e56af99c32a5510c83b2307b
BLAKE2b-256 9d182b3765eed38e6b584e2db4c2c4ba24acc06a5f41144358aff1ad12b3cb73

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a41-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.0a41-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.0a41-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f8477a2b2ef1fd167cae1d8d7f866b6fac8bfeace59d5ed6ca4a738c8f8bfa74
MD5 cba28876e966a59c4ed8034f4f2be748
BLAKE2b-256 d024f38f0be97445aea078192a5fae6121c9905f1d43d80773164565e05ddc7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a41-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.0a41-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytrajlib-1.0.0a41-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe8c64be580d127326222100fdbe9809e83befead4a414e0f75980f1ab2703c6
MD5 a88bd021cb419a7df0beba713304c532
BLAKE2b-256 e61e1f82be3467dccd6ae5992efb7069d5fc466cf75e1fcd0cd804e440ff7cf8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytrajlib-1.0.0a41-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.0a41 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