Skip to content

Commit

Permalink
A better presentation for all. Doxygenized
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-M committed Nov 28, 2014
1 parent 10ec0ca commit 55d114f
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 66 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ INCLUDE_DIRECTORIES( include )

ADD_DEFINITIONS( --std=c++11 )

#add_library(customer SHARED
#include/Customer.hpp
#src/Customer.cpp
#)
add_library(hhmod SHARED
include/HH_Model_class.hpp
src/HH_Model_class.cpp
)

ADD_EXECUTABLE(hh-model src/HH-model )
ADD_EXECUTABLE(hh-model HH-model )

target_link_libraries(hh-model mgl)
target_link_libraries(hh-model mgl hhmod)
4 changes: 3 additions & 1 deletion Doc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
rm -rf doc
doxygen HH-model.cfg
cd doc
cd pdflatex
make
okular refman.pdf &
mupdf refman.pdf
cd ..
4 changes: 2 additions & 2 deletions HH-model.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.

EXTENSION_MAPPING =
EXTENSION_MAPPING = *.cpp *.hpp

# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
# comments according to the Markdown format, which allows for more readable
Expand Down Expand Up @@ -655,7 +655,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.

INPUT =#"README.md" "HH-model.cpp" "include/"
INPUT =README.md HH-model.cpp include/ src/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
Expand Down
32 changes: 8 additions & 24 deletions src/HH-model.cpp → HH-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@

#include "HH_Includes.hpp"

using namespace boost::numeric::odeint;
//using namespace boost::numeric::odeint;

//void hhSolver(int POINTS, double tf, hh_model hhmodel,std::vector<double> y,std::string out_datafile);

// ==========================================================================
// MAIN CODE
Expand All @@ -55,15 +57,11 @@ int main(int argc, char **argv){

std::string out_datafile = basefile + "." + ext;



// ==========================================================================

double h_step; /// h_step This will be the h_step for integrate, will be redefined on line 333
std::vector<double> parametros; /// parametros[8] Here one stores the ODES parameters for solvig, i.e membrane capacitance, conductances and so on

double eps_abs = 1.e-6; /// eps_abs absolute error requested
double eps_rel = 1.e-8; /// eps_rel relative error requested
double t=0.0; /// t Starting time, this variable is a "time buffer"
double tf=25.0; /// tf 25 ms for time integration

Expand Down Expand Up @@ -213,30 +211,16 @@ int main(int argc, char **argv){
// ==========================================================================
// ==========================================================================

std::vector<std::vector<double>> y_vec;
std::vector<double> times;

std::ofstream hh_data(out_datafile.c_str());

hh_model hhmodel(parametros);

h_step=tf/POINTS;

size_t steps= integrate(hhmodel,y,0.0,tf,h_step,push_back_state_and_time( y_vec , times ));

/* output */
for( size_t i=0; i<=steps; i++ )
{
//std::cout << times[i] << '\t' << y_vec[i][0] << std::endl;
hh_data << times[i] << '\t' << y_vec[i][0] << std::endl;
}

hh_data.close();

hhSolver(POINTS, tf, hhmodel, y, out_datafile);

if(gengraphs!='n')
{
mglDrawFunction(parametros,POINTS,out_datafile);
}

exit(0);
} //End of Main Code
}//End of Main Code


50 changes: 27 additions & 23 deletions include/HH_Model_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@
//\file HH_Model_ODES.hpp
/*!
* \brief Defines the ODE system proposed by Hodgking and Huxley as a class
*
* The default constructor receives a std::vector<double> that contains the parameters of the model in the order
* * Membrane capacitance
* * Induced current on axon, 0 means no external current
* * Na conductances
* * Na Nernst Potential
* * K Conductance
* * K Nernst Potential
* * Leakage conductance (Due to a Cl current)
* * Leakage Nernst potential (Due to a Cl current)
*
* So parameter[0] contains membrane capacitance and so on
*/

/*!
* \param t Time instant
* \param y[] This array stores the solution of the previous iterarion
* \param f[] This array stores the result of the actual iteration (the derivatives)
* \param *params The array that stores the ODE constants, that is, the model parameters
*
* \return Must always return GSL_SUCCESS
*
*/

class hh_model
{
private:
Expand All @@ -65,21 +67,23 @@ class hh_model
}
};

void hhSolver(int POINTS, double tf, hh_model hhmodel,std::vector<double> y,std::string out_datafile);

//[ integrate_observer

