runtest_juelich_9.py 1.9 KB
Newer Older
Mohcine Chraibi's avatar
Mohcine Chraibi committed
1 2 3 4 5 6 7 8
#!/usr/bin/env python
"""
Test description
================
- Fundamental Diagram in 2D, test number 102
- Width = 1.8 m
- Length = 26.0 m
- Measurement area: X = [10, 16],  Y = [-0.9, 0.9]
9

Mohcine Chraibi's avatar
Mohcine Chraibi committed
10 11 12
Remarks
=======
TODO: Compare two "clouds" of points and return a number.
13

Mohcine Chraibi's avatar
Mohcine Chraibi committed
14 15
Source
======
Mohcine Chraibi's avatar
Mohcine Chraibi committed
16

Mohcine Chraibi's avatar
Mohcine Chraibi committed
17
"""
18

Mohcine Chraibi's avatar
Mohcine Chraibi committed
19 20 21 22 23 24 25 26 27
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
from JPSRunTest import JPSRunTestDriver
from utils import *
28

Mohcine Chraibi's avatar
Mohcine Chraibi committed
29 30 31
tolerance = 0.05
ms = 20 # size of labels
mt = 18 # size of ticks
Mohcine Chraibi's avatar
Test 11  
Mohcine Chraibi committed
32

Mohcine Chraibi's avatar
Mohcine Chraibi committed
33 34 35 36 37 38 39 40 41 42
def eval_results(results):
    results = np.sort(results, axis=0)
    num_threads = results[:, 0]
    evac_times = results[:, 1]
    std = np.std(evac_times)
    mean = np.mean(evac_times)
    logging.info("INFO: mean = %f (+-%f)", mean, std)
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    plt.plot(num_threads, evac_times, "o-b", alpha=0.5)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
43

Mohcine Chraibi's avatar
Mohcine Chraibi committed
44 45 46 47 48 49 50 51
    plt.ylabel(r"Evacuation Time [s]", size=ms)
    plt.xlabel(r"#Threads", size=ms)
    plt.xlim([min(num_threads)-0.5, max(num_threads)+0.5])
    plt.xticks(fontsize=mt)
    plt.xticks(num_threads, fontsize=mt)
    plt.title("mean = %f (+-%f) [s]" % (mean, std))
    plt.grid(alpha=0.7)
    plt.savefig("evactimes.png", dpi=300)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
52

Mohcine Chraibi's avatar
Mohcine Chraibi committed
53 54 55 56 57 58 59 60 61
def run_test_9(inifile, trajfile):
    maxtime = get_maxtime(inifile)
    num_threads = get_num_threads(inifile)
    fps, N, traj = parse_file(trajfile)
    if not N:
        logging.critical(" N = %d"%N)
        exit(FAILURE)
    evac_time = (max(traj[:, 1]) - min(traj[:, 1])) / float(fps)
    return (num_threads, evac_time)
Mohcine Chraibi's avatar
Mohcine Chraibi committed
62

Mohcine Chraibi's avatar
Mohcine Chraibi committed
63 64 65 66
if __name__ == "__main__":
    test = JPSRunTestDriver(9, argv0=argv[0],
                            testdir=sys.path[0],
                            utestdir=utestdir)
Mohcine Chraibi's avatar
Test 11  
Mohcine Chraibi committed
67

Mohcine Chraibi's avatar
Mohcine Chraibi committed
68 69 70 71
    results = test.run_test(testfunction=run_test_9)
    eval_results(results)
    logging.info("%s exits with SUCCESS" % (argv[0]))
    exit(SUCCESS)