I'm trying to generate a gaussain pulse in my FDTD 2D algorithm but it doesn't seem to generate with the defined spatial time step.
import numpy as np
import matplotlib.pyplot as plt
import math
delta_x = 6e-9
Nx = 500
beam_center = Nx / 2 * delta_x
s=2
epsilon_0 = 8.85e-12
mu_0 = 4*math.pi*1e-7
c = 1/math.sqrt(epsilon_0*mu_0)
eta_0 = math.sqrt(mu_0/epsilon_0)
# Calculate the time step based on spatial and time step
delta_x = 6e-9
delta_z = delta_x
delta_t = delta_z/(s*c)
total_time = 5000 * delta_t
# Generate the time array
t = np.arange(0, total_time, delta_t)
beam_waist = 200e-9
gaussian_pulse = np.exp(-((t-beam_center)**2)/2*beam_waist**2)
# Plot the Gaussian pulse
plt.plot(t, gaussian_pulse)
plt.xlabel('Time')
plt.ylabel('Amplitude')
plt.title('Gaussian Pulse')
plt.show()
This code above gives a straight horizontal line at 1. I understand its a scaling problem becaus if i use t=linspace(100,100,5000), it gives a gaussian pulse. But I'mbound by the timeseries as defined in code because it's part of the larger FDTD 2D code
try below and check if that works or not: gaussian_pulse = np.exp(-((t - beam_center)2) / (2 * beam_waist2))