/math536

math536 homework on numerical analysis programming tasks clone from bitbucket

Primary LanguageC++

Homework

This repository contains the part of the homework that needed to be programmed. File hw.pdf contains solutions for analytic problems.

Repository structure

  • hw.pdf - analytic solutions
  • hw1.cpp, hw2.cpp, hw3.cpp, hw4.cpp, hw4.py and hw5.cpp - main sources for homework.
  • include/ - headers.
  • sbms/ - Symmetric Banded Matrix Storage class and algorithms to work on them (Cholesky and SOR solvers)
  • cg/ - Compact Storage class and algorithms for it. Mainly Conjugate Gradients (CG) and with preconditioner (CGWPC).
  • util/ - utilities mainly for vectors.
  • test/ - various tests and helper programs.
  • plot_script/ - gnuplot scripts.

Building

“make” will build everything and make *.elf executable files for each homework assignement.

Running

  • main executables print most information to stdout.
  • hw1.elf outputs a plot of convergence rate over omega in “conv.txt”
  • hw2.elf outputs a plot of convergence rate and ln(error) over ln(h) in “conv_2.txt”
  • hw3.elf outputs “hw3_%f.txt” where %f is the Courant number
  • hw4.elf outputs the solution of problem 1 in hw4_prob1_sln.txt and problem 2 in hw4_prob2_sln_%f where %f is timestep k.
  • hw4.py outputs solutions for problem 2 in hw4_sln_2_%f.txt where %f is timestep k. plot script is in plot_script/hw4.py.gpl
  • hw5.elf outputs ln(error) vs ln(h) plot in hw5_errors.txt.
  • plotting scripts must be run in the same directory as plot files generated by main executables (in the root directory of repository) “gnuplot plot_script/<script>.gpl”

Notes

  • solution of hw4 problem 2 in hw4.cpp is not really correct, since the conjugate gradient method is used, which isn’t applicable in this case. To obtain solutions of hw4 problem 2 (Advection-Diffusion) use python script hw4.py