simulate 2d gaussian that decays with 3 picoseconds lifetime in python

main.py
import numpy as np
import matplotlib.pyplot as plt

# Define the parameters
x_size, y_size = 100, 100  # size of the 2D grid
x = np.linspace(-10, 10, x_size)  # x-coordinates
y = np.linspace(-10, 10, y_size)  # y-coordinates
X, Y = np.meshgrid(x, y)  # 2D grid

# Define the Gaussian distribution function
def gaussian_2d(x, y, amp, x0, y0, sigma_x, sigma_y):
    return amp * np.exp(-((x - x0) / sigma_x)**2 - ((y - y0) / sigma_y)**2)

# Define the parameters for the Gaussian distribution
amp = 1.0  # amplitude
x0 = 0.0  # center x-coordinate
y0 = 0.0  # center y-coordinate
sigma_x = 2.0  # standard deviation in x-direction
sigma_y = 2.0  # standard deviation in y-direction

# Simulate the Gaussian distribution at different times
time_points = np.linspace(0, 6, 7)  # time points to simulate (ps)
decay_time = 3.0  # decay time (ps)

for t in time_points:
    amp_decay = amp * np.exp(-t / decay_time)  # decayed amplitude
    Z = gaussian_2d(X, Y, amp_decay, x0, y0, sigma_x, sigma_y)
    plt.subplot(1, len(time_points), np.where(time_points == t)[0][0] + 1)
    plt.imshow(Z, extent=[-10, 10, -10, 10], cmap='hot', origin='lower')
    plt.title(f't = {t:.2f} ps')
    plt.axis('off')

plt.show()
1206 chars
34 lines

This script simulates a 2D Gaussian distribution that decays with a 3 ps lifetime. It generates a 2D grid of x and y coordinates and defines a Gaussian distribution function. The script then simulates the Gaussian distribution at different time points (0-6 ps) and plots the results as a series of 2D images, where the color intensity represents the amplitude of the Gaussian distribution at each point in space and time.

gistlibby LogSnag