-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheat_transfer_simulation.py
83 lines (69 loc) · 3.05 KB
/
heat_transfer_simulation.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
"""
This module is serving for running the Classic simulation.
It can be run separately or from the GUI, in which case
it will be updating the plot.
"""
from NumericalForward import Simulation
from experiment_data_handler import Material
from heat_transfer_simulation_utilities import SimulationController
def simulate_from_gui(parameters_from_gui: dict,
progress_callback) -> dict:
"""
Starts the whole simulation with the inputs from GUI
Args:
parameters_from_gui ... parameters for simulation defined in GUI
- including all the references to plots, queues and callbacks
progress_callback ... reference of progress callback
"""
return create_and_run_simulation(progress_callback=progress_callback,
**parameters_from_gui)
def create_and_run_simulation(parameters: dict,
heat_flux_plot=None,
temperature_plot=None,
progress_callback=None,
queue=None,
save_results: bool = False) -> dict:
"""
Creates a new simulation object, passes it into the controller
and makes sure the simulation will finish
Args:
parameters ... all defined parameters of simulation
heat_flux_plot ... reference of heat flux plot
temperature_plot ... reference of temperature plot
progress_callback ... reference of progress callback
queue ... reference of the shared queue
save_results ... whether to save results at the end or not
"""
my_material = Material(parameters["rho"], parameters["cp"], parameters["lmbd"])
Sim = Simulation(length=parameters["object_length"],
material=my_material,
N=parameters["number_of_elements"],
theta=parameters["theta"],
robin_alpha=parameters["robin_alpha"],
dt=parameters["dt"],
x0=parameters["place_of_interest"],
experiment_data_path=parameters["experiment_data_path"])
sim_controller = SimulationController(Sim=Sim,
parameters=parameters,
progress_callback=progress_callback,
temperature_plot=temperature_plot,
heat_flux_plot=heat_flux_plot,
queue=queue,
save_results=save_results)
result = sim_controller.complete_simulation()
return result
if __name__ == '__main__':
parameters = {
"rho": 7850,
"cp": 520,
"lmbd": 50,
"dt": 1,
"object_length": 0.01,
"place_of_interest": 0.0045,
"number_of_elements": 100,
"callback_period": 500,
"robin_alpha": 13.5,
"theta": 0.5,
"experiment_data_path": "DATA.csv"
}
create_and_run_simulation(parameters)