Skip to content

Commit a36a8c7

Browse files
committed
mean field model base
1 parent 7a4f1ba commit a36a8c7

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Virtual environment
2+
.venv/
3+
__pycache__/
4+
# Python bytecode
5+
*.pyc
6+
# Jupyter Notebook checkpoints
7+
.ipynb_checkpoints/
8+
# Data files
9+
data/

models/mean_field.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import numpy as np
2+
from scipy.integrate import odeint
3+
from scipy.ndimage import label
4+
from scipy.optimize import curve_fit
5+
from scipy.stats import kstest
6+
import matplotlib.pyplot as plt
7+
from typing import Tuple, List, Dict, Optional
8+
9+
class MeanFieldModel:
10+
"""
11+
Mean-field (non-spatial) predator-prey model.
12+
"""
13+
14+
def __init__(self, birth: float, consumption: float, predator_death: float):
15+
"""
16+
Initialize the mean-field model with given parameters.
17+
Args:
18+
birth (float): Prey birth rate (b)
19+
consumption (float): predator consumption rate (c)
20+
predator_death (float): predator death rat (d_c)
21+
"""
22+
23+
def ode_system(self, Z: np.ndarray, t: float, prey_death: float)->List[float]:
24+
"""
25+
Mean-field ODE system for predator prey dynamics
26+
27+
Args:
28+
Z (np.ndarray): _description_
29+
t (float): _description_
30+
prey_death (float): _description_
31+
32+
Returns:
33+
List[float]: _description_
34+
"""
35+
pass
36+
37+
def solve(self, prey_death: float, Z0: Tuple[float, float], t_max: float, n_points: int)->Tuple[np.ndarray, np.ndarray]:
38+
"""
39+
Solve the mean-field ODE system.
40+
41+
Args:
42+
prey_death (float): Prey death rate (d)
43+
Z0 (Tuple[float, float]): Initial conditions (prey, predator)
44+
t_max (float): Maximum time
45+
n_points (int): Number of time points
46+
47+
Returns:
48+
Tuple[np.ndarray, np.ndarray]: Time points and solution array
49+
"""
50+
pass
51+
52+
def equilibrium(self, prey_death: float)->Tuple[float, float]:
53+
"""
54+
Calculate the equilibrium point of the system.
55+
56+
Args:
57+
prey_death (float): Prey death rate (d)
58+
59+
Returns:
60+
Tuple[float, float]: Equilibrium populations (prey, predator)
61+
"""
62+
pass
63+
64+
def sweep_death_rate(self, d_r_values: np.ndarray, t_equilibrium: float) -> Dict[str, np.ndarray]:
65+
"""
66+
Sweep prey death rate and record equilibrium densities.
67+
"""
68+
pass
69+
70+
def nullclines(self, prey_death: float, Z_r_range: np.ndarray)->Dict[str, np.ndarray]:
71+
"""
72+
Compute nullclines for phase portrait.
73+
"""
74+
pass

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
matplotlib
2+
numpy
3+
scipy

0 commit comments

Comments
 (0)