-
Notifications
You must be signed in to change notification settings - Fork 0
/
curve.py
59 lines (48 loc) · 1.16 KB
/
curve.py
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
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
54
55
56
57
58
59
import argparse
import os
import glob
import numpy as np
import matplotlib.pyplot as plt
opt = argparse.ArgumentParser(
description='Evaluate fracture power law.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
opt.add_argument(
'-s', '--source',
type=str
)
opt.add_argument(
'-d', '--disorder',
type=float
)
opt.add_argument(
'-g', '--geometry',
type=str,
choices=['t', 'h', 's']
)
def convert_geometry(initial):
return {
't': '45 graus',
'h': 'hexagonal',
's': 'quadrada'
}[initial]
def sort_files(path):
filename = os.path.basename(path)
length = filename.split('.')[0]
return int(length)
args = opt.parse_args()
files = sorted(glob.glob(args.source + "/*.csv"), key=sort_files)
sizes = [7, 14, 20, 28]
data = [np.genfromtxt(path, delimiter=',', skip_header=1, names=['V', 'I'])
for path in files]
for L, data in zip(sizes, data):
plt.plot(data['V'], data['I'], label=f'L = {L}')
plt.legend(loc='upper left')
plt.grid(True)
plt.axis('equal')
plt.xlabel(r'$V$')
plt.ylabel(r'$I$')
disorder = args.disorder
geometry = convert_geometry(args.geometry)
plt.title(f'$D = {disorder}, G = ${geometry}')
plt.show()