Here's an example of how you can template a solution for the 2D Unsteady Heat Conduction equation. Below I will represent the Heat equation discretized with implicit Euler in time and central difference in space.
Where the coefficient matrix can be represented as
Here's an example code:
main.m1818 chars77 lines
Here we have used a Jacobi Solver to solve the system of equations. Jacobi iteration method is one of the simplest methods to solve a system of linear equations. It starts with an initial guess and performs iterations to approach the solution.
This code is a good starting point but you may need to modify it depending on your boundary conditions, domain size, and other requirements.
gistlibby LogSnag