CellModules
PluginGrimesOxygen.hpp
Go to the documentation of this file.
1#ifndef PLUGINGRIMESOXYGEN_HPP
2#define PLUGINGRIMESOXYGEN_HPP
3
11#include <vector>
12#include <mecacell/mecacell.h>
13#include "../SpheroidManager/PluginSpheroidManager.hpp"
14#include <math.h>
15
20namespace GrimesOxygen {
21
28 template<typename cell_t>
30
31 private:
32 double a = 5.634224/10.0;
33 double omega = 10.0*3.0318;
34 double D = 2000.0;
35 double po = 37.50319;
37
44 double rl = sqrt(6. * D * po / (a * omega)); // Limit radius in µm
45 double rn = 0; // Necrotic radius in µm
46 double cstConsoDiff = a * omega / (6. * D); // in mmHg/µm^2
47 if (spheroidManager->getSpheroidRadius() > rl)
48 rn = (spheroidManager->getSpheroidRadius() * (1.0f / 2.0f - cos((acos(1.0f - 2.0f * pow(rl, 2) / pow(spheroidManager->getSpheroidRadius(), 2)) - 2.0f * M_PI) / 3.0f)));
49
50 for (auto &c : cells) {
51 c->getBody().setOxygen(eqOxygen(cstConsoDiff, rn, c->getBody().getDistanceFromCentroid()));
52 }
53 }
54
63 double eqOxygen(double cstConsoDiff, double rn, double r) {
64 double pr = 0;
65 if (r < rn) {
66 return 0.0;
67 } else if (r >= spheroidManager->getSpheroidRadius()) {
68 return po;
69 } else {
70 if (r == 0)
71 pr = po + cstConsoDiff * (pow(r, 2) - pow(spheroidManager->getSpheroidRadius(), 2));
72 else
73 pr = po + cstConsoDiff * (pow(r, 2) - pow(spheroidManager->getSpheroidRadius(), 2) + 2.0f * pow(rn, 3) * ((1 / r) - (1 / spheroidManager->getSpheroidRadius())));
74 if (pr >= 0)
75 return pr;
76 else
77 return 0.0;
78 }
79 }
80
81 public:
85 inline PluginGrimesOxygen() = default;
86
93
99 inline void setPo(double p) { po = p; }
100
106 inline void setOxygenConsumption(double c) { a = c; }
107
113 inline void setDiffusionConstant(double d) { D = d; }
114
120 inline void setOmega(double om) { omega = om; }
121
130 template<typename world_t>
131 void preBehaviorUpdate(world_t *w) {
132 if(!spheroidManager) spheroidManager = &w->cellPlugin.pluginSpheroidManager;
133 if (w->cells.size() > 5) {
134 updateOxygen(w->cells);
135 }
136 }
137 };
138}
139
140#endif // PLUGINGRIMESOXYGEN_HPP
Class for managing spherical oxygen diffusion.
void setOmega(double om)
Sets the Henry constant for oxygen.
void setPo(double p)
Sets the external partial pressure of oxygen.
void updateOxygen(std::vector< cell_t * > cells)
Updates the oxygen levels for the given cells.
PluginGrimesOxygen()=default
Default constructor.
void preBehaviorUpdate(world_t *w)
Pre-behavior update hook for MecaCell.
void setDiffusionConstant(double d)
Sets the diffusion constant.
PluginGrimesOxygen(SpheroidManager::PluginSpheroidManager< cell_t > *sm)
Constructor with spheroid manager.
SpheroidManager::PluginSpheroidManager< cell_t > * spheroidManager
void setOxygenConsumption(double c)
Sets the oxygen consumption rate.
double eqOxygen(double cstConsoDiff, double rn, double r)
Computes the partial pressure of oxygen for a cell.
Class for managing spheroid bodies.
A simple vector class template.
Definition: std.hpp:290
Namespace for oxygen diffusion-related classes and functions.
double acos(double x)
Computes the arc cosine of a number.
Definition: std.hpp:113
double sqrt(double x)
Computes the square root of a number.
Definition: std.hpp:32
double pow(double base, double exponent)
Computes the power of a number.
Definition: std.hpp:43
double cos(double x)
Computes the cosine of a number.
Definition: std.hpp:63