struct push_back_state_and_time
{
std::vector< std::vector<double> >& m_states;
std::vector< double >& m_times;
////[ integrate_observer

push_back_state_and_time( std::vector< std::vector<double> > &states , std::vector< double > &times )
: m_states( states ) , m_times( times ) { }
//struct push_back_state_and_time
//{
//std::vector< std::vector<double> >& m_states;
//std::vector< double >& m_times;

void operator()( const std::vector<double> &x , double t )
{
m_states.push_back( x );
m_times.push_back( t );
}
};
//push_back_state_and_time( std::vector< std::vector<double> > &states , std::vector< double > &times )
//: m_states( states ) , m_times( times ) { }

//void operator()( const std::vector<double> &x , double t )
//{
//m_states.push_back( x );
//m_times.push_back( t );
//}
//};
//]
4 changes: 1 addition & 3 deletions include/getInfoFromFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
//\file getInfoFromFile.hpp
/*!
* \brief Reads datafile and stores the data into _double_ array
*/

/*! \param filename The name of the file to be readed
* \param filename The name of the file to be readed
* \param buffer[] The target array where the data will be stored
*
*/
Expand Down
9 changes: 2 additions & 7 deletions include/mglGraphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@
/ ==========================================================================
/ ==========================================================================*/
//\file mglGraphicsZB.hpp
/*!
* \brief Here is were the data plotting it's done.
*/

/*!
* \brief MathGL implementation to generate PNG graphics
*
* \param *k stores numerical values of the used parameters on the HH-model
* \param parametros stores numerical values of the used parameters on the HH-model
* \param POINT is the number of points used to generate the plots. Used only to put information on the key
* \param sFile stores the sFile to name the PNG output
* \param ext stores the extension to search the input datafiles
*
* So this class searches for files named _sFile.ext_ and then creates a _sFile-mgl.png_ file for each
* MathGL implementation to crete PNG file of the HH Action Potential on the given time
*
*/

Expand Down
102 changes: 102 additions & 0 deletions src/HH_Model_class.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
FILE NAME: HH_Model_class.hpp
DESCRIPTION: Part of Hodgking-Huxley model, used in HH-model.cpp
AUTHOR: Daniel Mejia Raigosa
E-MAIL: danielmejia55@gmail.com
GITHUB: http://github.com/Daniel-M/Hodgking-Huxley
DATE: 17 November 2014
VERSION: 1.0
LICENSE
This file is part of "Hodgking-Huxley".
"HH_Model_ODES.hpp" is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
"HH_Model_ODES.hpp" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with "HH_Model_ODES.hpp". If not, see <http://www.gnu.org/licenses/>.
*/

/* ==========================================================================
/ Defining the ODE system for the Hodgking Huxley Model
/ ==========================================================================*/
//\file HH_Model_ODES.hpp

#include "HH_Includes.hpp"

using namespace boost::numeric::odeint;

/*! \brief Structure that estores each set of points during the integration step.
*
* This structre stores the time value and the variable set in one file, this is
* the libboost odeint observer so the vectors x and t contain each time step value for time,
* voltaje, and gating probabilities h, m, and n.
*
* */

struct push_back_state_and_time
{
std::vector< std::vector<double> >& m_states;
std::vector< double >& m_times;

push_back_state_and_time( std::vector< std::vector<double> > &states , std::vector< double > &times )
: m_states( states ) , m_times( times ) { }

void operator()( const std::vector<double> &x , double t )
{
m_states.push_back( x );
m_times.push_back( t );
}
};

/*! \brief The ODE Solver for the HH Model
*
* This function performs the numerical solition of the hh_model object taking the values stored on y
* and placing them on the file out_datafile
* \param POINTS Number of points desired to make the numerical integral.
* \param tf Final time (in ms) of the integration.
* \param hhmodel hh_model object that contains the ODES and gating functions.
* \param y a vector that stores the solution (and initial conditions)
* \param out_datafile The filename where the solution is going to be placed
void hhSolver(int POINTS, double tf, hh_model hhmodel,std::vector<double> y,std::string out_datafile)
{
std::vector<std::vector<double>> y_vec;
std::vector<double> times;
std::ofstream hh_action_potential(out_datafile.c_str());
std::ofstream hh_data((out_datafile+"-all").c_str());
//hh_model hhmodel(parametros);
double h_step=tf/POINTS;
size_t steps = integrate(hhmodel,y,0.0,tf,h_step,push_back_state_and_time( y_vec , times ));
/* output */
for( size_t i=0; i<=steps; i++ )
{
//std::cout << times[i] << '\t' << y_vec[i][0] << std::endl;
hh_action_potential << times[i] << '\t' << y_vec[i][0] << std::endl;

hh_data << times[i] << "\t";

for(int j=0;j<4;j++)
{
hh_data << y_vec[i][j] << "\t";
}

hh_data << std::endl;
}
}

0 comments on commit 55d114f

Please sign in to comment.