Repository for homeworks of SP4E
Lars B.
Bertil T.
Recent Commits
Commit | Author | Details | Committed | ||||
---|---|---|---|---|---|---|---|
3b4e89a7a782 | blatny | cleaning up | Dec 11 | ||||
d9aff2a3042e | • trottet | Adaptation for : csvfile read/write compute_temperature.cc run tests run heat… | Dec 11 | ||||
7155c5f0c7be | blatny | added comment on BC in README | Dec 11 | ||||
4951f454e6ad | • trottet | Merge branch 'master' of ssh://c4science.ch/diffusion/9484/sp4e-homework-lars… | Dec 5 | ||||
761032bfda8e | • trottet | test_temparature.cc python script | Dec 5 | ||||
28dfe238aa68 | blatny | added comment in README | Dec 5 | ||||
1c0d21ab289b | blatny | adding compute in test_temperature | Dec 5 | ||||
773b521b27df | blatny | finished computeTemperature | Dec 5 | ||||
b8dd80803a2c | blatny | updated cmake to include fftw for partcles | Dec 5 | ||||
f4b7713dfc47 | blatny | changed cmakelists | Dec 5 | ||||
5bd7f1202d69 | blatny | trying to fix temperature test | Dec 5 | ||||
8c47e516659b | • trottet | test-temperature CMakeLists | Dec 5 | ||||
124ac36ac295 | • trottet | test : HomogeneousTemperature test : VolumetricHeatSource | Dec 4 | ||||
91dc370bc29d | blatny | trying to fix ComputeTemparature | Dec 4 | ||||
4225c9fa3950 | blatny | trying to fix Bertils mess - Part I | Dec 4 |
README.md
SP4E Homeworks
Students:
- Lars B.
- Bertil T.
In this repository, we will keep all homeworks for SP4E
Homework 1
See folder named *hw1-conjugate-gradient*.
- Requirements
- Numpy
- Scipy
- Matplotlib
- Argparse
The code as been tested with Python 3.
Usage
Run the *main_minimize.py* with the following arguments:
- -A < matrix elements in row major order >
- -b < vector elements >
- -x0 < initial guess elements >
- -method < CG-scipy or CG-ours >
- -plot < True or False >
Example
The following command will run the program with the coefficients given in Exercise 1:
python3 main_minimize.py -A 8 0 2 6 -b 0 1 -x0 4 4 -method CG-scipy -plot True
NB: Note that the quadratic function in Exercise 1 is implemented with a multiplicative factor 1/2 in order to be consistent with Exercise 2.
The following command will run the program with a 2x2 s.p.d. matrix A and 2-dim vector b using our self-implemented conjugate gradient method for solving the LSE Ax=b:
python3 main_minimize.py -A 3 0 0 4 -b 4 5 -x0 12 12 -plot True -method CG-ours
NB: Note that A must be s.p.d. in order for the conjugate gradient method to correctly solve Ax=b. Thus, the matrix A in Exercise 1 should not be used to compare the Scipy version (CG-scipy) againts our version (CG-ours). In the output of Exercise 1, you will see that it does not solve the LSE Ax=b (i.e., the residual outputted is high).
NB: Plotting can only be accomplished in 1D (A and b are both scalars) or 2D (A is a 2x2 matrix and b is a 2-dim vector) as it is not possible to plot higher dimensional problems in a way that makes sense.
Homework 2
See the homework2/ folder and the instructions within its own README file.
Homework 3
See the hw3-heat-fft/ folder and the instructions within its own README file.