freepaths 2.3.4__tar.gz → 2.4.2__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 (45) hide show
  1. {freepaths-2.3.4 → freepaths-2.4.2}/PKG-INFO +1 -1
  2. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/__main__.py +1 -1
  3. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/config.py +16 -2
  4. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/data.py +24 -4
  5. freepaths-2.4.2/freepaths/default_config.py +164 -0
  6. freepaths-2.4.2/freepaths/electron.py +149 -0
  7. freepaths-2.4.2/freepaths/flight.py +139 -0
  8. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/main_mfp_sampling.py +57 -7
  9. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/main_tracing.py +16 -6
  10. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/maps.py +30 -11
  11. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/materials.py +206 -72
  12. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/output_electron_plots.py +13 -0
  13. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/output_info.py +32 -15
  14. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/output_plots.py +106 -44
  15. freepaths-2.4.2/freepaths/phonon.py +167 -0
  16. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/post_computations.py +14 -13
  17. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/run_particle.py +32 -6
  18. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/scatterers.py +60 -6
  19. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/scattering.py +24 -19
  20. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths.egg-info/PKG-INFO +1 -1
  21. freepaths-2.3.4/freepaths/default_config.py +0 -97
  22. freepaths-2.3.4/freepaths/electron.py +0 -75
  23. freepaths-2.3.4/freepaths/flight.py +0 -89
  24. freepaths-2.3.4/freepaths/phonon.py +0 -120
  25. {freepaths-2.3.4 → freepaths-2.4.2}/README.md +0 -0
  26. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/animation.py +0 -0
  27. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/interface_smmm.py +0 -0
  28. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/move.py +0 -0
  29. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/options.py +0 -0
  30. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/output_structure.py +0 -0
  31. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/particle.py +0 -0
  32. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/progress.py +0 -0
  33. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/scattering_interfaces.py +0 -0
  34. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/scattering_primitives.py +0 -0
  35. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/scattering_semicircle.py +0 -0
  36. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/scattering_types.py +0 -0
  37. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths/sources.py +0 -0
  38. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths.egg-info/SOURCES.txt +0 -0
  39. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths.egg-info/dependency_links.txt +0 -0
  40. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths.egg-info/entry_points.txt +0 -0
  41. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths.egg-info/requires.txt +0 -0
  42. {freepaths-2.3.4 → freepaths-2.4.2}/freepaths.egg-info/top_level.txt +0 -0
  43. {freepaths-2.3.4 → freepaths-2.4.2}/pyproject.toml +0 -0
  44. {freepaths-2.3.4 → freepaths-2.4.2}/setup.cfg +0 -0
  45. {freepaths-2.3.4 → freepaths-2.4.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: freepaths
3
- Version: 2.3.4
3
+ Version: 2.4.2
4
4
  Summary: Phonon Monte Carlo simulator
5
5
  Home-page: https://github.com/anufrievroman/freepaths
6
6
  Author: Roman Anufriev
@@ -7,7 +7,7 @@ from colorama import Fore, Style
7
7
 
8
8
  from freepaths.options import SimulationMode
9
9
 
10
- __version__ = "2.3.4"
10
+ __version__ = "2.4.2"
11
11
 
12
12
  colorama.init()
13
13
 
@@ -71,6 +71,11 @@ class Config:
71
71
  self.energy_lower_bound = ENERGY_LOWER_BOUND
72
72
  self.energy_step = ENERGY_STEP
73
73
  self.electron_mfp = ELECTRON_MFP
74
+ self.doping_concentration = DOPING_CONCENTRATION
75
+ self.surface_potential = SURFACE_POTENTIAL
76
+ self.depletion_doping = DEPLETION_DOPING # doping for the dead-layer width only (falls back to DOPING_CONCENTRATION)
77
+ self.depletion_width = 0.0 # [m] carrier dead-layer width; set from the material at simulation start
78
+ self.electron_mfp_energy_exponent = ELECTRON_MFP_ENERGY_EXPONENT
74
79
  self.mean_mapping_constant = MEAN_MAPPING_CONSTANT
75
80
  self.is_carrier_electron = IS_CARRIER_ELECTRON
76
81
  self.fermi_level_lower_bound = FERMI_LEVEL_LOWER_BOUND
@@ -85,6 +90,7 @@ class Config:
85
90
  self.number_of_pixels_y = NUMBER_OF_PIXELS_Y
86
91
  self.number_of_virtual_timesteps = NUMBER_OF_VIRTUAL_TIMESTEPS
87
92
  self.ignore_faulty_particles = IGNORE_FAULTY_PARTICLES
93
+ self.gradient_fit_range = GRADIENT_FIT_RANGE
88
94
 
89
95
  # Material parameters:
90
96
  self.media = MEDIA
@@ -92,8 +98,11 @@ class Config:
92
98
 
93
99
  # Internal scattering:
94
100
  self.include_internal_scattering = INCLUDE_INTERNAL_SCATTERING
95
- self.use_gray_approximation_mfp = USE_GRAY_APPROXIMATION_MFP
96
- self.gray_approximation_mfp = GRAY_APPROXIMATION_MFP
101
+ self.use_dispersion_heat_capacity = USE_DISPERSION_HEAT_CAPACITY
102
+ self.max_number_of_scattering_events = MAX_NUMBER_OF_SCATTERING_EVENTS
103
+ self.grain_size = GRAIN_SIZE
104
+ self.grain_size_std = GRAIN_SIZE_STD
105
+ self.grain_roughness = GRAIN_ROUGHNESS
97
106
 
98
107
  # System dimensions:
99
108
  self.thickness = THICKNESS
@@ -157,6 +166,11 @@ class Config:
157
166
  if self.number_of_particles < self.output_trajectories_of_first:
158
167
  self.output_trajectories_of_first = self.number_of_particles
159
168
 
169
+ if not (0.0 <= self.gradient_fit_range[0] < self.gradient_fit_range[1] <= 1.0):
170
+ logging.error("Parameter GRADIENT_FIT_RANGE must be a pair (start, end) with 0 <= start < end <= 1.\n" +
171
+ f"See the documentation at {WEBSITE}")
172
+ sys.exit()
173
+
160
174
  if self.number_of_timeframes <= self.number_of_stabilization_timeframes:
161
175
  logging.error("Parameter NUMBER_OF_STABILIZATION_TIMEFRAMES exceeds or equal to NUMBER_OF_TIMEFRAMES.\n" +
162
176
  "Leave at least one timeframe after NUMBER_OF_STABILIZATION_TIMEFRAMES.\n" +
@@ -57,22 +57,30 @@ class GeneralData(Data):
57
57
  """Initialize arrays for writing various properties"""
58
58
  self.initial_angles = []
59
59
  self.exit_angles = []
60
+ self.launch_frequencies = []
61
+ self.exit_frequencies = []
60
62
  self.hole_diff_scattering_angles = []
61
63
  self.hole_spec_scattering_angles = []
62
64
  self.free_paths = []
63
- self.frequencies = []
65
+ # Last-known frequency of each particle, paired with group_velocities below
66
+ # (used for the frequency-velocity/MFP correlation plots, not a true launch value):
67
+ self.final_frequencies = []
64
68
  self.initial_energies = []
65
69
  self.group_velocities = []
66
70
  self.travel_times = []
67
71
  self.mean_free_paths = []
68
72
  self.thermal_conductivity = []
73
+ # Per-phonon internal and boundary scattering rates (MFP-sampling mode only),
74
+ # the two channels of the total rate v/MFP resolved as a function of frequency:
75
+ self.internal_scattering_rates = []
76
+ self.boundary_scattering_rates = []
69
77
  def save_particle_data(self, pt, mode=None):
70
78
  """Add information about the particle to the dataset"""
71
79
  from freepaths.options import SimulationMode
72
80
  if mode is SimulationMode.ELECTRON:
73
81
  self.initial_energies.append(pt.energy)
74
82
  else:
75
- self.frequencies.append(pt.f)
83
+ self.final_frequencies.append(pt.f)
76
84
  self.group_velocities.append(pt.speed)
77
85
 
78
86
  def save_flight_data(self, flight, mode=None):
@@ -83,12 +91,16 @@ class GeneralData(Data):
83
91
  if mode is SimulationMode.PHONON_TRACING:
84
92
  self.initial_angles.append(flight.initial_theta)
85
93
  self.exit_angles.append(flight.exit_theta)
94
+ self.launch_frequencies.append(flight.initial_frequency)
95
+ self.exit_frequencies.append(flight.exit_frequency)
86
96
  self.hole_diff_scattering_angles.extend(flight.hole_diff_scattering_angles)
87
97
  self.hole_spec_scattering_angles.extend(flight.hole_spec_scattering_angles)
88
98
  self.travel_times.append(flight.travel_time)
89
99
  self.mean_free_paths.append(flight.mean_free_path)
90
100
  if mode is SimulationMode.PHONON_MFP_SAMPLING:
91
101
  self.thermal_conductivity.append(flight.thermal_conductivity)
102
+ self.internal_scattering_rates.append(flight.internal_scattering_rate)
103
+ self.boundary_scattering_rates.append(flight.boundary_scattering_rate)
92
104
 
93
105
  def write_into_files(self, mode=None):
94
106
  import os
@@ -101,11 +113,13 @@ class GeneralData(Data):
101
113
  if mode is SimulationMode.ELECTRON:
102
114
  np.savetxt("Data/All initial energies.csv", self.initial_energies, fmt='%2.4e', header="Energy [J]", encoding='utf-8')
103
115
  else:
104
- np.savetxt("Data/All initial frequencies.csv", self.frequencies, fmt='%2.4e', header="f [Hz]", encoding='utf-8')
116
+ np.savetxt("Data/All final frequencies.csv", self.final_frequencies, fmt='%2.4e', header="f [Hz]", encoding='utf-8')
105
117
  np.savetxt("Data/All group velocities.csv", self.group_velocities, fmt='%.4f', header="Vg [m//s]", encoding='utf-8')
106
118
  if mode is SimulationMode.PHONON_TRACING:
107
119
  np.savetxt("Data/All exit angles.csv", self.exit_angles, fmt='%.4f', header="Angle [rad]", encoding='utf-8')
108
120
  np.savetxt("Data/All initial angles.csv", self.initial_angles, fmt='%.4f', header="Angle [rad]", encoding='utf-8')
121
+ np.savetxt("Data/All launch frequencies.csv", self.launch_frequencies, fmt='%2.4e', header="f [Hz]", encoding='utf-8')
122
+ np.savetxt("Data/All exit frequencies.csv", self.exit_frequencies, fmt='%2.4e', header="f [Hz]", encoding='utf-8')
109
123
  if cf.holes:
110
124
  np.savetxt("Data/All hole diffuse scattering angles.csv", self.hole_diff_scattering_angles, fmt='%.4f', header="Angle [rad]", encoding='utf-8')
111
125
  np.savetxt("Data/All hole specular scattering angles.csv", self.hole_spec_scattering_angles, fmt='%.4f', header="Angle [rad]", encoding='utf-8')
@@ -113,19 +127,25 @@ class GeneralData(Data):
113
127
  np.savetxt("Data/All mean free paths.csv", self.mean_free_paths, fmt='%2.4e', header="MFPs [m]", encoding='utf-8')
114
128
  if mode is SimulationMode.PHONON_MFP_SAMPLING:
115
129
  np.savetxt("Data/All thermal conductivities.csv", self.thermal_conductivity, fmt='%2.4e', header="K [W/mK]", encoding='utf-8')
130
+ np.savetxt("Data/All internal scattering rates.csv", self.internal_scattering_rates, fmt='%2.4e', header="1/tau_internal [1/s]", encoding='utf-8')
131
+ np.savetxt("Data/All boundary scattering rates.csv", self.boundary_scattering_rates, fmt='%2.4e', header="1/tau_boundary [1/s]", encoding='utf-8')
116
132
  def dump_data(self):
117
133
  """Return data of a process in the form of a dictionary to be attached to the global data"""
118
134
  return {
119
135
  'initial_angles': self.initial_angles,
120
136
  'exit_angles': self.exit_angles,
137
+ 'launch_frequencies': self.launch_frequencies,
138
+ 'exit_frequencies': self.exit_frequencies,
121
139
  'hole_diff_scattering_angles': self.hole_diff_scattering_angles,
122
140
  'hole_spec_scattering_angles': self.hole_spec_scattering_angles,
123
141
  'free_paths': self.free_paths,
124
- 'frequencies': self.frequencies,
142
+ 'final_frequencies': self.final_frequencies,
125
143
  'group_velocities': self.group_velocities,
126
144
  'travel_times': self.travel_times,
127
145
  'mean_free_paths': self.mean_free_paths,
128
146
  'thermal_conductivity': self.thermal_conductivity,
147
+ 'internal_scattering_rates': self.internal_scattering_rates,
148
+ 'boundary_scattering_rates': self.boundary_scattering_rates,
129
149
  'initial_energies': self.initial_energies,
130
150
  }
131
151
 
@@ -0,0 +1,164 @@
1
+ """Default config file"""
2
+
3
+ import numpy as np
4
+ from scipy.constants import k, electron_volt
5
+ from freepaths.sources import Source
6
+
7
+
8
+ # General parameters:
9
+ OUTPUT_FOLDER_NAME = "Si nanowire at 300 K"
10
+ NUMBER_OF_PARTICLES = 10000
11
+ NUMBER_OF_NODES = 400
12
+ T = 300
13
+ OUTPUT_SCATTERING_MAP = False
14
+ OUTPUT_TRAJECTORIES_OF_FIRST = 20
15
+ OUTPUT_STRUCTURE_COLOR = "#F0F0F0"
16
+ NUMBER_OF_LENGTH_SEGMENTS = 10
17
+ LOW_MEMORY_USAGE = False
18
+
19
+ # Time parameters:
20
+ TIMESTEP = 2e-12
21
+ NUMBER_OF_TIMESTEPS = 200000
22
+ NUMBER_OF_VIRTUAL_TIMESTEPS = NUMBER_OF_TIMESTEPS * 3
23
+ NUMBER_OF_TIMEFRAMES = 8
24
+ NUMBER_OF_STABILIZATION_TIMEFRAMES = 5
25
+
26
+ # Electron parameters [eV]
27
+ IS_CARRIER_ELECTRON = True
28
+ ENERGY_UPPER_BOUND = 350e-3
29
+ ENERGY_LOWER_BOUND = 0
30
+ ENERGY_STEP = 5e-3
31
+
32
+ ELECTRON_MFP = 10e-9 # [m] crystal (acoustic-phonon-limited) MFP, energy-independent
33
+ # Ionized-impurity scattering: if DOPING_CONCENTRATION > 0, the MFP becomes energy-
34
+ # and doping-dependent via Matthiessen's rule, 1/Lambda_tot(E) = 1/ELECTRON_MFP +
35
+ # 1/Lambda_ii(E), where Lambda_ii is the Brooks-Herring contribution from N_I ionized
36
+ # dopants (screened Coulomb scattering). This shortens the MFP with doping and raises
37
+ # the Seebeck coefficient. 0 -> pure crystal MFP.
38
+ DOPING_CONCENTRATION = 0.0 # [m^-3] ionized-impurity (dopant) concentration N_I
39
+ # Surface depletion of carriers: with SURFACE_POTENTIAL > 0, a dead layer of width
40
+ # W = sqrt(2*eps_s*phi_s/(e*N_D)) (abrupt-junction depletion) is excluded around every
41
+ # free surface (walls, top/bottom, hole edges) for CARRIERS ONLY. phi_s is the surface
42
+ # band bending set by Fermi-level pinning at the native oxide / surface states. Needs
43
+ # a doping (DEPLETION_DOPING or DOPING_CONCENTRATION) and the material dielectric
44
+ # constant. 0 -> no depletion.
45
+ SURFACE_POTENTIAL = 0.0 # [eV] surface band bending phi_s (0 = off)
46
+ # Doping used ONLY for the depletion-width formula. If 0/None it falls back to
47
+ # DOPING_CONCENTRATION. Set this (and leave DOPING_CONCENTRATION = 0) to add a surface
48
+ # dead layer from the real doping WITHOUT engaging Brooks-Herring, i.e. to isolate the
49
+ # depletion effect on top of a constant-MFP transport calibration.
50
+ DEPLETION_DOPING = 0.0 # [m^-3] dopant concentration for the dead-layer width only
51
+ # Legacy phenomenological energy dependence (only used when DOPING_CONCENTRATION = 0):
52
+ # Lambda(E) = ELECTRON_MFP * (E/kT)^p. p=0 -> constant; p=2 -> ionized-impurity-like.
53
+ ELECTRON_MFP_ENERGY_EXPONENT = 0.0
54
+ MEAN_MAPPING_CONSTANT = 5e-6 # [m²]
55
+
56
+ FERMI_LEVEL_LOWER_BOUND = -0.2 # [eV] lower end of post-processing Fermi level sweep
57
+ FERMI_LEVEL_UPPER_BOUND = 0.1 # [eV] upper end of post-processing Fermi level sweep;
58
+ # far above the band edge the Fermi window leaves the sampled energy range and
59
+ # the MC results become noisy, so there is little point in sweeping further
60
+
61
+
62
+ # Animation:
63
+ OUTPUT_PATH_ANIMATION = False
64
+ OUTPUT_ANIMATION_FPS = 24
65
+
66
+ # Map & profiles parameters:
67
+ NUMBER_OF_PIXELS_X = 7
68
+ NUMBER_OF_PIXELS_Y = 67
69
+ IGNORE_FAULTY_PARTICLES = False
70
+ GRADIENT_FIT_RANGE = (0.1, 0.9)
71
+
72
+ # Material parameters:
73
+ MEDIA = "Si"
74
+ MEDIA_FERMI_LEVEL = None
75
+
76
+ # Internal scattering:
77
+ INCLUDE_INTERNAL_SCATTERING = True
78
+
79
+ # Phonon frequencies and branches are always sampled from the tabulated dispersion
80
+ # (weight k^2 dk per bin, heat-capacity weighting, group-velocity weighting at the
81
+ # source), so particles are equal-energy deviational bundles and the thermal maps
82
+ # record a constant weight per phonon. At inelastic (anharmonic) internal scattering
83
+ # events the branch and frequency are re-drawn from the collision-rate-weighted
84
+ # distribution (Peraud & Hadjiconstantinou, PRB 84, 205331 (2011)), restoring local
85
+ # thermal equilibrium of the phonon population. Elastic internal events (impurity/alloy
86
+ # scattering) conserve the mode and only randomize the direction. This applies to the
87
+ # phonon tracing mode; MFP sampling and electron modes keep the particle identity by
88
+ # construction.
89
+
90
+ # Convert deposited particle energy into the temperature profile using the
91
+ # dispersion-only heat capacity (Material.dispersion_heat_capacity, summed only
92
+ # over the branches in the tabulated dispersion) instead of the experimental
93
+ # heat capacity fit (Material.assign_heat_capacity). On by default because it
94
+ # makes the reported temperature and kappa self-consistent with the
95
+ # dispersion-based sampling/rethermalization scheme and the model's own RTA
96
+ # integral. Set to False to use the real material heat capacity instead (e.g.
97
+ # including optical branches absent from the tabulated dispersion):
98
+ USE_DISPERSION_HEAT_CAPACITY = True
99
+
100
+ # MFP sampling mode only (no effect in phonon tracing, where particles must keep
101
+ # going for the full budget to build the flux map): end a phonon's flight early
102
+ # once it has accumulated this many free-path segments, instead of always running
103
+ # to NUMBER_OF_TIMESTEPS. A short-tau, low-velocity phonon takes tiny hops and
104
+ # diffuses so slowly that it essentially never reaches a domain boundary, but its
105
+ # mean free path already converges after a modest number of scattering events, so
106
+ # running it to the full timestep budget is wasted compute. 1000 is on by default,
107
+ # since it was validated (bulk Si MFP-sampling convergence study, Data/BulkSi_Phonon_MFP/)
108
+ # to give the same result as 5000 while being far cheaper. Set to None to disable
109
+ # (run to the timestep budget or a boundary, as before):
110
+ MAX_NUMBER_OF_SCATTERING_EVENTS = 1000
111
+
112
+ # Grain boundary scattering (polycrystalline materials):
113
+ # GRAIN_SIZE sets the mean grain diameter [m]. None disables grain boundary scattering entirely.
114
+ # GRAIN_SIZE_STD sets the standard deviation [m]; the grain size is drawn per phonon from a
115
+ # lognormal distribution with this mean and std. Set to 0 for monodisperse (single grain size).
116
+ # GRAIN_ROUGHNESS is the RMS disorder width of the grain boundary [m], used in a Soffer-type
117
+ # specularity factor: at low frequencies (long wavelengths) the boundary appears smooth and
118
+ # phonons pass through; at high frequencies it acts as a classical diffuse scatterer.
119
+ # Typical values: GRAIN_SIZE 100 nm – 10 µm, GRAIN_ROUGHNESS 0.5–2 nm.
120
+ GRAIN_SIZE = None
121
+ GRAIN_SIZE_STD = 0.0
122
+ GRAIN_ROUGHNESS = 1e-9
123
+
124
+ # System dimensions [m]:
125
+ THICKNESS = 150e-9
126
+ WIDTH = 200e-9
127
+ LENGTH = 2000e-9
128
+ IS_TWO_DIMENSIONAL_MATERIAL = False
129
+ INCLUDE_RIGHT_SIDEWALL = True
130
+ INCLUDE_LEFT_SIDEWALL = True
131
+ INCLUDE_TOP_SIDEWALL = False
132
+ INCLUDE_BOTTOM_SIDEWALL = False
133
+
134
+ # Hot and cold sides [m]:
135
+ COLD_SIDE_POSITION_TOP = True
136
+ COLD_SIDE_POSITION_BOTTOM = False
137
+ COLD_SIDE_POSITION_RIGHT = False
138
+ COLD_SIDE_POSITION_LEFT = False
139
+ HOT_SIDE_POSITION_TOP = False
140
+ HOT_SIDE_POSITION_BOTTOM = True
141
+ HOT_SIDE_POSITION_RIGHT = False
142
+ HOT_SIDE_POSITION_LEFT = False
143
+ RETHERMALIZATION_ON_HOT_SIDES = True
144
+
145
+ # Particle source:
146
+ PARTICLE_SOURCES = [Source(x=0, y=0, z=0, size_x=0, size_y=0, size_z=0, angle_distribution="random", angle=0)]
147
+
148
+ # Roughness [m]:
149
+ SIDE_WALL_ROUGHNESS = 2e-9
150
+ HOLE_ROUGHNESS = 2e-9
151
+ PILLAR_ROUGHNESS = 2e-9
152
+ TOP_ROUGHNESS = 0.2e-9
153
+ BOTTOM_ROUGHNESS = 0.2e-9
154
+ PILLAR_TOP_ROUGHNESS = 0.2e-9
155
+ INTERFACE_ROUGHNESS = 0.2e-9
156
+
157
+ # Holes and pillars:
158
+ HOLES = []
159
+ PILLARS = []
160
+ INTERFACES = []
161
+ BULKS = []
162
+
163
+ # Multiprocessing:
164
+ NUMBER_OF_PROCESSES = 10
@@ -0,0 +1,149 @@
1
+ """This module provides electron class which generates and moves an electron"""
2
+
3
+ from random import choice, random
4
+ from scipy.constants import h, k, hbar, electron_volt, elementary_charge, epsilon_0
5
+ from freepaths.config import cf
6
+ from freepaths.particle import Particle
7
+ from freepaths.options import ParticleType
8
+
9
+ import numpy as np
10
+
11
+
12
+ def _carrier_dos_mass(material):
13
+ """DOS effective mass of the active carrier (electron or hole)."""
14
+ return material.effective_electron_dos_mass if cf.is_carrier_electron else material.effective_hole_dos_mass
15
+
16
+
17
+ def depletion_width(material):
18
+ """Surface-depletion (dead-layer) width for carriers, from the abrupt-junction
19
+ depletion approximation W = sqrt(2*eps_s*phi_s/(e*N_D)), with phi_s = SURFACE_POTENTIAL
20
+ the surface band bending (eV, used as volts), N_D the doping, and eps_s the static
21
+ permittivity of the material. Carriers are excluded within W of every free surface
22
+ (Fermi-level pinning by surface states / native oxide). Returns 0 if there is no
23
+ doping or no surface potential. Reference: any semiconductor-device text (e.g. Sze),
24
+ surface-depletion / dead-layer model for nanostructure conductivity.
25
+
26
+ N_D is DEPLETION_DOPING if set, otherwise DOPING_CONCENTRATION. The separate
27
+ DEPLETION_DOPING lets the dead layer be driven by the real doping WITHOUT also
28
+ engaging the Brooks-Herring ionized-impurity MFP (which keys off DOPING_CONCENTRATION),
29
+ i.e. to isolate the depletion effect on top of a constant-MFP transport calibration."""
30
+ N_I = cf.depletion_doping if cf.depletion_doping else cf.doping_concentration
31
+ phi = cf.surface_potential
32
+ eps_r = getattr(material, 'dielectric_constant', None)
33
+ if not N_I or phi <= 0 or not eps_r:
34
+ return 0.0
35
+ eps = eps_r * epsilon_0
36
+ return np.sqrt(2.0 * eps * phi / (elementary_charge * N_I))
37
+
38
+
39
+ def electron_mfp(energy, material):
40
+ """Energy- and doping-dependent carrier mean free path via Matthiessen's rule:
41
+ 1/Lambda_tot(E) = 1/Lambda_ac + 1/Lambda_ii(E, N_I).
42
+
43
+ Lambda_ac = ELECTRON_MFP is the crystal (acoustic-phonon-limited) MFP, taken
44
+ energy-independent (for acoustic deformation-potential scattering tau ~ E^-1/2
45
+ cancels v ~ E^1/2, so Lambda = v*tau ~ E^0). Lambda_ii is the ionized-impurity
46
+ contribution from the Brooks-Herring model: screened Coulomb scattering off the
47
+ DOPING_CONCENTRATION ionized dopants, with tau_ii ~ E^{3/2} in the weak-screening
48
+ limit. Ionized impurities thus scatter LOW-energy carriers most, shortening the
49
+ MFP with doping and making scattering energy-selective, which raises the Seebeck
50
+ coefficient. DOPING_CONCENTRATION = 0 recovers the crystal MFP (optionally with
51
+ the legacy phenomenological exponent ELECTRON_MFP_ENERGY_EXPONENT).
52
+
53
+ Applies identically to electrons and holes: the carrier's own DOS effective mass
54
+ is used (chosen by IS_CARRIER_ELECTRON) and N_I is the density of ionized donors
55
+ (n-type) or acceptors (p-type). Reference: Brooks-Herring; Chattopadhyay &
56
+ Queisser, Rev. Mod. Phys. 53, 745 (1981). `energy` in J, scalar or array."""
57
+ lambda_ac = cf.electron_mfp
58
+ N_I = cf.doping_concentration
59
+
60
+ if not N_I:
61
+ # No ionized impurities: crystal MFP, with optional legacy power law.
62
+ p = cf.electron_mfp_energy_exponent
63
+ if p == 0:
64
+ return lambda_ac
65
+ return lambda_ac * (energy / (k * cf.temp)) ** p
66
+
67
+ # Brooks-Herring ionized-impurity MFP (Matthiessen-combined with the acoustic MFP):
68
+ energy = np.maximum(energy, 1e-4 * elementary_charge) # guard against E -> 0
69
+ m_star = _carrier_dos_mass(material)
70
+ eps = material.dielectric_constant * epsilon_0
71
+ T = cf.temp
72
+ # Debye screening from the free carriers (n = N_I, full activation): 1/L_D^2 = e^2 n / (eps kB T)
73
+ inv_screen_length_sq = elementary_charge**2 * N_I / (eps * k * T)
74
+ b = 8.0 * m_star * energy / (hbar**2 * inv_screen_length_sq) # b = (2k/beta)^2
75
+ screening = np.maximum(np.log1p(b) - b / (1.0 + b), 1e-12)
76
+ inv_tau_ii = (N_I * elementary_charge**4) / (16.0 * np.pi * np.sqrt(2.0 * m_star) * eps**2 * energy**1.5) * screening
77
+ v = np.sqrt(2.0 * energy / m_star)
78
+ lambda_ii = v / inv_tau_ii # = v * tau_ii
79
+ return 1.0 / (1.0 / lambda_ac + 1.0 / lambda_ii)
80
+
81
+
82
+ class Electron(Particle):
83
+ """An electron particle"""
84
+
85
+ def __init__(self, material):
86
+ super().__init__()
87
+
88
+ # Assign particle type
89
+ self.type = ParticleType.ELECTRON
90
+ self.is_electron_carrier = cf.is_carrier_electron # assign electron or hole behavior
91
+
92
+ source = choice(cf.particles_sources)
93
+ while True:
94
+ self.x, self.y, self.z = source.generate_coordinates()
95
+ is_in_hole = any(hole.is_inside(self.x, self.y, None, cf) for hole in cf.holes)
96
+ if not is_in_hole:
97
+ break
98
+
99
+ # Assign initial angles
100
+ self.theta, self.phi = source.generate_angles()
101
+ self.correct_angle()
102
+ if cf.is_two_dimensional_material:
103
+ self.phi, self.z = 0.0, 0.0
104
+
105
+ self.assign_energy()
106
+ self.assign_frequency(material)
107
+ self.assign_speed(material)
108
+ self.assign_internal_scattering_time(material)
109
+
110
+ def assign_energy(self):
111
+ """
112
+ Assign energy uniformly to an electron based on temperature.
113
+ Conduction minimum is considered at 0 energy by convention.
114
+ """
115
+ num_energy_points = int((cf.energy_upper_bound-cf.energy_lower_bound)/cf.energy_step)
116
+ # Keep energy in J for other computations
117
+ self.energy = np.random.choice(np.linspace(cf.energy_lower_bound, cf.energy_upper_bound - cf.energy_step, num_energy_points)) * electron_volt + cf.energy_step * electron_volt
118
+
119
+
120
+ @property
121
+ def wavelength(self):
122
+ raise Exception("Electron wavelength undefined")
123
+
124
+ def assign_frequency(self, material):
125
+ """
126
+ Conduction minimum is 0 by convention
127
+ """
128
+ self.f = self.energy / h
129
+
130
+ def assign_speed(self, material):
131
+ """
132
+ Assign speed to an electron using group velocity and considering parabolic energy-k relation and conduction minimum at 0
133
+ """
134
+ if self.is_electron_carrier:
135
+ effective_mass = material.effective_electron_dos_mass
136
+ else:
137
+ effective_mass = material.effective_hole_dos_mass
138
+ self.speed = (2*self.energy/(effective_mass))**(0.5)
139
+
140
+ def assign_internal_scattering_time(self, material):
141
+ """
142
+ Determine relaxation time after which this particle will undergo internal scattering.
143
+ Considering only elasctic scattering between electrons and phonons and thus a constant MFP.
144
+ With ELECTRON_MFP_ENERGY_EXPONENT != 0 the MFP becomes energy-dependent
145
+ (see electron_mfp_at_energy); scattering stays elastic so the electron's energy,
146
+ and hence its MFP, is fixed for the whole flight.
147
+ """
148
+ mfp = electron_mfp(self.energy, material)
149
+ self.time_of_internal_scattering = -np.log(random()) * (mfp / self.speed)
@@ -0,0 +1,139 @@
1
+ """Module that provides particle flight characteristics"""
2
+
3
+ from math import cos
4
+ import numpy as np
5
+
6
+ from freepaths.config import cf
7
+
8
+
9
+ class Path:
10
+ """Particle path coordinates"""
11
+
12
+ def __init__(self, x_init, y_init, z_init):
13
+ """Initialize a path"""
14
+ self.x = [x_init]
15
+ self.y = [y_init]
16
+ self.z = [z_init]
17
+
18
+ def add_point(self, x_new, y_new, z_new):
19
+ """Add a point to the particle path"""
20
+ self.x.append(x_new)
21
+ self.y.append(y_new)
22
+ self.z.append(z_new)
23
+
24
+ @property
25
+ def number_of_path_points(self):
26
+ """Calculate number of points in the path"""
27
+ return len(self.x)
28
+
29
+
30
+ class Flight:
31
+ """Particle flight characteristics"""
32
+
33
+ def __init__(self, particle):
34
+ """Initialize a particle
35
+ flight"""
36
+ self.particle = particle
37
+ self.initial_frequency = self.particle.f
38
+ self.initial_theta = self.particle.theta
39
+ self.path = Path(self.particle.x, self.particle.y, self.particle.z)
40
+ self.exit_theta = 0.0
41
+ self.exit_frequency = 0.0
42
+ self.free_path = 0.0
43
+ self.travel_time = 0.0
44
+ self.time_since_previous_scattering = 0.0
45
+ self.free_paths = []
46
+ self._mfp_sum = 0.0
47
+ self._mfp_count = 0
48
+ # Per-channel counts of the diffuse events that terminate a free-path segment,
49
+ # used to split the total scattering rate v/MFP into internal (phonon-phonon +
50
+ # impurity) and boundary (diffuse surface) spectra in the MFP-sampling mode:
51
+ self._internal_count = 0
52
+ self._boundary_count = 0
53
+ self.hole_diff_scattering_angles = []
54
+ self.hole_spec_scattering_angles = []
55
+ self.thermal_conductivity = 0.0
56
+ @property
57
+ def mean_free_path(self):
58
+ """Mean value of all free flights"""
59
+ return self._mfp_sum / self._mfp_count if self._mfp_count else 0
60
+
61
+ @property
62
+ def internal_scattering_rate(self):
63
+ """Per-phonon internal (phonon-phonon + impurity) scattering rate [1/s]:
64
+ number of internal events divided by the total flight time (mfp_sum / speed).
65
+ Summed with boundary_scattering_rate this recovers the total rate v/MFP, so the
66
+ two split the total scattering-rate spectrum into physical channels."""
67
+ if self._mfp_sum <= 0:
68
+ return 0.0
69
+ return self.particle.speed * self._internal_count / self._mfp_sum
70
+
71
+ @property
72
+ def boundary_scattering_rate(self):
73
+ """Per-phonon boundary (diffuse surface) scattering rate [1/s]: number of
74
+ diffuse boundary events divided by the total flight time (mfp_sum / speed)."""
75
+ if self._mfp_sum <= 0:
76
+ return 0.0
77
+ return self.particle.speed * self._boundary_count / self._mfp_sum
78
+
79
+ @property
80
+ def mean_free_path_sem(self):
81
+ """Standard error of the mean free path (MFP sampling mode only). Assumes
82
+ individual free-path segments are exponentially distributed (the natural
83
+ assumption for Poisson-process intrinsic scattering: coefficient of
84
+ variation = 1, i.e. std = mean), so SEM = mean_free_path / sqrt(n)."""
85
+ if self._mfp_count < 1:
86
+ return 0.0
87
+ return self.mean_free_path / (self._mfp_count ** 0.5)
88
+
89
+ def add_point_to_path(self):
90
+ """Add a scattering point to the path"""
91
+ self.path.add_point(self.particle.x, self.particle.y, self.particle.z)
92
+
93
+ def save_free_paths(self):
94
+ """Save current free path to the list of free paths"""
95
+ self._mfp_sum += self.free_path
96
+ self._mfp_count += 1
97
+ if not cf.low_memory_usage:
98
+ self.free_paths.append(self.free_path)
99
+
100
+ def record_scattering_channel(self, is_internal, is_boundary):
101
+ """Tally the channel of a diffuse event that ends a free-path segment, so the
102
+ total scattering rate can later be split into internal and boundary spectra."""
103
+ if is_internal:
104
+ self._internal_count += 1
105
+ if is_boundary:
106
+ self._boundary_count += 1
107
+
108
+ def save_hole_diff_scattering_angle(self, angle):
109
+ """Save angle of diffuse scattering from the hole"""
110
+ self.hole_diff_scattering_angles.append(angle)
111
+
112
+ def save_hole_spec_scattering_angle(self, angle):
113
+ """Save angle of specular scattering from the hole"""
114
+ self.hole_spec_scattering_angles.append(angle)
115
+
116
+ def restart(self):
117
+ """Restart the flight after a scattering event"""
118
+ self.time_since_previous_scattering = 0.0
119
+ self.free_path = 0.0
120
+
121
+ def finish(self, step, timestep, reached_cold_side=False):
122
+ """Finish the flight and record final state. travel_time is only set when
123
+ the particle genuinely reached the cold side - it means "time to cold side",
124
+ so leaving it at 0 for other exits (e.g. the MFP-sampling scattering-event
125
+ cap) keeps that meaning intact instead of recording a meaningless duration."""
126
+ self.exit_theta = self.particle.theta
127
+ self.exit_frequency = self.particle.f
128
+ if reached_cold_side:
129
+ self.travel_time = step * timestep
130
+
131
+ def add_step(self, timestep):
132
+ """Increase parameters of the flight by length of one step"""
133
+ step_length = self.particle.speed * timestep
134
+ self.free_path += step_length
135
+ self.time_since_previous_scattering += timestep
136
+
137
+ def reset_travel_time(self):
138
+ """Reset the travel time of a particle"""
139
+ self.travel_time = 0.0