Skip to content

Commit 201b6f7

Browse files
authored
Merge pull request #71 from bergolho/master
Add new scripts/New ToRORd model variant/New option to save the Purkinje on the Ensight save mesh function
2 parents 708f28a + cd6a2d3 commit 201b6f7

25 files changed

+3593
-149
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ sync_local.sh
186186
sync_outputs.sh
187187
private_configs/
188188
private_parameter_sets/
189+
private_src/
189190
/src/domains_library/custom_mesh_info_data.h
190191
retired_code/
191192
*.gcno
@@ -199,3 +200,4 @@ VV_49900.dat
199200
*.build_type*
200201
/ecg.txt
201202
__pycache__/
203+
backup/

example_configs/cable_mesh_with_ToRORd_fkatp_endo_mid_epi.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ x_limit = 500.0
7676
main_function=stim_if_x_less_than
7777

7878
[extra_data]
79-
main_function=set_extra_data_mixed_torord_fkatp_epi_mid_endo
79+
main_function=set_extra_data_mixed_torord_fkatp_epi_mid_endo

scripts/error_calculator/main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ int main (int argc, char *argv[])
7171
cerr << "[-] ERROR! The number of cells are different" << endl;
7272
exit(EXIT_FAILURE);
7373
}
74+
else
75+
{
76+
cout << "[+] Cell number are equal " << total_num_cells_1 << " " << total_num_cells_2 << endl;
77+
}
7478

7579
vtkSmartPointer<vtkFloatArray> array_1 =
7680
vtkFloatArray::SafeDownCast(unstructured_grid_1->GetCellData()->GetArray(array_name.c_str()));

scripts/evaluateBenchmarkCV/main.cpp

+35-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// Author: Lucas Berg
1+
// ------------------------------------------------------------------------------------
2+
// Author: Lucas Berg, Julia Camps and Jenny Wang
3+
// Script to evaluate the conductivities calibrated using the 'tuneCV' on a 3D wedge.
4+
// ------------------------------------------------------------------------------------
25

36
#include <iostream>
47
#include <string>
@@ -27,8 +30,12 @@
2730

2831
using namespace std;
2932

