From d1f6d69b252fdf979e0cfde9ce783b31965f4376 Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Wed, 27 Feb 2019 17:11:22 +0100 Subject: [PATCH 1/2] Install on debian/ubuntu instructions --- .gitignore | 9 +++++++++ README.md | 10 ++++++++++ install_deb.sh | 6 ++++++ requirements.txt | 10 ++++++++++ 4 files changed, 35 insertions(+) create mode 100644 .gitignore create mode 100644 install_deb.sh create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96f1c0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.idea +venv +src/CFES +src/final.png +src/log.txt +src/main.o +src/matrix.txt +src/output.txt +src/schematic.png \ No newline at end of file diff --git a/README.md b/README.md index 088bcc3..3b08f0c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,16 @@ # CFES - Classical Field Equation Solver ###### Theoretical Physics Group Programming Project +## Install on Debian/Ubuntu based Linux + +Run `instal_deb.sh` then: + +```bash +cd src +./CFES +``` + +## Run Please follow the instructions below first. diff --git a/install_deb.sh b/install_deb.sh new file mode 100644 index 0000000..ac4ac53 --- /dev/null +++ b/install_deb.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +sudo apt install build-essential libgsl-dev libgtk-3-dev python-tk python-virtualenv python-pip +make -C src/ +virtualenv venv +source venv/bin/activate +pip install -r requirements.txt \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e747ce9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +backports.functools-lru-cache==1.5 +cycler==0.10.0 +kiwisolver==1.0.1 +matplotlib==2.2.3 +numpy==1.16.2 +pyparsing==2.3.1 +python-dateutil==2.8.0 +pytz==2018.9 +six==1.12.0 +subprocess32==3.5.3 \ No newline at end of file From 7df7ba2938b250f112f7306524146942b49e58d9 Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Wed, 27 Feb 2019 23:35:17 +0100 Subject: [PATCH 2/2] set the matrix to be fixed from file so that just a button can be pressed --- src/combined.c | 27 +++++++++++++++++++-------- src/window_main.glade | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/combined.c b/src/combined.c index b3bf1e2..33906c4 100644 --- a/src/combined.c +++ b/src/combined.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include int type; int dimension; @@ -234,7 +236,7 @@ system("python plot_schematic.py > /dev/null"); void on_btn_matrix_clicked(GtkButton *button, app_widgets *app_wdgts) { //stores integer read from spin button widget - dimension = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(app_wdgts->w_sbtn_quantity)); + num_iterations = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(app_wdgts->w_sbtn_iterations)); //outputs dimension and initialises matrix elements @@ -245,29 +247,31 @@ void on_btn_matrix_clicked(GtkButton *button, app_widgets *app_wdgts) { } } f=fopen("log.txt","w"); -} -void on_btn_generate_clicked (GtkButton *button, app_widgets *app_wdgts) { - FILE *fp; fp = fopen("matrix.txt","w"); - f = fopen("log.txt","a"); - for (int i=0; i < dimension; i++) { for (int j=0; j < dimension; j++) { if (matrix[i][j] == 0.000001) { - fprintf(fp, "0.000001 "); + fprintf(fp, "0.000001 "); } else { fprintf(fp, "%f ", matrix[i][j]); } } } fclose(fp); +} + +void on_btn_generate_clicked (GtkButton *button, app_widgets *app_wdgts) { + f = fopen("log.txt","a"); + printf("Matrix successfully outputted to matrix.txt!\n"); fprintf(f,"Matrix successfully outputted to matrix.txt!\n"); fclose(f); printf("Passing Matrix to calculation handler\n"); + dimension = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(app_wdgts->w_sbtn_quantity)); + num_iterations = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(app_wdgts->w_sbtn_iterations)); calc_handle(dimension, num_iterations);// Take tolerance from a button soon gtk_main_quit(); } @@ -289,10 +293,17 @@ int calc_handle(int dimension, int num_iterations){ // Passes the matrix system (Ax=b) to the solver //solve(dimension, b, boundaryflag); //sparse_solve(dimension,b , boundaryflag, 2); + + clock_t start = clock(); jacobi(dimension,b ,boundaryflag, num_iterations); + clock_t end = clock(); + float seconds = (float)(end - start) / CLOCKS_PER_SEC; + printf("It took %.6f seconds\n", seconds); - system("python Plotter.py > /dev/null"); + // avoids race condition with the system call below - i.e. prints before calling python exec + sleep(0.1); + system("python Plotter.py > /dev/null"); exit(0); diff --git a/src/window_main.glade b/src/window_main.glade index 54204f0..05d742b 100644 --- a/src/window_main.glade +++ b/src/window_main.glade @@ -151,7 +151,7 @@ Please follow the instructions below first. 1 n_adjustment True - 1 + 101 False