Skip to content

Commit

Permalink
adding report
Browse files Browse the repository at this point in the history
  • Loading branch information
filippocasari committed Jun 21, 2023
1 parent 2f3bb23 commit 3d1b53b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Binary file added AS4ParticleMethodsReport.pdf
Binary file not shown.
30 changes: 22 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@
#include <omp.h>
#include <map>
#include <random>
#include <csignal>
#define ITER_PLOT 5
using namespace std;
namespace plt = matplotlibcpp;
bool interrupted = false;
bool Exit = false;

void handleInterrupt(int signal) {
std::cout << "Interrupt signal received. Exiting loop..." << std::endl;
interrupted = true;
}
void handleTermination(int signal) {
std::cout << "Termination signal received. Exiting..." << std::endl;
Exit = true;
}

double compute_init_kinetic_energy(const std::vector<Particle> &particles) {
double kinetic_energy = 0.0;
Expand All @@ -34,6 +45,12 @@ struct PairHash {
};

int main(int argc, char *argv[]) {
if(argv[1] == nullptr){
cerr<<"Not enough arguments"<<endl;
return -1;
}
std::signal(SIGINT, handleInterrupt);
std::signal(SIGTERM, handleTermination);
//plt::detail::_interpreter::kill();
int test =2; // 0 = no walls, just fluid, 1 = walls & chain molecules, 2 = fixed walls & ring molecules
assert(test<3 && test>=0);
Expand Down Expand Up @@ -147,10 +164,7 @@ int main(int argc, char *argv[]) {
}

}
if(argv[1] == nullptr){
cerr<<"Not enough arguments"<<endl;
return -1;
}


printf("Assignment 4\n");
cout << "Arguments to pass: dt" << endl;
Expand Down Expand Up @@ -343,16 +357,16 @@ int main(int argc, char *argv[]) {
cout<<"xi_map size: "<< xi_map.size()<<endl;
//plt::clf();
plt::figure();
//plt::backend("TkAgg");
plt::backend("TkAgg");
plt::ion();

plt::figure_size(800, 750);
plt::title("Particle Methods with dt = "+to_string(dt)+" , T = "+to_string(T));



while (iter < 20000) {
//cout<<"starting the loop"<<endl;
while (iter < 10000 && !interrupted && !Exit) {

iter++;


Expand Down Expand Up @@ -618,7 +632,7 @@ int main(int argc, char *argv[]) {

cout <<endl<<"Execution time: " << (double)duration.count() / 1000000.0 << " seconds" << endl;

plt::detail::_interpreter::kill();


cout << "AS4 completed" << endl;
return 0;
Expand Down

0 comments on commit 3d1b53b

Please sign in to comment.