From da910e22826574b99b1ec9cda5818984e4590bea Mon Sep 17 00:00:00 2001 From: shofmeyr Date: Thu, 31 Oct 2024 06:28:09 -1000 Subject: [PATCH] Add print out of age group counts --- examples/inputs.nm | 46 +++++++++++++++++++++--------------------- src/AgentContainer.H | 4 +++- src/AgentContainer.cpp | 36 +++++++++++++++++++++++++++++++-- src/CensusData.cpp | 3 --- src/UrbanPopData.cpp | 2 -- src/main.cpp | 2 ++ 6 files changed, 62 insertions(+), 31 deletions(-) diff --git a/examples/inputs.nm b/examples/inputs.nm index 9ee9205..8ce1ebf 100644 --- a/examples/inputs.nm +++ b/examples/inputs.nm @@ -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 diff --git a/src/AgentContainer.H b/src/AgentContainer.H index 462f6ba..44b21d6 100644 --- a/src/AgentContainer.H +++ b/src/AgentContainer.H @@ -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 m_disease_names; /*!< names of the diseases */ diff --git a/src/AgentContainer.cpp b/src/AgentContainer.cpp index 827dbdd..2d1c51f 100644 --- a/src/AgentContainer.cpp +++ b/src/AgentContainer.cpp @@ -896,7 +896,7 @@ void AgentContainer::interactNight (MultiFab& a_mask_behavior /*!< Masking behav void AgentContainer::printStudentTeacherCounts() const { ReduceOps reduce_ops; + ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum, ReduceOpSum> reduce_ops; auto r = ParticleReduce> ( *this, [=] AMREX_GPU_DEVICE (const AgentContainer::ParticleTileType::ConstParticleTileDataType& ptd, const int i) noexcept @@ -931,4 +931,36 @@ void AgentContainer::printStudentTeacherCounts() const { << " Total " << total_educators << " " << total_students << " " << ((Real)total_students / total_educators) << "\n"; } -} \ No newline at end of file +} + +void AgentContainer::printAgeGroupCounts() const { + ReduceOps reduce_ops; + auto r = ParticleReduce> ( + *this, [=] AMREX_GPU_DEVICE (const AgentContainer::ParticleTileType::ConstParticleTileDataType& ptd, + const int i) noexcept + -> GpuTuple + { + 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 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"; + } +} diff --git a/src/CensusData.cpp b/src/CensusData.cpp index d43b6f5..193e125 100644 --- a/src/CensusData.cpp +++ b/src/CensusData.cpp @@ -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) { diff --git a/src/UrbanPopData.cpp b/src/UrbanPopData.cpp index 9e95b2b..1fd613d 100644 --- a/src/UrbanPopData.cpp +++ b/src/UrbanPopData.cpp @@ -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(); } diff --git a/src/main.cpp b/src/main.cpp index ddc4f16..a41abbf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -223,6 +223,8 @@ void runAgent () } else { Abort("Unimplemented ic_type"); } + pc.printStudentTeacherCounts(); + pc.printAgeGroupCounts(); } //#define DUMP_INITIAL_AGENTS_ASCII