freepaths 2.2.2__tar.gz → 2.3.0__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 (42) hide show
  1. {freepaths-2.2.2 → freepaths-2.3.0}/PKG-INFO +18 -5
  2. {freepaths-2.2.2 → freepaths-2.3.0}/README.md +17 -4
  3. freepaths-2.3.0/freepaths/__main__.py +64 -0
  4. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/config.py +4 -5
  5. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/data.py +9 -25
  6. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/default_config.py +10 -10
  7. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/flight.py +1 -1
  8. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/main_mfp_sampling.py +135 -137
  9. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/main_tracing.py +305 -295
  10. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/maps.py +11 -14
  11. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/materials.py +16 -10
  12. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/move.py +1 -1
  13. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/output_info.py +11 -17
  14. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/output_plots.py +88 -53
  15. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/output_structure.py +1 -1
  16. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/particle.py +15 -15
  17. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/phonon.py +1 -1
  18. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/post_computations.py +1 -1
  19. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/run_particle.py +8 -9
  20. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/scatterers.py +21 -13
  21. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/scattering.py +2 -20
  22. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/scattering_interfaces.py +5 -6
  23. freepaths-2.3.0/freepaths/scattering_semicircle.py +422 -0
  24. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/scattering_types.py +11 -11
  25. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths.egg-info/PKG-INFO +18 -5
  26. freepaths-2.2.2/freepaths/__main__.py +0 -42
  27. freepaths-2.2.2/freepaths/scattering_semicircle.py +0 -789
  28. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/animation.py +0 -0
  29. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/electron.py +0 -0
  30. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/interface_smmm.py +0 -0
  31. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/particle_types.py +0 -0
  32. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/progress.py +0 -0
  33. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/scattering_primitives.py +0 -0
  34. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths/sources.py +0 -0
  35. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths.egg-info/SOURCES.txt +0 -0
  36. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths.egg-info/dependency_links.txt +0 -0
  37. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths.egg-info/entry_points.txt +0 -0
  38. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths.egg-info/requires.txt +0 -0
  39. {freepaths-2.2.2 → freepaths-2.3.0}/freepaths.egg-info/top_level.txt +0 -0
  40. {freepaths-2.2.2 → freepaths-2.3.0}/pyproject.toml +0 -0
  41. {freepaths-2.2.2 → freepaths-2.3.0}/setup.cfg +0 -0
  42. {freepaths-2.2.2 → freepaths-2.3.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: freepaths
3
- Version: 2.2.2
3
+ Version: 2.3.0
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
 
@@ -54,9 +54,13 @@ FreePATHS is a command line application, so it runs inside Linux, MacOS, or Wind
54
54
 
55
55
  There are two modes of using the program. Main mode traces a large number of phonons through a structure and collects statistics about their paths. The MFP sampling mode measures phonon mean free paths using a small number of phonons and calculates the thermal conductivity by integrating phonon dispersion.
56
56
 
57
- ### Demo
57
+ ### Getting started
58
58
 
59
- If you simply run `freepaths` without specifying an input file, the program will run a demo simulation.
59
+ If you run `freepaths` without any arguments, the program will print a usage summary. To run a demo simulation with default parameters, use the `--demo` flag:
60
+
61
+ `freepaths --demo`
62
+
63
+ Example input files are available in the [examples](https://github.com/anufrievroman/freepaths/tree/master/examples) folder.
60
64
 
61
65
  ### Main mode
62
66
 
@@ -73,6 +77,15 @@ See [documentation](https://anufrievroman.gitbook.io/freepaths/examples) for exp
73
77
  After the simulation, see the results in a newly created **Results** folder.
74
78
 
75
79
 
80
+ ### Electron mode
81
+
82
+ 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:
83
+
84
+ `freepaths -e your_input_file.py`
85
+
86
+ 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.
87
+
88
+
76
89
  ### MFP sampling mode
77
90
 
78
91
  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
 
@@ -18,9 +18,13 @@ FreePATHS is a command line application, so it runs inside Linux, MacOS, or Wind
18
18
 
19
19
  There are two modes of using the program. Main mode traces a large number of phonons through a structure and collects statistics about their paths. The MFP sampling mode measures phonon mean free paths using a small number of phonons and calculates the thermal conductivity by integrating phonon dispersion.
20
20
 
21
- ### Demo
21
+ ### Getting started
22
22
 
23
- If you simply run `freepaths` without specifying an input file, the program will run a demo simulation.
23
+ If you run `freepaths` without any arguments, the program will print a usage summary. To run a demo simulation with default parameters, use the `--demo` flag:
24
+
25
+ `freepaths --demo`
26
+
27
+ Example input files are available in the [examples](https://github.com/anufrievroman/freepaths/tree/master/examples) folder.
24
28
 
25
29
  ### Main mode
26
30
 
@@ -37,6 +41,15 @@ See [documentation](https://anufrievroman.gitbook.io/freepaths/examples) for exp
37
41
  After the simulation, see the results in a newly created **Results** folder.
38
42
 
39
43
 
44
+ ### Electron mode
45
+
46
+ 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:
47
+
48
+ `freepaths -e your_input_file.py`
49
+
50
+ 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.
51
+
52
+
40
53
  ### MFP sampling mode
41
54
 
42
55
  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:
@@ -0,0 +1,64 @@
1
+ """FreePATHS - Free Phonon and THermal Simulator"""
2
+
3
+ import sys
4
+ import argparse
5
+ import colorama
6
+ from colorama import Fore, Style
7
+
8
+ from freepaths.particle_types import ParticleType
9
+
10
+ __version__ = "2.3.0"
11
+
12
+ colorama.init()
13
+
14
+ # Parse user arguments:
15
+ parser = argparse.ArgumentParser(
16
+ prog = 'FreePATHS',
17
+ description = 'Phonon Monte Carlo simulator',
18
+ epilog = 'For more information, examples, and tutorials, visit: https://anufrievroman.gitbook.io/freepaths'
19
+ )
20
+ parser.add_argument('input_file', nargs='?', default=None, help='The input file')
21
+ parser.add_argument("-v", "--version", action="version", version=f"FreePATHS {__version__}")
22
+ parser.add_argument("-s", "--sampling", help="Run in phonon MFP sampling mode", action="store_true")
23
+ parser.add_argument("-e", "--electron", help="Run simulation for electrons", action="store_true")
24
+ parser.add_argument("--demo", help="Run a demo simulation with default parameters", action="store_true")
25
+ args = parser.parse_args()
26
+
27
+
28
+ def run():
29
+ """Run the program depending on the mode"""
30
+ print(f"\n{Fore.BLUE}FreePATHS v{__version__}{Style.RESET_ALL}")
31
+
32
+ if not args.input_file and not args.demo:
33
+ print("\nUsage:")
34
+ print(f" freepaths <input_file> run phonon simulation")
35
+ print(f" freepaths <input_file> -e run electron simulation")
36
+ print(f" freepaths <input_file> -s run in MFP sampling mode")
37
+ print(f" freepaths --demo run a demo with default parameters")
38
+ print(f" freepaths --version show version")
39
+ print(f"\nExample input files:")
40
+ print(f" https://github.com/anufrievroman/freepaths/tree/master/examples")
41
+ print(f"\nDocumentation:")
42
+ print(f" https://anufrievroman.gitbook.io/freepaths")
43
+ sys.exit(0)
44
+
45
+ try:
46
+ if args.sampling:
47
+ import freepaths.main_mfp_sampling
48
+ freepaths.main_mfp_sampling.main(args.input_file, ParticleType.PHONON)
49
+
50
+ elif args.electron:
51
+ import freepaths.main_tracing
52
+ freepaths.main_tracing.main(args.input_file, ParticleType.ELECTRON)
53
+
54
+ else:
55
+ import freepaths.main_tracing
56
+ freepaths.main_tracing.main(args.input_file, ParticleType.PHONON)
57
+
58
+ except KeyboardInterrupt:
59
+ print(f"\n{Fore.RED}Simulation interrupted by user.{Style.RESET_ALL}")
60
+ sys.exit(0)
61
+
62
+
63
+ if __name__ == "__main__":
64
+ run()
@@ -26,6 +26,7 @@ parser = argparse.ArgumentParser(prog='FreePATHS', description='Monte Carlo simu
26
26
  parser.add_argument('input_file', nargs='?', default=None, help='The input file')
27
27
  parser.add_argument("-s", "--sampling", help="Run in MFP sampling mode", action="store_true")
28
28
  parser.add_argument("-e", "--electron", help="Run with electrons", action="store_true")
29
+ parser.add_argument("--demo", help="Run a demo simulation with default parameters", action="store_true")
29
30
  args = parser.parse_args()
30
31
 
31
32
 
@@ -36,8 +37,6 @@ if args.input_file:
36
37
  except FileNotFoundError:
37
38
  logging.error("Input file does not exist. Check if you are in the right folder and the file name is correct.")
38
39
  sys.exit()
39
- else:
40
- logging.warning("You provided no input file, so we will run a demo simulation:")
41
40
 
42
41
 
43
42
  class Config:
@@ -160,7 +159,7 @@ class Config:
160
159
 
161
160
  for source in self.particles_sources:
162
161
  if source.y > self.length:
163
- logging.error("Y coordinate of a source exceeded LENGHT")
162
+ logging.error("Y coordinate of a source exceeded LENGTH")
164
163
  sys.exit()
165
164
 
166
165
  if source.y < 0:
@@ -215,7 +214,7 @@ class Config:
215
214
  sys.exit()
216
215
 
217
216
 
218
- def check_depricated_parameters(self):
217
+ def check_deprecated_parameters(self):
219
218
  """Check for deprecated parameters and warn about them"""
220
219
 
221
220
  if 'COLD_SIDE_POSITION' in globals():
@@ -258,5 +257,5 @@ class Config:
258
257
  cf = Config()
259
258
  cf.convert_to_enums()
260
259
  cf.check_parameter_validity()
261
- cf.check_depricated_parameters()
260
+ cf.check_deprecated_parameters()
262
261
 
@@ -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):
@@ -212,17 +204,15 @@ class ScatteringData(Data):
212
204
  def write_into_files(self):
213
205
  """Write data into a file"""
214
206
  filename = "Data/Scattering events statistics.csv"
215
- data = np.vstack((self.wall_diffuse, self.wall_specular, self.top_diffuse, self.top_specular, self.hole_diffuse,
216
- self.hole_specular, self.hot_side, self.internal, self.pillar_diffuse, self.pillar_specular,
217
- 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
207
+ n = cf.number_of_length_segments
208
+ data = np.vstack((self.wall_diffuse[:n], self.wall_specular[:n], self.top_diffuse[:n], self.top_specular[:n],
209
+ self.hole_diffuse[:n], self.hole_specular[:n], self.hot_side[:n], self.internal[:n],
210
+ self.pillar_diffuse[:n], self.pillar_specular[:n],
211
+ self.interfaces_diffuse[:n], self.interfaces_specular[:n],
212
+ self.interfaces_transmission_diffuse[:n], self.interfaces_transmission_specular[:n])).T
213
+ header = ("Sidewalls diffuse, Sidewalls specular, Top & bottom diffuse, Top & bottom specular, "
214
+ "Holes diffuse, Holes specular, Hot side, Internal, Pillars diffuse, Pillars specular, "
215
+ "Interfaces diffuse, Interfaces specular, Interfaces transmission diffuse, Interfaces transmission specular")
226
216
  np.savetxt(filename, data, fmt='%1.3e', delimiter=",", header=header, encoding='utf-8')
227
217
 
228
218
  def dump_data(self):
@@ -242,11 +232,6 @@ class ScatteringData(Data):
242
232
  'interfaces_specular': self.interfaces_specular,
243
233
  'interfaces_transmission_specular': self.interfaces_transmission_specular,
244
234
  '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
235
  'total': self.total
251
236
  }
252
237
 
@@ -297,7 +282,6 @@ class TriangleScatteringData(Data):
297
282
  }
298
283
 
299
284
 
300
-
301
285
  class SegmentData(Data):
302
286
  """Statistics of events happening in different segments"""
303
287
 
@@ -7,29 +7,29 @@ from freepaths.sources import Source
7
7
 
8
8
  # General parameters:
9
9
  OUTPUT_FOLDER_NAME = "Si nanowire at 300 K"
10
- NUMBER_OF_PARTICLES = 5000
10
+ NUMBER_OF_PARTICLES = 10000
11
11
  NUMBER_OF_NODES = 400
12
12
  T = 300
13
13
  OUTPUT_SCATTERING_MAP = False
14
- OUTPUT_TRAJECTORIES_OF_FIRST = 50
14
+ OUTPUT_TRAJECTORIES_OF_FIRST = 20
15
15
  OUTPUT_STRUCTURE_COLOR = "#F0F0F0"
16
16
  NUMBER_OF_LENGTH_SEGMENTS = 10
17
17
  LOW_MEMORY_USAGE = False
18
18
 
19
19
  # Time parameters:
20
- TIMESTEP = 1e-12
21
- NUMBER_OF_TIMESTEPS = 300000
20
+ TIMESTEP = 2e-12
21
+ NUMBER_OF_TIMESTEPS = 200000
22
22
  NUMBER_OF_VIRTUAL_TIMESTEPS = NUMBER_OF_TIMESTEPS * 3
23
23
  NUMBER_OF_TIMEFRAMES = 8
24
24
  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
 
@@ -38,8 +38,8 @@ OUTPUT_PATH_ANIMATION = False
38
38
  OUTPUT_ANIMATION_FPS = 24
39
39
 
40
40
  # Map & profiles parameters:
41
- NUMBER_OF_PIXELS_X = 25
42
- NUMBER_OF_PIXELS_Y = 100
41
+ NUMBER_OF_PIXELS_X = 7
42
+ NUMBER_OF_PIXELS_Y = 67
43
43
  IGNORE_FAULTY_PARTICLES = False
44
44
 
45
45
  # Material parameters:
@@ -53,7 +53,7 @@ GRAY_APPROXIMATION_MFP = None
53
53
 
54
54
  # System dimensions [m]:
55
55
  THICKNESS = 150e-9
56
- WIDTH = 500e-9
56
+ WIDTH = 200e-9
57
57
  LENGTH = 2000e-9
58
58
  IS_TWO_DIMENSIONAL_MATERIAL = False
59
59
  INCLUDE_RIGHT_SIDEWALL = True
@@ -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")