Swiftest API reference#
This section of the documentation provides a detailed reference for the Production classes in the Swiftest project.
Simulation#
The Simulation class is the main class for the Swiftest project.
Creating a Simulation#
|
Defines the basic Swift/Swifter/Swiftest simulation object. |
Running a Simulation#
|
Runs a Swiftest integration. |
Setting Simulation Parameters#
|
Setter for all possible parameters. |
|
Set the parameters that control how a simulation is run, such as start and stop time, step size, and the cadence of output to both the screen and to file. |
|
Sets the integrator to be used when running a simulation. |
|
Turns on or off various features of a simulation. |
Sets the initial condition file parameters in the parameters dictionary. |
|
|
Sets the output file parameters in the parameter dictionary. |
|
Setter for setting the unit conversion between one of the standard sets. |
|
Sets the minimum and maximum distances of the simulation. |
Retrieving Simulation Parameters#
|
Setter for all possible parameters. |
|
Returns a subset of the parameter dictionary containing the current simulation time parameters. |
|
Returns a subset of the parameter dictionary containing the current values of the distance range parameters. |
|
Returns a subset of the parameter dictionary containing the current value of the feature boolean values. |
|
Returns a subset of the parameter dictionary containing the current initial condition file parameters. |
|
Returns a subset of the parameter dictionary containing the current output file parameters. |
|
Returns a subset of the parameter dictionary containing the current simulation unit system. |
|
Returns a subset of the parameter dictionary containing the current values of the distance range parameters. |
|
Prints the current value of the ephemeris date. |
Adding Bodies to a Simulation#
|
Adds a solar system body to an existing simulation Dataset from the JPL Horizons ephemeris service. |
|
Adds a body (test particle or massive body) to the internal Dataset given a set of either orbital elements or cartesian state vectors. |
|
Modifies an existing body in the internal Dataset given a new value of either the orbital elements or cartesian state vectors, or the physical property of the body (mass, radius, etc). |
|
Removes a body (test particle or massive body) from the internal Dataset. |
File Input and Output#
|
Reads in an input parameter file and stores the values in the param dictionary. |
|
Writes to a param.in file and determines whether the output format needs to be converted between Swift/Swifter/Swiftest. |
|
Reads in an encounter history file and stores it as a SwiftestDataset in the encounters instance variable. |
|
Reads in a collision history file and stores it as an Xarray Dataset in the collisions instance variable. |
|
An implementation of the Swift tool_follow algorithm. |
|
Saves an xarray dataset to a set of input files. |
|
Converts simulation input files from one format to another (Swift, Swifter, or Swiftest). |
|
Cleans up simulation directory by deleting old files (dump, logs, and output files). |
Attributes#
A dictionary of simulation parameters. |
|
A dataset containing the simulation data. |
|
A dataset containing the initial conditions. |
|
A dataset containing the encounter history |
|
A dataset containing the collision history. |
|
The name of the mass unit currently defined in the simulation. |
|
The name of the distance unit currently defined in the simulation. |
|
The name of the time unit currently defined in the simulation. |
|
The conversion factor from mass unit to kilograms. |
|
The conversion factor from kilograms to mass unit. |
|
The conversion factor from time unit to seconds. |
|
The conversion factor from seconds to time unit. |
|
The conversion factor from distance unit to meters. |
|
The conversion factor from meters to distance unit. |
|
The gravitational constant in the simulation units. |
|
The name of the integrator used in the simulation. |
|
The name of the n-body code used in the simulation. |
|
The simulation directory. |
|
A boolean value indicating whether verbose output is enabled. |
|
ISO-formatted date sto use when obtaining the ephemerides in the format YYYY-MM-DD. |
|
A boolean value indicating whether the run should be restarted from a previous output. |
Data Representation#
DataArray#
|
N-dimensional |
DataArray Methods#
|
Computes the magnitude of a vector quantity. |
|
Rotates a vector quantity using a rotation matrix. |
Dataset#
|
A |
Dataset Methods#
|
Rotates the coordinate system such that the z-axis is aligned with an input pole. |
|
Converts A Dataset's Cartesian state vectors to orbital elements. |
|
Converts a Dataset's orbital elements to Cartesian state vectors. |
Initial Conditions Generation Functions#
|
Initializes a Swiftest dataset containing the major planets of the Solar System at a particular data from JPL/Horizons. |
|
Queries JPL/Horizons for a body matching the id. |
Parses the raw output from JPL Horizons in order to extract physical properties of a body if they exist. |
Gravitional Harmonics Functions#
|
Creates and returns the gravity coefficients for an ellipsoid with principal axes a, b, c upto a certain maximum degree lmax. |
|
Creates and returns the gravity coefficients for a body with a given DH grid upto a certain maximum degree lmax. |
Input/Output Processing Functions#
A collection of functions for processing simulation files.
Reading and writing simulation parameter and initial conditions files#
|
Performs several tasks to convert raw NetCDF files output by the Fortran program into a form that is used by the Python side. |
|
Reads in a Swiftest param.in file and saves it as a dictionary. |
|
Reads in a Swifter param.in file and saves it as a dictionary. |
|
Reads in a Swift param.in file and saves it as a dictionary. |
|
Writes a Swift param.in file. |
|
Writes a Swifter/Swiftest param.in file. |
|
Selects a particular frame from a DataSet and returns only the active particles in that frame. |
|
Writes a set of Swiftest input files from a single frame of a Swiftest xarray dataset. |
Tools for fixing differences between NetCDF-Fortran and xarray data structures#
|
Converts a Swiftest binary data file into an xarray DataSet. |
|
Re-order dimension coordinates so that they are in the same order as the Fortran side. |
|
Converts all variables in the dataset to the specified type. |
Tools#
Miscellaneous helper functions
|
Converts angles to be between 0 and 360 degrees. |
|
Emulates the Swift version of tool_follow.f It will generate a file called follow.out containing 10 columns (angles are all in degrees). |
Core#
Compiled Fortran routines for the core of the Swiftest project.
|
|
|
Convert orbital elements to state vectors |
|
Convert state vectors to orbital elements |
Constants#
The constants module defines several astronomical and physical constants. Below is a description of each constant:
Constant |
Description |
|---|---|
|
The gravitational constant (G) from Astropy constants, in SI units (m^3 kg^-1 s^-2). |
|
Astronomical Unit in meters, representing the average distance from the Earth to the Sun. |
|
Standard gravitational parameter for the Sun in m^3 s^-2. |
|
Mass of the Sun in kilograms. |
|
Radius of the Sun in meters. |
|
Mass of the Earth in kilograms. |
|
Radius of the Earth in meters. |
|
Standard gravitational parameter for the Earth in m^3 s^-2. |
|
Number of seconds in a Julian day. |
|
Number of seconds in a Julian year (365.25 days). |
|
Speed of light in vacuum in meters per second. |
|
Solar quadrupole moment coefficient (J2), indicating the extent of the Sun’s equatorial bulge. |
|
Higher order coefficient (J4) for the Sun’s shape, indicating asymmetry in its mass distribution. |
|
SkyCoord object representing the rotation pole of the Sun in right ascension (ra) and declination (dec), converted to Cartesian coordinates. |
|
Angular velocity of the Sun’s rotation in radians per second, considering an average rotational period of 25.05 days. |
Fortran API Documentation#
For detailed documentation of the Fortran API, see the Fortran API.