Skip to content

Commit 6136db6

Browse files
salva24vgvassilev
authored andcommitted
fixing comments
1 parent ad83009 commit 6136db6

File tree

10 files changed

+264
-1045
lines changed

10 files changed

+264
-1045
lines changed

src/cart_cell.h

Lines changed: 8 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -59,221 +59,60 @@ class CartCell : public Cell {
5959
BDM_AGENT_HEADER(CartCell, Cell, 1);
6060

6161
public:
62-
/** @brief Default constructor */
6362
CartCell() {}
64-
65-
/** @brief Constructor with position parameter
66-
* @param position Initial 3D position of the cell
67-
*/
6863
explicit CartCell(const Real3& position);
69-
70-
/** @brief Virtual destructor */
7164
virtual ~CartCell() {}
7265

73-
/** @name State Management
74-
* @brief Methods for managing cell state
75-
* @{
76-
*/
77-
78-
/** @brief Set the current state of the CAR-T cell
79-
* @param state The new state to set
80-
*/
66+
///Getters and Setters
8167
void SetState(CartCellState state) { state_ = state; }
82-
83-
/** @brief Get the current state of the CAR-T cell
84-
* @return The current cell state
85-
*/
8668
CartCellState GetState() const { return state_; }
8769

88-
/** @brief Set the timer for tracking time in current state
89-
* @param timer_state Timer value in minutes
90-
*/
9170
void SetTimerState(int timer_state) { timer_state_ = timer_state; }
92-
93-
/** @brief Get the timer for tracking time in current state
94-
* @return Timer value in minutes
95-
*/
9671
int GetTimerState() const { return timer_state_; }
97-
98-
/** @} */ // end of State Management group
9972

100-
/** @name Volume and Physical Properties
101-
* @brief Methods for managing cell volume and physical characteristics
102-
* @{
103-
*/
104-
105-
/** @brief Set the fluid fraction of the cell
106-
* @param fluid_fraction The fluid fraction value
107-
*/
10873
void SetFluidFraction(real_t fluid_fraction) { fluid_fraction_ = fluid_fraction; }
109-
110-
/** @brief Get the fluid fraction of the cell
111-
* @return The current fluid fraction
112-
*/
11374
real_t GetFluidFraction() const { return fluid_fraction_; }
11475

115-
/** @brief Set the nuclear volume
116-
* @param nuclear_volume The nuclear volume value
117-
*/
11876
void SetNuclearVolume(real_t nuclear_volume) { nuclear_volume_ = nuclear_volume; }
119-
120-
/** @brief Get the nuclear volume
121-
* @return The current nuclear volume
122-
*/
12377
real_t GetNuclearVolume() const { return nuclear_volume_; }
12478

125-
/** @brief Set the target cytoplasm solid volume
126-
* @param target_cytoplasm_solid The target cytoplasm solid volume
127-
*/
12879
void SetTargetCytoplasmSolid(real_t target_cytoplasm_solid) { target_cytoplasm_solid_ = target_cytoplasm_solid; }
129-
130-
/** @brief Get the target cytoplasm solid volume
131-
* @return The target cytoplasm solid volume
132-
*/
13380
real_t GetTargetCytoplasmSolid() const { return target_cytoplasm_solid_; }
13481

135-
/** @brief Set the target nucleus solid volume
136-
* @param target_nucleus_solid The target nucleus solid volume
137-
*/
13882
void SetTargetNucleusSolid(real_t target_nucleus_solid) { target_nucleus_solid_ = target_nucleus_solid; }
139-
140-
/** @brief Get the target nucleus solid volume
141-
* @return The target nucleus solid volume
142-
*/
14383
real_t GetTargetNucleusSolid() const { return target_nucleus_solid_; }
14484

145-
/** @brief Set the target fraction of fluid
146-
* @param target_fraction_fluid The target fluid fraction
147-
*/
14885
void SetTargetFractionFluid(real_t target_fraction_fluid) { target_fraction_fluid_ = target_fraction_fluid; }
149-
150-
/** @brief Get the target fraction of fluid
151-
* @return The target fluid fraction
152-
*/
15386
real_t GetTargetFractionFluid() const { return target_fraction_fluid_; }
15487

155-
/** @brief Set the target relation between cytoplasm and nucleus
156-
* @param target_relation_cytoplasm_nucleus The target relation value
157-
*/
15888
void SetTargetRelationCytoplasmNucleus(real_t target_relation_cytoplasm_nucleus) { target_relation_cytoplasm_nucleus_ = target_relation_cytoplasm_nucleus; }
159-
160-
/** @brief Get the target relation between cytoplasm and nucleus
161-
* @return The target relation value
162-
*/
16389
real_t GetTargetRelationCytoplasmNucleus() const { return target_relation_cytoplasm_nucleus_; }
16490

165-
/** @} */ // end of Volume and Physical Properties group
166-
167-
/** @name Tumor Cell Attachment
168-
* @brief Methods for managing attachment to tumor cells
169-
* @{
170-
*/
171-
172-
/** @brief Set whether the cell is attached to a tumor cell
173-
* @param attached True if attached, false otherwise
174-
*/
17591
void SetAttachedToTumorCell(bool attached) { attached_to_tumor_cell_ = attached; }
176-
177-
/** @brief Check if the cell is attached to a tumor cell
178-
* @return True if attached to a tumor cell, false otherwise
179-
*/
18092
bool IsAttachedToTumorCell() const { return attached_to_tumor_cell_; }
18193

182-
/** @brief Get the attached tumor cell
183-
* @return Pointer to the attached tumor cell, or nullptr if not attached
184-
*/
185-
TumorCell* GetAttachedCell() const { return attached_cell_; }
186-
187-
/** @brief Set the attached tumor cell
188-
* @param cell Pointer to the tumor cell to attach
189-
*/
190-
void SetAttachedCell(TumorCell* cell) { attached_cell_ = cell; }
191-
192-
/** @} */ // end of Tumor Cell Attachment group
193-
194-
/** @name Movement and Velocity
195-
* @brief Methods for managing cell movement and velocity
196-
* @{
197-
*/
198-
199-
/** @brief Get the velocity from the previous time step
200-
* @return The velocity vector from the previous step
201-
*/
20294
Real3 GetOlderVelocity() const { return older_velocity_; }
203-
204-
/** @brief Set the velocity from the previous time step
205-
* @param velocity The velocity vector to set
206-
*/
20795
void SetOlderVelocity(const Real3& velocity) { older_velocity_ = velocity; }
20896

209-
/** @brief Check whether the cell moves by its own
210-
* @return True if the cell can move independently, false otherwise
211-
*/
212-
bool DoesCellMove();
213-
214-
/** @} */ // end of Movement and Velocity group
215-
216-
/** @name Biochemical Properties
217-
* @brief Methods for managing oxygen consumption and cell lifetime
218-
* @{
219-
*/
220-
221-
/** @brief Get the oxygen consumption rate
222-
* @return The current oxygen consumption rate
223-
*/
22497
real_t GetOxygenConsumptionRate() const { return oxygen_consumption_rate_; }
225-
226-
/** @brief Set the oxygen consumption rate
227-
* @param rate The oxygen consumption rate to set
228-
*/
22998
void SetOxygenConsumptionRate(real_t rate) { oxygen_consumption_rate_ = rate; }
23099

231-
/** @brief Get the current live time
232-
* @return The current time until apoptosis
233-
*/
234100
real_t GetCurrentLiveTime() const { return current_live_time_; }
235-
236-
/** @brief Set the current live time
237-
* @param time The current live time to set
238-
*/
239101
void SetCurrentLiveTime(real_t time) { current_live_time_ = time; }
240102

241-
/** @} */ // end of Biochemical Properties group
103+
TumorCell* GetAttachedCell() const { return attached_cell_; }
104+
void SetAttachedCell(TumorCell* cell) { attached_cell_ = cell; }
242105

243-
/** @name Volume Calculations
244-
* @brief Methods for volume calculations
245-
* @{
246-
*/
106+
/// Returns whether the cell moves by its own
107+
bool DoesCellMove();
247108

248-
/** @brief Calculate the target total volume of the cell
249-
* @return The target total volume
250-
*/
251109
real_t GetTargetTotalVolume();
252110

253-
/** @} */ // end of Volume Calculations group
254-
255-
/** @name Diffusion Grids
256-
* @brief Methods for accessing diffusion grids
257-
* @{
258-
*/
259-
260-
/** @brief Get the diffusion grid for oxygen
261-
* @return Pointer to the oxygen diffusion grid
262-
*/
111+
/// Returns the diffusion grid for oxygen
263112
DiffusionGrid* GetOxygenDiffusionGrid() const { return oxygen_dgrid_; }
264-
265-
/** @brief Get the diffusion grid for immunostimulatory factors
266-
* @return Pointer to the immunostimulatory factor diffusion grid
267-
*/
113+
/// Returns the diffusion grid for immunostimulatory factors
268114
DiffusionGrid* GetImmunostimulatoryFactorDiffusionGrid() const { return immunostimulatory_factor_dgrid_; }
269-
270-
/** @} */ // end of Diffusion Grids group
271-
272-
/** @name Core Simulation Methods
273-
* @brief Core methods for cell simulation and behavior
274-
* @{
275-
*/
276-
115+
277116
/** @brief Change volume using exponential relaxation equation
278117
*
279118
* This method explicitly solves the system of exponential relaxation differential
@@ -317,7 +156,6 @@ class CartCell : public Cell {
317156
*/
318157
void ComputeConstantsConsumptionSecretion();
319158

320-
/** @} */ // end of Core Simulation Methods group
321159

322160
/** @name Private Member Variables
323161
* @brief Private attributes of the CAR-T cell
@@ -396,12 +234,8 @@ class CartCell : public Cell {
396234
struct StateControlCart : public Behavior {
397235
BDM_BEHAVIOR_HEADER(StateControlCart, Behavior, 1);
398236

399-
/** @brief Default constructor
400-
* Calls AlwaysCopyToNew() to ensure the behavior is copied to new cells
401-
*/
402237
StateControlCart() { AlwaysCopyToNew(); }
403238

404-
/** @brief Virtual destructor */
405239
virtual ~StateControlCart() {}
406240

407241
/** @brief Execute the state control behavior

src/cart_tumor.cc

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,100 @@
1818
* for the compiler-research.org organization.
1919
*/
2020
#include "cart_tumor.h"
21+
#include "tumor_cell.h"
22+
#include "cart_cell.h"
23+
#include "diffusion_thomas_algorithm.h"
24+
#include "forces_tumor_cart.h"
25+
#include "core/environment/uniform_grid_environment.h"
26+
#include "core/operation/mechanical_forces_op.h"
27+
28+
namespace bdm {
29+
30+
int Simulate(int argc, const char** argv) {
31+
// Set simulation bounds
32+
auto set_param = [](Param* param) {
33+
param->random_seed = kSeed; // Set a fixed random seed for reproducibility
34+
param->bound_space = Param::BoundSpaceMode::kTorus;// Periodic boundary
35+
param->min_bound = -kBoundedSpaceLength/2;
36+
param->max_bound = kBoundedSpaceLength/2; // Cube of 1000x1000x1000 centered at origin
37+
param->simulation_time_step = kDt;
38+
};
39+
40+
Simulation simulation(argc, argv, set_param);
41+
auto* ctxt = simulation.GetExecutionContext();
42+
43+
//Change Forces
44+
auto* scheduler = simulation.GetScheduler();
45+
46+
auto* op = scheduler->GetOps("mechanical forces")[0];
47+
op->GetImplementation<MechanicalForcesOp>()->SetInteractionForce(new InteractionVelocity());
48+
49+
auto* env = dynamic_cast<UniformGridEnvironment*>(Simulation::GetActive()->GetEnvironment());
50+
// Fix the box length for the uniform grid environment
51+
env->SetBoxLength(kLengthBoxMechanics);
52+
53+
// Define Substances
54+
auto* rm = Simulation::GetActive()->GetResourceManager();
55+
56+
// Oxygen
57+
// substance_id, name, diffusion_coefficient, decay_constant, resolution, time_step
58+
auto* oxygen_grid = new DiffusionThomasAlgorithm(
59+
kOxygen, "oxygen",
60+
kDiffusionCoefficientOxygen,// 100000 micrometers^2/minute
61+
kDecayConstantOxygen, // 0.1 minutes^-1
62+
kResolutionGridSubstances,
63+
kDtSubstances,
64+
true); // true indicates Dirichlet border conditions
65+
rm->AddContinuum(oxygen_grid);
66+
67+
// Immunostimulatory Factor
68+
// substance_id, name, diffusion_coefficient, decay_constant, resolution
69+
auto* immunostimulatory_factor_grid = new DiffusionThomasAlgorithm(
70+
kImmunostimulatoryFactor, "immunostimulatory_factor",
71+
kDiffusionCoefficientImmunostimulatoryFactor, // 1000 micrometers^2/minute
72+
kDecayConstantImmunostimulatoryFactor, // 0.016 minutes^-1
73+
kResolutionGridSubstances,
74+
kDtSubstances,
75+
false); // false indicates Neumann border conditions
76+
rm->AddContinuum(immunostimulatory_factor_grid);
77+
78+
// Boundary Conditions Dirichlet: simulating absorption or total loss at the boundaries of the space.
79+
//Oxygen comming from the borders (capillary vessels)
80+
ModelInitializer::AddBoundaryConditions(
81+
kOxygen, BoundaryConditionType::kDirichlet,
82+
std::make_unique<ConstantBoundaryCondition>(kOxygenReferenceLevel));// kOxygenReferenceLevel mmHg is the physiological level of oxygen in tissues, o2 saturation is 100% at this level
83+
84+
//This is useless now but should be added this way in a future version of BioDynaMo
85+
ModelInitializer::AddBoundaryConditions(
86+
kImmunostimulatoryFactor, BoundaryConditionType::kNeumann, nullptr);
87+
88+
//Initialize oxygen voxels
89+
ModelInitializer::InitializeSubstance(kOxygen, [](real_t x, real_t y, real_t z) {
90+
return kInitialOxygenLevel; // Set all voxels to kInitialOxygenLevel mmHg
91+
});
92+
93+
// One spherical tumor of radius kInitialRadiusTumor in the center of the simulation space
94+
std::vector<Real3> positions=CreateSphereOfTumorCells(kInitialRadiusTumor);//positions of the cells
95+
for (const auto& pos : positions) {
96+
TumorCell* tumor_cell = new TumorCell(pos);
97+
tumor_cell->AddBehavior(new StateControlGrowProliferate());
98+
ctxt->AddAgent(tumor_cell);
99+
}
100+
101+
//OutputSummary operation
102+
auto* summary_op = new bdm::Operation("OutputSummary");
103+
// Set the interval for outputting CSV files
104+
summary_op->frequency_ = kOutputCsvInterval;
105+
summary_op->AddOperationImpl(bdm::kCpu, new bdm::OutputSummary());
106+
scheduler->ScheduleOp(summary_op);
107+
108+
// Run simulation
109+
//simulate kTotalMinutesToSimulate minutes including the last minute
110+
scheduler->Simulate(1+kTotalMinutesToSimulate/kDt);
111+
std::cout << "Simulation completed successfully!" << std::endl;
112+
return 0;
113+
}
114+
115+
} // namespace bdm
21116

22117
int main(int argc, const char** argv) { return bdm::Simulate(argc, argv); }

0 commit comments

Comments
 (0)