Skip to content

Commit

Permalink
Add print out of age group counts
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenhofmeyr committed Oct 31, 2024
1 parent 0bee8af commit da910e2
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 31 deletions.
46 changes: 23 additions & 23 deletions examples/inputs.nm
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ agent.seed = 11

diag.output_filename = "output.dat"

disease.nstrain = 2
disease.p_trans = 0.20 0.30
disease.p_asymp = 0.40 0.40
disease.reduced_inf = 0.75 0.75
disease.reinfect_prob = 0.0


disease.xmit_comm = 0.000145 0.000145 0.000145 0.000145 0.000145 0.000145
disease.xmit_hood = 0.00058 0.00058 0.00058 0.00058 0.00058 0.00058
disease.xmit_hh_adult = 0.4 0.4 0.4 0.4 0.4 0.4
disease.xmit_hh_child = 0.3 0.3 0.3 0.3 0.3 0.3
disease.xmit_nc_adult = 0.05 0.05 0.05 0.05 0.05 0.05
disease.xmit_nc_child = 0.04 0.04 0.04 0.04 0.04 0.04
disease.xmit_school = 0 0.0315 0.0315 0.0315 0.0315 0.0315
disease.xmit_school_a2c = 0 0.0315 0.0315 0.0315 0.0315 0.0315
disease.xmit_school_c2a = 0 0.0315 0.0315 0.0315 0.0315 0.0315
disease.hospitalization_days = 7 7 7
disease.CHR = 0.070 0.070 0.070 0.070 0.070 0.070
disease.CIC = 0.24 0.24 0.24 0.24 0.24 0.24
disease.CVE = 0.12 0.12 0.12 0.12 0.12 0.12
disease.hospCVF = 0 0 0 0 0 0
disease.icuCVF = 0.1 0.1 0.1 0.1 0.1 0.1
disease.ventCVF = 0.5 0.5 0.5 0.5 0.5 0.5
#disease.nstrain = 2
#disease.p_trans = 0.20 0.30
#disease.p_asymp = 0.40 0.40
#disease.reduced_inf = 0.75 0.75
#disease.reinfect_prob = 0.0


#disease.xmit_comm = 0.000145 0.000145 0.000145 0.000145 0.000145 0.000145
#disease.xmit_hood = 0.00058 0.00058 0.00058 0.00058 0.00058 0.00058
#disease.xmit_hh_adult = 0.4 0.4 0.4 0.4 0.4 0.4
#disease.xmit_hh_child = 0.3 0.3 0.3 0.3 0.3 0.3
#disease.xmit_nc_adult = 0.05 0.05 0.05 0.05 0.05 0.05
#disease.xmit_nc_child = 0.04 0.04 0.04 0.04 0.04 0.04
#disease.xmit_school = 0 0.0315 0.0315 0.0315 0.0315 0.0315
#disease.xmit_school_a2c = 0 0.0315 0.0315 0.0315 0.0315 0.0315
#disease.xmit_school_c2a = 0 0.0315 0.0315 0.0315 0.0315 0.0315
#disease.hospitalization_days = 7 7 7
#disease.CHR = 0.070 0.070 0.070 0.070 0.070 0.070
#disease.CIC = 0.24 0.24 0.24 0.24 0.24 0.24
#disease.CVE = 0.12 0.12 0.12 0.12 0.12 0.12
#disease.hospCVF = 0 0 0 0 0 0
#disease.icuCVF = 0.1 0.1 0.1 0.1 0.1 0.1
#disease.ventCVF = 0.5 0.5 0.5 0.5 0.5 0.5

4 changes: 3 additions & 1 deletion src/AgentContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ public:

void printStudentTeacherCounts() const;

void printAgeGroupCounts() const;

amrex::iMultiFab m_student_counts;
amrex::Real m_student_teacher_ratio = 20;
amrex::Real m_student_teacher_ratio = 15; /*!< Used only for Census data */

