Skip to content

Commit

Permalink
update and merge air travel code
Browse files Browse the repository at this point in the history
  • Loading branch information
tannguyen153 committed Oct 4, 2024
2 parents 5089d4e + 673646e commit db218d1
Show file tree
Hide file tree
Showing 26 changed files with 1,318 additions and 1,328 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ docs/doxyhtml
docs/doxyxml
docs/exaepi-doxygen-web.tag.xml
docs/amrex-doxygen-web.tag.xml
.vscode
.build
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ project( ExaEpi
#VERSION ${AMREX_PKG_VERSION}
)

# Defines a DEBUG symbol for use in the code
add_compile_options("$<$<CONFIG:DEBUG>:-DDEBUG>")

set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake )

set(AMReX_PARTICLES ON)
Expand Down Expand Up @@ -72,3 +75,4 @@ foreach (_subdir IN LISTS AMREX_AGENT_SUBDIRS)
add_subdirectory(${_dir})
endforeach ()
endforeach ()

4 changes: 2 additions & 2 deletions docs/source/usage/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ Data is either written as an ``int`` or a ``real``.

- Real data:

- ``incubation_period``: (currently misleadingly named) Latent period length, i.e. time between exposure and infectiousness.
- ``latent_period``: Latent period length, i.e. time between exposure and infectiousness.

- ``infectious_period``: Infections period length, i.e. time during which agent can spread disease

- ``symptomdev_period``: Symptom development period length (known as incubation period in some contexts), i.e. time between exposure and symptoms appearing.
- ``incubation_period``: Symptom development period length (known as incubation period in some contexts), i.e. time between exposure and symptoms appearing.

- Every day (time-varying)

Expand Down
6 changes: 3 additions & 3 deletions etc/plot_infected.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"never = []\n",
"with open(\"agent_data/run_9_cases.out\") as f:\n",
" for line in f:\n",
" if line.startswith(\"Never infected: \"):\n",
" if line.startswith(\"Susceptible: \"):\n",
" never.append(int(line.strip().split()[-1]))\n",
" if line.startswith(\"Infected: \"):\n",
" infected.append(int(line.strip().split()[1]))\n",
" if line.startswith(\"Immune: \"):\n",
" if line.startswith(\"Recovered: \"):\n",
" immune.append(int(line.strip().split()[1]))"
]
},
Expand All @@ -53,7 +53,7 @@
"ax = plt.gca()\n",
"ax.set_xlabel(\"Day\")\n",
"ax.set_ylabel(\"Number\")\n",
"plt.legend((\"Never infected\", \"Infected\", \"Immune\"))\n",
"plt.legend((\"Susceptible\", \"Infected\", \"Recovered\"))\n",
"\n",
"plt.savefig(\"infected_9_cases\")"
]
Expand Down
37 changes: 14 additions & 23 deletions src/AgentContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AgentContainer
using PType = ParticleType;
using PTileType = ParticleTileType;
using PTDType = PTileType::ParticleTileDataType;
using IntModel = InteractionModel<PCType,PTileType,PTDType,PType>;
using IntModel = InteractionModel<PCType, PTDType, PType>;

using MFPtr = std::unique_ptr<MultiFab>;
using MFPtrVec = std::vector<MFPtr>;
Expand All @@ -45,7 +45,8 @@ public:
const amrex::DistributionMapping & a_dmap,
const amrex::BoxArray & a_ba,
const int & a_num_diseases,
const std::vector<std::string> & a_disease_names);
const std::vector<std::string> & a_disease_names,
const bool fast);

void morningCommute(amrex::MultiFab&);

Expand All @@ -57,19 +58,17 @@ public:

void interactNight(amrex::MultiFab&);

void interactRandomTravel(amrex::MultiFab&, AgentContainer& on_travel_pc);
void moveAirTravel (const amrex::iMultiFab& unit_mf, AirTravelFlow& air, DemographicData& demo);

void interactAirTravel(amrex::MultiFab&, AgentContainer& on_travel_pc);
void setAirTravel (const iMultiFab& unit_mf, AirTravelFlow& air, DemographicData& demo);

void moveAgentsRandomWalk ();

void moveRandomTravel ();
void moveAirTravel (const amrex::iMultiFab& unit_mf, AirTravelFlow& air, DemographicData& demo);
void setAirTravel (const iMultiFab& unit_mf, AirTravelFlow& air, DemographicData& demo);
void moveRandomTravel (const amrex::Real random_travel_prob);

void returnRandomTravel (const AgentContainer& on_travel_pc);
void returnRandomTravel ();

void returnAirTravel (const AgentContainer& on_travel_pc);
void returnAirTravel ();

void updateStatus (MFPtrVec&);

Expand All @@ -83,12 +82,12 @@ public:

std::array<amrex::Long, 9> getTotals (const int);

int getMaxGroup(const int group_idx);

void moveAgentsToWork ();

void moveAgentsToHome ();

amrex::DenseBins<PType>* getBins(const std::pair<int,int>& a_idx, const std::string& a_mod_name);

/*! \brief Return flag indicating if agents are at work */
inline bool isAtWork() const {
return m_at_work;
Expand Down Expand Up @@ -164,25 +163,17 @@ protected:
std::vector<DiseaseParm*> m_h_parm; /*!< Disease parameters */
std::vector<DiseaseParm*> m_d_parm; /*!< Disease parameters (GPU device) */

/*! Map of home bins (of agents) indexed by MultiFab iterator and tile index;
see AgentContainer::interactAgentsHomeWork() */
std::map<std::pair<int, int>, amrex::DenseBins<PType> > m_bins_home;
/*! Map of work bins (of agents) indexed by MultiFab iterator and tile index;
see AgentContainer::interactAgentsHomeWork() */
std::map<std::pair<int, int>, amrex::DenseBins<PType> > m_bins_work;
/*! Map of air and random travel bins (of agents) indexed by MultiFab iterator and tile index;
see AgentContainer::interactAgentsRandom() */
std::map<std::pair<int, int>, amrex::DenseBins<PType> > m_bins_travel;

std::map<std::string,IntModel*> m_interactions; /*!< Map of interaction models */
std::unique_ptr<HospitalModel<PCType,PTileType,PTDType,PType>> m_hospital; /*!< hospital model */
std::map<std::string, IntModel*> m_interactions; /*!< Map of interaction models */
std::unique_ptr<HospitalModel<PCType, PTDType, PType>> m_hospital; /*!< hospital model */

/*! Flag to indicate if agents are at work */
bool m_at_work;

/*! Disease status update model */
DiseaseStatus<PCType,PTileType,PTDType,PType> m_disease_status;

Array<int, IntIdx::nattribs> max_attribute_values;

/*! \brief queries if a given interaction type (model) is available */
inline bool haveInteractionModel( const std::string& a_mod_name ) const {
return (m_interactions.find(a_mod_name) != m_interactions.end());
Expand Down
Loading

0 comments on commit db218d1

Please sign in to comment.