README.rst (4389B)
1 ============================================ 2 README: ODE integration with complex numbers 3 ============================================ 4 Exam exercise for *Numerical Methods* by Anders D. Christensen (mail_) 5 6 File description 7 ---------------- 8 - ``Makefile``: Description for GNU Make, handles compilation and execution. 9 - ``README.rst`` (this file): Description of numeric implementation and usage. 10 Written with reStructuredText syntax. 11 - ``check.cpp``: Function for displaying the state of a condition to stdout. 12 - ``check.h``: Prototype for the check-function. 13 - ``functions.h``: Input functions to be evaluated. 14 - ``mainA.cpp``: Main source code file for part A. 15 - ``ode.cpp``: Constructor and functions for the ODE class, including Runge-Kutta 16 stepper and driver. 17 - ``ode.h``: Header file with the ODE class. This file must be included in all 18 programs that want to utilize the ODE functionality. 19 - ``plot.gp``: Script for plotting all graphs with Gnuplot. 20 - ``typedefs.h``: Header file containing definitions of two main types, 21 ``Inttype``, a whole-number type, and ``Floattype``, a floating point number 22 type. The type definitions can be changed to different lengths and precisions. 23 The program can be compiled for verbose output by changing the ``verbose`` 24 variable. 25 - ``vector_arithmetic.h``: Operator overloading functions for the ``std::vector`` 26 class. 27 28 Problem descriptions 29 -------------------- 30 The four generated executables each demonstrate the ODE solvers functionality by 31 performing the following tasks. The results consist of the console output and 32 the corresponding plot with filename ``plot<Character>.png``. 33 - *A*: Construct an ODE solver that can handle functions with complex values. 34 Demonstrate that it solves the real component correctly, by stepping along 35 a path in the real range. 36 - *B*: Demonstrate that the ODE solver can solve the imaginary component by 37 stepping along a path in the imaginary range. 38 - *C*: Demonstrate the solution of a set of complex equations by stepping 39 through the complex plane. 40 - *D*: For an integration path in the complex plane, visualize how the 41 requirements of absolute- and relative precision are related to the number of 42 integration steps, for a given floating point precision. 43 44 Implementation 45 -------------- 46 This exercise was written in object-oriented C++ for easy reuse. For 47 portability, all included classes are from the standard template library. 48 49 The necessary ``std::vector`` arithmetic operations where overloaded to support 50 element-wise operations, such as vector-scalar multiplication, vector-vector 51 addition, etc. This approach was preferred over using ``std::valarray``, since it 52 is not dynamically expandable. 53 54 When creating a new ODE object, the user specifies the end-points of the linear 55 range, where the specified system of ordinary differential equations with 56 complex values will be solved. The range end-points are complex numbers 57 themselves, and the user can thus specify whether the integrator steps through a 58 range of real values, imaginary values, or both components in the complex plane. 59 60 The solver steps through the specified range by an adaptive step size, which is 61 also a complex number. The user specifies the fraction of the range to be used 62 as a start value for the step. The default value is 0.01. 63 64 The ODE class contains functions for writing the ODE solution to stdout 65 (``ODE::print``) or to a text file (``ODE::write``). The output format is the 66 following; the first column is the real part of x, second column the imaginary 67 part. The subsequent columns do in turn consist of real- and imaginary parts of 68 the variables in the ODE. 69 70 The program requires a modern C++ compiler, GNU Make and Gnuplot. It has been 71 tested with GCC, Clang and llvm. 72 73 Compiliation and execution 74 -------------------------- 75 To make and execute the program, go to the root folder and type `make`. This 76 will compile and execute the programs for part A-D, and plot output graphs. If 77 desired, individual parts can be compiled and executed using `make <Character>`. 78 79 To view the source code in a browser with vim's syntax highlighting, type `make 80 html`, and view the files in the `html` folder. The generation of HTML files 81 requires a newer vim for the source code files, and Docutils for the readme. 82 83 All output and objects can be removed using `make clean`. 84 85 86 87 .. _mail: mailto:adc@geo.au.dk 88 89 #vim: set tw=80