MorphoGraphX  2.0-1-227
DynamXProcessMorphogens.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2016 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef DYNAMX_PROCESS_MORPHOGENS_HPP
12 #define DYNAMX_PROCESS_MORPHOGENS_HPP
13 
14 #include <Process.hpp>
15 #include <Solver.hpp>
18 
19 //
20 // Morphogen simulations
21 //
22 
23 namespace mgx
24 {
25  class mgxBase_EXPORT MeinhardtAI : public Process
26  {
27  public:
28  // Cell data, used for Meinhardt-style reaction-diffusion simulation
29  struct CellData
30  {
31  bool ProdA; // Cell produces activator
32  bool ProdH; // Cell produces inhibitor
33 
34  double A; // Activator concentration
35  double H; // Inhibitor concentration
36 
37  double dA; // Derivatives
38  double dH;
39 
40  // Constructor, set initial values
41  CellData() : ProdA(true), ProdH(true), A(0), H(0), dA(0), dH(0) {}
42 
43  bool operator==(const CellData &other) const
44  {
45  if(ProdA == other.ProdA and ProdH == other.ProdH
46  and A == other.A and H == other.H
47  and dA == other.dA and dH == other.dH)
48  return true;
49  return false;
50  }
51  };
52 
53  // Define the attribute map
55 
56  // Class to define methods for subdivision
57  class mgxBase_EXPORT Subdivide : virtual public mgx::Subdivide
58  {
59  public:
60  Subdivide(CellAttr *cAttr) : cellAttr(cAttr) {}
61 
62  virtual bool updateCellData(cell c, cell cl, cell cr);
63 
65  };
66 
67  // Class to define methods for solver
68  class mgxBase_EXPORT Solver : public mgx::Solver
69  {
70  public:
71  Solver(CellAttr *cAttr, Mesh* m, cellGraph& C, SolvingMethod method, int variables, double stepSize)
72  : mgx::Solver(m, C, method,variables,stepSize), cellAttr(cAttr) {}
73 
74  std::vector<double> getValues(const cell& c);
75  bool setValues(const cell& c, const std::vector<double> &values);
76  std::vector<double> getDerivatives(const cell& c);
77  void updateDerivatives(const cell& c);
78 
79  void setValues(const cell& c, std::vector<double> values);
80 
83  };
84 
85 
86  // Parameters
87  enum ParmNames { pDrawSteps, pStatStep, pDt, pAProd, pAAProd, pADecay, pADiff, pANoise,
88  pAMax, pAViewMax, pHProd, pHAProd, pHDecay, pHDiff, pHMax, pSolvingMethod, pNumParms };
89 
91 
92  MeinhardtAI(const Process &process) : Process(process) {}
93 
94  void calcDerivatives(const cell& c);
95 
96  // Initialize simulation, called from GUI thread
97  bool initialize(QStringList &parms, QWidget* parent = 0);
98 
99  // Process model parameters
100  void processParms(const QStringList &parms);
101 
102  // Run a step of the simulation
103  bool step(const QStringList &parms);
104 
105  // Run a step of the simulation
106  bool step(const QStringList &parms, Subdivide *sDiv);
107 
108  // Rewind of the simulation
109  bool rewind(QStringList &parms, QWidget *parent);
110 
111  // Clip max qtys and report
112  void checkMaxQtys(CellTissue *T);
113 
114  // Put the signal in the graph
115  void updateSignal();
116 
117  // Process long description
118  QString description() const { return "Meinhardt-style activator-inhibitor system"; }
119 
120  QStringList parmNames() const
121  {
122  QVector <QString> vec(pNumParms);
123 
124  vec[pDrawSteps] = "DrawSteps";
125  vec[pStatStep] = "StatStep";
126  vec[pDt] = "Dt";
127  vec[pAProd] = "AProd";
128  vec[pAAProd] = "AAProd";
129  vec[pADecay] = "ADecay";
130  vec[pADiff] = "ADiff";
131  vec[pANoise] = "ANoise";
132  vec[pAMax] = "AMax";
133  vec[pAViewMax] = "AViewMax";
134  vec[pHProd] = "HProd";
135  vec[pHAProd] = "HAProd";
136  vec[pHDecay] = "HDecay";
137  vec[pHDiff] = "HDiff";
138  vec[pHMax] = "HMax";
139  vec[pSolvingMethod] = "Forward Euler";
140 
141  return vec.toList();
142  }
143  QStringList parmDescs() const
144  {
145  QVector <QString> vec(pNumParms);
146 
147  vec[pDrawSteps] = "Simulation steps between drawing";
148  vec[pStatStep] = "Time between statistics reporting, 0 = none";
149  vec[pDt] = "Step duration";
150  vec[pAProd] = "Activator default production";
151  vec[pAAProd] = "Activator production, self enhanced";
152  vec[pADecay] = "Activator decay";
153  vec[pADiff] = "Activator diffusion";
154  vec[pANoise] = "Activator noise";
155  vec[pAMax] = "Activator max concentration";
156  vec[pAViewMax] = "Activator max for viewing";
157  vec[pHProd] = "Inhibitor default production";
158  vec[pHAProd] = "Inhibitor production, self enhanced";
159  vec[pHDecay] = "Inhibitor decay";
160  vec[pHDiff] = "Inhibitor diffusion";
161  vec[pHMax] = "Inhibitor max concentration";
162  vec[pSolvingMethod] = "ODE Solving Method (Euler or Backward Euler)";
163 
164  return vec.toList();
165  }
166  QStringList parmDefaults() const
167  {
168  QVector <QString> vec(pNumParms);
169 
170  vec[pDrawSteps] = "10";
171  vec[pStatStep] = "1.0";
172  vec[pDt] = "0.001";
173  vec[pAProd] = "0.1";
174  vec[pAAProd] = "100";
175  vec[pADecay] = "1";
176  vec[pADiff] = "0.01";
177  vec[pANoise] = "0.1";
178  vec[pAMax] = "20000";
179  vec[pAViewMax] = "25";
180  vec[pHProd] = "0";
181  vec[pHAProd] = "500";
182  vec[pHDecay] = "50";
183  vec[pHDiff] = "100";
184  vec[pHMax] = "20000";
185  vec[pSolvingMethod] = "Yes";
186 
187  return vec.toList();
188  }
189 
190  // Gui dropdowns
191  ParmChoiceMap parmChoice() const
192  {
193  ParmChoiceMap map;
194  map[pSolvingMethod] = booleanChoice();
195  return map;
196  }
197 
198  // Icon file
199  QIcon icon() const { return QIcon(":/images/MeinhardtAI.png"); }
200 
201  private:
202  Mesh *mesh;
203  CellTissue *T;
204  // vertex attributes required for simulation
205  CellAttr *cellAttr;
206 
207  // Parameters
208  int drawSteps; // Integration steps
209  double statStep; // Time between stats printouts
210  double dtRD; // Step duration
211 
212  double aProd; // Activator default production constant
213  double aaProd; // Activator self-enhanced production
214  double aDecay; // Activator decay constant
215  double aDiff; // Activator diffusion constant
216  double aNoise; // Activator noise
217  double aMax; // Activator max amount
218  double aViewMax; // Activator max for viewing
219 
220  double hProd; // Inhibitor default production constant
221  double haProd; // Inhibitor self-enhanced production
222  double hDecay; // Inhibitor decay constant
223  double hDiff; // Inhibitor diffusion constant
224  double hMax; // Inhibitor max amount
225 
226  double time; // Current time in simulation
227  double lastStat; // Time of last statistics printout
228 
229  bool solvingMethod; // ODE solving method
230  };
231 
232  // Read/write Cell data
233  bool inline readAttr(MeinhardtAI::CellData &m, const QByteArray &ba, size_t &pos)
234  {
235  return readChar((char *)&m, sizeof(MeinhardtAI::CellData), ba, pos);
236  }
237  bool inline writeAttr(const MeinhardtAI::CellData &m, QByteArray &ba)
238  {
239  return writeChar((char *)&m, sizeof(MeinhardtAI::CellData), ba);
240  }
241 }
242 #endif
mgx::MeinhardtAI::pStatStep
@ pStatStep
Definition: DynamXProcessMorphogens.hpp:87
mgx::SolvingMethod
SolvingMethod
Definition: Solver.hpp:32
mgx::MeinhardtAI
Definition: DynamXProcessMorphogens.hpp:25
mgx::MeinhardtAI::Solver::Solver
Solver(CellAttr *cAttr, Mesh *m, cellGraph &C, SolvingMethod method, int variables, double stepSize)
Definition: DynamXProcessMorphogens.hpp:71
mgx::MeinhardtAI::CellData::A
double A
Definition: DynamXProcessMorphogens.hpp:34
Process.hpp
mgx::MeinhardtAI::CellAttr
AttrMap< cell, CellData > CellAttr
Definition: DynamXProcessMorphogens.hpp:54
mgx::MeinhardtAI::MeinhardtAI
MeinhardtAI(const Process &process)
Definition: DynamXProcessMorphogens.hpp:92
mgx::MeinhardtAI::CellData::ProdA
bool ProdA
Definition: DynamXProcessMorphogens.hpp:31
mgx::Solver
Definition: Solver.hpp:41
mgx::CellTissue
Definition: CellTissue.hpp:46
mgx::MeinhardtAI::icon
QIcon icon() const
Definition: DynamXProcessMorphogens.hpp:199
mgx::MeinhardtAI::CellData::operator==
bool operator==(const CellData &other) const
Definition: DynamXProcessMorphogens.hpp:43
mgx::MeinhardtAI::Solver
Definition: DynamXProcessMorphogens.hpp:68
mgx::MeinhardtAI::CellData::dA
double dA
Definition: DynamXProcessMorphogens.hpp:37
mgx::MeinhardtAI::~MeinhardtAI
~MeinhardtAI()
Definition: DynamXProcessMorphogens.hpp:90
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::MeinhardtAI::parmNames
QStringList parmNames() const
Definition: DynamXProcessMorphogens.hpp:120
mgx::MeinhardtAI::Subdivide::cellAttr
CellAttr * cellAttr
Definition: DynamXProcessMorphogens.hpp:64
mgx::MeinhardtAI::CellData::dH
double dH
Definition: DynamXProcessMorphogens.hpp:38
mgx::MeinhardtAI::pSolvingMethod
@ pSolvingMethod
Definition: DynamXProcessMorphogens.hpp:88
mgx::Process
Definition: Process.hpp:219
mgx::MeinhardtAI::Solver::m
MeinhardtAI * m
Definition: DynamXProcessMorphogens.hpp:81
DynamXProcessCellDivide.hpp
mgx::MeinhardtAI::Solver::cellAttr
CellAttr * cellAttr
Definition: DynamXProcessMorphogens.hpp:82
mgx::MeinhardtAI::Subdivide::Subdivide
Subdivide(CellAttr *cAttr)
Definition: DynamXProcessMorphogens.hpp:60
DynamXProcessCellTissue.hpp
mgx::MeinhardtAI::CellData::ProdH
bool ProdH
Definition: DynamXProcessMorphogens.hpp:32
mgx::MeinhardtAI::ParmNames
ParmNames
Definition: DynamXProcessMorphogens.hpp:87
mgx::Mesh
Definition: Mesh.hpp:54
mgx::MeinhardtAI::parmDefaults
QStringList parmDefaults() const
Definition: DynamXProcessMorphogens.hpp:166
mgx::MeinhardtAI::Subdivide
Definition: DynamXProcessMorphogens.hpp:57
Solver.hpp
mgx::MeinhardtAI::parmChoice
ParmChoiceMap parmChoice() const
Definition: DynamXProcessMorphogens.hpp:191
mgx::MeinhardtAI::CellData
Definition: DynamXProcessMorphogens.hpp:29
mgx::MeinhardtAI::CellData::H
double H
Definition: DynamXProcessMorphogens.hpp:35
mgx::writeAttr
bool writeAttr(const T &data, QByteArray &ba)
Write the attribute value from a QByteArray.
Definition: Attributes.hpp:510
mgx::VVGraph< mgx::CellData, mgx::WallData >
mgx::Subdivide
Definition: Subdivide.hpp:25
mgx::readAttr
bool readAttr(T &data, const QByteArray &ba, size_t &pos)
Read the attribute value from a QByteArray.
Definition: Attributes.hpp:244
mgx::MeinhardtAI::parmDescs
QStringList parmDescs() const
Definition: DynamXProcessMorphogens.hpp:143
mgx::MeinhardtAI::description
QString description() const
Definition: DynamXProcessMorphogens.hpp:118
mgx::AttrMap
Attribute map wraps std::map.
Definition: Attributes.hpp:686
mgx::MeinhardtAI::CellData::CellData
CellData()
Definition: DynamXProcessMorphogens.hpp:41
mgx::Vertex
Definition: Vertex.hpp:58
mgx::map
CU_HOST_DEVICE Vector< dim, T > map(const T &(*fct)(const T1 &), const Vector< dim, T1 > &v)
Definition: Vector.hpp:1380