int m_num_diseases; /*!< Number of diseases */
std::vector<std::string> m_disease_names; /*!< names of the diseases */
Expand Down
36 changes: 34 additions & 2 deletions src/AgentContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ void AgentContainer::interactNight (MultiFab& a_mask_behavior /*!< Masking behav

void AgentContainer::printStudentTeacherCounts() const {
ReduceOps<ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum,
ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum> reduce_ops;
ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum> reduce_ops;
auto r = ParticleReduce<ReduceData<int, int, int, int, int, int, int, int, int, int>> (
*this, [=] AMREX_GPU_DEVICE (const AgentContainer::ParticleTileType::ConstParticleTileDataType& ptd,
const int i) noexcept
Expand Down Expand Up @@ -931,4 +931,36 @@ void AgentContainer::printStudentTeacherCounts() const {
<< " Total " << total_educators << " " << total_students << " "
<< ((Real)total_students / total_educators) << "\n";
}
}
}

void AgentContainer::printAgeGroupCounts() const {
ReduceOps<ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum> reduce_ops;
auto r = ParticleReduce<ReduceData<int, int, int, int, int, int>> (
*this, [=] AMREX_GPU_DEVICE (const AgentContainer::ParticleTileType::ConstParticleTileDataType& ptd,
const int i) noexcept
-> GpuTuple<int, int, int, int, int, int>
{
int counts[6] = {0, 0, 0, 0, 0, 0};
int age_group = ptd.m_idata[IntIdx::age_group][i];
counts[age_group] = 1;
return {counts[0], counts[1], counts[2], counts[3], counts[4], counts[5]};
}, reduce_ops);

std::array<Long, 6> counts = {amrex::get<0>(r), amrex::get<1>(r), amrex::get<2>(r), amrex::get<3>(r), amrex::get<4>(r),
amrex::get<5>(r)};
ParallelDescriptor::ReduceLongSum(&counts[0], 6, ParallelDescriptor::IOProcessorNumber());
if (ParallelDescriptor::MyProc() == ParallelDescriptor::IOProcessorNumber()) {
int total_agents = 0;
for (int i = 0; i < 6; i++) {
total_agents += counts[i];
}
Print() << "Age group counts (percentage):\n" << std::fixed << std::setprecision(1)
<< " under 5 " << counts[0] << " " << 100.0 * (Real)counts[0] / total_agents << "\n"
<< " 5 to 17 " << counts[1] << " " << 100.0 * (Real)counts[1] / total_agents << "\n"
<< " 18 to 29 " << counts[2] << " " << 100.0 * (Real)counts[2] / total_agents << "\n"
<< " 30 to 49 " << counts[3] << " " << 100.0 * (Real)counts[3] / total_agents << "\n"
<< " 50 to 64 " << counts[4] << " " << 100.0 * (Real)counts[4] / total_agents << "\n"
<< " over 64 " << counts[5] << " " << 100.0 * (Real)counts[5] / total_agents << "\n"
<< " Total " << total_agents << "\n";
}
}
3 changes: 0 additions & 3 deletions src/CensusData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,6 @@ void CensusData::read_workerflow (AgentContainer& pc, /*!< Agent conta
The_Device_Arena()->free(d_flow);

assignTeachersAndWorkgroup(pc, workgroup_size);

// check teacher and student counts
pc.printStudentTeacherCounts();
}

void CensusData::assignTeachersAndWorkgroup (AgentContainer& pc, const int workgroup_size) {
Expand Down
2 changes: 0 additions & 2 deletions src/UrbanPopData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,6 @@ void UrbanPopData::initAgents (AgentContainer &pc, const ExaEpi::TestParams &par
<< "Communities: " << all_num_communities << " (balance " << load_balance_communities << ")\n";

num_communities = all_num_communities;

pc.printStudentTeacherCounts();
}


2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ void runAgent ()
} else {
Abort("Unimplemented ic_type");
}
pc.printStudentTeacherCounts();
pc.printAgeGroupCounts();
}

//#define DUMP_INITIAL_AGENTS_ASCII
Expand Down

0 comments on commit da910e2

Please sign in to comment.