SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
Group3-Gravitation.pdf
1. Gravitation
Project
Workshop on Advanced Techniques for Scientific
Programming and Management of Open Source
Software Packages
Bellomo, Franco @fnbellomo
Aguena da Silva, Michel
Fogliatto, Ezequiel
Romero Abad, David
2. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
PROBLEM DESCRIPTION
MAIN TASK
Compute the movement of
bodies under gravity forces
using collaborative
techniques
3. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
Fij =
G mimj
|⃗
xi− ⃗
x j|
2
⃗
xj−⃗
xi
|⃗
xi− ⃗
xj|
PROBLEM DESCRIPTION
MAIN TASK
Compute the movement of
bodies under gravity forces
using collaborative
techniques
4. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
⃗
Fij =mi gij ( ⃗
xj−⃗
xi)
¨
⃗
Xi=∑j
gij ( ⃗
xj−⃗
xi)
˙
⃗
Xi=⃗
vi
¨
⃗
Vi=∑j
gij ( ⃗
xj−⃗
xi)
X' X
V' V
0 Identity
0
0
g
0
g
˙
⃗
α M ⃗
α
EQUATION DISCRETIZATION
5. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
X' X
V' V
0 Identity
0
0
g
0
g
˙
⃗
α M ⃗
α
⃗
αn+1= ⃗
αn+δt M ⃗
αn
Explicit Euler
⃗
αn+1= ⃗
αn+
δt
2
[M ⃗
αn+1+ M ⃗
αn]
Crank-Nicholson
⃗
αn+1= ⃗
αn+
1
6
( K1+2K2+2 K3+K4)
Runge – Kutta 4th
order
EQUATION DISCRETIZATION
6. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
PYTHON + GIT + GITHUB
class Gravitation(object):
“”” This is the main gravitation wrapper”””
class Body(object):
“”” Base class for space objects”””
class make_plot(object):
“””Class designed for runtime plotting”””
List of bodies
Time advancement
Mass, position,
velocity
Runtime plotting
Image and video
Multi-processing
def main():
“””Main function”””
usage: Main.py [-h] [--method METHOD] [--tstep TSTEP]
[--file FILENAME] [--plot] [--profile] [--nsteps NSTEPS]
[--config][--confile CONFIG_FILE]
7. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
PYTHON + GIT + GITHUB
make_plot Gravitation
body
body
body
GITHUB
base update move gfactor
https://github.com/fnbellomo/GProject.git
8. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
9. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
10. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
11. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
make_plot
● First approach: sequential plotting
● Second approach: multi-processing
make_plot
move()
plot()
process 1
process 2
Shared memory
12. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
LATEST VERSION
A python program that integrates the equation of movement for an
arbitrary number of bodies
Main features
● Collaborative project
● Command-line options. Reads data and options from file or during
runtime
● Several numerical methods: Explicit Euler, Crank-Nicholson, Runge-
Kutta4, adaptive Runge-Kutta
● Runtime plotting with multiprocessing
● Plot saving for post-processing
● Implements Unit test
● Class documentation with pydoc
13. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
SOME RESULTS
14. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
PROFILING
import cProfile, pstats
Pr = cProfile.Profile()
pr.enable()
pr.disable()
16. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
INSTALL
Dependences:
Dependences:
● Numpy
● Matplotlib
Installation:
$ git clone https://github.com/fnbellomo/GProject.git
$ cd GProyect
$ sudo python install setup.py
17. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
DOCUMENTATION (pydoc)
18. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
WHAT WE LEARNED?
● Working in collaboration is not easy!
● Implementation of better programming
● Use of Control Version Software
TO DO
● Rewrite class design
● Split the program into a larger number of independent modules
● Optimize calculations
● Optimize communication between processes
19. Workshop on Advanced Techniques for Scientific Programming and
Management of Open Source Software Packages
Gravitation project
Thanks!
Any questions?