Skip to content

Commit

Permalink
fix phase (#2132)
Browse files Browse the repository at this point in the history
Co-authored-by: Mo Chen <mochen@Mos-MacBook-Pro.local>
  • Loading branch information
mochen4 and Mo Chen authored Jul 14, 2022
1 parent 0bc1e70 commit 5f7c6fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/adjoint/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _adj_src_scale(self, include_resolution=True):
src_center_dtft = np.matmul(
np.exp(1j * 2 * np.pi * np.array([src.frequency])[:, np.newaxis] *
np.arange(y.size) * dt), y) * dt / np.sqrt(2 * np.pi)
adj_src_phase = np.exp(1j * np.angle(src_center_dtft))
adj_src_phase = np.exp(1j * np.angle(src_center_dtft)) * self.fwidth_scale

if self._frequencies.size == 1:
# Single frequency simulations. We need to drive it with a time profile.
Expand All @@ -99,7 +99,7 @@ def _adj_src_scale(self, include_resolution=True):
scale *= 2
return scale

def _create_time_profile(self, fwidth_frac=0.1):
def _create_time_profile(self, fwidth_frac=0.1, adj_cutoff=5):
"""Creates a time domain waveform for normalizing the adjoint source(s).
For single frequency objective functions, we should generate a guassian pulse with a reasonable
Expand All @@ -109,9 +109,10 @@ def _create_time_profile(self, fwidth_frac=0.1):
The user may specify a scalar valued objective function across multiple frequencies (e.g. MSE) in
which case we should check that all the frequencies fit in the specified bandwidth.
"""
self.fwidth_scale = np.exp(-2j*np.pi*adj_cutoff/fwidth_frac)
return mp.GaussianSource(
np.mean(self._frequencies),
fwidth=fwidth_frac * np.mean(self._frequencies),
fwidth=fwidth_frac * np.mean(self._frequencies),cutoff=adj_cutoff
)


Expand Down

0 comments on commit 5f7c6fd

Please sign in to comment.