-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_simulate.py
121 lines (114 loc) · 3.72 KB
/
test_simulate.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from structure.pyramid import Pyramid
from structure.silverball import Balls
import sys
import datetime
from functionality.api import polar_to_complex_conv,sim_to_json,write_result, complex_to_polar_conv
#FOR RUNNING ONE SIMULATION WITH THE CONFIG BELOW
simulation = "pyramid"
config_pyramid = {
"simulate": {
"resolution": 100,
"use_fixed_time": False,
"simulation_time": 50,
"dpml": 0.1,
"padding": 0.025,
"ff_pts": 800,
"ff_calc": "Below",
"ff_cover": False,
"use_symmetries": True,
"calculate_flux": True,
"calculate_source_flux": True,
"source_flux_pixel_size": 2,
"ff_calculations": True,
"ff_angle": 6,
"fibb_sampling": True,
"simulation_ratio": "7/5",
"substrate_ratio": "2/10",
"output_ff": False,
"geometry": False,
"material_function": "truncPyramidWithCoating",
"polarization_in_plane": False
},
"pyramid": {
"source_position": [0,0,0.03],
"pyramid_height": 0.94,
"pyramid_width": 1,
"truncation_width": 0.1,
"CL_thickness": 0.1,
"CL_material":"Pd",
"source_direction": [1,0,0],
"source_on_wall": False,
"frequency_center": 1.85,
"frequency_width": 0.76,
"number_of_freqs": 8,
"cutoff": 4
},
"result": {}
}
config_balls = {
"simulate": {
"resolution": 750,
"use_fixed_time": True,
"simulation_time": 60,
"dpml": 0.01,
"padding": 0.0025,
"ff_pts": 800,
"ff_calc": "Below",
"ff_cover": False,
"use_symmetries": True,
"calculate_flux": True,
"calculate_source_flux": True,
"source_flux_pixel_size": 8,
"ff_calculations": False,
"ff_angle": 6,
"fibb_sampling": True,
"simulation_ratio": "1",
"substrate_ratio": "2/10",
"output_LDOS": True,
"output_ff": False,
"geometry": "balls",
"material_function": None,
"polarization_in_plane": False
},
"structure": {
"source_position": [0,0,0],
"distance": 0.03,
"radius": 0.035,
"pyramid_height": 0.2,
"pyramid_width": 0.12,
"truncation_width": 0.1,
"CL_thickness": 0.1,
"CL_material":"Ag_visible",
"source_direction": [0,0,1],
"source_on_wall": False,
"frequency_center": 2.5,
"frequency_width": 1.33,
"number_of_freqs": 8,
"cutoff": 4
},
"result": {}
}
if (len(sys.argv)) != 1:
print("Not enough arguments")
exit(0)
if simulation == "balls":
ball = Balls()
config = config_balls
ball.setup(config_balls["structure"])
result = ball.simulate(config["simulate"])
else:
pyramid = Pyramid()
config = config_pyramid
pyramid.setup(config_pyramid["pyramid"])
result = pyramid.simulate(config["simulate"])
print(config)
print(result)
print('Simulation finished at:',datetime.datetime.now())
output_ff = config["simulate"]["output_ff"]
calculate_source_flux = config["simulate"]["calculate_source_flux"]
#data = sim_to_json(config, result,output_ff, calculate_source_flux)
#print('pyramid data:',data)
config["result"] = result
if config["simulate"]["output_ff"] == True:
config["result"]["fields"] = complex_to_polar_conv(config["result"]["fields"])
write_result("db/test_simulate.json", config)