Skip to content

Commit e716582

Browse files
salva24vgvassilev
andauthored
Midterm code push (#1)
* all work I have done untill the midterm: tumor replicated from the nature paper including forces and diffusion modules * car-t oxygen consumption * Update README.md Co-authored-by: Vassil Vassilev <[email protected]> * Update src/cart_cell.cc Co-authored-by: Vassil Vassilev <[email protected]> * still in progress CAR-T displacement * cleaned comments to follow Doxygen-style * changed comments to follow doxygen-style * Remove draft_code_my_own_analysis/ from tracking and add to .gitignore * remove draft_code_my_own_analysis * add to gitignore draft_code_my_own_analysis * fixing comments * [ci] Add basic github actions infrastructure * Update CMakeLists.txt Co-authored-by: Vassil Vassilev <[email protected]> * Update README.md Co-authored-by: Vassil Vassilev <[email protected]> * Update README.md Co-authored-by: Vassil Vassilev <[email protected]> * Update src/cart_cell.cc use *Simulation::GetActive()->GetResourceManager() just once Co-authored-by: Vassil Vassilev <[email protected]> * Update src/cart_cell.cc Co-authored-by: Vassil Vassilev <[email protected]> * Update src/forces_tumor_cart.cc Co-authored-by: Vassil Vassilev <[email protected]> * changed some things to imporve code quality * cart_cell comments fixed * changed all comments to /// in the .h and changed some of them * changed the project name + new readme part Results * minor change spelling * 30-days simulation --------- Co-authored-by: Vassil Vassilev <[email protected]>
1 parent 07ed3cd commit e716582

File tree

11 files changed

+358
-502
lines changed

11 files changed

+358
-502
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
cmake_minimum_required(VERSION 3.19.3)
1515
project(cart_tumor)
1616

17+
1718
# BioDynaMo curretly uses the C++17 standard.
1819
set(CMAKE_CXX_STANDARD 17)
1920

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ The simulation integrates computational modeling and biological insights to expl
1414
3. [Installation](#installation)
1515
4. [Building the Simulation](#building-the-simulation)
1616
5. [Running the Simulation](#running-the-simulation)
17-
6. [Acknowledgments](#acknowledgments)
18-
7. [License](#license)
17+
6. [Visualizing Results](#results)
18+
7. [Acknowledgments](#acknowledgments)
19+
8. [License](#license)
20+
1921

2022
---
2123

@@ -49,7 +51,8 @@ By adjusting biological and therapeutic parameters, the model enables **in silic
4951
Clone the repository:
5052
```bash
5153
git clone https://github.com/compiler-research/CARTopiaX.git
52-
cd cart_tumor
54+
cd CARTopiaX
55+
5356
```
5457

5558
---
@@ -85,7 +88,20 @@ biodynamo run
8588
**Option 2:**
8689
Directly from the build directory:
8790
```bash
88-
./build/cart_tumor
91+
92+
./build/CARTopiaX
93+
```
94+
95+
---
96+
97+
## Results
98+
99+
Data about tumor growth and diffrent types of cell populations is output in ./output/final_data.csv
100+
101+
To visualize the results in paraview use:
102+
```bash
103+
paraview ./output/CARTopiaX/CARTopiaX.pvsm
104+
89105
```
90106

91107
---

src/cart_cell.cc

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ CartCell::CartCell(const Real3& position) {
3838
SetNuclearVolume(kDefaultVolumeNucleusCartCell);
3939

4040

41+
4142
ResourceManager &rm = *Simulation::GetActive()->GetResourceManager();
4243
// Pointer to oxygen diffusion grid
4344
oxygen_dgrid_ = rm.GetDiffusionGrid("oxygen");
@@ -64,7 +65,9 @@ CartCell::CartCell(const Real3& position) {
6465

6566
// Cart cells can move if they are alive and not attached to a tumor cell
6667
bool CartCell::DoesCellMove() {
68+
6769
return (state_ == CartCellState::kAlive && !attached_to_tumor_cell_);
70+
6871
}
6972

7073

@@ -135,11 +138,13 @@ Real3 CartCell::CalculateDisplacement(const InteractionForce* force,
135138
squared_radius=kSquaredMaxDistanceNeighborsForce;
136139

137140
// the physics force to move the point mass
141+
138142
Real3 translation_velocity_on_point_mass{0, 0, 0};
139143

140144
// We check for every neighbor object if they touch us, i.e. push us
141145
// away and agreagate the velocities
142146

147+
143148
uint64_t non_zero_neighbor_forces = 0;
144149
if (!IsStatic()) {
145150
auto* ctxt = Simulation::GetActive()->GetExecutionContext();
@@ -161,53 +166,11 @@ Real3 CartCell::CalculateDisplacement(const InteractionForce* force,
161166
}
162167
}
163168

169+
164170
// Two step Adams-Bashforth approximation of the time derivative for position
165171
// position(t + dt) ≈ position(t) + dt * [ 1.5 * velocity(t) - 0.5 * velocity(t - dt) ]
166172
movement_at_next_step += translation_velocity_on_point_mass * kDnew + older_velocity_ * kDold;
167173

168-
//Debug
169-
// std::ofstream file1("output/movement_at_next_step.csv", std::ios::app);
170-
// if (file1.is_open()) {
171-
172-
// // Calculate time in days, hours, minutes
173-
// double total_minutes = Simulation::GetActive()->GetScheduler()->GetSimulatedTime();
174-
// // Write data to CSV file
175-
// file1
176-
// << "minute"<<total_minutes << ","
177-
// <<"translation_velocity_on_point_mass"<< translation_velocity_on_point_mass[0]<< ","
178-
// << translation_velocity_on_point_mass[1] << ","
179-
// << translation_velocity_on_point_mass[2] << ","
180-
// << "kDnew" << kDnew << ","
181-
// << "older_velocity_" << older_velocity_[0] << ","
182-
// << older_velocity_[1] << ","
183-
// << older_velocity_[2] << ","
184-
// << "kDold" << kDold << "\n";
185-
// }
186-
187-
//Debug Output forces
188-
// std::ofstream file("output/forces.csv", std::ios::app);
189-
// if (file.is_open()) {
190-
191-
// // Calculate time in days, hours, minutes
192-
// double total_minutes = Simulation::GetActive()->GetScheduler()->GetSimulatedTime();
193-
// double modulus_total_displacement = movement_at_next_step[0] * movement_at_next_step[0] +
194-
// movement_at_next_step[1] * movement_at_next_step[1] +
195-
// movement_at_next_step[2] * movement_at_next_step[2];
196-
// modulus_total_displacement = std::sqrt(modulus_total_displacement);
197-
// Real3 position = GetPosition();
198-
// // Write data to CSV file
199-
// file
200-
// << total_minutes << ","
201-
// << position[0] << ","
202-
// << position[1] << ","
203-
// << position[2] << ","
204-
// << movement_at_next_step[0] << ","
205-
// << movement_at_next_step[1] << ","
206-
// << movement_at_next_step[2] << ","
207-
// << modulus_total_displacement << "\n";
208-
// }
209-
// End Debug Output
210-
211174
older_velocity_ = translation_velocity_on_point_mass;
212175

213176
// Displacement

src/cart_cell.h

Lines changed: 69 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,22 @@
3030

3131
namespace bdm {
3232

33-
34-
/**
35-
* @brief Enumeration defining the possible states of a CAR-T cell
36-
*
37-
* This enum class represents the different states that a CAR-T cell can be in
38-
* during its lifecycle in the simulation.
39-
*/
33+
/// Enumeration defining the possible states of a CAR-T cell
34+
///
35+
/// This enum class represents the different states that a CAR-T cell can be in
36+
/// during its lifecycle in the simulation.
4037
enum class CartCellState : int {
41-
/** @brief Living cell state - the cell is alive and functioning normally */
42-
kAlive=0,
38+
kAlive=0,///< Living cell state - the cell is alive and functioning normally
4339

44-
/** @brief Apoptotic phase - the cell is undergoing programmed cell death
45-
* characterized by cell shrinkage and controlled death
46-
*/
47-
kApoptotic=1
40+
kApoptotic=1///< Apoptotic phase - the cell is undergoing programmed cell death characterized by cell shrinkage and controlled death
4841
};
4942

50-
/**
51-
* @brief CAR-T cell class implementation
52-
*
53-
* This class represents a CAR-T (Chimeric Antigen Receptor T-cell) in the simulation.
54-
* It inherits from the base Cell class and includes specific behaviors and properties
55-
* related to CAR-T cell biology, including states, volume dynamics, and interactions
56-
* with tumor cells.
57-
*/
43+
/// CAR-T cell class implementation
44+
///
45+
/// This class represents a CAR-T (Chimeric Antigen Receptor T-cell) in the simulation.
46+
/// It inherits from the base Cell class and includes specific behaviors and properties
47+
/// related to CAR-T cell biology, including states, volume dynamics, and interactions
48+
/// with tumor cells.
5849
class CartCell : public Cell {
5950
BDM_AGENT_HEADER(CartCell, Cell, 1);
6051

@@ -113,134 +104,118 @@ class CartCell : public Cell {
113104
/// Returns the diffusion grid for immunostimulatory factors
114105
DiffusionGrid* GetImmunostimulatoryFactorDiffusionGrid() const { return immunostimulatory_factor_dgrid_; }
115106

116-
/** @brief Change volume using exponential relaxation equation
117-
*
118-
* This method explicitly solves the system of exponential relaxation differential
119-
* equations using a discrete update step. It is used to grow or shrink the volume
120-
* (and proportions) smoothly toward a desired target volume over time. The relaxation
121-
* rate controls the speed of convergence and dt=1 (the time_step).
122-
*
123-
* @param relaxation_rate_cytoplasm Relaxation rate for cytoplasm volume changes
124-
* @param relaxation_rate_nucleus Relaxation rate for nucleus volume changes
125-
* @param relaxation_rate_fluid Relaxation rate for fluid volume changes
126-
*/
107+
/// Change volume using exponential relaxation equation
108+
///
109+
/// This method explicitly solves the system of exponential relaxation differential
110+
/// equations using a discrete update step. It is used to grow or shrink the volume
111+
/// (and proportions) smoothly toward a desired target volume over time. The relaxation
112+
/// rate controls the speed of convergence and dt=1 (the time_step).
113+
///
114+
/// @param relaxation_rate_cytoplasm Relaxation rate for cytoplasm volume changes
115+
/// @param relaxation_rate_nucleus Relaxation rate for nucleus volume changes
116+
/// @param relaxation_rate_fluid Relaxation rate for fluid volume changes
127117
void ChangeVolumeExponentialRelaxationEquation(real_t relaxation_rate_cytoplasm, real_t relaxation_rate_nucleus, real_t relaxation_rate_fluid);
128118

129-
/** @brief Calculate displacement of the cell
130-
*
131-
* Computes the displacement of the cell based on interaction forces.
132-
*
133-
* @param force Pointer to the interaction force object
134-
* @param squared_radius The squared radius of the cell
135-
* @param dt The time step for the simulation
136-
* @return The calculated displacement vector
137-
*/
119+
/// Calculate displacement of the cell
120+
///
121+
/// Computes the displacement of the cell based on interaction forces.
122+
///
123+
/// @param force Pointer to the interaction force object
124+
/// @param squared_radius The squared radius of the cell
125+
/// @param dt The time step for the simulation
126+
/// @return The calculated displacement vector
138127
Real3 CalculateDisplacement(const InteractionForce* force,
139128
real_t squared_radius, real_t dt) override;
140129

141-
/** @brief Consume or secrete substances
142-
*
143-
* Computes new oxygen or immunostimulatory factor concentration after
144-
* consumption or secretion by the cell.
145-
*
146-
* @param substance_id The ID of the substance (oxygen or immunostimulatory factor)
147-
* @param old_concentration The previous concentration of the substance
148-
* @return The new concentration after consumption/secretion
149-
*/
130+
/// Consume or secrete substances
131+
///
132+
/// Computes new oxygen or immunostimulatory factor concentration after
133+
/// consumption or secretion by the cell.
134+
///
135+
/// @param substance_id The ID of the substance (oxygen or immunostimulatory factor)
136+
/// @param old_concentration The previous concentration of the substance
137+
/// @return The new concentration after consumption/secretion
150138
real_t ConsumeSecreteSubstance(int substance_id, real_t old_concentration);
151139

152-
/** @brief Compute constants for consumption and secretion
153-
*
154-
* Updates constants after the cell's change of volume or quantities.
155-
* These constants are used in the consumption/secretion differential equations.
156-
*/
140+
/// Compute constants for consumption and secretion
141+
///
142+
/// Updates constants after the cell's change of volume or quantities.
143+
/// These constants are used in the consumption/secretion differential equations.
157144
void ComputeConstantsConsumptionSecretion();
158145

159-
160-
/** @name Private Member Variables
161-
* @brief Private attributes of the CAR-T cell
162-
* @{
163-
*/
164146
private:
165-
/** @brief Current state of the CAR-T cell */
147+
/// Current state of the CAR-T cell
166148
CartCellState state_;
167149

168-
/** @brief Timer to track time in the current state (in minutes)
169-
* Used for apoptotic state timing
170-
*/
150+
/// Timer to track time in the current state (in minutes)
151+
/// Used for apoptotic state timing
171152
int timer_state_;
172153

173-
/** @brief Pointer to the oxygen diffusion grid */
154+
/// Pointer to the oxygen diffusion grid
174155
DiffusionGrid* oxygen_dgrid_;
175156

176-
/** @brief Pointer to the immunostimulatory factor diffusion grid */
157+
/// Pointer to the immunostimulatory factor diffusion grid
177158
DiffusionGrid* immunostimulatory_factor_dgrid_;
178159

179-
/** @brief Flag indicating if the cell is attached to a tumor cell */
160+
/// Flag indicating if the cell is attached to a tumor cell
180161
bool attached_to_tumor_cell_;
181162

182-
/** @brief Current time until apoptosis */
163+
/// Current time until apoptosis
183164
real_t current_live_time_;
184165

185-
/** @brief Fluid fraction of the cell volume */
166+
/// Fluid fraction of the cell volume
186167
real_t fluid_fraction_;
187168

188-
/** @brief Volume of the nucleus */
169+
/// Volume of the nucleus
189170
real_t nuclear_volume_;
190171

191-
/** @brief Target cytoplasm solid volume for exponential relaxation
192-
* Used during volume changes following exponential relaxation equation
193-
*/
172+
/// Target cytoplasm solid volume for exponential relaxation
173+
/// Used during volume changes following exponential relaxation equation
194174
real_t target_cytoplasm_solid_;
195175

196-
/** @brief Target nucleus solid volume for exponential relaxation */
176+
/// Target nucleus solid volume for exponential relaxation
197177
real_t target_nucleus_solid_;
198178

199-
/** @brief Target fluid fraction for exponential relaxation */
179+
/// Target fluid fraction for exponential relaxation
200180
real_t target_fraction_fluid_;
201181

202-
/** @brief Target relation between cytoplasm and nucleus volumes */
182+
/// Target relation between cytoplasm and nucleus volumes
203183
real_t target_relation_cytoplasm_nucleus_;
204184

205-
/** @brief Velocity of the cell in the previous time step */
185+
/// Velocity of the cell in the previous time step
206186
Real3 older_velocity_;
207187

208-
/** @brief Rate of oxygen consumption by the cell */
188+
/// Rate of oxygen consumption by the cell
209189
real_t oxygen_consumption_rate_;
210190

211-
/** @brief Rate of immunostimulatory factor secretion by the cell */
191+
/// Rate of immunostimulatory factor secretion by the cell
212192
real_t immunostimulatory_factor_secretion_rate_;
213193

214-
/** @brief Constant 1 for oxygen consumption/secretion differential equation solution */
194+
/// Constant 1 for oxygen consumption/secretion differential equation solution
215195
real_t constant1_oxygen_;
216196

217-
/** @brief Constant 2 for oxygen consumption/secretion differential equation solution */
197+
/// Constant 2 for oxygen consumption/secretion differential equation solution
218198
real_t constant2_oxygen_;
219199

220-
/** @brief Pointer to the attached tumor cell */
200+
/// Pointer to the attached tumor cell
221201
TumorCell* attached_cell_;
222202

223-
/** @} */ // end of Private Member Variables group
224203
};
225204

226-
/**
227-
* @brief Behavior class for controlling CAR-T cell state transitions
228-
*
229-
* This behavior handles the state control logic for CAR-T cells, managing
230-
* transitions between different cell states such as alive and apoptotic phases.
231-
* It inherits from the base Behavior class and implements the Run method to
232-
* execute the state control logic during simulation steps.
233-
*/
205+
/// Behavior class for controlling CAR-T cell state transitions
206+
///
207+
/// This behavior handles the state control logic for CAR-T cells, managing
208+
/// transitions between different cell states: alive and apoptotic phases.
209+
/// It inherits from the base Behavior class and implements the Run method to
210+
/// execute the state control logic during simulation steps.
234211
struct StateControlCart : public Behavior {
235212
BDM_BEHAVIOR_HEADER(StateControlCart, Behavior, 1);
236213

237214
StateControlCart() { AlwaysCopyToNew(); }
238215

239216
virtual ~StateControlCart() {}
240217

241-
/** @brief Execute the state control behavior
242-
* @param agent Pointer to the agent (cell) on which to apply the behavior
243-
*/
218+
/// Execute the state control behavior
244219
void Run(Agent* agent) override;
245220
};
246221

0 commit comments

Comments
 (0)