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
+ // ------------------------------------------------------------------------------------
2
5
3
6
#include < iostream>
4
7
#include < string>
27
30
28
31
using namespace std ;
29
32
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 () {
32
39
string filename = " outputs/benchmark/tissue_activation_time_map_pulse_it_0.vtu" ;
33
40
34
41
// Read all the data from the file
@@ -93,8 +100,7 @@ double* calculate_conduction_velocity_from_benchmark_simulation ()
93
100
double cv_y = -1.0 ;
94
101
double cv_z = -1.0 ;
95
102
96
- if (array)
97
- {
103
+ if (array) {
98
104
99
105
double delta_lat_x = (array->GetValue (cellId_x_1) - array->GetValue (cellId_x_0)); // ms
100
106
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 ()
109
115
cv_y = (delta_s_y / delta_lat_y)*0.001 ; // {m/s}
110
116
cv_z = (delta_s_z / delta_lat_z)*0.001 ; // {m/s}
111
117
}
112
- else
113
- {
118
+ else {
114
119
cerr << " [!] ERROR! No Scalar_value found for the points!" << endl;
115
120
exit (EXIT_FAILURE);
116
121
}
@@ -126,31 +131,33 @@ double* calculate_conduction_velocity_from_benchmark_simulation ()
126
131
// TODO: Maybe pass a pre-configured config file as an input parameter with the cellular model setup that the user will use
127
132
void write_configuration_file (const double sigma_x, const double sigma_y, const double sigma_z)
128
133
{
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+" );
130
137
131
138
fprintf (file," [main]\n " );
132
139
fprintf (file," num_threads=6\n " );
133
140
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!
135
142
fprintf (file," abort_on_no_activity=false\n " );
136
143
fprintf (file," use_adaptivity=false\n " );
137
144
fprintf (file," quiet=true\n " );
138
145
fprintf (file," \n " );
139
146
140
147
fprintf (file," [update_monodomain]\n " );
141
148
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 );
143
150
fprintf (file," \n " );
144
151
145
152
// For saving the LATs in a format that can be read for calculating the CVs
146
153
fprintf (file," [save_result]\n " );
147
154
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 );
149
156
fprintf (file," save_pvd=true\n " );
150
157
fprintf (file," file_prefix=V\n " );
151
158
fprintf (file," save_activation_time=true\n " );
152
159
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 );
154
161
fprintf (file," main_function=save_tissue_with_activation_times\n " );
155
162
fprintf (file," init_function=init_save_tissue_with_activation_times\n " );
156
163
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
161
168
// For saving the VMs for debugging
162
169
fprintf(file,"[save_result]\n");
163
170
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 );
165
172
fprintf(file,"add_timestamp=false\n");
166
173
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 );
168
175
fprintf(file,"main_function=save_as_ensight\n");
169
176
fprintf(file,"remove_older_simulation=true\n");
170
177
fprintf(file,"\n");
@@ -175,7 +182,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
175
182
fprintf (file," sigma_x=%g\n " ,sigma_x);
176
183
fprintf (file," sigma_y=%g\n " ,sigma_y);
177
184
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 );
179
186
fprintf (file," main_function=homogeneous_sigma_assembly_matrix\n " );
180
187
fprintf (file," \n " );
181
188
@@ -184,7 +191,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
184
191
fprintf (file," use_preconditioner=no\n " );
185
192
fprintf (file," use_gpu=yes\n " );
186
193
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 );
188
195
fprintf (file," init_function=init_conjugate_gradient\n " );
189
196
fprintf (file," end_function=end_conjugate_gradient\n " );
190
197
fprintf (file," main_function=conjugate_gradient\n " );
@@ -194,7 +201,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
194
201
fprintf (file," name=N-Version Benchmark\n " );
195
202
fprintf (file," start_discretization=500.0\n " );
196
203
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 );
198
205
fprintf (file," main_function=initialize_grid_with_benchmark_mesh\n " );
199
206
fprintf (file," side_length_x=20000\n " );
200
207
fprintf (file," side_length_y=10000\n " );
@@ -205,7 +212,7 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
205
212
fprintf (file," dt=0.01\n " );
206
213
fprintf (file," use_gpu=yes\n " );
207
214
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 );
209
216
fprintf (file," \n " );
210
217
211
218
fprintf (file," [stim_benchmark]\n " );
@@ -219,26 +226,25 @@ void write_configuration_file (const double sigma_x, const double sigma_y, const
219
226
fprintf (file, " min_z = 0.0\n " );
220
227
fprintf (file, " max_z = 3000.0\n " );
221
228
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 );
223
230
fprintf (file," \n " );
224
231
225
232
fclose (file);
226
233
}
227
234
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 ) {
232
237
cerr << " =============================================================================" << endl;
233
238
cerr << " Usage:> " << argv[0 ] << " <target_cv_x>" << " <target_cv_y>" << " <target_cv_z>" << \
234
239
" <sigma_x>" << " <sigma_y>" << " <sigma_z>" << endl;
235
240
cerr << " =============================================================================" << endl;
236
241
cerr << " <target_CV> = Target conduction velocity in m/s" << endl;
242
+ cerr << " <sigma> = Target conductivity in mS/um" << endl;
237
243
cerr << " =============================================================================" << endl;
238
244
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;
242
248
cerr << " =============================================================================" << endl;
243
249
244
250
exit (EXIT_FAILURE);
@@ -255,7 +261,9 @@ int main (int argc, char *argv[])
255
261
write_configuration_file (sigma_x, sigma_y, sigma_z);
256
262
257
263
// 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);
259
267
260
268
double * cv;
261
269
cv = calculate_conduction_velocity_from_benchmark_simulation ();
0 commit comments