Permalink
Newer
Older
100644 85 lines (76 sloc) 3.64 KB
Apr 24, 2014 @miscco Cleanup. Made comments line save
1 /*
Nov 9, 2015 @miscco Updated the code with correct license.
2 * Copyright (c) 2015 University of Lübeck
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 *
22 * AUTHORS: Michael Schellenberger Costa: mschellenbergercosta@gmail.com
23 *
24 * Based on: A thalamocortical neural mass model of the EEG during NREM sleep and its response
25 * to auditory stimulation.
26 * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
27 * JC Claussen.
Sep 13, 2016 @miscco Major cleanup and moderinization
28 * PLoS Computational Biology http://dx.doi.org/10.1371/journal.pcbi.1005022
Nov 9, 2015 @miscco Updated the code with correct license.
29 */
Apr 24, 2014 @miscco Cleanup. Made comments line save
30
Sep 13, 2016 @miscco Major cleanup and moderinization
31 /******************************************************************************/
32 /* Main file for compilation and runtime tests */
33 /******************************************************************************/
Nov 9, 2015 @miscco Updated the code with correct license.
34 #include <iostream>
Sep 13, 2016 @miscco Major cleanup and moderinization
35 #include <chrono>
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
36
Sep 13, 2016 @miscco Major cleanup and moderinization
37 #include "Cortical_Column.h"
38 #include "ODE.h"
39 #include "Thalamic_Column.h"
Nov 9, 2015 @miscco Updated the code with correct license.
40
Sep 13, 2016 @miscco Major cleanup and moderinization
41 /******************************************************************************/
42 /* Fixed simulation settings */
43 /******************************************************************************/
44 typedef std::chrono::high_resolution_clock::time_point timer;
45 extern const int T = 30; /* Time until data is stored in s */
46 extern const int res = 1E4; /* Number of iteration steps per s */
47 extern const double dt = 1E3/res; /* Duration of a time step in ms */
48 extern const double h = sqrt(dt); /* Square root of dt for SRK iteration */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
49
Sep 13, 2016 @miscco Major cleanup and moderinization
50 /******************************************************************************/
51 /* Main simulation routine */
52 /******************************************************************************/
Nov 9, 2015 @miscco Updated the code with correct license.
53 int main(void) {
Sep 13, 2016 @miscco Major cleanup and moderinization
54 /* Initializing the populations */
55 std::vector<double> param = {6, 1.33, 1E-3};
56 std::vector<double> con = {2, 10};
57 Cortical_Column Cortex(param.data(), con.data());
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
58
Sep 13, 2016 @miscco Major cleanup and moderinization
59 param = {0.2, 0.06};
60 con = {2, 10};
61 Thalamic_Column Thalamus (param.data(), con.data());
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
62
Sep 13, 2016 @miscco Major cleanup and moderinization
63 /* Connect both modules */
64 Cortex.get_Thalamus(Thalamus);
65 Thalamus.get_Cortex(Cortex);
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
66
Sep 13, 2016 @miscco Major cleanup and moderinization
67 /* Take the time of the simulation */
68 time_t start,end;
69 time (&start);
70 /* Simulation */
71 for (unsigned t=0; t< T*res; ++t) {
72 ODE(Cortex, Thalamus);
73 }
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
74
Sep 13, 2016 @miscco Major cleanup and moderinization
75 time (&end);
76 /* Time consumed by the simulation */
77 double dif = difftime(end,start);
78 std::cout << "simulation done!\n";
79 std::cout << "took " << dif << " seconds" << "\n";
80 std::cout << "end\n";
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
81 }
82 /****************************************************************************************************/
83 /* end */
84 /****************************************************************************************************/