Skip to content

Commit

Permalink
Add new TT3-Mixed-Model for transmurality example
Browse files Browse the repository at this point in the history
  • Loading branch information
bergolho committed Jan 22, 2024
1 parent 8ec255a commit cef01d2
Show file tree
Hide file tree
Showing 11 changed files with 894 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# x | | x
# |______|
# -----------------------------------------------------------------------------------------------
# Execute:> ./bin/MonoAlg3D -c example_configs/intro_to_monoalg3d/EX05_transmurality_modeling.ini
# Execute:> ./bin/MonoAlg3D -c example_configs/intro_to_monoalg3d/EX05_transmurality_modeling_torord_land.ini
# Visualize:> ./bin/MonoAlg3D_visualizer ./outputs/EX05_IntroMonoAlg_plain_mesh_healthy_transmurality_200um
# - The simulation can be open on Paraview as well!
# ===============================================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Version: 12/01/2024
# ===============================================================================================
# Author: Lucas Berg (@bergolho)
# Last update: 12/01/2024
# Description: Plain wave simulation using a slab (5,5cm x 5,5cm) using a
# space discretization of 200um. Here, we model transmurality across
# the domain using three types of cells (ENDO/MCELL/EPI).
# Stimulus:
# - Two pulses with a Basic Cycle Length (BCL) equal to 1000ms
# Cellular model:
# - Ten & Tusscher 3
# ECG:
# - Two electrodes positioned on each side of the slab.
#
# ______ x = electrodes
# | |
# x | | x
# |______|
# -----------------------------------------------------------------------------------------------
# Execute:> ./bin/MonoAlg3D -c example_configs/intro_to_monoalg3d/EX06_transmurality_modeling_tt3.ini
# Visualize:> ./bin/MonoAlg3D_visualizer ./outputs/EX06_transmurality_modeling_tt3
# - The simulation can be open on Paraview as well!
# ===============================================================================================
[main]
num_threads=6
dt_pde=0.02
simulation_time=500.0
abort_on_no_activity=false
use_adaptivity=false

[update_monodomain]
main_function=update_monodomain_default

[save_result]
print_rate=200
output_dir=./outputs/EX06_transmurality_modeling_tt3
add_timestamp=false
binary=true
save_ode_state_variables=false
main_function=save_as_ensight

; Anisotropic
[assembly_matrix]
init_function=set_initial_conditions_fvm
sigma_x=0.0001334
sigma_y=0.0000176
sigma_z=0.0000176
main_function=homogeneous_sigma_assembly_matrix

[linear_system_solver]
tolerance=1e-16
use_preconditioner=no
max_iterations=500
library_file=shared_libs/libdefault_linear_system_solver.so
use_gpu=yes
main_function=conjugate_gradient
init_function=init_conjugate_gradient
end_function=end_conjugate_gradient

[domain]
name=Plain Mesh Transmurality
num_layers=1
start_dx=200.0
start_dy=200.0
start_dz=200.0
side_length=55000
main_function=initialize_grid_with_square_mesh

[ode_solver]
dt=0.02
use_gpu=yes
gpu_id=0
library_file=shared_libs/libten_tusscher_tt3_mixed_endo_mid_epi.so

[extra_data]
main_function=set_extra_data_mixed_tt3

[stim_plain_s1]
start = 0.0
duration = 2.0
current = -38.0
x_limit = 500.0
main_function=stim_if_x_less_than

[calc_ecg]
main_function=pseudo_bidomain
init_function=init_pseudo_bidomain
end_function=end_pseudo_bidomain
calc_rate=10
lead1=-5000,27500,50
lead2=60000,27500,50
sigma_b=20
use_gpu=true
filename=./outputs/EX06_transmurality_modeling_tt3/ecg.txt
158 changes: 0 additions & 158 deletions example_configs/plain_mesh_source_sink_mismatch_with_fibrosis.ini

This file was deleted.

28 changes: 18 additions & 10 deletions src/extra_data_library/extra_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,38 +429,46 @@ SET_EXTRA_DATA (set_mixed_model_purkinje_and_tissue)
return (void*)mapping;
}

