Given an initial 2D temperature distribution and spatially-varying diffusion coefficients, compute the evolution of the temperature field over time using the following update equation:
where:
- is the temperature at position (row , column ) at time step
- is the diffusion coefficient in the row direction (controls diffusion when row index for the tensor changes: )
- is the diffusion coefficient in the column direction (controls diffusion when column index changes: )
- is the time step size
Input
A_initial: Initial temperature distribution of size (given at )Drow: Diffusion coefficients in row direction of sizeDcol: Diffusion coefficients across the columns, of sizeN: Size of the gridT: Total physical simulation timedt: Time step size (0.5 seconds)
Output
A_out: Temperature field at all time steps of size- The initial condition () should be copied to
A_out[0, :, :] - Fill in time steps
- The initial condition () should be copied to
Notes
Use zero-flux (Neumann) boundary conditions at all edges:
- At (first row): treat
- At (last row): treat
- At (first column): treat
- At (last column): treat
Loading...
Loading editor...
CUDA C++ environment
Desktop Required for Code Submission
For the best coding experience, please switch to a desktop device to write and submit your solution.