Skip to content

Commit

Permalink
If no sources set the runtime based on index of 1
Browse files Browse the repository at this point in the history
  • Loading branch information
momchil-flex committed Nov 25, 2024
1 parent 4ac954b commit 50c2530
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tidy3d/components/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3772,6 +3772,7 @@ def _run_time(self) -> float:
# contribution from the time of of the source pulses
if not self.sources:
source_time = 0.0
max_ref_ind = 1
else:
source_times = [src.source_time.end_time() for src in self.sources]
source_times = [x for x in source_times if x is not None]
Expand All @@ -3784,15 +3785,16 @@ def _run_time(self) -> float:
source_time_max = np.max(source_times)
source_time = run_time_spec.source_factor * source_time_max

# get the maximum refractive index evaluated over each of all the source central frequencies
all_ref_inds = [
self.get_refractive_indices(src.source_time.freq0) for src in self.sources
]
avg_ref_inds = [np.mean(np.array(n)) for n in all_ref_inds]
max_ref_ind = np.max(avg_ref_inds, initial=1)

# contribution from field decay out of the simulation
propagation_lengths = np.array(self.bounds[1]) - np.array(self.bounds[0])
max_propagation_length = np.max(propagation_lengths)

# get the maximum refractive index evaluated over each of all the source central frequencies
all_ref_inds = [self.get_refractive_indices(src.source_time.freq0) for src in self.sources]
avg_ref_inds = [np.mean(np.array(n)) for n in all_ref_inds]
max_ref_ind = np.max(avg_ref_inds)

propagation_time = run_time_spec.quality_factor * max_ref_ind * max_propagation_length / C_0

return source_time + propagation_time
Expand Down

0 comments on commit 50c2530

Please sign in to comment.