Skip to content

Commit

Permalink
Merge branch 'development' into dg/hospitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
debog committed Aug 13, 2024
2 parents f67e1b1 + 550b5a9 commit 3800fff
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
5 changes: 5 additions & 0 deletions src/AgentContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ public:
}
}

/*! \brief Return flag indicating if agents are at work */
inline bool isAtWork() const {
return m_at_work;
}

/*! \brief Return disease parameters object pointer (host) */
inline const DiseaseParm* getDiseaseParameters_h (int d /*!< disease index */) const {
return h_parm[d];
Expand Down
4 changes: 2 additions & 2 deletions src/AgentContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,15 @@ void AgentContainer::initAgentsCensus (iMultiFab& num_residents, /*!< Number
hosp_i_ptr[ip] = -1;
hosp_j_ptr[ip] = -1;
nborhood_ptr[ip] = nborhood;
work_nborhood_ptr[ip] = 5*nborhood;
work_nborhood_ptr[ip] = nborhood;
workgroup_ptr[ip] = 0;

if (age_group == 0) {
school_ptr[ip] = 5; // note - need to handle playgroups
} else if (age_group == 1) {
school_ptr[ip] = assign_school(nborhood, engine);
} else {
school_ptr[ip] = -1;
school_ptr[ip] = 0; // only use negative values to indicate school closed
}

// Increment the appropriate student counter based on the school assignment
Expand Down
4 changes: 2 additions & 2 deletions src/AgentDefinitions.H
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ struct SchoolType
total = 0, /*!< All School type */
high, /*!< High School */
middle, /*!< Middle School */
elem_3, /*!< Elementary School Neighbordhood 1 */
elem_4, /*!< Elementary School Neighbordhood 2 */
elem_3, /*!< Elementary School Neighbordhood 1 & 2 */
elem_4, /*!< Elementary School Neighbordhood 3 & 4 */
day_care, /*!< Day care + Playground */
total_school_type
};
Expand Down
17 changes: 13 additions & 4 deletions src/Initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ namespace Initialization
auto work_i_ptr = soa.GetIntData(IntIdx::work_i).data();
auto work_j_ptr = soa.GetIntData(IntIdx::work_j).data();
auto workgroup_ptr = soa.GetIntData(IntIdx::workgroup).data();
auto work_nborhood_ptr = soa.GetIntData(IntIdx::work_nborhood).data();
auto np = soa.numParticles();

auto unit_arr = unit_mf[mfi].array();
Expand Down Expand Up @@ -198,6 +199,7 @@ namespace Initialization

if (number) {
workgroup_ptr[ip] = 1 + amrex::Random_int(number, engine);
work_nborhood_ptr[ip] = workgroup_ptr[ip] % 4; // each workgroup is assigned to a neighborhood as well
}
}
});
Expand Down Expand Up @@ -248,6 +250,7 @@ namespace Initialization
auto work_i_ptr = soa.GetIntData(IntIdx::work_i).data();
auto work_j_ptr = soa.GetIntData(IntIdx::work_j).data();
auto school_ptr = soa.GetIntData(IntIdx::school).data();
auto work_nborhood_ptr = soa.GetIntData(IntIdx::work_nborhood).data();

auto Ndaywork = demo.Ndaywork_d.data();
auto Start = demo.Start_d.data();
Expand Down Expand Up @@ -290,24 +293,29 @@ namespace Initialization
{
int choice = amrex::Random_int(total_available);
if (choice < available_slots[0]) {
school_ptr[ip] = 3; // elementary 3 school
school_ptr[ip] = 3; // elementary school for kids in Neighbordhood 1 & 2
workgroup_ptr[ip] = 3 ;
work_nborhood_ptr[ip] = 1; // assuming the first elementary school is located in Neighbordhood 1
elem3_teacher_counts_ptr[comm_to]++;
} else if (choice < available_slots[0] + available_slots[1]) {
school_ptr[ip] = 4; // elementary 4 school
school_ptr[ip] = 4; // elementary school for kids in Neighbordhood 3 & 4
workgroup_ptr[ip] = 4 ;
work_nborhood_ptr[ip] = 3; // assuming the first elementary school is located in Neighbordhood 3
elem4_teacher_counts_ptr[comm_to]++;
} else if (choice < available_slots[0] + available_slots[1] + available_slots[2]) {
school_ptr[ip] = 2; // middle school
school_ptr[ip] = 2; // middle school for kids in all Neighbordhoods (1 through 4)
workgroup_ptr[ip] = 2 ;
work_nborhood_ptr[ip] = 3; // assuming the middle school is located in Neighbordhood 2
middle_teacher_counts_ptr[comm_to]++;
} else if (choice < available_slots[0] + available_slots[1] + available_slots[2] + available_slots[3]) {
school_ptr[ip] = 1; // high school
school_ptr[ip] = 1; // high school for kids in all Neighbordhoods (1 through 4)
workgroup_ptr[ip] = 1 ;
work_nborhood_ptr[ip] = 4; // assuming the high school is located in Neighbordhood 4
high_teacher_counts_ptr[comm_to]++;
} else if (choice < total_available) {
school_ptr[ip] = 5; // day care
workgroup_ptr[ip] = 5 ;
work_nborhood_ptr[ip] = 1; // deal with daycare/playgroups later
daycr_teacher_counts_ptr[comm_to]++;
}
}
Expand All @@ -319,6 +327,7 @@ namespace Initialization

