Skip to content

Commit

Permalink
New 'evaluateBenchmarkCV' script
Browse files Browse the repository at this point in the history
  • Loading branch information
bergolho committed Jun 2, 2024
2 parents 0008f6e + 82a5e32 commit 736bf15
Show file tree
Hide file tree
Showing 13 changed files with 3,846 additions and 31 deletions.
15 changes: 1 addition & 14 deletions src/domains_library/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ SET_SPATIAL_DOMAIN(initialize_grid_with_rabbit_mesh) {
return num_loaded > 0;
}

/**
* Sets the current domain as a domain described in the N-version benchmark
* (http://rsta.royalsocietypublishing.org/content/369/1954/4331)
*/
SET_SPATIAL_DOMAIN(initialize_grid_with_benchmark_mesh) {

real_cpu side_length;
Expand All @@ -141,15 +137,6 @@ SET_SPATIAL_DOMAIN(initialize_grid_with_benchmark_mesh) {
real_cpu max_h = start_h;
GET_PARAMETER_NUMERIC_VALUE_OR_USE_DEFAULT(real_cpu, max_h, config, "maximum_discretization");

real_cpu side_length_x = 20000.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, side_length_x, config, "side_length_x");

real_cpu side_length_y = 7000.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, side_length_y, config, "side_length_y");

real_cpu side_length_z = 3000.0;
GET_PARAMETER_NUMERIC_VALUE_OR_REPORT_ERROR(real_cpu, side_length_z, config, "side_length_z");

log_info("Loading N-Version benchmark mesh using dx %lf um, dy %lf um, dz %lf um\n", start_h, start_h, start_h);

side_length = start_h;
Expand All @@ -163,7 +150,7 @@ SET_SPATIAL_DOMAIN(initialize_grid_with_benchmark_mesh) {
int num_steps = get_num_refinement_steps_to_discretization(side_length, start_h);

refine_grid(the_grid, num_steps);
set_benchmark_domain(the_grid, side_length_x, side_length_y, side_length_z);
set_benchmark_domain(the_grid);

log_info("Cleaning grid\n");
int i;
Expand Down
29 changes: 17 additions & 12 deletions src/domains_library/domain_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,13 @@ int calculate_cuboid_side_lengths(real_cpu start_dx, real_cpu start_dy, real_cpu
* (http://rsta.royalsocietypublishing.org/content/369/1954/4331)
*
*/
void set_benchmark_domain(struct grid *the_grid, real_cpu sx, real_cpu sy, real_cpu sz) {
void set_benchmark_domain(struct grid *the_grid) {
struct cell_node *grid_cell = the_grid->first_cell;

//real_cpu sx, sy, sz;
//sx = 20000;
//sy = 7000;
//sz = 3000;
real_cpu sx, sy, sz;
sx = 20000;
sy = 7000;
sz = 3000;

while(grid_cell != 0) {
grid_cell->active = (grid_cell->center.x < sx) && (grid_cell->center.y < sy) && (grid_cell->center.z < sz);
Expand Down Expand Up @@ -1013,7 +1013,7 @@ int calc_num_refs(real_cpu start_h, real_cpu desired_h) {
void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu phi, real_cpu plain_center_x, real_cpu plain_center_y, \
real_cpu sphere_radius, real_cpu bz_size, real_cpu bz_radius, unsigned fib_seed, real_cpu cone_slope) {

log_info("Making %.2lf %% of cells inactive\n", phi * 100.0f);
struct cell_node *grid_cell;

if(fib_seed == 0)
fib_seed = (unsigned)time(NULL) + getpid();
Expand All @@ -1022,9 +1022,10 @@ void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu

log_info("Using %u as seed\n", fib_seed);

real_cpu bz_radius_2 = pow(bz_radius, 2.0);
real_cpu sphere_radius_2 = pow(sphere_radius, 2.0);
struct cell_node *grid_cell;
real_cpu a1 = (2.0*side_length) / (side_length - 2*source_sink_min_x);
real_cpu b1 = -source_sink_min_x*a1;
real_cpu a2 = (2.0*side_length) / (side_length - 2*source_sink_max_x);
real_cpu b2 = -source_sink_max_x*a2;

grid_cell = the_grid->first_cell;
while(grid_cell != 0) {
Expand Down Expand Up @@ -1073,11 +1074,15 @@ void set_cuboid_sphere_fibrosis_with_conic_path(struct grid *the_grid, real_cpu
distance_from_center = (distance_from_center - sphere_radius) / bz_size;
real_cpu phi_local = phi - phi * distance_from_center;
real_cpu p = (real_cpu)(rand()) / (RAND_MAX);
if(p < phi_local)
if(p < phi) {
grid_cell->active = false;
grid_cell->can_change = false;
}

INITIALIZE_FIBROTIC_INFO(grid_cell);
FIBROTIC(grid_cell) = true;
}
}

grid_cell = grid_cell->next;
}
}
}
2 changes: 1 addition & 1 deletion src/domains_library/domain_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int set_cuboid_domain_mesh(struct grid *the_grid, real_cpu start_dx, real_cpu st
real_cpu side_length_z);
int set_square_mesh(struct config *config, struct grid *the_grid);

void set_benchmark_domain(struct grid *the_grid, real_cpu sx, real_cpu sy, real_cpu sz);
void set_benchmark_domain(struct grid *the_grid);
void set_cuboid_domain(struct grid *the_grid, real_cpu sizeX, real_cpu sizeY, real_cpu sizeZ);

void set_custom_mesh(struct grid *the_grid, const char *file_name, size_t size, char *read_format);
Expand Down
25 changes: 24 additions & 1 deletion src/extra_data_library/extra_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,4 +626,27 @@ SET_EXTRA_DATA(set_extra_data_trovato) {

return (void*)extra_data;

}
}

// For cable simulations for tuneCV
SET_EXTRA_DATA(set_extra_data_for_cable_ToRORd_Land_mixed_endo_mid_epi_IKs) {
uint32_t num_active_cells = the_grid->num_active_cells;
struct cell_node ** ac = the_grid->active_cells;

struct extra_data_for_torord_land_twave *extra_data = NULL;
extra_data = set_common_torord_Land_twave_data(config, num_active_cells);

// All cells will be the same type
OMP(parallel for)
for (int i = 0; i < num_active_cells; i++) {
// ENDO
extra_data->transmurality[i] = 0.0;
extra_data->sf_IKs[i] = 1.0;
}

SET_EXTRA_DATA_SIZE(sizeof(struct extra_data_for_torord_land_twave));

return (void*)extra_data;


}
Loading

0 comments on commit 736bf15

Please sign in to comment.