test_plain.py 3.26 KB
Newer Older
Cristian Lalescu's avatar
Cristian Lalescu committed
1
#! /usr/bin/env python2
Chichi Lalescu's avatar
Chichi Lalescu committed
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
#######################################################################
#                                                                     #
#  Copyright 2015 Max Planck Institute                                #
#                 for Dynamics and Self-Organization                  #
#                                                                     #
#  This file is part of bfps.                                         #
#                                                                     #
#  bfps is free software: you can redistribute it and/or modify       #
#  it under the terms of the GNU General Public License as published  #
#  by the Free Software Foundation, either version 3 of the License,  #
#  or (at your option) any later version.                             #
#                                                                     #
#  bfps is distributed in the hope that it will be useful,            #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of     #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      #
#  GNU General Public License for more details.                       #
#                                                                     #
#  You should have received a copy of the GNU General Public License  #
#  along with bfps.  If not, see <http://www.gnu.org/licenses/>       #
#                                                                     #
# Contact: Cristian.Lalescu@ds.mpg.de                                 #
#                                                                     #
#######################################################################


Cristian Lalescu's avatar
Cristian Lalescu committed
27

Cristian Lalescu's avatar
Cristian Lalescu committed
28
from base import *
Cristian Lalescu's avatar
Cristian Lalescu committed
29

30
31
32
33
34
35
import numpy as np
import matplotlib.pyplot as plt

parser.add_argument('--multiplejob',
        dest = 'multiplejob', action = 'store_true')

Cristian Lalescu's avatar
Cristian Lalescu committed
36
37
38
def plain(opt):
    wd = opt.work_dir
    opt.work_dir = wd + '/N{0:0>3x}_1'.format(opt.n)
39
    c0 = launch(opt, dt = 0.2/opt.n)
Cristian Lalescu's avatar
Cristian Lalescu committed
40
    c0.compute_statistics()
Chichi Lalescu's avatar
Chichi Lalescu committed
41
42
43
44
    print ('Re = {0:.0f}'.format(c0.statistics['Re']))
    print ('Rlambda = {0:.0f}'.format(c0.statistics['Rlambda']))
    print ('Lint = {0:.4e}, etaK = {1:.4e}'.format(c0.statistics['Lint'], c0.statistics['etaK']))
    print ('Tint = {0:.4e}, tauK = {1:.4e}'.format(c0.statistics['Tint'], c0.statistics['tauK']))
Cristian Lalescu's avatar
Cristian Lalescu committed
45
    print ('kMetaK = {0:.4e}'.format(c0.statistics['kMeta']))
Chichi Lalescu's avatar
Chichi Lalescu committed
46
    for s in range(c0.particle_species):
Cristian Lalescu's avatar
Cristian Lalescu committed
47
        acceleration_test(c0, species = s, m = 1)
48
49
    if not opt.multiplejob:
        return None
50
    assert(opt.niter_todo % 3 == 0)
Cristian Lalescu's avatar
Cristian Lalescu committed
51
52
    opt.work_dir = wd + '/N{0:0>3x}_2'.format(opt.n)
    opt.njobs *= 2
Cristian Lalescu's avatar
Cristian Lalescu committed
53
    opt.niter_todo = opt.niter_todo//2
54
    c1 = launch(opt, dt = c0.parameters['dt'])
Cristian Lalescu's avatar
Cristian Lalescu committed
55
    c1.compute_statistics()
56
    opt.work_dir = wd + '/N{0:0>3x}_3'.format(opt.n)
Cristian Lalescu's avatar
Cristian Lalescu committed
57
58
    opt.njobs = 3*opt.njobs//2
    opt.niter_todo = 2*opt.niter_todo//3
59
    c2 = launch(opt, dt = c0.parameters['dt'])
60
    c2.compute_statistics()
61
    compare_stats(opt, c0, c1)
Cristian Lalescu's avatar
Cristian Lalescu committed
62
63
64
    return None

if __name__ == '__main__':
65
66
67
    opt = parser.parse_args(
            ['-n', '32',
             '--run',
Cristian Lalescu's avatar
Cristian Lalescu committed
68
             '--initialize',
69
70
71
72
73
74
             '--ncpu', '2',
             '--nparticles', '1000',
             '--niter_todo', '48',
             '--precision', 'single',
             '--wd', 'data/single'] +
            sys.argv[1:])
Cristian Lalescu's avatar
Cristian Lalescu committed
75
76
    plain(opt)