freepaths 2.2.1__tar.gz → 2.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {freepaths-2.2.1 → freepaths-2.2.4}/PKG-INFO +12 -3
  2. {freepaths-2.2.1 → freepaths-2.2.4}/README.md +11 -2
  3. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/__main__.py +1 -1
  4. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/config.py +3 -3
  5. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/data.py +4 -22
  6. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/default_config.py +3 -3
  7. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/flight.py +1 -1
  8. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/main_mfp_sampling.py +135 -137
  9. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/main_tracing.py +294 -295
  10. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/maps.py +7 -11
  11. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/materials.py +16 -10
  12. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/move.py +1 -1
  13. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/output_plots.py +53 -28
  14. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/output_structure.py +1 -1
  15. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/particle.py +15 -15
  16. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/phonon.py +1 -1
  17. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/post_computations.py +1 -1
  18. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/run_particle.py +6 -9
  19. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/scatterers.py +21 -13
  20. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/scattering_interfaces.py +5 -6
  21. freepaths-2.2.4/freepaths/scattering_semicircle.py +422 -0
  22. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/scattering_types.py +11 -11
  23. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths.egg-info/PKG-INFO +12 -3
  24. freepaths-2.2.1/freepaths/scattering_semicircle.py +0 -789
  25. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/animation.py +0 -0
  26. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/electron.py +0 -0
  27. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/interface_smmm.py +0 -0
  28. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/output_info.py +0 -0
  29. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/particle_types.py +0 -0
  30. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/progress.py +0 -0
  31. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/scattering.py +0 -0
  32. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/scattering_primitives.py +0 -0
  33. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths/sources.py +0 -0
  34. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths.egg-info/SOURCES.txt +0 -0
  35. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths.egg-info/dependency_links.txt +0 -0
  36. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths.egg-info/entry_points.txt +0 -0
  37. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths.egg-info/requires.txt +0 -0
  38. {freepaths-2.2.1 → freepaths-2.2.4}/freepaths.egg-info/top_level.txt +0 -0
  39. {freepaths-2.2.1 → freepaths-2.2.4}/pyproject.toml +0 -0
  40. {freepaths-2.2.1 → freepaths-2.2.4}/setup.cfg +0 -0
  41. {freepaths-2.2.1 → freepaths-2.2.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: freepaths
3
- Version: 2.2.1
3
+ Version: 2.2.4
4
4
  Summary: Phonon Monte Carlo simulator
5
5
  Home-page: https://github.com/anufrievroman/freepaths
6
6
  Author: Roman Anufriev
@@ -34,9 +34,9 @@ Dynamic: requires-dist
34
34
  Dynamic: requires-python
35
35
  Dynamic: summary
36
36
 
37
- # FreePATHS - Free Phonon And Thermal Simulator
37
+ # FreePATHS - Free Phonon And THermal Simulator
38
38
 
39
- This Monte Carlo algorithm simulates trajectories of phonons in 3D models of nanostructures, which consists of a box with holes or pillars of various shapes. The algorithm outputs phonon trajectories, heat fluxes, temperature maps and profiles, the thermal conductivity, scattering maps and statistics and other information. See [documentation](https://anufrievroman.gitbook.io/freepaths/) for the details of the simulation.
39
+ This Monte Carlo algorithm simulates trajectories of phonons or electrons in 3D models of nanostructures, which consists of a box with holes, pillars, or interfaces of various shapes. For phonons, the algorithm outputs heat fluxes, temperature maps and profiles, thermal conductivity, scattering maps and statistics, and other information. For electrons, it outputs electrical conductivity, Seebeck coefficient, electronic thermal conductivity, power factor, and related quantities as a function of Fermi level. See [documentation](https://anufrievroman.gitbook.io/freepaths/) for the details of the simulation.
40
40
 
41
41
  ![Screenshot](https://github.com/anufrievroman/Monte-Carlo/blob/master/screenshot.png)
42
42
 
@@ -73,6 +73,15 @@ See [documentation](https://anufrievroman.gitbook.io/freepaths/examples) for exp
73
73
  After the simulation, see the results in a newly created **Results** folder.
74
74
 
75
75
 
76
+ ### Electron mode
77
+
78
+ FreePATHS can also simulate electron transport. In this mode, electrons are traced through the structure and thermoelectric properties — electrical conductivity, Seebeck coefficient, electronic thermal conductivity, and power factor — are computed as a function of Fermi level. To run in electron mode, add the `-e` flag:
79
+
80
+ `freepaths -e your_input_file.py`
81
+
82
+ See the [tutorial](https://anufrievroman.gitbook.io/freepaths/basic-tutorials/electrons-in-holey-membranes) and [theory](https://anufrievroman.gitbook.io/freepaths/theory/electrical-conductivity) for details.
83
+
84
+
76
85
  ### MFP sampling mode
77
86
 
78
87
  Alternatively, you can run FreePATHS in the mean free path sampling mode, which is designed to calculate the thermal conductivity by integrating phonon dispersion. To run the program in this mode, it is advised to reduce the number of phonons to about 30 and add `-s` flag in the command:
@@ -1,6 +1,6 @@
1
- # FreePATHS - Free Phonon And Thermal Simulator
1
+ # FreePATHS - Free Phonon And THermal Simulator
2
2
 
3
- This Monte Carlo algorithm simulates trajectories of phonons in 3D models of nanostructures, which consists of a box with holes or pillars of various shapes. The algorithm outputs phonon trajectories, heat fluxes, temperature maps and profiles, the thermal conductivity, scattering maps and statistics and other information. See [documentation](https://anufrievroman.gitbook.io/freepaths/) for the details of the simulation.
3
+ This Monte Carlo algorithm simulates trajectories of phonons or electrons in 3D models of nanostructures, which consists of a box with holes, pillars, or interfaces of various shapes. For phonons, the algorithm outputs heat fluxes, temperature maps and profiles, thermal conductivity, scattering maps and statistics, and other information. For electrons, it outputs electrical conductivity, Seebeck coefficient, electronic thermal conductivity, power factor, and related quantities as a function of Fermi level. See [documentation](https://anufrievroman.gitbook.io/freepaths/) for the details of the simulation.
4
4
 
5
5
  ![Screenshot](https://github.com/anufrievroman/Monte-Carlo/blob/master/screenshot.png)
6
6
 
@@ -37,6 +37,15 @@ See [documentation](https://anufrievroman.gitbook.io/freepaths/examples) for exp
37
37
  After the simulation, see the results in a newly created **Results** folder.
38
38
 
39
39
 
40
+ ### Electron mode
41
+
42
+ FreePATHS can also simulate electron transport. In this mode, electrons are traced through the structure and thermoelectric properties — electrical conductivity, Seebeck coefficient, electronic thermal conductivity, and power factor — are computed as a function of Fermi level. To run in electron mode, add the `-e` flag:
43
+
44
+ `freepaths -e your_input_file.py`
45
+
46
+ See the [tutorial](https://anufrievroman.gitbook.io/freepaths/basic-tutorials/electrons-in-holey-membranes) and [theory](https://anufrievroman.gitbook.io/freepaths/theory/electrical-conductivity) for details.
47
+
48
+
40
49
  ### MFP sampling mode
41
50
 
42
51
  Alternatively, you can run FreePATHS in the mean free path sampling mode, which is designed to calculate the thermal conductivity by integrating phonon dispersion. To run the program in this mode, it is advised to reduce the number of phonons to about 30 and add `-s` flag in the command:
@@ -6,7 +6,7 @@ from colorama import Fore, Style
6
6
 
7
7
  from freepaths.particle_types import ParticleType
8
8
 
9
- __version__ = "2.2.1"
9
+ __version__ = "2.2.4"
10
10
 
11
11
  colorama.init()
12
12
 
@@ -160,7 +160,7 @@ class Config:
160
160
 
161
161
  for source in self.particles_sources:
162
162
  if source.y > self.length:
163
- logging.error("Y coordinate of a source exceeded LENGHT")
163
+ logging.error("Y coordinate of a source exceeded LENGTH")
164
164
  sys.exit()
165
165
 
166
166
  if source.y < 0:
@@ -215,7 +215,7 @@ class Config:
215
215
  sys.exit()
216
216
 
217
217
 
218
- def check_depricated_parameters(self):
218
+ def check_deprecated_parameters(self):
219
219
  """Check for deprecated parameters and warn about them"""
220
220
 
221
221
  if 'COLD_SIDE_POSITION' in globals():
@@ -258,5 +258,5 @@ class Config:
258
258
  cf = Config()
259
259
  cf.convert_to_enums()
260
260
  cf.check_parameter_validity()
261
- cf.check_depricated_parameters()
261
+ cf.check_deprecated_parameters()
262
262
 
@@ -96,7 +96,6 @@ class GeneralData(Data):
96
96
  self.interfaces_mode.extend(flight.interfaces_mode)
97
97
 
98
98
 
99
-
100
99
  def write_into_files(self):
101
100
  import os
102
101
  if not os.path.exists("Data"):
@@ -142,7 +141,6 @@ class GeneralData(Data):
142
141
  }
143
142
 
144
143
 
145
-
146
144
  class ScatteringData(Data):
147
145
  """Statistics of particle scattering events"""
148
146
 
@@ -163,12 +161,6 @@ class ScatteringData(Data):
163
161
  self.total = np.zeros(cf.number_of_length_segments+1)
164
162
  self.interfaces_transmission_specular= np.zeros(cf.number_of_length_segments + 1)
165
163
  self.interfaces_transmission_diffuse = np.zeros(cf.number_of_length_segments + 1)
166
- self.interfaces_angles = np.zeros(cf.number_of_length_segments + 1)
167
- self.interfaces_transmission_factor = np.zeros(cf.number_of_length_segments + 1)
168
- self.interfaces_wavelength = np.zeros(cf.number_of_length_segments+1)
169
- self.interfaces_frequency = np.zeros(cf.number_of_length_segments+1)
170
- self.interfaces_mode = np.zeros(cf.number_of_length_segments+1)
171
-
172
164
 
173
165
 
174
166
  def save_scattering_events(self, y, scattering_types):
@@ -215,14 +207,10 @@ class ScatteringData(Data):
215
207
  data = np.vstack((self.wall_diffuse, self.wall_specular, self.top_diffuse, self.top_specular, self.hole_diffuse,
216
208
  self.hole_specular, self.hot_side, self.internal, self.pillar_diffuse, self.pillar_specular,
217
209
  self.interfaces_diffuse, self.interfaces_specular,
218
- self.interfaces_transmission_diffuse, self.interfaces_transmission_specular,
219
- self.interfaces_transmission_factor, self.interfaces_angles,
220
- self.interfaces_wavelength, self.interfaces_mode)).T
221
- header1 = "Sidewalls diffuse, Sidewalls specular, Top & bottom diffuse, Top & bottom specular, "
222
- header2 = "Holes diffuse, Holes specular, Hot side, Internal, Pillars diffuse, Pillars specular"
223
- header3 = "Interfaces diffuse, Interfaces specular, Interfaces transmission diffuse, Interfaces transmission specular, " \
224
- "Interfaces transmission factor, Interfaces angles, Interfaces wavelength, Interfaces frequency, Interfaces mode"
225
- header = header1 + header2 + header3
210
+ self.interfaces_transmission_diffuse, self.interfaces_transmission_specular)).T
211
+ header = ("Sidewalls diffuse, Sidewalls specular, Top & bottom diffuse, Top & bottom specular, "
212
+ "Holes diffuse, Holes specular, Hot side, Internal, Pillars diffuse, Pillars specular, "
213
+ "Interfaces diffuse, Interfaces specular, Interfaces transmission diffuse, Interfaces transmission specular")
226
214
  np.savetxt(filename, data, fmt='%1.3e', delimiter=",", header=header, encoding='utf-8')
227
215
 
228
216
  def dump_data(self):
@@ -242,11 +230,6 @@ class ScatteringData(Data):
242
230
  'interfaces_specular': self.interfaces_specular,
243
231
  'interfaces_transmission_specular': self.interfaces_transmission_specular,
244
232
  'interfaces_transmission_diffuse': self.interfaces_transmission_diffuse,
245
- 'interfaces_angles': self.interfaces_angles,
246
- 'interfaces_transmission_factor': self.interfaces_transmission_factor,
247
- 'interfaces_wavelength': self.interfaces_wavelength,
248
- 'interfaces_frequency': self.interfaces_frequency,
249
- 'interfaces_mode' : self.interfaces_mode,
250
233
  'total': self.total
251
234
  }
252
235
 
@@ -297,7 +280,6 @@ class TriangleScatteringData(Data):
297
280
  }
298
281
 
299
282
 
300
-
301
283
  class SegmentData(Data):
302
284
  """Statistics of events happening in different segments"""
303
285
 
@@ -25,11 +25,11 @@ NUMBER_OF_STABILIZATION_TIMEFRAMES = 5
25
25
 
26
26
  # Electron parameters [eV]
27
27
  IS_CARRIER_ELECTRON = True
28
- ENERGY_UPPER_BOUND = 3*k*T / electron_volt
28
+ ENERGY_UPPER_BOUND = 6*k*T / electron_volt
29
29
  ENERGY_LOWER_BOUND = 0
30
30
  ENERGY_STEP = 5e-3
31
31
 
32
- ELECTRON_MFP = 15e-9 # [m]
32
+ ELECTRON_MFP = 10e-9 # [m]
33
33
  MEAN_MAPPING_CONSTANT = 5e-6 # [m²]
34
34
 
35
35
 
@@ -88,7 +88,7 @@ INTERFACE_ROUGHNESS = 0.2e-9
88
88
  HOLES = []
89
89
  PILLARS = []
90
90
  INTERFACES = []
91
- BULKS = []
91
+ BULKS = []
92
92
 
93
93
  # Multiprocessing:
94
94
  NUMBER_OF_PROCESSES = 10
@@ -54,7 +54,7 @@ class Flight:
54
54
  """Mean value of all free flights"""
55
55
  try:
56
56
  mfp = sum(self.free_paths)/len(self.free_paths)
57
- except:
57
+ except ZeroDivisionError:
58
58
  mfp = 0
59
59
  return mfp
60
60
 
@@ -1,137 +1,135 @@
1
- """Module to run thermal conductivity calculations by integrating the phonon dispersion"""
2
-
3
- import os
4
- import numpy as np
5
- import sys
6
- import time
7
- import shutil
8
- import scipy
9
- import math
10
- import logging
11
- from colorama import Fore, Style
12
-
13
- # Modules:
14
- from freepaths.animation import create_animation
15
- from freepaths.config import cf
16
- from freepaths.run_particle import run_particle
17
- from freepaths.phonon import Phonon
18
- from freepaths.flight import Flight
19
- from freepaths.particle_types import ParticleType
20
- from freepaths.data import ScatteringData, GeneralData, SegmentData, PathData, TriangleScatteringData
21
- from freepaths.progress import Progress
22
- from freepaths.materials import Si, SiC, Graphite, Ge
23
- from freepaths.maps import ScatteringMap, ThermalMaps
24
- from freepaths.output_info import output_general_information, output_scattering_information, output_parameter_warnings
25
- from freepaths.output_plots import plot_data
26
-
27
-
28
- def main(input_file, particle_type):
29
- """This is the main function, which integrates phonon dispersion to get thermal conductivity"""
30
-
31
- print(f'Mean free path sampling of {Fore.GREEN}{cf.output_folder_name}{Style.RESET_ALL}')
32
- start_time = time.time()
33
- progress = Progress()
34
-
35
- # Initialize the material:
36
- if cf.media == "Si":
37
- material = Si(cf.temp, num_points=cf.number_of_particles +1)
38
-
39
- # -------- has to be modified fro have only SiGe values and not a mix between Ge and SiGe------------
40
- elif cf.media == "Ge":
41
- material = Ge(cf.temp, num_points=cf.number_of_particles +1)
42
- # -------- has to be modified fro have only SiGe values and not a mix between Ge and SiGe------------
43
-
44
- elif cf.media == "SiC":
45
- material = SiC(cf.temp, num_points=cf.number_of_particles+1)
46
- elif cf.media == "Graphite":
47
- material = Graphite(cf.temp, num_points=cf.number_of_particles+1)
48
- else:
49
- logging.error(f"Material {cf.media} is not supported")
50
- sys.exit()
51
-
52
- # Initiate data structures:
53
- scatter_stats = ScatteringData()
54
- general_stats = GeneralData()
55
- segment_stats = SegmentData()
56
- places_stats = TriangleScatteringData()
57
- path_stats = PathData()
58
- scatter_maps = ScatteringMap()
59
- thermal_maps = ThermalMaps()
60
-
61
- total_thermal_conductivity = 0.0
62
-
63
- # For each polarization branch:
64
- for branch_number in range(3):
65
- sys.stdout.write(f"\rIntegrating branch number {branch_number+1}.\n")
66
-
67
- # For each phonon:
68
- for index in range(cf.number_of_particles):
69
-
70
- # Wave vector:
71
- k_vector = (material.dispersion[index+1, 0] + material.dispersion[index, 0]) / 2
72
- d_k_vector = (material.dispersion[index+1, 0] - material.dispersion[index, 0])
73
-
74
- # Initiate a phonon and its flight:
75
- phonon = Phonon(material, branch_number, index)
76
- flight = Flight(phonon)
77
-
78
- # Run this phonon through the structure:
79
- run_particle(phonon, flight, scatter_stats, places_stats, segment_stats, thermal_maps, scatter_maps, material)
80
-
81
- # Heat capacity, Ref. PRB 88 155318 (2013):
82
- omega = 2 * math.pi * phonon.f
83
- part = scipy.constants.hbar * omega / (scipy.constants.k * cf.temp)
84
- c_p = scipy.constants.k * part**2 * math.exp(part) / (math.exp(part) - 1)**2
85
-
86
- # Thermal conductivity, Ref. Phys. Rev. 132 2461 (1963):
87
- mean_relax_time = flight.mean_free_path/phonon.speed
88
- flight.thermal_conductivity = (1/(6*(math.pi**2)))*c_p*(phonon.speed**2)*mean_relax_time*(k_vector**2)*d_k_vector
89
- total_thermal_conductivity += flight.thermal_conductivity
90
-
91
- # Record the properties returned for this phonon:
92
- general_stats.save_particle_data(phonon)
93
- general_stats.save_flight_data(flight)
94
-
95
- # Record trajectories of the first N phonons:
96
- if index < cf.output_trajectories_of_first:
97
- path_stats.save_particle_path(flight)
98
-
99
- # Run additional calculations:
100
- thermal_maps.calculate_thermal_conductivity()
101
- thermal_maps.calculate_weighted_flux()
102
- thermal_maps.calculate_heat_flux_modulus()
103
-
104
- # Create the folder if it does not exist and copy input file there:
105
- if not os.path.exists("Results/" + cf.output_folder_name):
106
- os.makedirs("Results/" + cf.output_folder_name)
107
- os.makedirs("Results/" + cf.output_folder_name + '/Data')
108
- if input_file:
109
- shutil.copy(input_file, "Results/" + cf.output_folder_name)
110
- os.chdir("Results/" + cf.output_folder_name)
111
-
112
- # Save data into files:
113
- general_stats.write_into_files()
114
- scatter_stats.write_into_files()
115
- segment_stats.write_into_files()
116
- thermal_maps.write_into_files()
117
-
118
- scatter_maps.write_into_files()
119
- path_stats.write_into_files()
120
-
121
- # Generate animation of phonon paths:
122
- if cf.output_path_animation:
123
- create_animation()
124
-
125
- # Analyze and plot the data:
126
- sys.stdout.write("\rAnalyzing the data...")
127
- plot_data(particle_type, cf, mfp_sampling=True)
128
-
129
- # Output general information:
130
- output_general_information(start_time)
131
- output_scattering_information(scatter_stats)
132
- output_parameter_warnings()
133
-
134
- np.savetxt("Data/Thermal conductivity from MFP.csv", np.array([total_thermal_conductivity]), fmt='%2.4e', header="K [W/mK]", encoding='utf-8')
135
- sys.stdout.write(f'\rSee the results in {Fore.GREEN}Results/{cf.output_folder_name}{Style.RESET_ALL}\n')
136
- sys.stdout.write(f"\rThermal conductivity = {Fore.GREEN}{total_thermal_conductivity:.5f}{Style.RESET_ALL} W/m·K\n")
137
- sys.stdout.write(f"\r{Fore.BLUE}Thank you for using FreePATHS{Style.RESET_ALL}\n\n")
1
+ """Module to run thermal conductivity calculations by integrating the phonon dispersion"""
2
+
3
+ import os
4
+ import numpy as np
5
+ import sys
6
+ import time
7
+ import shutil
8
+ import scipy
9
+ import math
10
+ import logging
11
+ from colorama import Fore, Style
12
+
13
+ # Modules:
14
+ from freepaths.animation import create_animation
15
+ from freepaths.config import cf
16
+ from freepaths.run_particle import run_particle
17
+ from freepaths.phonon import Phonon
18
+ from freepaths.flight import Flight
19
+ from freepaths.particle_types import ParticleType
20
+ from freepaths.data import ScatteringData, GeneralData, SegmentData, PathData, TriangleScatteringData
21
+ from freepaths.progress import Progress
22
+ from freepaths.materials import Si, SiC, Graphite, SiGe
23
+ from freepaths.maps import ScatteringMap, ThermalMaps
24
+ from freepaths.output_info import output_general_information, output_scattering_information, output_parameter_warnings
25
+ from freepaths.output_plots import plot_data
26
+
27
+
28
+ def main(input_file, particle_type):
29
+ """This is the main function, which integrates phonon dispersion to get thermal conductivity"""
30
+
31
+ print(f'Mean free path sampling of {Fore.GREEN}{cf.output_folder_name}{Style.RESET_ALL}')
32
+ start_time = time.time()
33
+ progress = Progress()
34
+
35
+ # Initialize the material:
36
+ if cf.media == "Si":
37
+ material = Si(cf.temp, num_points=cf.number_of_particles +1)
38
+
39
+ elif cf.media == "SiGe":
40
+ material = SiGe(cf.temp, num_points=cf.number_of_particles +1)
41
+
42
+ elif cf.media == "SiC":
43
+ material = SiC(cf.temp, num_points=cf.number_of_particles+1)
44
+ elif cf.media == "Graphite":
45
+ material = Graphite(cf.temp, num_points=cf.number_of_particles+1)
46
+ else:
47
+ logging.error(f"Material {cf.media} is not supported")
48
+ sys.exit()
49
+
50
+ # Initiate data structures:
51
+ scatter_stats = ScatteringData()
52
+ general_stats = GeneralData()
53
+ segment_stats = SegmentData()
54
+ places_stats = TriangleScatteringData()
55
+ path_stats = PathData()
56
+ scatter_maps = ScatteringMap()
57
+ thermal_maps = ThermalMaps()
58
+
59
+ total_thermal_conductivity = 0.0
60
+
61
+ # For each polarization branch:
62
+ for branch_number in range(3):
63
+ sys.stdout.write(f"\rIntegrating branch number {branch_number+1}.\n")
64
+
65
+ # For each phonon:
66
+ for index in range(cf.number_of_particles):
67
+
68
+ # Wave vector:
69
+ k_vector = (material.dispersion[index+1, 0] + material.dispersion[index, 0]) / 2
70
+ d_k_vector = (material.dispersion[index+1, 0] - material.dispersion[index, 0])
71
+
72
+ # Initiate a phonon and its flight:
73
+ phonon = Phonon(material, branch_number, index)
74
+ flight = Flight(phonon)
75
+
76
+ # Run this phonon through the structure:
77
+ run_particle(phonon, flight, scatter_stats, places_stats, segment_stats, thermal_maps, scatter_maps, material)
78
+
79
+ # Heat capacity, Ref. PRB 88 155318 (2013):
80
+ omega = 2 * math.pi * phonon.f
81
+ part = scipy.constants.hbar * omega / (scipy.constants.k * cf.temp)
82
+ c_p = scipy.constants.k * part**2 * math.exp(part) / (math.exp(part) - 1)**2
83
+
84
+ # Thermal conductivity, Ref. Phys. Rev. 132 2461 (1963):
85
+ mean_relax_time = flight.mean_free_path/phonon.speed
86
+ flight.thermal_conductivity = (1/(6*(math.pi**2)))*c_p*(phonon.speed**2)*mean_relax_time*(k_vector**2)*d_k_vector
87
+ total_thermal_conductivity += flight.thermal_conductivity
88
+
89
+ # Record the properties returned for this phonon:
90
+ general_stats.save_particle_data(phonon)
91
+ general_stats.save_flight_data(flight)
92
+
93
+ # Record trajectories of the first N phonons:
94
+ if index < cf.output_trajectories_of_first:
95
+ path_stats.save_particle_path(flight)
96
+
97
+ # Run additional calculations:
98
+ thermal_maps.calculate_thermal_conductivity()
99
+ thermal_maps.calculate_weighted_flux()
100
+ thermal_maps.calculate_heat_flux_modulus()
101
+
102
+ # Create the folder if it does not exist and copy input file there:
103
+ if not os.path.exists("Results/" + cf.output_folder_name):
104
+ os.makedirs("Results/" + cf.output_folder_name)
105
+ os.makedirs("Results/" + cf.output_folder_name + '/Data')
106
+ if input_file:
107
+ shutil.copy(input_file, "Results/" + cf.output_folder_name)
108
+ os.chdir("Results/" + cf.output_folder_name)
109
+
110
+ # Save data into files:
111
+ general_stats.write_into_files()
112
+ scatter_stats.write_into_files()
113
+ segment_stats.write_into_files()
114
+ thermal_maps.write_into_files()
115
+
116
+ scatter_maps.write_into_files()
117
+ path_stats.write_into_files()
118
+
119
+ # Generate animation of phonon paths:
120
+ if cf.output_path_animation:
121
+ create_animation()
122
+
123
+ # Analyze and plot the data:
124
+ sys.stdout.write("\rAnalyzing the data...")
125
+ plot_data(particle_type, cf, mfp_sampling=True)
126
+
127
+ # Output general information:
128
+ output_general_information(start_time)
129
+ output_scattering_information(scatter_stats)
130
+ output_parameter_warnings()
131
+
132
+ np.savetxt("Data/Thermal conductivity from MFP.csv", np.array([total_thermal_conductivity]), fmt='%2.4e', header="K [W/mK]", encoding='utf-8')
133
+ sys.stdout.write(f'\rSee the results in {Fore.GREEN}Results/{cf.output_folder_name}{Style.RESET_ALL}\n')
134
+ sys.stdout.write(f"\rThermal conductivity = {Fore.GREEN}{total_thermal_conductivity:.5f}{Style.RESET_ALL} W/m·K\n")
135
+ sys.stdout.write(f"\r{Fore.BLUE}Thank you for using FreePATHS{Style.RESET_ALL}\n\n")