-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparams.py
More file actions
88 lines (74 loc) · 3.31 KB
/
Copy pathparams.py
File metadata and controls
88 lines (74 loc) · 3.31 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'''
Changing parameters to see correlation with AP/HTPB/Interface ratios
Make a bunch of for loops, changing one param at a time
Do 10 random generators per param change
radius size: go from 1% to 10%, 100 steps
% comp: 30% to 80%, 100 steps
last: standard deviation, 0.3 to 0.8, 100 steps
plot param vs %AP, %HTPB, and % interface on separate plots
'''
import numpy as np
import os
import gen_meso as gm
import line_comp as lc
#temporary file directory
folder = "./generated_images"
os.makedirs(folder, exist_ok=True) # create folder if it doesn't exist
# Full path for saving the figure
temp_ignore = os.path.join(folder, "ignore.png") #we won't actually use this
temp_img = os.path.join(folder, "temp_meso.png")
img_trimmed = os.path.join(folder, "trimmed.png")
#set of points to test for each parameter
radius_set = np.linspace(0.02, 0.1, 5)
comp_set = np.linspace(0.40, 0.80, 2)
dev_set = np.linspace(0.3, 0.8, 50)
#set other parameters as constant while testing one
radius_const = np.median(radius_set) #0.055
comp_const = np.median(comp_set) #0.6
dev_const = np.median(dev_set) #0.45
n = len(radius_set)
def test_radius(radius_set):
combined_avg = [] #this will be compositions, AP/HTPB/Interface
'''Test a parameter while keeping the others constant'''
#do five microstructure generations and analyses per point
for i in range(n): #for each
mini_list = []
for j in range(10):
img_trimmed = img_trimmed = os.path.join(folder, f"trimmed_{i}.png")
temp_ignore = os.path.join(folder, f"ignore_{i}.png")
gm.gen_struct(temp_ignore, temp_img, 1, radius_set[i], comp_const, dev_const, 50000)
lc.trim_edges(temp_img, img_trimmed)
mini_list.append(lc.vert_avg(img_trimmed))
combined_avg.append(np.mean(mini_list, axis=0))
return combined_avg
def test_comp(comp_set):
combined_avg = [] #this will be compositions, AP/HTPB/Interface
'''Test a parameter while keeping the others constant'''
#do five microstructure generations and analyses per point
for i in range(n): #for each
mini_list = []
for j in range(1):
img_trimmed = img_trimmed = os.path.join(folder, f"trimmed_{i}.png")
temp_ignore = os.path.join(folder, f"ignore_{i}.png")
gm.gen_struct(temp_ignore, temp_img, 1, radius_const, comp_set[i], dev_const, 50000)
lc.trim_edges(temp_img, img_trimmed)
mini_list.append(lc.vert_avg(img_trimmed))
combined_avg.append(np.mean(mini_list, axis=0))
return combined_avg
def test_dev(dev_set):
combined_avg = [] #this will be compositions, AP/HTPB/Interface
'''Test a parameter while keeping the others constant'''
#do five microstructure generations and analyses per point
for i in range(n): #for each
mini_list = []
for j in range(1):
img_trimmed = img_trimmed = os.path.join(folder, f"trimmed_{i}.png")
temp_ignore = os.path.join(folder, f"ignore_{i}.png")
gm.gen_struct(temp_ignore, temp_img, 1, radius_const, comp_const, dev_set[i], 50000)
lc.trim_edges(temp_img, img_trimmed)
mini_list.append(lc.vert_avg(img_trimmed))
combined_avg.append(np.mean(mini_list, axis=0))
return combined_avg
if __name__ == "__main__":
list = test_radius(radius_set)
print(list)