v0.14.0
Loading...
Searching...
No Matches
iterations.py
Go to the documentation of this file.
1import numpy as np
2import matplotlib.pyplot as plt
3import os
4import pandas as pd
5# import tikzplotlib
6
7#global parameters
8markersize=6
9line_width=2
10font_size=12
11font_weight='normal'
12plt.rcParams['figure.figsize'] = [16, 9]
13plt.rcParams['figure.dpi'] = 100
14plt.rcParams['font.family'] = "DejaVu Serif"
15plt.rcParams['font.size'] = font_size
16plt.rcParams['font.weight'] = font_weight
17
18nb_columns=2
19
20
21
22def main():
23 # my_data1=get_data_from_string(my_multiplicative, nb_columns)
24 # my_data2=get_data_from_string(my_additive, nb_columns)
25 # my_data3=get_data_from_string(my_multifield, nb_columns)
26 # my_data3[:,[0, 1]] = my_data3[:,[1, 0]]
27 # print(my_data1[:,1])
28 # 301 TS dt 0.0053405 time 1.24046
29 # grep "SNES Function norm" log_constraint_bc_old > log_constraint_bc
30 # grep "SNES Function norm" log_classical_bc_old > log_classical_bc
31 newton_log_file1="/home/karol/mofem_install/users_modules_debug/multifield_plasticity/test_vertical_flow_form_3D/log_classical_bc"
32 newton_log_file2="/home/karol/mofem_install/users_modules_debug/multifield_plasticity/test_vertical_flow_form_3D/log_constraint_bc"
33
34 newton_data1=pd.read_fwf(newton_log_file1, header=None)
35 newton_data2=pd.read_fwf(newton_log_file2, header=None)
36
37 plt.plot(newton_data1[8].to_numpy(), ls='solid',lw=line_width, marker='o', markersize=markersize, c='blue', label="classical bc")
38 plt.plot(newton_data2[8].to_numpy(), ls='solid', lw=line_width, marker='x', markersize=markersize, c='orange', label="constraint bc")
39
40 plt.legend(loc='upper right')
41
42 # plt.gca().set_xlim(left=0, right=None)
43 # plt.gca().set_ylim(bottom=0, top=None)
44
45 # plt.plot(newton_data[7].to_numpy(),'r^-')
46 plt.title('Newton method convergence')
47 plt.ylabel('absolute residual')
48 plt.xlabel('accumulated iterations')
49 plt.yscale('log')
50 plt.grid(True)
51 plt.show()
52 plt.savefig("my_log.png")
53
54 # tikzplotlib.save("my_graph.tex")
55
56def get_data_from_string(data_string, columns, delimiter=' '):
57 my_data=np.fromstring(data_string, dtype=float, sep=delimiter)
58 my_data = my_data.reshape(int(my_data.size/nb_columns),nb_columns)
59 return my_data
60
61if __name__ == '__main__':
62 main()
def get_data_from_string(data_string, columns, delimiter=' ')
Definition: iterations.py:56
def main()
Definition: iterations.py:22