Reaction-Diffusion model
ReactionDiffusion3D
Bases: TumorGrowthModel3D
A 3D reaction-diffusion model for simulating tumor growth.
This class extends the TumorGrowthModel3D
base class to implement a reaction-diffusion
framework with support for radiotherapy and chemotherapy. The model incorporates spatial
diffusion, proliferation dynamics, and treatment effects.
Attributes:
Name | Type | Description |
---|---|---|
k |
Tensor
|
Tumor growth rate parameter (proliferation rate). |
d |
Tensor
|
Tumor diffusion coefficient (spatial spread rate). |
theta |
Tensor
|
Carrying capacity of the tumor cells (maximum density). |
bcs |
Tensor
|
Boundary conditions derived from the patient brain mask. |
brain_mask |
Tensor
|
Binary mask indicating the brain region. |
radiotherapy_specification |
Optional[RadiotherapySpecification]
|
Specification of radiotherapy protocol. |
radiotherapy_days |
Optional[dict]
|
Dictionary mapping days (since initial time) to radiotherapy doses. |
chemotherapy_specifications |
Optional[List[ChemotherapySpecification]]
|
List of chemotherapy protocols. |
t_initial |
datetime
|
Initial time of the simulation. |
fd_stencil_backward_coeff |
List[Tensor]
|
Backward finite-difference coefficients for each axis. |
fd_stencil_central_coeff |
List[Tensor]
|
Central finite-difference coefficients for each axis. |
fd_stencil_forward_coeff |
List[Tensor]
|
Forward finite-difference coefficients for each axis. |
device |
device
|
The device on which to perform computations (e.g., CPU or GPU). |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the model with parameters and treatment specifications. |
forward |
Computes the rate of change of tumor density at a given time step. |
callback_step |
Applies treatment effects (e.g., radiotherapy) and ensures constraints on the tumor density. |
_compute_laplacian |
Computes the spatial Laplacian of the tumor density field. |
_backward_slice |
Extracts the backward slice along a given axis. |
_central_slice |
Extracts the central slice along a given axis. |
_forward_slice |
Extracts the forward slice along a given axis. |
__init__(k, d, theta, patient_data, initial_time, *, radiotherapy_specification=None, chemotherapy_specifications=None, radiotherapy_days=None, require_grad=True, device=torch.device('cpu'))
Initializes the ReactionDiffusion3D model with patient-specific data and parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
k
|
Tensor
|
Tumor proliferation rate tensor. |
required |
d
|
Tensor
|
Tumor diffusion coefficient tensor. |
required |
theta
|
Tensor
|
Tumor carrying capacity tensor. |
required |
patient_data
|
HGGPatientData
|
Patient-specific data including brain mask and imaging. |
required |
initial_time
|
datetime
|
Initial simulation time. |
required |
radiotherapy_specification
|
Optional[RadiotherapySpecification]
|
Radiotherapy protocol. |
None
|
chemotherapy_specifications
|
Optional[List[ChemotherapySpecification]]
|
Chemotherapy protocols. |
None
|
radiotherapy_days
|
Optional[dict]
|
Mapping of radiotherapy days to doses. |
None
|
require_grad
|
bool
|
Whether the parameters |
True
|
callback_step(t, u, dt)
Handles per-step updates during the simulation, including applying treatment effects.
This method updates the tumor density field by applying radiotherapy effects (if specified) and ensures the tumor density is clamped within valid bounds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
Tensor
|
Current simulation time. |
required |
u
|
Tensor
|
Tumor density field. |
required |
dt
|
Tensor
|
Time step duration. |
required |
Returns:
Name | Type | Description |
---|---|---|
u |
Tensor
|
Updated tumor density field. |
callback_step_adjoint(t, u, dt)
Handles per-step updates during the backward pass of the adjoint method.
This method updates the adjoint variables by applying radiotherapy effects (if specified).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
Tensor
|
Current simulation time. |
required |
u
|
Tensor
|
Adjoint variables. |
required |
dt
|
Tensor
|
Time step duration. |
required |
Returns:
Name | Type | Description |
---|---|---|
u |
Tensor
|
Updated adjoint variables. |
forward(t, u)
Computes the rate of change of tumor density at a given time step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
Tensor
|
Current simulation time (in days). |
required |
u
|
Tensor
|
Tumor density field. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
torch.Tensor: Rate of change of tumor density. |