30-
double* calculate_conduction_velocity_from_benchmark_simulation ()
31-
{
33+
// Change your MonoAlg3D path here:
34+
// ----------------------------------------------------------
35+
const char MONOALG_PATH[500] = "/home/berg/Github/MonoAlg3D_C";
36+
// ----------------------------------------------------------
37+
38+
double* calculate_conduction_velocity_from_benchmark_simulation () {
3239
string filename = "outputs/benchmark/tissue_activation_time_map_pulse_it_0.vtu";
3340

3441
// Read all the data from the file
@@ -93,8 +100,7 @@ double* calculate_conduction_velocity_from_benchmark_simulation ()
93100
double cv_y = -1.0;
94101
double cv_z = -1.0;
95102

96-
if(array)
97-
{
103+
if(array) {
98104

99105
double delta_lat_x = (array->GetValue(cellId_x_1) - array->GetValue(cellId_x_0)); // ms
100106
double delta_lat_y = (array->GetValue(cellId_y_1) - array->GetValue(cellId_y_0)); // ms
@@ -109,8 +115,7 @@ double* calculate_conduction_velocity_from_benchmark_simulation ()
109115
cv_y = (delta_s_y / delta_lat_y)*0.001; // {m/s}
110116
cv_z = (delta_s_z / delta_lat_z)*0.001; // {m/s}
111117
}
112-
else
113-
{
118+
else {
114119
cerr << "[!] ERROR! No Scalar_value found for the points!" << endl;
115120
exit(EXIT_FAILURE);
116121
}
@@ -126,31 +131,33 @@ double* calculate_conduction_velocity_from_benchmark_simulation ()
126131
// TODO: Maybe pass a pre-configured config file as an input parameter with the cellular model setup that the user will use
127132
void write_configuration_file (const double sigma_x, const double sigma_y, const double sigma_z)
128133
{
129-
FILE *file = fopen("/home/Julia/MonoAlg3D_C/scripts/evaluateBenchmarkCV/configs/benchmark.ini","w+");
134+
char filename[500];
135+
sprintf(filename,"%s/scripts/evaluateBenchmarkCV/configs/benchmark.ini",MONOALG_PATH);
136+
FILE *file = fopen(filename,"w+");
130137

131138
fprintf(file,"[main]\n");
132139
fprintf(file,"num_threads=6\n");
133140
fprintf(file,"dt_pde=0.01\n");
134-
fprintf(file,"simulation_time=50.0\n"); // CAREFUL DON'T USE A VALUE THAT'S TOO SMALL!
141+
fprintf(file,"simulation_time=100.0\n"); // CAREFUL DON'T USE A VALUE THAT'S TOO SMALL!
135142
fprintf(file,"abort_on_no_activity=false\n");
136143
fprintf(file,"use_adaptivity=false\n");
137144
fprintf(file,"quiet=true\n");
138145
fprintf(file,"\n");
139146

140147
fprintf(file,"[update_monodomain]\n");
141148
fprintf(file,"main_function=update_monodomain_default\n");
142-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libdefault_update_monodomain.so\n");
149+
fprintf(file,"library_file=%s/shared_libs/libdefault_update_monodomain.so\n",MONOALG_PATH);
143150
fprintf(file,"\n");
144151

145152
// For saving the LATs in a format that can be read for calculating the CVs
146153
fprintf(file,"[save_result]\n");
147154
fprintf(file,"print_rate=1\n");
148-
fprintf(file,"output_dir=/home/Julia/MonoAlg3D_C/scripts/evaluateBenchmarkCV/outputs/benchmark\n");
155+
fprintf(file,"output_dir=%s/scripts/evaluateBenchmarkCV/outputs/benchmark\n",MONOALG_PATH);
149156
fprintf(file,"save_pvd=true\n");
150157
fprintf(file,"file_prefix=V\n");
151158
fprintf(file,"save_activation_time=true\n");
152159
fprintf(file,"save_apd=false\n");
153-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libdefault_save_mesh_purkinje.so\n");
160+
fprintf(file,"library_file=%s/shared_libs/libdefault_save_mesh_purkinje.so\n",MONOALG_PATH);
154161
fprintf(file,"main_function=save_tissue_with_activation_times\n");
155162
fprintf(file,"init_function=init_save_tissue_with_activation_times\n");
156163
fprintf(file,"end_function=end_save_tissue_with_activation_times\n");
@@ -161,10 +168,10 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
161168
// For saving the VMs for debugging
162169
fprintf(file,"[save_result]\n");
163170
fprintf(file,"print_rate=100\n");
164-
fprintf(file,"output_dir=/home/Julia/MonoAlg3D_C/scripts/evaluateBenchmarkCV/outputs/benchmark\n");
171+
fprintf(file,"output_dir=%s/scripts/evaluateBenchmarkCV/outputs/benchmark\n",MONOALG_PATH);
165172
fprintf(file,"add_timestamp=false\n");
166173
fprintf(file,"binary=true\n");
167-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libdefault_save_mesh.so\n");
174+
fprintf(file,"library_file=%s/shared_libs/libdefault_save_mesh.so\n",MONOALG_PATH);
168175
fprintf(file,"main_function=save_as_ensight\n");
169176
fprintf(file,"remove_older_simulation=true\n");
170177
fprintf(file,"\n");
@@ -175,7 +182,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
175182
fprintf(file,"sigma_x=%g\n",sigma_x);
176183
fprintf(file,"sigma_y=%g\n",sigma_y);
177184
fprintf(file,"sigma_z=%g\n",sigma_z);
178-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libdefault_matrix_assembly.so\n");
185+
fprintf(file,"library_file=%s/shared_libs/libdefault_matrix_assembly.so\n",MONOALG_PATH);
179186
fprintf(file,"main_function=homogeneous_sigma_assembly_matrix\n");
180187
fprintf(file,"\n");
181188

@@ -184,7 +191,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
184191
fprintf(file,"use_preconditioner=no\n");
185192
fprintf(file,"use_gpu=yes\n");
186193
fprintf(file,"max_iterations=200\n");
187-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libdefault_linear_system_solver.so\n");
194+
fprintf(file,"library_file=%s/shared_libs/libdefault_linear_system_solver.so\n",MONOALG_PATH);
188195
fprintf(file,"init_function=init_conjugate_gradient\n");
189196
fprintf(file,"end_function=end_conjugate_gradient\n");
190197
fprintf(file,"main_function=conjugate_gradient\n");
@@ -194,7 +201,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
194201
fprintf(file,"name=N-Version Benchmark\n");
195202
fprintf(file,"start_discretization=500.0\n");
196203
fprintf(file,"maximum_discretization=500.0\n");
197-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libdefault_domains.so\n");
204+
fprintf(file,"library_file=%s/shared_libs/libdefault_domains.so\n",MONOALG_PATH);
198205
fprintf(file,"main_function=initialize_grid_with_benchmark_mesh\n");
199206
fprintf(file,"side_length_x=20000\n");
200207
fprintf(file,"side_length_y=10000\n");
@@ -205,7 +212,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
205212
fprintf(file,"dt=0.01\n");
206213
fprintf(file,"use_gpu=yes\n");
207214
fprintf(file,"gpu_id=0\n");
208-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libToRORd_fkatp_mixed_endo_mid_epi.so\n");
215+
fprintf(file,"library_file=%s/shared_libs/libToRORd_fkatp_mixed_endo_mid_epi_GKsGKrtjca_adjustments.so\n",MONOALG_PATH);
209216
fprintf(file,"\n");
210217

211218
fprintf(file,"[stim_benchmark]\n");
@@ -219,26 +226,25 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
219226
fprintf(file, "min_z = 0.0\n");
220227
fprintf(file, "max_z = 3000.0\n");
221228
fprintf(file,"main_function=stim_x_y_z_limits\n");
222-
fprintf(file,"library_file=/home/Julia/MonoAlg3D_C/shared_libs/libdefault_stimuli.so\n");
229+
fprintf(file,"library_file=%s/shared_libs/libdefault_stimuli.so\n",MONOALG_PATH);
223230
fprintf(file,"\n");
224231

225232
fclose(file);
226233
}
227234

228-
int main (int argc, char *argv[])
229-
{
230-
if (argc-1 != 6)
231-
{
235+
int main (int argc, char *argv[]) {
236+
if (argc-1 != 6) {
232237
cerr << "=============================================================================" << endl;
233238
cerr << "Usage:> " << argv[0] << " <target_cv_x>" << " <target_cv_y>" << " <target_cv_z>" << \
234239
" <sigma_x>" << " <sigma_y>" << " <sigma_z>" << endl;
235240
cerr << "=============================================================================" << endl;
236241
cerr << "<target_CV> = Target conduction velocity in m/s" << endl;
242+
cerr << "<sigma> = Target conductivity in mS/um" << endl;
237243
cerr << "=============================================================================" << endl;
238244
cerr << "Example:" << endl;
239-
cerr << argv[1] << " 0.67 (Longitudinal normal direction ventricle)" << endl;
240-
cerr << argv[2] << " 0.33 (Transversal normal direction ventricle)" << endl;
241-
cerr << argv[3] << " 0.17 (Sheet normal direction ventricle)" << endl;
245+
cerr << argv[1] << " 0.65 (Longitudinal direction ventricle)" << endl;
246+
cerr << argv[2] << " 0.39 (Transversal direction ventricle)" << endl;
247+
cerr << argv[3] << " 0.48 (Normal direction ventricle)" << endl;
242248
cerr << "=============================================================================" << endl;
243249

244250
exit(EXIT_FAILURE);
@@ -255,7 +261,9 @@ int main (int argc, char *argv[])
255261
write_configuration_file(sigma_x, sigma_y, sigma_z);
256262

257263
// Run the simulation
258-
system("/home/Julia/MonoAlg3D_C/bin/MonoAlg3D -c /home/Julia/MonoAlg3D_C/scripts/evaluateBenchmarkCV/configs/benchmark.ini");
264+
char command[500];
265+
sprintf(command,"%s/bin/MonoAlg3D -c %s/scripts/evaluateBenchmarkCV/configs/benchmark.ini",MONOALG_PATH,MONOALG_PATH);
266+
system(command);
259267

260268
double* cv;
261269
cv = calculate_conduction_velocity_from_benchmark_simulation();

0 commit comments

Comments
 (0)