Skip to main content

A SIR diffusive model based in CuPy

Project description

CuSIR

Introduction

CuSIR is a Python code built on top of CuPy, a NumPy-like library for GPU-accelerated computing. It provides a solver for the two-dimensional diffusive SIR model, described by the following system of reaction-diffusion equations:

$$ \begin{align}
\partial_t S &= -\beta_{\mathbf{r}} S I - \gamma I + D_I \nabla^2 I \\\\ \partial_t I &= \beta_{\mathbf{r}} S I + D_S \nabla^2 S - \mathbf{v} \cdot \nabla I, \end{align} $$

where $S$ is the density of susceptible individuals, $I$ is the density of infected individuals, $\beta_{\mathbf{r}}$ is the transmission rate that depends on the location $\mathbf{r}$, $\gamma$ is the recovery/removal rate, $D_I$ and $D_S$ are diffusion coefficients, and $\mathbf{v}$ is the convection field.

Requirements

To use the CuSIR package, you will need the following software and hardware:

  • A CUDA-compatible GPU: A graphics processing unit (GPU) that supports CUDA. Check the list of CUDA-compatible GPUs on the NVIDIA website (https://developer.nvidia.com/cuda-gpus) to see if your GPU is supported.

  • CUDA Toolkit: A parallel computing platform and programming model developed by NVIDIA for general-purpose computing on GPUs. You can download CUDA from the NVIDIA website (https://developer.nvidia.com/cuda-downloads).

Note: Currently (January, 2023), the last version of CUDA (12) is not supported by CuPy. You will need to install any previous version of CUDA (recommended 11.2) to use CuSIR.

Installation

To install the CuSIR package, you can use pip by running the following command in your command prompt or terminal:

pip install cusir

This command will install the latest version of the CuSIR package. It is mandatory to meet the requirements listed above for CuSIR to work properly.

Usage

Almost everything is implemented in the system class, which is located in the system module. The following code shows how to use the system class to solve the diffusive SIR model:

import cusir.system as cs

# Define the spatial domain
Lx = 2**10
Ly = 2**10

# Create the system object
s = cs.system(Lx, Ly)

# Define the system parameters
s.beta = 1 # Transmission rate
s.gamma = 0.1 # Recovery/removal rate  
s.D_I = 1 # Diffusion coefficient for infected individuals
s.D_S = 1 # Diffusion coefficient for susceptible individuals

# Define the initial conditions
s.set_plane_initial_conditions()

# Solve the system
for _ in range(10000):
    s.update() # Update the system
    s.rigid_x() # Apply rigid boundary conditions in the x-direction

#You can also use the following to do the same:
#s.solve(10000)

# Get the solution
S = s.S.get() # get() pulls the data from the GPU to the CPU as a NumPy array
I = s.I.get()

License

CuSIR is licensed under the MIT license. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cusir-1.0.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

cusir-1.0.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file cusir-1.0.1.tar.gz.

File metadata

  • Download URL: cusir-1.0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for cusir-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fb82e99f85a0b285834e3496b83a76bbc2b8990298eafe90c3741b8a03f29168
MD5 763ec618cab520e41662d09d8fae2a4d
BLAKE2b-256 2433db72509660f415ce45d497ad840696b9d2057662ce85bac953d06f83e2e0

See more details on using hashes here.

File details

Details for the file cusir-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cusir-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for cusir-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f36c4d43a9edd17c4fa47945f52b3ccc241775109dae6267a170bf3981c3300
MD5 08e5f0f4b2b34e62f753fc688e80483d
BLAKE2b-256 922e87a6543c961c5b6341bc0ba41e7fc2afadf082fa5830e6afc84582e6b15e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page