| import numpy as np |
|
|
| def solver(u0_batch, t_coordinate, nu, rho): |
| """Solves the 1D reaction diffusion equation for all times in t_coordinate. |
| |
| Args: |
| u0_batch (np.ndarray): Initial condition [batch_size, N], |
| where batch_size is the number of different initial conditions, |
| and N is the number of spatial grid points. |
| t_coordinate (np.ndarray): Time coordinates of shape [T+1]. |
| It begins with t_0=0 and follows the time steps t_1, ..., t_T. |
| nu (float): The parameter nu in the equation. |
| rho (float): The parameter rho in the equation. |
| |
| Returns: |
| solutions (np.ndarray): Shape [batch_size, T+1, N]. |
| solutions[:, 0, :] contains the initial conditions (u0_batch), |
| solutions[:, i, :] contains the solutions at time t_coordinate[i]. |
| """ |
| |
| |
| |
| |
| return solutions |
|
|
|
|