-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
136 lines (114 loc) · 5.08 KB
/
main.cpp
File metadata and controls
136 lines (114 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include <iostream>
#include <vector>
#include <omp.h>
#include <Eigen/Dense>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include "nucleation.hpp"
#include "potential.hpp"
#include "transfer_matrix.hpp"
void CleanOutputData(std::string dir){
boost::filesystem::path data_dir(dir);
if(boost::filesystem::exists(data_dir)){
std::cout << "--> Clearing old " << dir << " data..." << std::endl;
boost::filesystem::remove_all(data_dir);
}
boost::filesystem::create_directory(data_dir);
std::cout << "--> Complete." << std::endl;
}
int main(int argc, char* argv[])
{
Nucleation *parameters;
try{
boost::program_options::options_description desc("Nucleation required parameters");
desc.add_options()
("N", boost::program_options::value<int>()->required(), "Length of the biomolecule (nodes)")
("L", boost::program_options::value<double>()->required(), "Length of dimensionless space eta")
("m", boost::program_options::value<int>()->required(), "Number of discrete intervals across eta")
("kappa", boost::program_options::value<double>()->required(), "Backbone spring constant")
("sigma", boost::program_options::value<double>()->required(), "Base-pair spring constant")
("etab", boost::program_options::value<double>()->required(), "Set eta_b limit")
("umin", boost::program_options::value<int>()->required(), "Minimum extension value")
("umax", boost::program_options::value<int>()->required(), "Maximum extension value")
;
boost::program_options::variables_map vm;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc),vm);
// Test whether any arguments have been passed, print help otherwise
if(vm.empty()==true){
std::cout << desc << std::endl;
return 0;
}
// Test all required parameters have been passed on the cmd line, throws exception if not
boost::program_options::notify(vm);
// Create object containing the nucleation parameters from cmdline (through BOOST vm)
parameters = new Nucleation(vm["N"].as<int>(),
vm["L"].as<double>(),
vm["m"].as<int>(),
vm["kappa"].as<double>(),
vm["sigma"].as<double>(),
vm["etab"].as<double>(),
vm["umin"].as<int>(),
vm["umax"].as<int>());
}
catch(std::exception& e){
std::cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
std::cerr << "Exception of unknown type!\n";
}
////////////////////////
// Setup Calculations //
////////////////////////
// Clear old data
std::cout << "--> Results directory: " << parameters->results_dir << std::endl;
CleanOutputData(parameters->results_dir);
std::cout << "--> Log directory: " << parameters->log_dir << std::endl;
CleanOutputData(parameters->log_dir);
std::cout << "--> Eigensystem directory: " << parameters->eigen_dir << std::endl;
CleanOutputData(parameters->eigen_dir);
// Detects number of processing cores available
const int num_processors = omp_get_max_threads();
std::cout << std::endl << "*** Number of parallel processing threads (" << num_processors << ")" << std::endl << std::endl;
// Sets number of threads for parallel programming
omp_set_num_threads(num_processors);
///////////////////////////////////
// Initialize Nucleation Objects //
///////////////////////////////////
std::cout << "--> Initialising pair potential..." << std::endl;
HarmonicPotential pair_potential(*parameters);
pair_potential.OutputPotentialData();
std::cout << "--> Complete." << std::endl << std::endl;
std::cout << "--> Initialising transfer matrix functions..." << std::endl;
TransferMatrixFunctions functions(pair_potential);
std::cout << "--> Complete." << std::endl << std::endl;
std::cout << "--> Initialising T, T00, T11 transfer matrices, calculating eigenvalues and eigenvectors..." << std::endl;
T t_matrix(pair_potential);
T00 t00_matrix(pair_potential);
T11 t11_matrix(pair_potential);
#pragma omp parallel sections
{
#pragma omp section
{
t_matrix.ComputeEigensystem();
std::cout << "--> Transfer Matrix " << t_matrix.Label() << " Complete." << std::endl;
}
#pragma omp section
{
t00_matrix.ComputeEigensystem();
std::cout << "--> Transfer Matrix " << t00_matrix.Label() << " Complete." << std::endl;
}
#pragma omp section
{
t11_matrix.ComputeEigensystem();
std::cout << "--> Transfer Matrix " << t11_matrix.Label() << " Complete." << std::endl;
}
}
const int smax = t_matrix.OrderEigenSystemMax();
const int tmax = t00_matrix.OrderEigenSystemMax();
const int vmax = t11_matrix.OrderEigenSystemMax();
std::cout << std::endl << "--> MAX EVAL (T Matrix)\t\t: " << smax << std::endl;
std::cout << "--> MAX EVAL (T00 Matrix)\t: " << tmax << std::endl;
std::cout << "--> MAX EVAL (T11 Matrix)\t: " << vmax << std::endl << std::endl;
return 0;
}