if (number) {
workgroup_ptr[ip] = 6 + amrex::Random_int(number);
work_nborhood_ptr[ip] = workgroup_ptr[ip] % 4; // each workgroup is assigned to a neighborhood as well
}

}
Expand Down
30 changes: 21 additions & 9 deletions src/InteractionModNborhood.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static void binaryInteractionNborhood ( const int a_i, /*!< Index of infectious
const DiseaseParm* const a_lparm, /*!< disease paramters */
const Real a_social_scale, /*!< Social scale */
ParticleReal* const a_prob_ptr, /*!< infection probability */
const bool a_at_work_ptr, /*!< whether agents are at work or at home */
const int a_thread /*!< agent index of this thread */)
{
Real infect = a_lparm->infect;
Expand All @@ -31,28 +32,37 @@ static void binaryInteractionNborhood ( const int a_i, /*!< Index of infectious
auto nborhood_ptr = a_ptd.m_idata[IntIdx::nborhood];
auto school_ptr = a_ptd.m_idata[IntIdx::school];
auto withdrawn_ptr = a_ptd.m_idata[IntIdx::withdrawn];
auto work_nborhood_ptr = a_ptd.m_idata[IntIdx::work_nborhood];

if (withdrawn_ptr[a_i] || withdrawn_ptr[a_j]) { return; }

//infect *= i_mask;
//infect *= j_mask;
ParticleReal prob = 1.0_prt;

/* define neighbordhood based on whether agent is in home or work community */
int nborhood_ai = nborhood_ptr[a_i];
int nborhood_aj = nborhood_ptr[a_j];
if (a_at_work_ptr) {
nborhood_ai = (age_group_ptr[a_i] <= 1) ? nborhood_ptr[a_i] : work_nborhood_ptr[a_i];
nborhood_aj = (age_group_ptr[a_j] <= 1) ? nborhood_ptr[a_j] : work_nborhood_ptr[a_j];
}

// school < 0 means a child normally attends school, but not today
/* Should always be in the same community = same cell */
if (school_ptr[a_i] < 0) { // not attending school, use _SC contacts
prob *= 1.0_prt - infect * a_lparm->xmit_comm_SC[age_group_ptr[a_j]] * a_social_scale;
} else {
prob *= 1.0_prt - infect * a_lparm->xmit_comm[age_group_ptr[a_j]] * a_social_scale;
}
// /* Neighborhood? */
if (nborhood_ptr[a_i] == nborhood_ptr[a_j]) {
if (school_ptr[a_i] < 0) {
// not attending school, use _SC contacts
if (nborhood_ai == nborhood_aj) {
if (school_ptr[a_i] < 0 ) { // not attending school, use _SC contacts
prob *= 1.0_prt - infect * a_lparm->xmit_hood_SC[age_group_ptr[a_j]] * a_social_scale;
} else {
prob *= 1.0_prt - infect * a_lparm->xmit_hood[age_group_ptr[a_j]] * a_social_scale;
}
} else { // /* Community? */
if (school_ptr[a_i] < 0) { // not attending school, use _SC contacts
prob *= 1.0_prt - infect * a_lparm->xmit_comm_SC[age_group_ptr[a_j]] * a_social_scale;
} else {
prob *= 1.0_prt - infect * a_lparm->xmit_comm[age_group_ptr[a_j]] * a_social_scale;
}
}

AMREX_ASSERT(a_j == a_thread);
Expand Down Expand Up @@ -132,6 +142,7 @@ void InteractionModNborhood<AC,ACT,ACTD,A>::interactAgents( AC& a_agents, /*!< A
auto pair_ind = std::make_pair(mfi.index(), mfi.LocalTileIndex());
auto bins_ptr = a_agents.getBins(pair_ind, ExaEpi::InteractionNames::nborhood);

auto flag_at_work = a_agents.isAtWork(); /*! Flag to indicate if agents are at work */
auto& ptile = a_agents.ParticlesAt(lev, mfi);
const auto& ptd = ptile.getParticleTileData();
auto& aos = ptile.GetArrayOfStructs();
Expand Down Expand Up @@ -178,6 +189,7 @@ void InteractionModNborhood<AC,ACT,ACTD,A>::interactAgents( AC& a_agents, /*!< A
lparm,
social_scale,
prob_ptr,
flag_at_work,
i );
}
}
Expand All @@ -189,4 +201,4 @@ void InteractionModNborhood<AC,ACT,ACTD,A>::interactAgents( AC& a_agents, /*!< A
}
}

#endif
#endif

0 comments on commit 3800fff

Please sign in to comment.