MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SteadyStateBoost.cpp File Reference
#include "header.h"
#include "global.h"
#include "SparseMatrix.h"
#include "KinSparseMatrix.h"
#include "RateTerm.h"
#include "FuncTerm.h"
#include "VoxelPoolsBase.h"
#include "../mesh/VoxelJunction.h"
#include "XferInfo.h"
#include "ZombiePoolInterface.h"
#include "Stoich.h"
#include "../randnum/RNG.h"
#include "NonlinearSystem.h"
#include "boost/numeric/bindings/lapack/lapack.hpp"
#include "boost/numeric/bindings/lapack/geev.hpp"
#include "OdeSystem.h"
#include "VoxelPools.h"
#include "SteadyStateBoost.h"
+ Include dependency graph for SteadyStateBoost.cpp:

Go to the source code of this file.

Classes

struct  reac_info
 

Functions

static bool checkAboveZero (const vector< double > &y)
 
void eliminateRowsBelow (ublas::matrix< double > &U, int start, int leftCol)
 
static bool isSolutionValid (const vector< double > &x)
 
unsigned int rankUsingBoost (ublas::matrix< double > &U)
 
void recalcTotal (vector< double > &tot, ublas::matrix< double > &g, const double *S)
 Utility funtion to doing scans for steady states. More...
 
int reorderRows (ublas::matrix< double > &U, int start, int leftCol)
 
void ss_func (const vector_type &x, void *params, vector_type &f)
 
void swapRows (ublas::matrix< double > &mat, unsigned int r1, unsigned int r2)
 Swap row r1 and r2. More...
 

Variables

static const CinfosteadyStateCinfo = SteadyState::initCinfo()
 

Function Documentation

static bool checkAboveZero ( const vector< double > &  y)
static

Definition at line 934 of file SteadyStateBoost.cpp.

Referenced by SteadyState::randomizeInitialCondition().

935 {
936  for ( vector< double >::const_iterator
937  i = y.begin(); i != y.end(); ++i )
938  {
939  if ( *i < 0.0 )
940  return false;
941  }
942  return true;
943 }

+ Here is the caller graph for this function:

void eliminateRowsBelow ( ublas::matrix< double > &  U,
int  start,
int  leftCol 
)

Definition at line 890 of file SteadyStateBoost.cpp.

References SteadyState::EPSILON.

Referenced by rankUsingBoost().

891 {
892  int numMols = U.size1();
893  double pivot = U( start, leftCol );
894  assert( fabs( pivot ) > SteadyState::EPSILON );
895  for ( int i = start + 1; i < numMols; ++i )
896  {
897  double factor = U(i, leftCol);
898  if( fabs ( factor ) > SteadyState::EPSILON )
899  {
900  factor = factor / pivot;
901  for ( size_t j = leftCol + 1; j < U.size2(); ++j )
902  {
903  double x = U(i,j);
904  double y = U( start, j );
905  x -= y * factor;
906  if ( fabs( x ) < SteadyState::EPSILON )
907  x = 0.0;
908  U( i, j ) = x;
909  }
910  }
911  U(i, leftCol) = 0.0;
912  }
913 }
static const double EPSILON

+ Here is the caller graph for this function:

static bool isSolutionValid ( const vector< double > &  x)
static

Definition at line 712 of file SteadyStateBoost.cpp.

Referenced by SteadyState::settle().

713 {
714  for( size_t i = 0; i < x.size(); i++ )
715  {
716  double v = x[i];
717  if ( std::isnan( v ) or std::isinf( v ) )
718  {
719  cout << "Warning: SteadyState iteration gave nan/inf concs\n";
720  return false;
721  }
722  else if( v < 0.0 )
723  {
724  cout << "Warning: SteadyState iteration gave negative concs\n";
725  return false;
726  }
727  }
728  return true;
729 }

+ Here is the caller graph for this function:

unsigned int rankUsingBoost ( ublas::matrix< double > &  U)

Definition at line 915 of file SteadyStateBoost.cpp.

References eliminateRowsBelow(), and reorderRows().

Referenced by SteadyState::randomizeInitialCondition(), and SteadyState::setupSSmatrix().

916 {
917  int numMols = U.size1();
918  int numReacs = U.size2() - numMols;
919  int i;
920  // Start out with a nonzero entry at 0,0
921  int leftCol = reorderRows( U, 0, 0 );
922 
923  for ( i = 0; i < numMols - 1; ++i )
924  {
925  eliminateRowsBelow( U, i, leftCol );
926  leftCol = reorderRows( U, i + 1, leftCol );
927  if ( leftCol == numReacs )
928  break;
929  }
930  return i + 1;
931 }
void eliminateRowsBelow(ublas::matrix< double > &U, int start, int leftCol)
int reorderRows(ublas::matrix< double > &U, int start, int leftCol)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void recalcTotal ( vector< double > &  tot,
ublas::matrix< double > &  g,
const double *  S 
)

Utility funtion to doing scans for steady states.

Parameters
tot
g
S

Definition at line 952 of file SteadyStateBoost.cpp.

Referenced by SteadyState::randomizeInitialCondition().

953 {
954  assert( g.size1() == tot.size() );
955  for ( size_t i = 0; i < g.size1(); ++i )
956  {
957  double t = 0.0;
958  for ( unsigned int j = 0; j < g.size2(); ++j )
959  t += g( i, j ) * S[j];
960  tot[ i ] = t;
961  }
962 }

+ Here is the caller graph for this function:

int reorderRows ( ublas::matrix< double > &  U,
int  start,
int  leftCol 
)

Definition at line 863 of file SteadyStateBoost.cpp.

References SteadyState::EPSILON, and swapRows().

Referenced by rankUsingBoost().

864 {
865  int leftMostRow = start;
866  int numReacs = U.size2() - U.size1();
867  int newLeftCol = numReacs;
868  for ( size_t i = start; i < U.size1(); ++i )
869  {
870  for ( int j = leftCol; j < numReacs; ++j )
871  {
872  if ( fabs( U(i,j )) > SteadyState::EPSILON )
873  {
874  if ( j < newLeftCol )
875  {
876  newLeftCol = j;
877  leftMostRow = i;
878  }
879  break;
880  }
881  }
882  }
883 
884  if ( leftMostRow != start ) // swap them.
885  swapRows( U, start, leftMostRow );
886 
887  return newLeftCol;
888 }
static const double EPSILON
void swapRows(ublas::matrix< double > &mat, unsigned int r1, unsigned int r2)
Swap row r1 and r2.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ss_func ( const vector_type x,
void *  params,
vector_type f 
)
void swapRows ( ublas::matrix< double > &  mat,
unsigned int  r1,
unsigned int  r2 
)

Swap row r1 and r2.

Parameters
matMatrix input
r1index of row 1
r2index of row 2

Definition at line 849 of file SteadyStateBoost.cpp.

Referenced by reorderRows().

850 {
851  ublas::vector<value_type> temp( mat.size2() );
852  for (size_t i = 0; i < mat.size2(); i++)
853  {
854  temp[i] = mat(r1, i );
855  mat(r1, i ) = mat(r2, i );
856  }
857 
858  for (size_t i = 0; i < mat.size2(); i++)
859  mat(r2, i) = temp[i];
860 }

+ Here is the caller graph for this function:

Variable Documentation

const Cinfo* steadyStateCinfo = SteadyState::initCinfo()
static

Definition at line 316 of file SteadyStateBoost.cpp.

Referenced by SteadyState::initCinfo().