// 'libten_tusscher_2004_mixed_endo_mid_epi.so' transmurality
// 'libten_tusscher_tt3_mixed_endo_mid_epi.so' with transmurality and fibrosis (all cells healthy)
SET_EXTRA_DATA (set_extra_data_mixed_tt3) {
uint32_t num_active_cells = the_grid->num_active_cells;
real side_length = the_grid->mesh_side_length.x;
struct cell_node ** ac = the_grid->active_cells;

//
struct extra_data_for_tt3 *extra_data = NULL;
extra_data = set_common_tt3_data(config, num_active_cells);

// Divide the domain in three sections (ENDO/MID/EPI)
// The percentages were taken from the ToRORd paper (Transmural experiment)
real side_length_endo = side_length*0.45;
real side_length_mid = side_length_endo + side_length*0.25;
real side_length_epi = side_length_mid + side_length*0.3;

*extra_data_size = sizeof(uint32_t)*(num_active_cells);
uint32_t *mapping = (uint32_t*)malloc(*extra_data_size);

int i;

// Transmurality and fibrosis tags
OMP(parallel for)
for (i = 0; i < num_active_cells; i++) {
for (int i = 0; i < num_active_cells; i++) {

real center_x = ac[i]->center.x;

// Cellular model tags: ENDO = 0; MCELL = 1; EPI = 2
// Tag the model transmurality
// ENDO=0, MID=1, EPI=2
if (center_x < side_length_endo)
mapping[i] = 0.0;
extra_data->transmurality[i] = 0.0;
else if (center_x >= side_length_endo && center_x < side_length_mid)
mapping[i] = 1.0;
extra_data->transmurality[i] = 1.0;
else
mapping[i] = 2.0;
extra_data->transmurality[i] = 2.0;

// Tag the fibrosis region
extra_data->fibrosis[i] = 1.0;
}

return (void*)mapping;
SET_EXTRA_DATA_SIZE(sizeof(struct extra_data_for_tt3));

return (void*)extra_data;
}

// Initial condition - 'libToRORd_fkatp_mixed_endo_mid_epi.so' + transmurality + current modifiers (plain and cuboid)
Expand Down
42 changes: 42 additions & 0 deletions src/extra_data_library/helper_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,48 @@ struct extra_data_for_fibrosis* set_common_schemia_data(struct config *config, u
return extra_data;
}

struct extra_data_for_tt3* set_common_tt3_data (struct config *config, uint32_t num_cells) {

struct extra_data_for_tt3 *extra_data = MALLOC_ONE_TYPE(struct extra_data_for_tt3);

real atpi = 6.8;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, atpi, config, "atpi");

real Ko = 5.4;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, Ko, config, "Ko");

real Ki = 138.3;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, Ki, config, "Ki");

real GNa_multiplicator = 1.0f;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, GNa_multiplicator, config, "GNa_multiplicator");

real GCaL_multiplicator = 1.0f;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, GCaL_multiplicator, config, "GCaL_multiplicator");

real INaCa_multiplicator = 1.0f;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, INaCa_multiplicator, config, "INaCa_multiplicator");

real Vm_modifier = 0.0f;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, Vm_modifier, config, "Vm_modifier");

real Ikatp_multiplicator = 1.0f;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real, Ikatp_multiplicator, config, "Ikatp_multiplicator");

extra_data->atpi = atpi;
extra_data->Ko = Ko;
extra_data->Ki = Ki;
extra_data->GNa_multiplicator = GNa_multiplicator;
extra_data->GCaL_multiplicator = GCaL_multiplicator;
extra_data->INaCa_multiplicator = INaCa_multiplicator;
extra_data->Ikatp_multiplicator = Ikatp_multiplicator;
extra_data->Vm_modifier = Vm_modifier;
extra_data->fibrosis = MALLOC_ARRAY_OF_TYPE(real, num_cells);
extra_data->transmurality = MALLOC_ARRAY_OF_TYPE(real, num_cells);

return extra_data;
}

struct extra_data_for_torord * set_common_torord_data (struct config *config, uint32_t num_cells) {
struct extra_data_for_torord *extra_data = MALLOC_ONE_TYPE(struct extra_data_for_torord);

Expand Down
14 changes: 14 additions & 0 deletions src/extra_data_library/helper_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ struct extra_data_for_fibrosis {
real *fibrosis;
};

struct extra_data_for_tt3 {
real atpi;
real Ko;
real Ki;
real GNa_multiplicator;
real GCaL_multiplicator;
real INaCa_multiplicator;
real Ikatp_multiplicator;
real Vm_modifier;
real *fibrosis;
real *transmurality;
};

struct extra_data_for_torord {
real INa_Multiplier;
real ICaL_Multiplier;
Expand Down Expand Up @@ -108,6 +121,7 @@ struct extra_data_for_trovato {
};

struct extra_data_for_fibrosis * set_common_schemia_data(struct config *config, uint32_t num_cells);
struct extra_data_for_tt3 * set_common_tt3_data (struct config *config, uint32_t num_cells);
struct extra_data_for_torord * set_common_torord_data (struct config *config, uint32_t num_cells);
struct extra_data_for_torord * set_common_torord_dyncl_data (struct config *config, uint32_t num_cells);
struct extra_data_for_torord_land * set_common_torord_Land_data (struct config *config, uint32_t num_cells);
Expand Down
Loading

0 comments on commit cef01d2

Please sign in to comment.