readData.py 2.8 KB
Newer Older
François Trigaux's avatar
François Trigaux committed
1
#!/usr/bin/env python3
2
# Launch the Euler-Bernoulli comparison for the beam
François Trigaux's avatar
François Trigaux committed
3
#%% 
4
5
6
7
8
import numpy as np
import matplotlib.pyplot as plt
from readIni import IniReader
import subprocess as sp

9
ini = IniReader("Gebt.ini");
10
11
12
13
14
15
nkp = ini.getValue("Beam","nkp",typeCast=int);
L   = ini.getValue("Beam","L"  ,typeCast=float);
dt  = ini.getValue("Beam","dt" ,typeCast=float);
nmemb = nkp-1
display = 0

François Trigaux's avatar
François Trigaux committed
16
17
18
19
20
21
22
23
24
25
26
#out = sp.run(["./gebt"],check=True);

u2 = {}; 
u3 = {};
phi1 = {};

for f in ["output"]:
    u2[f] = []
    u3[f] = []
    phi1[f] = []
    for k in range(100):
François Trigaux's avatar
François Trigaux committed
27
        for j in range(10):
François Trigaux's avatar
François Trigaux committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
            print("%s_%d_%03d.dat"%(f,k,j))
            data_pts = np.loadtxt("%s_%d_%03d.dat"%(f,k,j),max_rows=nkp);
            data_mem = np.loadtxt("%s_%d_%03d.dat"%(f,k,j),skiprows=nkp);

            pts = data_pts;
            mem = data_mem;

            if(display):
                #plt.plot(mem[:,0]+mem[:,3],mem[:,4]+mem[:,1]);
                plt.plot(pts[:,0]+pts[:,3],pts[:,5]+pts[:,2],'.-k');
                #plt.plot(mem[:,0]+mem[:,3],mem[:,5]+mem[:,2],'.r');

                plt.xlabel('x');
                plt.ylabel('w(x)');
                
                #plt.axis('scaled');

                plt.ylim([-10,10]);

                plt.pause(0.01);
                plt.clf();

                print("u2 = %f m"%(pts[-1,4]))
                print("u3 = %f m"%(pts[-1,5]))
                

54

François Trigaux's avatar
François Trigaux committed
55
56
57
            u2[f].append(pts[-1,4]);
            u3[f].append(pts[-1,5]);
            phi1[f].append(pts[-1,6]);
58

François Trigaux's avatar
François Trigaux committed
59
60
61
62
    u2[f] = np.array(u2[f]);
    u3[f] = np.array(u3[f]);
    phi1[f] = np.array(phi1[f]);
    t = np.linspace(0,u3[f].size*dt,u3[f].size);
63

François Trigaux's avatar
François Trigaux committed
64
65
66
67
68
69
70
for f in []:
    u2[f] = []
    u3[f] = []
    for k in range(100):
        for j in range(100):
            data_pts = np.loadtxt("output%s_%d_%03d.dat"%(f,k,j),max_rows=nkp);
            data_mem = np.loadtxt("output%s_%d_%03d.dat"%(f,k,j),skiprows=nkp);
71

François Trigaux's avatar
François Trigaux committed
72
73
            pts = data_pts;
            mem = data_mem;
74

François Trigaux's avatar
François Trigaux committed
75
76
77
78
            if(display):
                #plt.plot(mem[:,0]+mem[:,3],mem[:,4]+mem[:,1]);
                plt.plot(pts[:,0]+pts[:,3],pts[:,5]+pts[:,2],'.-k');
                #plt.plot(mem[:,0]+mem[:,3],mem[:,5]+mem[:,2],'.r');
79

François Trigaux's avatar
François Trigaux committed
80
81
82
83
                plt.xlabel('x');
                plt.ylabel('w(x)');
                
                #plt.axis('scaled');
84

François Trigaux's avatar
François Trigaux committed
85
                plt.ylim([-10,10]);
86

François Trigaux's avatar
François Trigaux committed
87
88
                plt.pause(0.01);
                plt.clf();
89

François Trigaux's avatar
François Trigaux committed
90
91
                print("u2 = %f m"%(pts[-1,4]))
                print("u3 = %f m"%(pts[-1,5]))
92
93


François Trigaux's avatar
François Trigaux committed
94
95
            u2[f].append(pts[-1,4]);
            u3[f].append(pts[-1,5]);
96

François Trigaux's avatar
François Trigaux committed
97
98
99
    u2[f] = np.array(u2[f]);
    u3[f] = np.array(u3[f]);
    t = np.linspace(0,u3[f].size*dt,u3[f].size);
100
101

plt.figure()
François Trigaux's avatar
François Trigaux committed
102
103
104
105
106
107
for f in ["output"]:
    plt.plot(t,u2[f]);
    plt.plot(t,u3[f]);
    plt.plot(t,phi1[f]);
    plt.grid(True);
    plt.title("GEBT");
108
109
110
111

print("Done!");

plt.show();