From ce9ee8ee26c191f86dac70c0cfe52f6716ebe3c1 Mon Sep 17 00:00:00 2001 From: Daniel Bergman Date: Thu, 29 Aug 2024 14:03:39 -0400 Subject: [PATCH] Replace all time checks with improved version Specifically, any time check I found (searching the codebase for uses of `fabs`), I replaced with the form: ``` current_time > next_event_time - 0.5 * diffusion_dt ``` Assuming diffusion_dt really is the smallest time step, this will evaluate true at the time step closest to next_event_time. Importantly, this will never accumulate floating point errors to the point where the check fails. This has happened with the save checks: ``` abs( current_time - next_save_time ) < 0.01 * diffusion_dt ``` Finally, this is ever so slightly more robust than a user's suggestion to convert save times to integers as this does not rely on time steps being multiples of one another. --- addons/PhysiMeSS/PhysiMeSS.cpp | 3 +-- core/PhysiCell_cell_container.cpp | 4 ++-- examples/PhysiCell_test_DCIS.cpp | 2 +- examples/PhysiCell_test_HDS.cpp | 2 +- examples/PhysiCell_test_cell_cycle.cpp | 2 +- examples/PhysiCell_test_mechanics_1.cpp | 2 +- examples/PhysiCell_test_mechanics_2.cpp | 3 +-- examples/PhysiCell_test_volume.cpp | 2 +- sample_projects/biorobots/main.cpp | 5 +++-- sample_projects/cancer_biorobots/main.cpp | 4 ++-- sample_projects/cancer_immune/main-cancer_immune_3D.cpp | 4 ++-- sample_projects/celltypes3/main.cpp | 4 ++-- sample_projects/custom_division/main.cpp | 4 ++-- sample_projects/heterogeneity/main.cpp | 4 ++-- sample_projects/immune_test_2024/main.cpp | 4 ++-- sample_projects/interactions/main.cpp | 4 ++-- sample_projects/mechano/main.cpp | 4 ++-- sample_projects/physimess/main.cpp | 4 ++-- sample_projects/pred_prey_farmer/main.cpp | 4 ++-- sample_projects/rules_sample/main.cpp | 4 ++-- sample_projects/template/main.cpp | 4 ++-- sample_projects/virus_macrophage/main.cpp | 4 ++-- sample_projects/worm/main.cpp | 4 ++-- .../boolean/cancer_invasion/main.cpp | 4 ++-- .../boolean/physiboss_cell_lines/main.cpp | 4 ++-- sample_projects_intracellular/boolean/template_BM/main.cpp | 4 ++-- sample_projects_intracellular/boolean/tutorial/main.cpp | 4 ++-- sample_projects_intracellular/fba/cancer_metabolism/main.cpp | 4 ++-- .../fba/ecoli_acetic_switch/main_ecoli_acetic_switch.cpp | 4 ++-- sample_projects_intracellular/ode/ode_energy/main.cpp | 4 ++-- unit_tests/custom_DCs_2substrates/main.cpp | 4 ++-- unit_tests/custom_voxel_values/main.cpp | 4 ++-- .../substrate_internalization/unit_test_conservation.cpp | 4 ++-- 33 files changed, 60 insertions(+), 61 deletions(-) diff --git a/addons/PhysiMeSS/PhysiMeSS.cpp b/addons/PhysiMeSS/PhysiMeSS.cpp index 79034b0a5..5bf99c756 100644 --- a/addons/PhysiMeSS/PhysiMeSS.cpp +++ b/addons/PhysiMeSS/PhysiMeSS.cpp @@ -134,8 +134,7 @@ void physimess_update_cell_velocity( Cell* pCell, Phenotype& phenotype, double d void physimess_mechanics( double dt ) { - static double dt_tolerance = 0.001 * dt; - if(fabs(((PhysiCell_globals.current_time - last_update_time)) - dt) < dt_tolerance) + if ( PhysiCell_globals.current_time >= last_update_time + dt - 0.5 * diffusion_dt) // last_update_time + dt = next update time; - 0.5 * diffusion_dt will give the time step closest to the desired next time (assumign diffusion_dt is the smallest time step) { last_update_time = PhysiCell_globals.current_time; diff --git a/core/PhysiCell_cell_container.cpp b/core/PhysiCell_cell_container.cpp index 3c5547fd5..2f30c518b 100644 --- a/core/PhysiCell_cell_container.cpp +++ b/core/PhysiCell_cell_container.cpp @@ -159,7 +159,7 @@ void Cell_Container::update_all_cells(double t, double phenotype_dt_ , double me } } - if( fabs(time_since_last_cycle-phenotype_dt_ ) < phenotype_dt_tolerance || !initialzed) + if( time_since_last_cycle > phenotype_dt_ - 0.5 * diffusion_dt_ || !initialzed ) { // Reset the max_radius in each voxel. It will be filled in set_total_volume // It might be better if we calculate it before mechanics each time @@ -201,7 +201,7 @@ void Cell_Container::update_all_cells(double t, double phenotype_dt_ , double me double time_since_last_mechanics= t- last_mechanics_time; // if( time_since_last_mechanics>= mechanics_dt || !initialzed) - if( fabs(time_since_last_mechanics - mechanics_dt_) < mechanics_dt_tolerance || !initialzed) + if( time_since_last_mechanics > mechanics_dt_ - 0.5 * diffusion_dt_ || !initialzed ) { if(!initialzed) { diff --git a/examples/PhysiCell_test_DCIS.cpp b/examples/PhysiCell_test_DCIS.cpp index 3aa571941..41b2273ae 100644 --- a/examples/PhysiCell_test_DCIS.cpp +++ b/examples/PhysiCell_test_DCIS.cpp @@ -311,7 +311,7 @@ int main( int argc, char* argv[] ) { while( t < t_max ) { - if( fabs( t - t_next_output_time ) < 0.0001 ) + if( t > t_next_output_time - 0.5 * dt ) { log_output(t, output_index, microenvironment, report_file); t_next_output_time += t_output_interval; diff --git a/examples/PhysiCell_test_HDS.cpp b/examples/PhysiCell_test_HDS.cpp index b56fd69f6..a8a1a6aea 100644 --- a/examples/PhysiCell_test_HDS.cpp +++ b/examples/PhysiCell_test_HDS.cpp @@ -276,7 +276,7 @@ for(int i=0;i t_next_output_time - 0.5 * dt ) { log_output(t, output_index, microenvironment, report_file); t_next_output_time += t_output_interval; diff --git a/examples/PhysiCell_test_cell_cycle.cpp b/examples/PhysiCell_test_cell_cycle.cpp index f00a024f5..00162e4af 100644 --- a/examples/PhysiCell_test_cell_cycle.cpp +++ b/examples/PhysiCell_test_cell_cycle.cpp @@ -272,7 +272,7 @@ int main( int argc, char* argv[] ) { while( t < t_max ) { - if( fabs( t - t_next_output_time ) < 0.0001 ) + if( t > t_next_output_time - 0.5 * dt ) { write_test_report(*all_cells,t); t_next_output_time += t_output_interval; diff --git a/examples/PhysiCell_test_mechanics_1.cpp b/examples/PhysiCell_test_mechanics_1.cpp index 3dad283b5..76a74a10f 100644 --- a/examples/PhysiCell_test_mechanics_1.cpp +++ b/examples/PhysiCell_test_mechanics_1.cpp @@ -209,7 +209,7 @@ int main( int argc, char* argv[] ) while( t < t_max ) { - if( fabs( t - t_next_output_time ) < dt/10.0 ) + if( t > t_next_output_time - 0.5 * dt ) { report_file<position,pCell2->position)<<"\n"; t_next_output_time += t_output_interval; diff --git a/examples/PhysiCell_test_mechanics_2.cpp b/examples/PhysiCell_test_mechanics_2.cpp index ef0bd25cc..3279fdf55 100644 --- a/examples/PhysiCell_test_mechanics_2.cpp +++ b/examples/PhysiCell_test_mechanics_2.cpp @@ -208,8 +208,7 @@ int main( int argc, char* argv[] ) { while( t < t_max ) { - // std::cout<<"time: "< t_next_output_time - 0.5 * dt ) { std::cout<<"time: "< t_next_output_time - 0.5 * dt ) { vol_report<get_total_volume()<<"\t"<phenotype.volume.fluid<<"\t"<phenotype.volume.nuclear_solid<<"\t"<phenotype.volume.cytoplasmic_solid<<"\n"; t_next_output_time += t_output_interval; diff --git a/sample_projects/biorobots/main.cpp b/sample_projects/biorobots/main.cpp index 214399ebb..64f51310c 100644 --- a/sample_projects/biorobots/main.cpp +++ b/sample_projects/biorobots/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,8 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/cancer_biorobots/main.cpp b/sample_projects/cancer_biorobots/main.cpp index 41876503a..7b2131179 100644 --- a/sample_projects/cancer_biorobots/main.cpp +++ b/sample_projects/cancer_biorobots/main.cpp @@ -196,7 +196,7 @@ int main( int argc, char* argv[] ) } // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -216,7 +216,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/cancer_immune/main-cancer_immune_3D.cpp b/sample_projects/cancer_immune/main-cancer_immune_3D.cpp index 3959fb514..10f9aca2f 100644 --- a/sample_projects/cancer_immune/main-cancer_immune_3D.cpp +++ b/sample_projects/cancer_immune/main-cancer_immune_3D.cpp @@ -199,7 +199,7 @@ int main( int argc, char* argv[] ) } // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -219,7 +219,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/celltypes3/main.cpp b/sample_projects/celltypes3/main.cpp index cc2b26152..c329cfdfb 100644 --- a/sample_projects/celltypes3/main.cpp +++ b/sample_projects/celltypes3/main.cpp @@ -222,7 +222,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -242,7 +242,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/custom_division/main.cpp b/sample_projects/custom_division/main.cpp index 2f7e98c75..bf6e65d15 100644 --- a/sample_projects/custom_division/main.cpp +++ b/sample_projects/custom_division/main.cpp @@ -181,7 +181,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -201,7 +201,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/heterogeneity/main.cpp b/sample_projects/heterogeneity/main.cpp index 09bd280c0..98b47d9e5 100644 --- a/sample_projects/heterogeneity/main.cpp +++ b/sample_projects/heterogeneity/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/immune_test_2024/main.cpp b/sample_projects/immune_test_2024/main.cpp index 9d26e541d..8df1843ec 100644 --- a/sample_projects/immune_test_2024/main.cpp +++ b/sample_projects/immune_test_2024/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/interactions/main.cpp b/sample_projects/interactions/main.cpp index 050ba8569..ec4b5f408 100644 --- a/sample_projects/interactions/main.cpp +++ b/sample_projects/interactions/main.cpp @@ -183,7 +183,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -203,7 +203,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/mechano/main.cpp b/sample_projects/mechano/main.cpp index ffe29342f..24c358803 100644 --- a/sample_projects/mechano/main.cpp +++ b/sample_projects/mechano/main.cpp @@ -186,7 +186,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -206,7 +206,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/physimess/main.cpp b/sample_projects/physimess/main.cpp index 9d9d2b67f..86601cdb4 100644 --- a/sample_projects/physimess/main.cpp +++ b/sample_projects/physimess/main.cpp @@ -182,7 +182,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -202,7 +202,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/pred_prey_farmer/main.cpp b/sample_projects/pred_prey_farmer/main.cpp index 2d6ddec87..9797710f0 100644 --- a/sample_projects/pred_prey_farmer/main.cpp +++ b/sample_projects/pred_prey_farmer/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/rules_sample/main.cpp b/sample_projects/rules_sample/main.cpp index 9d26e541d..8df1843ec 100644 --- a/sample_projects/rules_sample/main.cpp +++ b/sample_projects/rules_sample/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/template/main.cpp b/sample_projects/template/main.cpp index 2f7e98c75..bf6e65d15 100644 --- a/sample_projects/template/main.cpp +++ b/sample_projects/template/main.cpp @@ -181,7 +181,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -201,7 +201,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/virus_macrophage/main.cpp b/sample_projects/virus_macrophage/main.cpp index b9fdfca8e..7009514aa 100644 --- a/sample_projects/virus_macrophage/main.cpp +++ b/sample_projects/virus_macrophage/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects/worm/main.cpp b/sample_projects/worm/main.cpp index 2d6ddec87..9797710f0 100644 --- a/sample_projects/worm/main.cpp +++ b/sample_projects/worm/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects_intracellular/boolean/cancer_invasion/main.cpp b/sample_projects_intracellular/boolean/cancer_invasion/main.cpp index 162ce4bc5..eac3e89cf 100644 --- a/sample_projects_intracellular/boolean/cancer_invasion/main.cpp +++ b/sample_projects_intracellular/boolean/cancer_invasion/main.cpp @@ -191,7 +191,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -211,7 +211,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects_intracellular/boolean/physiboss_cell_lines/main.cpp b/sample_projects_intracellular/boolean/physiboss_cell_lines/main.cpp index a3d872462..002ed6092 100644 --- a/sample_projects_intracellular/boolean/physiboss_cell_lines/main.cpp +++ b/sample_projects_intracellular/boolean/physiboss_cell_lines/main.cpp @@ -189,7 +189,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -209,7 +209,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects_intracellular/boolean/template_BM/main.cpp b/sample_projects_intracellular/boolean/template_BM/main.cpp index f30923d04..e1dfd12cb 100644 --- a/sample_projects_intracellular/boolean/template_BM/main.cpp +++ b/sample_projects_intracellular/boolean/template_BM/main.cpp @@ -183,7 +183,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -203,7 +203,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects_intracellular/boolean/tutorial/main.cpp b/sample_projects_intracellular/boolean/tutorial/main.cpp index 8b7814154..0cfa59427 100644 --- a/sample_projects_intracellular/boolean/tutorial/main.cpp +++ b/sample_projects_intracellular/boolean/tutorial/main.cpp @@ -191,7 +191,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -211,7 +211,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects_intracellular/fba/cancer_metabolism/main.cpp b/sample_projects_intracellular/fba/cancer_metabolism/main.cpp index e3bb3381d..0901f0038 100644 --- a/sample_projects_intracellular/fba/cancer_metabolism/main.cpp +++ b/sample_projects_intracellular/fba/cancer_metabolism/main.cpp @@ -185,7 +185,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -205,7 +205,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects_intracellular/fba/ecoli_acetic_switch/main_ecoli_acetic_switch.cpp b/sample_projects_intracellular/fba/ecoli_acetic_switch/main_ecoli_acetic_switch.cpp index eb79727da..e26e6f11f 100644 --- a/sample_projects_intracellular/fba/ecoli_acetic_switch/main_ecoli_acetic_switch.cpp +++ b/sample_projects_intracellular/fba/ecoli_acetic_switch/main_ecoli_acetic_switch.cpp @@ -174,7 +174,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -194,7 +194,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/sample_projects_intracellular/ode/ode_energy/main.cpp b/sample_projects_intracellular/ode/ode_energy/main.cpp index 7b11e6b77..f8e88e18c 100644 --- a/sample_projects_intracellular/ode/ode_energy/main.cpp +++ b/sample_projects_intracellular/ode/ode_energy/main.cpp @@ -176,7 +176,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -196,7 +196,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/unit_tests/custom_DCs_2substrates/main.cpp b/unit_tests/custom_DCs_2substrates/main.cpp index 9d26e541d..8df1843ec 100644 --- a/unit_tests/custom_DCs_2substrates/main.cpp +++ b/unit_tests/custom_DCs_2substrates/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/unit_tests/custom_voxel_values/main.cpp b/unit_tests/custom_voxel_values/main.cpp index 9d26e541d..8df1843ec 100644 --- a/unit_tests/custom_voxel_values/main.cpp +++ b/unit_tests/custom_voxel_values/main.cpp @@ -180,7 +180,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -200,7 +200,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) { diff --git a/unit_tests/substrate_internalization/unit_test_conservation.cpp b/unit_tests/substrate_internalization/unit_test_conservation.cpp index 895956a97..912660a50 100644 --- a/unit_tests/substrate_internalization/unit_test_conservation.cpp +++ b/unit_tests/substrate_internalization/unit_test_conservation.cpp @@ -170,7 +170,7 @@ int main( int argc, char* argv[] ) while( PhysiCell_globals.current_time < PhysiCell_settings.max_time + 0.1*diffusion_dt ) { // save data if it's time. - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_full_save_time - 0.5 * diffusion_dt ) { display_simulation_status( std::cout ); if( PhysiCell_settings.enable_legacy_saves == true ) @@ -190,7 +190,7 @@ int main( int argc, char* argv[] ) } // save SVG plot if it's time - if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + if( PhysiCell_globals.current_time > PhysiCell_globals.next_SVG_save_time - 0.5 * diffusion_dt ) { if( PhysiCell_settings.enable_SVG_saves == true ) {