Draft
Conversation
Implement configurable initial immunity fraction for agent-based disease modeling. Agents can be initialized as immune based on a user-specified fraction (0.0-1.0) per disease, with immune duration sampled from gamma distribution. Changes: - Add initial_immunity_fraction parameter to DiseaseParm structure - Update setAgentData to randomly assign immune status at initialization - Modify Census and UrbanPop initialization to support initial immunity - Update documentation in inputs.defaults and RST files - Support disease-specific parameters for multiple disease simulations Default value is 0.0 (no initial immunity) to maintain backward compatibility.
Create AgentEnums.H to hold shared enum definitions and helper functions used by both AgentDefinitions.H and DiseaseParm.H. This eliminates circular dependency and removes need for forward declarations. Changes: - Create src/AgentEnums.H with AgeGroups, SchoolType, IntIdx, IntIdxDisease, RealIdxDisease, Status, DiseaseStats enums and i0(), r0() helper functions - Update src/AgentDefinitions.H to include AgentEnums.H and remove duplicate definitions - Update src/DiseaseParm.H to include AgentEnums.H instead of AgentDefinitions.H - Include DiseaseParm.H in AgentDefinitions.H after basic definitions to provide complete type for setAgentData function Build completes without warnings or errors.
Modify initial immunity implementation to place agents at random points within their immunity period rather than all starting at the beginning. Changes: - Sample full immune duration from gamma distribution - Set remaining immunity to uniform random value between 0 and full duration - Update both Census and UrbanPop initialization code paths - Update documentation in inputs.defaults and RST files to reflect new behavior This provides more realistic initial conditions for simulations with pre-existing immunity.
Short-circuit the immunity check so amrex::Random(engine) is not called when initial_immunity_fraction is 0.0. Previously, the random draw was consumed unconditionally for every agent, advancing the RNG state and causing results to diverge from baseline even with default parameters.
Replace host pointer arrays with Gpu::AsyncArray to prevent illegal memory access on device. Fixes CUDA error 700 on Nvidia GPUs. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add configurable initial immunity fraction for disease initialization: Implements a new parameter
disease.initial_immunity_fractionthat allows users to specify the fraction of agents (0.0to1.0) that are initially immune at simulation start. This feature supports bothCensusandUrbanPopinitialization types and can be configured per disease in multi-disease simulations.Implementation: Added
initial_immunity_fractionparameter toDiseaseParmstructure with default value0.0. ModifiedsetAgentDatafunction to accept disease parameters and random engine. Updated agent initialization to randomly assign immune status based on specified fraction. Immune duration is sampled from gamma distribution using immune_length_alpha and immune_length_beta parameters. Updated bothCensusandUrbanPopinitialization code paths.Code structure refactoring: Created
AgentEnums.Hto hold shared enum definitions and helper functions, eliminating circular dependency betweenAgentDefinitions.HandDiseaseParm.H. This removes the need for forward declarations and resolves all compilation warnings.Usage: For single disease:
For multiple diseases:
Default value is 0.0, ensuring existing simulations are unaffected unless parameter is explicitly set.