Swarm-NG
1.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
__init__.doc.py
Go to the documentation of this file.
1
## @file __init__.doc.py
2
# This is the documentation for libswarmng_ext, but because
3
# all the symbols from libswarmng_ext are included in the swarmng module
4
# we document it under swarmng package.
5
#
6
# The implementation of all of these is in src/python/module.cpp but
7
# we have to separate the documentation and put it here.
8
#
9
# To read the documentation generated from this file refer to @ref swarmng
10
#
11
12
## @package swarmng
13
14
# The reason for lib prefix is because CMake automatically
15
# adds lib prefix to the name of the target
16
#
17
18
19
## Initialize the Swarm library, registering the GPU and Logging subsystem.
20
#
21
# The initialization procedure must be run before
22
# any integration can be done. However, data structure
23
# manipulation and loading can be done before swarm.init
24
#
25
# @arg \c cfg : an object of type @ref swarmng.Config, for inline creation
26
# of Config objects look at @ref swarmng.config.
27
#
28
# For more info on what configuration options are available for swarmng.init
29
# refer to @ref Configuration page.
30
#
31
# If you are trying to Swarm on a system without GPUs
32
# try setting nogpu = 1 in the configuration.
33
#
34
def
init
(cfg):
pass
35
36
## Generate an trivial ensemble with planets in circular orbits
37
#
38
# @arg @c cfg : a @ref Config object with properties for creating the ensemble
39
# only `nsys` and `nbod` are mandatory.
40
#
41
# Returns a @ref DefaultEnsemble populated with generated systems.
42
#
43
# This function is a wrapper for \ref swarm.generate_ensemble. For more details refer to it.
44
def
generate_ensemble
(cfg):
pass
45
46
## Synchronize all CUDA kernels
47
#
48
# This function is rarely used after
49
# running an integration to make sure that
50
# the data structures have been updated.
51
#
52
# Note: this is an wrapper for \c cudaThreadSynchronize from CUDA runtime.
53
def
sync
():
pass
54
55
## Returns Keplerian coordinates (as a list) from position and
56
# velocity of a body in cartesian coordinates.
57
#
58
# The returned list has the following structure:
59
# @code{.py}
60
# [ a, e, i, O, w, M ]
61
# @endcode
62
#
63
def
calc_keplerian_for_cartesian
(x,y,z,vx,vy,vz,GM):
pass
64
## Returns cartesian coordinates (position and velocity) of
65
# an object for the given Keplerian coordinates.
66
#
67
# The return value is a list of following structure:
68
# @code{.py}
69
# [ x, y, z, vx, vy, vz ]
70
# @endcode
71
#
72
def
calc_cartesian_for_keplerian
(a,e,i,O,w,M):
pass
73
74
75
## Specialization of std::map to hold all our configuration attributes
76
#
77
# To construct an object of this type easily refer to @ref config
78
#
79
# For a complete list of configuration options used in Swarm refer to @ref Configuration
80
class
Config
:
81
82
## Load a Config object from a file name.
83
#
84
# @arg @c filename : path to a text file in swarm config format. The file format is similar to INI format.
85
@staticmethod
86
def
load
(filename):
pass
87
88
## A planetary system within an ensemble.
89
#
90
# To obtain an instance of System class you should index into an ensemble.
91
#
92
# This class can be treated as a collection
93
# of bodies. The bodies can be accessed using
94
# brackets or a for loop.
95
class
System
:
96
## Time of the system (floating point value)
97
time = property
98
## Unique integer identifier for the system
99
id = property
100
## Total kinetic and potential energy of the planetary system (floating point value)
101
total_energy = property
102
## Integer value representing the state of the system
103
# - 0 means active
104
# - 1 means inactive
105
# - -1 means disabled
106
# - other numbers may have special meanings
107
#
108
state = property
109
## Collection of attributes of the system of type \ref System.Attributes
110
attributes = property
111
112
## Number of bodies in the system
113
# Usage
114
# @code{.py}
115
# >>> len(self)
116
# @endcode
117
def
__len__
(self):
pass
118
## Equivalent to state == 0
119
def
is_active
(self):
pass
120
## Equivalent to state == 1
121
def
is_inactive
(self):
pass
122
## Equivalent to state != -1
123
def
is_enabled
(self):
pass
124
## Set state = 0
125
def
set_active
(self):
pass
126
## Set state = 1
127
def
set_inactive
(self):
pass
128
## Set state = -1
129
def
set_disabled
(self):
pass
130
131
## Get the ith body of the system
132
# Usage
133
# @code{.py}
134
# >>> self[i]
135
# @endcode
136
def
__getitem__
(self,i):
pass
137
138
139
## Attributes of the system, it is just
140
# a list of floating point values. You
141
# can use [] and len to extract values from it
142
# or iterate over it with a for loop.
143
class
Attribute
:
144
## Get the ith value
145
# Usage
146
# @code{.py}
147
# >>> self[i]
148
# @endcode
149
def
__getitem__
(self,i):
pass
150
## Set the ith value
151
# Usage
152
# @code{.py}
153
# >>> self[i] = 3
154
# @endcode
155
def
__setitem__
(self,i,v):
pass
156
## Length of the list
157
# Usage
158
# @code{.py}
159
# >>> len(self)
160
# @endcode
161
def
__len__
(self):
pass
162
163
## A body object within a system
164
class
Body
:
165
## mass of the body (floating point)
166
mass = property
167
168
## Position: a list of 3 floating point values: [ x,y,z ]
169
pos = property
170
171
## Velocity: a list of 3 floating point values: [ vx,vy,vz ]
172
vel = property
173
174
## Distance to (0,0,0) (floating point value)
175
def
distance_to_origin
(self):
pass
176
177
## Magnitude of the velocity (floating point value)
178
def
speed
(self):
pass
179
180
## Representetive for one component (x,y,z) of the object
181
# Contains position and velocity for that component.
182
class
Components
:
183
## Position for the specified component (single floating point value)
184
pos = property
185
## Velocity for the specified property (single floating point value)
186
vel = property
187
188
## Attributes of the body, it is just
189
# a list of floating point values. You
190
# can use [] and len to extract values from it
191
# or iterate over it with a for loop.
192
class
Attribute
:
193
## Get the ith value
194
# Usage
195
# @code{.py}
196
# >>> self[i]
197
# @endcode
198
def
__getitem__
(self,i):
pass
199
## Set the ith value
200
# Usage
201
# @code{.py}
202
# >>> self[i] = 3
203
# @endcode
204
def
__setitem__
(self,i,v):
pass
205
## Length of the list
206
# Usage
207
# @code{.py}
208
# >>> len(self)
209
# @endcode
210
def
__len__
(self):
pass
211
212
213
## Abstract ensemble data structure.
214
#
215
# The ensemble class has all the accessor methods
216
# it is only abstract in terms of storage. Because
217
# an ensemble can be stored on GPU memory or system memory.
218
#
219
# To create an ensemble refer to DefaultEnsemble.create or DefaultEnsemble.load_from_bin or DefaultEnsemble.load_from_text
220
class
Ensemble
:
221
## Number of systems in the ensemble (integer value)
222
nsys = property
223
## Number of bodies per system (integer value)
224
nbod = property
225
## Get the ith system as a @ref System object.
226
# Usage
227
# @code{.py}
228
# >>> self[i]
229
# @endcode
230
def
__getitem__
(self,i):
pass
231
## Number of systems in the ensemble equal to nsys
232
# Usage
233
# @code{.py}
234
# >>> len(self)
235
# @endcode
236
def
__len__
(self):
pass
237
238
## The default implementation of ensemble data structor
239
# that stores data in system memory.
240
class
DefaultEnsemble
(
Ensemble
):
241
## @static
242
# Create an ensemble with specified
243
# number of systems and bodies
244
#
245
# @arg @c number_of_bodies : number of bodies per system
246
# @arg @c number_of_systems: total number of systems in the ensemble.
247
#
248
# Note that an ensemble is not resizable and all
249
# systems have the same number of bodies.
250
def
create
(number_of_bodies,number_of_systems):
pass
251
## Save a binary representation of the whole ensemble to a file
252
# @arg @c fileName : name of the file to save the contents to
253
def
save_to_bin
(self, fileName):
pass
254
## Save a textual representation of the whole ensemble to a file
255
# @arg @c fileName : name of the file to save the contents to
256
def
save_to_text
(self, fileName):
pass
257
## @static
258
# Load an ensemble from a text file
259
#
260
# returns a @ref DefaultEnsemble
261
def
load_from_text
(fileName):
pass
262
## @static
263
# Load an ensemble from a binary file
264
#
265
# returns a @ref DefaultEnsemble
266
def
load_from_bin
(fileName):
pass
267
268
## An ODE integration algorithms
269
#
270
# The different implementations of ODE integration methods
271
# provide the same interface, this class is abstract and
272
# the create method loads a specific implementation based
273
# on the configuration that is passed to the method.
274
class
Integrator
:
275
## The ensemble data structure to operate on, of type @ref Ensemble
276
ensemble = property
277
## All of the systems will be integrated to this
278
# specified time. (scalar floating point value)
279
destination_time = property
280
## @static
281
# Create an integrator object from the configuration specified
282
# the only mandatory items is an identifier for the
283
# integrator, namely the value 'integrator'.
284
#
285
# @arg @c cfg : configuration object of type @ref swarmng.Config for selecting
286
# and configuring the integrator.
287
#
288
# For more information refer to \ref swarm.integrator.create
289
def
create
(cfg):
pass
290
## Run the integration up to the specified @ref destination_time
291
def
integrate
(self):
pass
292
293
## GPU accelerated integrator
294
#
295
# WARNING: this class is not thoroughly tested
296
# for most intents and purposes, just use the regular
297
# Integrator class.
298
class
GpuIntegrator
(
Integrator
):
299
## GPU ensemble that is used for the integration
300
#
301
# this seems redundant since ensemble property is already
302
# defined in Integrator.
303
ensemble = property
304
305
## Same as @ref Integrator.create, but returns an instance of GpuIntegrator
306
def
create
(cfg):
pass
307
## The default integrate method updates the GPU ensemble
308
# every time. The core_integrate just launches the kernel.
309
def
core_integrate
(self):
pass
310
## Update the ensemble in system memory from GPU ensemble
311
def
download_ensemble
(self):
pass
312
## Update the GPU ensemble from the ensemble in system memory.
313
def
upload_ensemble
(self):
pass
314
315
## Compare two ensembles and find the maximum of energy
316
# conservation error amongst systems.
317
#
318
# @arg ref : Reference ensemble, possibly from the initial conditions, (should be of type @ref swarmng.Ensemble)
319
# @arg ens : Ensemble to check (should be of type @ref swarmng.Ensemble)
320
# Returns one number, that is the maximum of energy conservation error.
321
# Energy conservation error for a system is the difference in total energy compared
322
# to the reference system normalized by the amount of energy in the reference system.
323
#
324
def
find_max_energy_conservation_error
(ref,ens):
pass
swarm
py
swarmng
__init__.doc.py
Generated on Sun Jul 21 2013 11:11:53 for Swarm-NG by
1.8.4