Swarm-NG
1.1
|
Python interface to the Swarm-NG library. More...
Namespaces | |
logdb | |
Interface to the Log files generated by bdb_writer plugin. | |
logrecord | |
Contains the support functions for accessing the C++ logrecord data strcture. | |
range_type | |
Classes for defining arbitrary ranges easily in Python. | |
Classes | |
class | Config |
Specialization of std::map to hold all our configuration attributes. More... | |
class | System |
A planetary system within an ensemble. More... | |
class | Body |
A body object within a system. More... | |
class | Ensemble |
Abstract ensemble data structure. More... | |
class | DefaultEnsemble |
The default implementation of ensemble data structor that stores data in system memory. More... | |
class | Integrator |
An ODE integration algorithms. More... | |
class | GpuIntegrator |
GPU accelerated integrator. More... | |
Functions | |
def | init |
Initialize the Swarm library, registering the GPU and Logging subsystem. More... | |
def | generate_ensemble |
Generate an trivial ensemble with planets in circular orbits. More... | |
def | sync |
Synchronize all CUDA kernels. More... | |
def | calc_keplerian_for_cartesian |
Returns Keplerian coordinates (as a list) from position and velocity of a body in cartesian coordinates. More... | |
def | calc_cartesian_for_keplerian |
Returns cartesian coordinates (position and velocity) of an object for the given Keplerian coordinates. More... | |
def | find_max_energy_conservation_error |
Compare two ensembles and find the maximum of energy conservation error amongst systems. More... | |
def | config |
Convert hashes and keyword arguments to a swarmng.Config object. More... | |
def | keplerian_for_cartesian |
Caluclate Keplerian coordinates for a planet with respect to a predefined center. More... | |
Python interface to the Swarm-NG library.
This package loads and verifies the libswarmng_ext.so and adds some API that is implemented in Python.
The extensive module for opening log files is also included in swarmng.logdb
def swarmng.calc_cartesian_for_keplerian | ( | a, | |
e, | |||
i, | |||
O, | |||
w, | |||
M | |||
) |
Returns cartesian coordinates (position and velocity) of an object for the given Keplerian coordinates.
The return value is a list of following structure:
Definition at line 72 of file __init__.doc.py.
def swarmng.calc_keplerian_for_cartesian | ( | x, | |
y, | |||
z, | |||
vx, | |||
vy, | |||
vz, | |||
GM | |||
) |
Returns Keplerian coordinates (as a list) from position and velocity of a body in cartesian coordinates.
The returned list has the following structure:
Definition at line 63 of file __init__.doc.py.
Referenced by keplerian_for_cartesian().
def swarmng.config | ( | l, | |
kw | |||
) |
Convert hashes and keyword arguments to a swarmng.Config object.
There are three ways to use this function: # Combining one or more hashes into a swarmng.Config object
# Create a config object for inline use using keyword arguments. Following snippet initializes Swarm with nogpu = 1
# Combine hashes and keyword arguments.
Arguments and return type:
Returns: a swarmng.Config object that combines configuration options from the hashes and keyword arguments.
Definition at line 75 of file __init__.py.
References peyton::util.str().
Referenced by keplerian_for_cartesian(), and main().
def swarmng.find_max_energy_conservation_error | ( | ref, | |
ens | |||
) |
Compare two ensembles and find the maximum of energy conservation error amongst systems.
Definition at line 324 of file __init__.doc.py.
def swarmng.generate_ensemble | ( | cfg) |
Generate an trivial ensemble with planets in circular orbits.
cfg
: a Config object with properties for creating the ensemble only nsys
and nbod
are mandatory.Returns a DefaultEnsemble populated with generated systems.
This function is a wrapper for swarm::generate_ensemble. For more details refer to it.
Definition at line 44 of file __init__.doc.py.
def swarmng.init | ( | cfg) |
Initialize the Swarm library, registering the GPU and Logging subsystem.
The initialization procedure must be run before any integration can be done. However, data structure manipulation and loading can be done before swarm.init
cfg
: an object of type swarmng.Config, for inline creation of Config objects look at swarmng.config.For more info on what configuration options are available for swarmng.init refer to Configuration Files page.
If you are trying to Swarm on a system without GPUs try setting nogpu = 1 in the configuration.
Definition at line 34 of file __init__.doc.py.
def swarmng.keplerian_for_cartesian | ( | planet, | |
center | |||
) |
Caluclate Keplerian coordinates for a planet with respect to a predefined center.
planet
: a tuple of structure ((x,y,z),(vx,vy,vz),mass) center
: the supposed center of the orbit that planet is orbiting ( around of structure ((x,y,z),(vx,vy,vz),mass) )Return type: a named tuple that has the following attributes
Refer to Wikipedia:Orbital elements for meaning of these.
Definition at line 105 of file __init__.py.
References calc_keplerian_for_cartesian(), and config().
Referenced by swarmng.logrecord.LogRecord.bodies_in_keplerian(), and swarmng.logrecord.LogRecord.bodies_in_keplerian_jacobi().
def swarmng.sync | ( | ) |
Synchronize all CUDA kernels.
This function is rarely used after running an integration to make sure that the data structures have been updated.
Note: this is an wrapper for cudaThreadSynchronize
from CUDA runtime.
Definition at line 53 of file __init__.doc.py.