class: titlepage .title[Introduction to Scientific Programming - TP :notebook:] .subtitle[`IPS-DEV-TP` - N. Dubray - ENSIIE - 2017] .row[ `$$\int_{-\infty}^\infty f(x)e^{-x^2} dx \simeq \sum_{i=0}^{n-1}w_if(x_i)$$` ] .footnote[ [:book:](../toc/index.html) ] --- layout: true class: animated fadeIn numbers .footnote[ `IPS-DEV-TP` - N. Dubray - ENSIIE - 2017 - [:book:](../toc/index.html) ] --- # Project rules .mermaid[ graph LR A("Week #1
Initialization") --> B B("Week #2
Project") --> C C("Week #3
Project") --> D D("Week #4
Project") --> E E("Week #5
Project") --> F("Week #6
Presentation") ] .column.middle.grow[ ## Rules: * a "`AUTHORS`" file **must** be present and contain your name(s) * the source **must** be written in `C++11` (and optionally `Python2`) * the source **must** be documented with `Doxygen` * the compilation chain **must** use `GNU Make` * the presentation **must** be at the location "`pres/index.html`" * using branches is OK but **only master will be checked** * some `Python2` bindings can be used, but are **not mandatory** * the presentation **must** use `remark.js` ## :moneybag: Bonuses: * no warning at {compilation, bindings, tests, doc} * project is implementing other methods * source code is well written (comments, easy to read, etc...) * commits are small and explicit * unit tests pass ] --- # IPS-DEV-TP - Week #1 - Initialization .mermaid[ graph LR A("Week #1
Initialization") --> B B("Week #2
Project") --> C C("Week #3
Project") --> D D("Week #4
Project") --> E E("Week #5
Project") --> F("Week #6
Presentation") style A fill:#090 ] .column.middle.grow[ ## Start your project from scratch * create a **bare `git` project** on the remote server * clone this project locally * structure the project * create the file tree * prepare the compilation chain * prepare the documentation generation * prepare the unit tests :arrow_right: write a dummy program which only parses the CLI flags. .hcenter[:warning: Do not forget to push your commits ! :warning:] ] --- # IPS-DEV-TP - Weeks #2-#5 - Project description .mermaid[ graph LR A("Week #1
Initialization") --> B B("Week #2
Project") --> C C("Week #3
Project") --> D D("Week #4
Project") --> E E("Week #5
Project") --> F("Week #6
Presentation") style B fill:#090 style C fill:#090 style D fill:#090 style E fill:#090 ] .column.middle.grow[ ## Summary During this 6-week long project, solutions to the **1D quantum harmonic oscillator** will be calculated and some of their properties will be checked. ## Quantum Harmonic Oscillator Schrödinger equation: `$$\hat{H}_{(z)}\psi_n(z) = E_n\psi_n(z)$$` with the 1D-Hamiltonian and 1D-momentum operator defined as `$$\hat{H}_{(z)}\equiv \frac{\hat{p}_{(z)}^2}{2m} + \frac{1}{2}m\omega^2\hat{z}^2, \hspace{5mm}\hat{p}_{(z)}\equiv -i\hbar\frac{\partial}{\partial z}.$$` ] --- # Quantum Harmonic Oscillator .mermaid[ graph LR A("Week #1
Initialization") --> B B("Week #2
Project") --> C C("Week #3
Project") --> D D("Week #4
Project") --> E E("Week #5
Project") --> F("Week #6
Presentation") style B fill:#090 style C fill:#090 style D fill:#090 style E fill:#090 ] .column.middle.grow[ ## Resulting 1D-HO Schrödinger equation `$$\left(\frac{\hat{p}_{(z)}^2}{2m} + \frac{1}{2}m\omega^2\hat{z}^2\right)\psi_n = E_n\psi_n.$$` ## Solutions: The analytic solutions take the form `$$\psi_n(z) = \frac{1}{\sqrt{2^n n!}}\left(\frac{m\omega}{\pi\hbar}\right)^{1/4}e^{-\frac{m\omega z^2}{2\hbar}}H_n\left(\sqrt{\frac{m\omega}{\hbar}} . z\right).$$` ## Orthonormality One has `$$\forall (m,n), \int \psi^*_m(z)\psi_n(z) dz = \delta_{mn}.$$` ] --- # Hermite polynomials .mermaid[ graph LR A("Week #1
Initialization") --> B B("Week #2
Project") --> C C("Week #3
Project") --> D D("Week #4
Project") --> E E("Week #5
Project") --> F("Week #6
Presentation") style B fill:#090 style C fill:#090 style D fill:#090 style E fill:#090 ] .column.middle.grow[ ## Definition (physicists' version) `$$\forall n\ge 0, H_n(z)\equiv (-1)^n e^{z^2} \frac{d^n}{dz^n}\left( e^{-z^2} \right).$$` ## Recurrence relation One has `$$H_0(z) = 1$$` `$$H_1(z) = 2z$$` `$$\forall n\ge 1, H_{n+1}(z) = 2zH_n(z)-2nH_{n-1}(z).$$` ] --- # Project instructions .mermaid[ graph LR A("Week #1
Initialization") --> B B("Week #2
Project") --> C C("Week #3
Project") --> D D("Week #4
Project") --> E E("Week #5
Project") --> F("Week #6
Presentation") style B fill:#090 style C fill:#090 style D fill:#090 style E fill:#090 ] .column.middle.grow[ ## Work to be done * implement the calculation of the 1D-HO solutions (along the `\(z\)`-axis, using the recurrence relation) * evaluate and plot the first 1D-HO solutions (using `xmgrace`, `matplotlib`...) * numerically check the energy `\(E_n\)` of the 1D-HO solutions (**estimate the derivatives**) * numerically check the orthonormality of the 1D-HO solutions (**use a quadrature**) * present your results using the [remark.js template](../template_ensiie/index.html) ## :moneybag: Bonus: do the same (calculation [+ plots] [+ checks]) for * the 2D-HO solutions (polar coordinates) * the 3D-HO solutions (spherical coordinates) ] --- # Week #6 - Presentation .mermaid[ graph LR A("Week #1
Initialization") --> B B("Week #2
Project") --> C C("Week #3
Project") --> D D("Week #4
Project") --> E E("Week #5
Project") --> F("Week #6
Presentation") style F fill:#090 ] .column.middle.grow[ ## Presentation format * length: ~10min * questions: ~10min * the presentation **must use** the [remark.js template](../template_ensiie/index.html) ## Presentation content * the structure of the project (choice of classes, files hierarchy, etc...) * the compilation chain (content of the Makefile) * the generated documentation * some code samples * some unit tests * the git history, and some commit messages * **the calculation results** ] --- class: middle # Presentations - 1st part .hcenter[ | Presentation time | Students | Gitlab account | | :---------------: | :----------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | | 9:00 | Younès **Benallal** Thomas **Dilasser** | [younes.benallal](http://pedago-etu.ensiie.fr/younes.benallal/IPS) | | 9:25 | Eléna **Bouchaud** Hanna **Ben Jedidia** | [elena.bouchaud-bougouin](http://pedago-etu.ensiie.fr/elena.bouchaud-bougouin/Bouchaud_BenJedidia_IPS.git) | | 9:50 | Yufei **Wang** Fatma **Bali** | [yufei.wang](http://pedago-etu.ensiie.fr/yufei.wang/IPS.git) | | 10:15 | Alexis **Puddu** Domitille **Ailleret** | [domitille.ailleret](http://pedago-etu.ensiie.fr/domitille.ailleret/IPS) | | 10:40 | Dinghao **Li** Tingting **Wang** | [tingting.wang](http://pedago-etu.ensiie.fr/tingting.wang/) | ] --- class: middle # Presentations - 2nd part .hcenter[ | Presentation time | Students | Gitlab account | | :---------------: | :----------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | | 11:05 | Aymeric **Marboeuf** Pierre **Prevelle** | [pierre.prevelle](http://pedago-etu.ensiie.fr/pierre.prevelle/idv) | | 11:30 | Louis **Melchior** Tàzio **Gennuso** | [tazio.gennuso](http://pedago-etu.ensiie.fr/tazio.gennuso/projetIPS) | | 11:55 | Yael **Halimi** Van man **Nguyen** | [vanman.nguyen](http://pedago-etu.ensiie.fr/vanman.nguyen/Projet_IPS.git) | | 12:20 | Abdourahmane **Afifi** Ruide **Song** | [ruide.song](http://pedago-etu.ensiie.fr/ruide.song/projet-IPS.git) | | 12:45 | Bylel **Trabelsi** Théotime **Donnenfeld** | [bitbucket](https://bitbucket.org/sneakyBite/projetips) | ] --- class: middle # IPS-DEV-TP debriefing 1/3 ## General remarks :+: good team work :+: nice file trees, well organized projects .vspace[] ## Development tools :+: rather good `git` use, may use more **branches** :+: nice recursive `Makefiles` :+: `Doxygen` compiles with some warnings, may use more the **main page**, some LaTeX, etc... :warning: unit tests are perfectible: * some missing or dummy unit tests * some difficulties to test user-defined classes * no need to re-compile the whole project to link the tests :warning: overlooked `astyle` tool --- class: middle # IPS-DEV-TP debriefing 2/3 ## Development :+: Hermite polynomials calculated by recurrence :+: no iteration over armadillo object elements = **good vectorization** :warning: hard to check if the Hermite polynomial values are OK, mandatory plots / unit tests ? :warning: orthonormality of the 1D-HO solutions should be presented as a **matrix** :warning: not ideal numerical calculation of the energy of the 1D-HO solutions, diverging values not disturbing .vspace[] ## Presentation :+: nice presentations in general :warning: may include more plots :warning: physics context not well understood / presented :question: should we keep `remark.js` for the presentations ? --- class: middle class: top # IPS-DEV-TP debriefing 3/3 ## Conclusions :arrow_right: do not get stuck during the TPs, **ask for help** :arrow_right: **anticipate**, no commit frenzy during the last minutes :arrow_right: test your whole project **before the deadline** (compilation, cleanup, documentation, tests, etc...) :arrow_right: test your whole project **before every major commit** (branch merge ?) :arrow_right: **test your slides** and talk length in the real presentation context (projector, slides, etc...) --- class: top # IPS-DEV-TP debriefing 3/3 ## Conclusions :arrow_right: do not get stuck during the TPs, **ask for help** :arrow_right: **anticipate**, no commit frenzy during the last minutes :arrow_right: test your whole project **before the deadline** (compilation, cleanup, documentation, tests, etc...) :arrow_right: test your whole project **before every major commit** (branch merge ?) :arrow_right: **test your slides** and talk length in the real presentation context (projector, slides, etc...) .vspace[] .row[ .column.w48.animated.fadeInLeft[ ## .hcenter[Slides not tested] .shadow[] ] ] --- class: top # IPS-DEV-TP debriefing 3/3 ## Conclusions :arrow_right: do not get stuck during the TPs, **ask for help** :arrow_right: **anticipate**, no commit frenzy during the last minutes :arrow_right: test your whole project **before the deadline** (compilation, cleanup, documentation, tests, etc...) :arrow_right: test your whole project **before every major commit** (branch merge ?) :arrow_right: **test your slides** and talk length in the real presentation context (projector, slides, etc...) .vspace[] .row[ .column.w48[ ## .hcenter[Slides not tested] .shadow[] ] .column.w48.animated.fadeInRight[ ## .hcenter[Slides tested] .shadow[] ] ] --- class: middle # IPS-DEV-TP Evaluation .row[ .hcenter.column.w48[ | Student | Grade | | :------------- | :-----: | | Benallal Y. | 11/20 | | Dilasser T. | 13/20 | | Bouchaud E. | 14.5/20 | | Benjedidia H. | 14.5/20 | | Wang Y. | 13.5/20 | | Bali F. | 13.5/20 | | Puddu A. | 16/20 | | Ailleret D. | 16/20 | | Wang T. | 17/20 | | Li D. | 17/20 | ] .hcenter.column.w48[ | Student | Grade | | :------------- | :-----: | | Marboeuf A. | 13.5/20 | | Prevelle P. | 13.5/20 | | Gennuso T. | 15/20 | | Melchior L. | 15/20 | | Halimi Y. | 19/20 | | Nguyen V. | 19/20 | | Afifi A. | 12.5/20 | | Song R. | 12.5/20 | | Trabelsi B. | 11.5/20 | | Donnenfeld T. | 11.5/20 | ] ] --- class: middle # Unit tests: real example .row[ .column.w48[ ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int _a) : a(_a) { // possible other ways: "a = int(_a);" // or simply "a = _a;" } int MyClass::myFunc(int b) { return a + b; // "a" is the same as "this->a" in C++ } ``` ] .column.w48[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H class MyClass { public: MyClass(int); int myFunc(int); int a; }; #endif // MYCLASS_H ``` ] ] .row[ .column.w48[ ## .hcenter[`main.cpp`] ```C++ #include "myclass.h" #include
int main(int charc, char** argv) { MyClass myClass(2); std::cout << "Result: " << myClass.myFunc(3); std::cout << std::endl; return 0; } ``` ] .column.w48[ ## .hcenter[`test_myclass.h`] ```C++ #include
#include "myclass.h" class TestMyClass : public CxxTest::TestSuite { public: void testMyFunc(void) { MyClass myClass(2); TS_ASSERT_EQUALS(myClass.myFunc(3), 5); } }; ``` ] ] .row[ .column.w48[ ## .hcenter[Build & launch `main`] ```shell *$ g++ -Wall -c myclass.cpp -o myclass.o *$ g++ -Wall -c main.cpp -o main.o *$ g++ main.o myclass.o -o main $ ./main Result: 5 ``` ] .column.w48[ ## .hcenter[Build & launch `tests`] ```shell *$ g++ -Wall -c myclass.cpp -o myclass.o $ cxxtestgen --error-printer -o t.cpp test_myclass.h *$ g++ -Wall -c t.cpp -o t.o *$ g++ t.o myclass.o -o tests $ ./tests Running cxxtest tests (1 test).OK! ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: MyClass(int, int); int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` :arrow_left: * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: * MyClass(int, int); * int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" *MyClass::MyClass(int a, int b) { ... } *int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file :arrow_left: * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
*class MyClass { public: MyClass(int, int); int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` :arrow_left: * no `everything.h` header * use `#define` guards * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: MyClass(int, int); int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ *#include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header :arrow_left: * use `#define` guards * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: MyClass(int, int); int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards :arrow_left: * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ *#ifndef MYCLASS_H *#define MYCLASS_H #include
class MyClass { public: MyClass(int, int); int myFunc(double e = -1.0); }; *#endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards * separate public and private headers :arrow_left: * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: MyClass(int, int); int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards * separate public and private headers * default values belong to `%.h` :arrow_left: * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: MyClass(int, int); * int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) :arrow_left: * **no forward-declarations** (if possible) ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: * MyClass(int, int); * int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ] --- class: middle # `C++` headers: main rules .row[ .column.w55.middle[ ## Rules * same methods in `%.h` and `%.cpp` * one class per `%.h` file * `%.h` **first included file** in `%.cpp` * no `everything.h` header * use `#define` guards * separate public and private headers * default values belong to `%.h` * no argument names in `%.h` (except defaults) * **no forward-declarations** (if possible) :arrow_left: ] .column.w40[ ## .hcenter[`myclass.h`] ```C++ #ifndef MYCLASS_H #define MYCLASS_H #include
class MyClass { public: MyClass(int, int); int myFunc(double e = -1.0); }; #endif // MYCLASS_H ``` ## .hcenter[`myclass.cpp`] ```C++ #include "myclass.h" MyClass::MyClass(int a, int b) { ... } int MyClass::myFunc(double e) { ... } ``` ] ]