/FEMFortran

Fortran code used to calculate heat equation in 1D using FEM

Primary LanguageFortran

Heat equation project using FEM

Requirements

  • gnuplot
  • gfortran
  • linux/mac, no windows port at the moment

Installation

make install

Executing

./exec.sh
./exec.sh n

,where n stands for amount of elements

Cleaning

make clean

or just delete build folder

Solution

So the solution looks simple:

Why Fortran

For this task I could use probably every language except Octave and Matlab. So why Fortran you might have asked?

Well I also did it in Python3 with NumPy And here are the times of executions.

times.png

Problem

 -ku^{''}=0 |:-k

u(2) = 0

\frac{du(0)}{dx} + u(0) = 20

k_func

x \in [0,2]

Find u(x) in [0,2]


-ku^{''}=0 |:-k

u^{''} = 0

 v \in u, u^{''}v=0

\int_0^{2} u^{''}v=0


\int_0^{2} u^{''}v dx = u^{'}(2)v(2) - u^{'}(0)v(0) - \int_0^{2}u^{'}v^{'}dx = 0

u^{'}(2)v(2) - u^{'}(0)v(0) = v(0)(20-v(0))

(u(0)-20)v(0) - \int_0^{2}u^{'}v^{'}dx = 0

w(0)v(0)- \int_0^{2}u^{'}v^{'}dx = 20v(0)


B(w,v) = w(0)v(0)- \int_0^{2}u^{'}v^{'}dx

\tau(v)= 20v(0)

Code used

During making this project I used: