Skip to content

Commit

Permalink
Fix formatting and timing of the output.dat files
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers committed Apr 5, 2024
1 parent 0fd174c commit df70230
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
20 changes: 11 additions & 9 deletions src/AgentContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,12 +841,14 @@ void AgentContainer::updateStatus (MultiFab& disease_stats /*!< Community-wise d
}
else if (status_ptr[i] == Status::infected) {
counter_ptr[i] += 1;
if (amrex::Random(engine) < lparm->p_asymp[0]) {
symptomatic_ptr[i] = 2;
} else {
symptomatic_ptr[i] = 0;
if (counter_ptr[i] == 1) {
if (amrex::Random(engine) < lparm->p_asymp[0]) {
symptomatic_ptr[i] = 2;
} else {
symptomatic_ptr[i] = 0;
}
}
if (counter_ptr[i] == amrex::Math::ceil(symptomdev_period_ptr[i])) {
if (counter_ptr[i] == amrex::Math::floor(symptomdev_period_ptr[i])) {
if (symptomatic_ptr[i] != 2) {
symptomatic_ptr[i] = 1;
}
Expand All @@ -858,7 +860,7 @@ void AgentContainer::updateStatus (MultiFab& disease_stats /*!< Community-wise d
// incubation phase
return;
}
if (counter_ptr[i] == amrex::Math::ceil(incubation_period_ptr[i])) {
if (counter_ptr[i] == amrex::Math::floor(incubation_period_ptr[i])) {
// decide if hospitalized
Real p_hosp = CHR[age_group_ptr[i]];
if (amrex::Random(engine) < p_hosp) {
Expand Down Expand Up @@ -1312,7 +1314,7 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M
AMREX_ALWAYS_ASSERT( (Long) i < np);
if (status_ptr[i] == Status::immune) { return; }
if (status_ptr[i] == Status::dead) { return; }
if (status_ptr[i] == Status::infected && counter_ptr[i] < incubation_period_ptr[i]) { return; } // incubation stage
if ((status_ptr[i] == Status::infected) && (counter_ptr[i] < incubation_period_ptr[i])) { return; } // incubation stage
//amrex::Real i_mask = mask_arr(home_i_ptr[i], home_j_ptr[i], 0);
for (unsigned int jj = cell_start; jj < cell_stop; ++jj) {
auto j = inds[jj];
Expand All @@ -1321,7 +1323,7 @@ void AgentContainer::interactAgentsHomeWork ( MultiFab& /*mask_behavior*/ /*!< M
//amrex::Real j_mask = mask_arr(home_i_ptr[j], home_j_ptr[j], 0);
if (status_ptr[j] == Status::immune) {continue;}
if (status_ptr[j] == Status::dead) {continue;}
if (status_ptr[j] == Status::infected && counter_ptr[j] < incubation_period_ptr[j]) { continue; } // incubation stage
if ((status_ptr[j] == Status::infected) && (counter_ptr[j] < incubation_period_ptr[j])) { continue; } // incubation stage

if (status_ptr[j] == Status::infected &&
(status_ptr[i] != Status::infected && status_ptr[i] != Status::dead)) {
Expand Down Expand Up @@ -1494,7 +1496,7 @@ std::array<Long, 9> AgentContainer::getTotals () {
AMREX_ALWAYS_ASSERT(p.idata(IntIdx::status) <= 4);
s[p.idata(IntIdx::status)] = 1;
if (p.idata(IntIdx::status) == 1) { // exposed
if (p.rdata(RealIdx::disease_counter) <= amrex::Math::ceil(p.rdata(RealIdx::incubation_period))) {
if (p.rdata(RealIdx::disease_counter) <= p.rdata(RealIdx::incubation_period)) {
s[5] = 1; // exposed, but not infectious
} else { // infectious
if (p.idata(IntIdx::symptomatic) == 2) {
Expand Down
41 changes: 21 additions & 20 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void runAgent ()
amrex::FileOpenFailed(output_filename);
}

File << "Day Never Infected Immune Deaths Hospitalized Ventilated ICU Exposed Asymptomatic Presymptomatic Symptomatic\n";
File << std::setw(5) << "Day" << std::setw(10) << "Never" << std::setw(10) << "Infected" << std::setw(10) << "Immune" << std::setw(10) << "Deaths" << std::setw(15) << "Hospitalized" << std::setw(15) << "Ventilated" << std::setw(10) << "ICU" << std::setw(10) << "Exposed" << std::setw(15) << "Asymptomatic" << std::setw(15) << "Presymptomatic" << std::setw(15) << "Symptomatic\n";

File.flush();

Expand Down Expand Up @@ -191,25 +191,7 @@ void runAgent ()
ExaEpi::IO::writeFIPSData(pc, unit_mf, FIPS_mf, comm_mf, demo, params.aggregated_diag_prefix, i);
}

if (params.shelter_start > 0 && params.shelter_start == i) {
pc.shelterStart();
}

if (params.shelter_start > 0 && params.shelter_start + params.shelter_length == i) {
pc.shelterStop();
}

pc.updateStatus(disease_stats);
pc.moveAgentsToWork();
pc.interactAgentsHomeWork(mask_behavior, false);
pc.moveAgentsToHome();
pc.interactAgentsHomeWork(mask_behavior, true);
pc.infectAgents();

// if ((params.random_travel_int > 0) && (i % params.random_travel_int == 0)) {
// pc.moveRandomTravel();
// }
// pc.Redistribute();

auto counts = pc.getTotals();
if (counts[1] > num_infected_peak) {
Expand Down Expand Up @@ -254,7 +236,7 @@ void runAgent ()
amrex::FileOpenFailed(output_filename);
}

File << i << " " << counts[0] << " " << counts[1] << " " << counts[2] << " " << counts[4] << " " << mmc[0] << " " << mmc[1] << " " << mmc[2] << " " << counts[5] << " " << counts[6] << " " << counts[7] << " " << counts[8] << "\n";
File << std::setw(5) << i << std::setw(10) << counts[0] << std::setw(10) << counts[1] << std::setw(10) << counts[2] << std::setw(10) << counts[4] << std::setw(15) << mmc[0] << std::setw(15) << mmc[1] << std::setw(10) << mmc[2] << std::setw(10) << counts[5] << std::setw(15) << counts[6] << std::setw(15) << counts[7] << std::setw(15) << counts[8] << "\n";

File.flush();

Expand All @@ -265,6 +247,25 @@ void runAgent ()
}
}

if (params.shelter_start > 0 && params.shelter_start == i) {
pc.shelterStart();
}

if (params.shelter_start > 0 && params.shelter_start + params.shelter_length == i) {
pc.shelterStop();
}

pc.moveAgentsToWork();
pc.interactAgentsHomeWork(mask_behavior, false);
pc.moveAgentsToHome();
pc.interactAgentsHomeWork(mask_behavior, true);
pc.infectAgents();

// if ((params.random_travel_int > 0) && (i % params.random_travel_int == 0)) {
// pc.moveRandomTravel();
// }
// pc.Redistribute();

cur_time += 1.0; // time step is one day
}
}
Expand Down

0 comments on commit df70230

Please sign in to comment.