Fundamentals 8 min read

How a Simple Java Simulation Reveals COVID‑19 Spread Dynamics

This article explains a Java‑based epidemic simulation that models virus transmission using a normal distribution, demonstrates how parameters like initial infections, transmission rate, hospital capacity, and mobility affect outbreak curves, and shows how adjusting these values can illustrate the impact of public health interventions.

ITPUB
ITPUB
ITPUB
How a Simple Java Simulation Reveals COVID‑19 Spread Dynamics

Simulation Model

A Java program models virus spread in a closed population. Individuals and their movement intentions are sampled from normal (Gaussian) distributions, while the virus transmission rate is a fixed constant. The model tracks infection status, incubation delay, hospital isolation, and resource limits.

Key Parameters

Initial infected count public static int ORIGINAL_COUNT = 50; Transmission rate (BROAD_RATE) public static float BROAD_RATE = 0.8f; Incubation period (SHADOW_TIME) – number of simulation steps before an infected individual becomes contagious. 0 means no delay; 140 represents 14 days. public static float SHADOW_TIME = 0; Hospital response time (HOSPITAL_RECEIVE_TIME) – steps from diagnosis to isolation. public static int HOSPITAL_RECEIVE_TIME = 10; Hospital bed capacity (BED_COUNT) – number of isolation beds available at the start of the outbreak. public static int BED_COUNT = 0; Mobility intention (u) – average tendency to move. Positive values allow free movement; negative values simulate strict movement restrictions.

public static float u = 0.99f;

Scenario Experiments

1. No Hospital Capacity, High Mobility

Configuration: ORIGINAL_COUNT = 50, BED_COUNT = 0, u = 0.99f. The simulation shows rapid exponential growth because infected individuals cannot be isolated.

Scenario 1 animation
Scenario 1 animation

2. Adding Hospital Beds

Increasing BED_COUNT to 100 provides isolation capacity, which flattens the infection curve.

public static int BED_COUNT = 100;
Scenario 2 animation
Scenario 2 animation

When mobility is also reduced (lower u), the outbreak can be quickly contained.

3. Long Incubation Period

Setting SHADOW_TIME = 140 (14 days) mimics COVID‑19’s latent period. Early spread appears hidden; once the incubation ends, cases surge and overwhelm hospital capacity.

public static float SHADOW_TIME = 140;
Scenario 3 animation
Scenario 3 animation

4. Reducing Mobility

Assigning a negative mobility value ( u = -0.99f) simulates strict movement restrictions, dramatically curtailing transmission.

public static float u = -0.99f;
Scenario 4 animation
Scenario 4 animation

Insights

The experiments demonstrate that the mobility intention parameter u dominates epidemic dynamics. Adequate hospital capacity and a short HOSPITAL_RECEIVE_TIME reduce the peak, but a long incubation period ( SHADOW_TIME) hides early cases, making early detection essential. Controlling population movement is the most effective lever to prevent explosive growth.

Source Code

The full source code is available on GitHub:

https://github.com/KikiLetGo/VirusBroadcast/tree/master/src

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaModelingParameter TuningCOVID-19Virus Spread
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.