sources.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python
  2. """ Simulation sources """
  3. import numpy as np
  4. def gaussian(t: int, t0: int = 70, sigma: float = 12) -> float:
  5. """
  6. Gaussian pulse source
  7. :param int t: an integer counter that serves as the temporal index
  8. :param int t0: time step at which gaussian function is maximum, default 40
  9. :param float sigma: width of the gaussian pulse, default 12
  10. :return: gaussian pulse
  11. :rtype: float
  12. """
  13. return np.exp(-0.5 * ((t - t0) / sigma) ** 2)
  14. def normalized_gaussian(t: int, t0: int = 40, sigma: float = 12) -> float:
  15. """
  16. Normalized differentiated Gaussian pulse source
  17. :param int t: an integer counter that serves as the temporal index
  18. :param int t0: time step at which gaussian function is maximum, default 40
  19. :param float sigma: width of the gaussian pulse, default 12
  20. :return: normalized differentiated gaussian pulse
  21. :rtype: float
  22. """
  23. return -(t - t0) / sigma * np.exp(-0.5 * ((t - t0) / sigma) ** 2)
  24. def sinusoidal(t: int, ddx: float = 0.01, freq: float = 700e6) -> float:
  25. """
  26. Sinusoidal wave source
  27. :param int t: an integer counter that serves as the temporal index
  28. :param float ddx: the cell size (m), default 0.01 m
  29. :param float freq: frequency of the sinusoidal wave source, default 700 MHz
  30. :return: sinusoidal wave
  31. :rtype: float
  32. """
  33. dt: float = ddx / 6e8 # time step
  34. return np.sin(2 * np.pi * freq * dt * t)