forked from barbagroup/FMM_tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirect_sum.py
More file actions
27 lines (22 loc) · 692 Bytes
/
direct_sum.py
File metadata and controls
27 lines (22 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
# direct summation: serial
import sys
import numpy
import time
from treecode_helper import *
assert (len(sys.argv) == 2), "The format should be \n [script.py] [filename]"
filename = sys.argv[1]
particles = read_particle(filename)
tic = time.time()
direct_sum(particles)
toc = time.time()
t_direct = toc - tic
# print info
print(filename + '-serial' + '-direct-summation')
print(len(filename + '-serial' + '-direct-summation')*'-')
print("N = %i" % len(particles))
print(28*'-')
print("time elapsed: %f s" % t_direct)
# option to write the result
#phi_direct = numpy.asarray([particle.phi for particle in particles])
#write_result(phi_direct, filename + '_result')