COPASI API  4.16.103
CLyapMethod.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/lyap/CLyapMethod.cpp,v $
3 // $Revision: 1.8 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:30:19 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 /**
24  * CLyapMethod class.
25  */
26 
27 #include "copasi.h"
28 #include "CLyapMethod.h"
29 #include "CLyapProblem.h"
30 #include "model/CState.h"
31 #include "model/CCompartment.h"
32 #include "model/CModel.h"
33 
35  std::vector< CCopasiMethod::SubType >()
36 {
37  push_back(CCopasiMethod::lyapWolf);
38 }
39 
41 
42 //******************************************************
43 
44 //static
46 
47 //static
49 {
50  size_t i, imax = CLyapMethod::ValidSubTypes.size();
51 
52  for (i = 0; i < imax; i++)
53  if (CLyapMethod::ValidSubTypes[i] == subType) return true;
54 
55  return false;
56 }
57 
59 {
60  CLyapMethod * pMethod = NULL;
61 
62  switch (subType)
63  {
64  case unset:
65  case lyapWolf:
66  pMethod = new CLyapWolfMethod();
67  break;
68 
69  default:
70  fatalError();
71  }
72 
73  return pMethod;
74 }
75 
76 /**
77  * Default constructor.
78  */
80  const CCopasiContainer * pParent) :
81  CCopasiMethod(CCopasiTask::lyap, subType, pParent),
82  //mpCurrentState(NULL),
83  mpProblem(NULL)
85 
86 /**
87  * Copy constructor.
88  * @param "const CLyapMethod &" src
89  */
91  const CCopasiContainer * pParent):
92  CCopasiMethod(src, pParent),
93  //mpCurrentState(src.mpCurrentState),
94  mpProblem(src.mpProblem)
96 
97 /**
98  * Destructor.
99  */
102 
103 //void CLyapMethod::setCurrentState(CState * currentState)
104 //{
105 // mpCurrentState = currentState;
106 //}
107 
108 /**
109  * Set a pointer to the problem.
110  * This method is used by CLyap
111  * @param "CLyapProblem *" problem
112  */
114 {mpProblem = problem;}
115 
116 /**
117  * This instructs the method to calculate a a time step of deltaT
118  * starting with the current state, i.e., the result of the previous
119  * step.
120  * The new state (after deltaT) is expected in the current state.
121  * The return value is the actual timestep taken.
122  * @param "const double &" deltaT
123  */
124 double CLyapMethod::step(const double & C_UNUSED(deltaT))
125 {return 0;}
126 
127 /**
128  * This instructs the method to calculate a a time step of deltaT
129  * starting with the initialState given.
130  * The new state (after deltaT) is expected in the current state.
131  * The return value is the actual timestep taken.
132  * @param "double &" deltaT
133  * @param "const CState *" initialState
134  * @return "const double &" actualDeltaT
135  */
136 void CLyapMethod::start(const CState * C_UNUSED(initialState))
137 {return;}
138 
139 //virtual
141 {
142  if (!CCopasiMethod::isValidProblem(pProblem)) return false;
143 
144  const CLyapProblem * pLP = dynamic_cast<const CLyapProblem *>(pProblem);
145 
146  if (!pLP)
147  {
148  //not a LyapProblem
150  return false;
151  }
152 
153  if ((!pLP->divergenceRequested()) && (pLP->getExponentNumber() < 1))
154  {
156  return false;
157  }
158 
159  unsigned C_INT32 tmp = (unsigned C_INT32) pLP->getModel()->getState().getNumIndependent();
160 
161  if (pLP->getExponentNumber() > tmp)
162  {
163  //to few exponents
165  return false;
166  }
167 
168  return true;
169 }
static const CLyapValidSubTypes ValidSubTypes
Definition: CLyapMethod.h:53
void setProblem(CLyapProblem *problem)
virtual double step(const double &deltaT)
#define fatalError()
Definition: CState.h:305
CLyapProblem * mpProblem
Definition: CLyapMethod.h:74
#define C_UNUSED(p)
Definition: copasi.h:220
#define C_INT32
Definition: copasi.h:90
virtual bool isValidProblem(const CCopasiProblem *pProblem)
#define MCLyap
#define DESTRUCTOR_TRACE
Definition: copasi.h:206
virtual bool isValidProblem(const CCopasiProblem *pProblem)
size_t getNumIndependent() const
Definition: CState.cpp:342
static CLyapMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::lyapWolf)
Definition: CLyapMethod.cpp:58
const unsigned C_INT32 & getExponentNumber() const
static bool isValidSubType(const CCopasiMethod::SubType &subType)
Definition: CLyapMethod.cpp:48
bool divergenceRequested() const
const CState & getState() const
Definition: CModel.cpp:1771
CModel * getModel() const
virtual void start(const CState *initialState)
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202