casasglobal-org / psymple

GNU General Public License v3.0
1 stars 1 forks source link

Modular population structure #4

Open GJHSimmons opened 11 months ago

GJHSimmons commented 11 months ago

Description

A population object should recursively consist of:

The most basic population object consists of:

A population object should provide functionality to assign parameters and expressions to self. Convenience functions should be provided to implement common functionality.

GJHSimmons commented 11 months ago

Population objects have been implemented as described, along with some convenience functions.

For example, the function add_growth_rate(r) creates a parameter growth_rate with value r, and an expression corresponding to the ODE dx/dt = rx. It assigns these to the lists P and E, respectively.

Another convenience function is link_populations. At base, given two populations Pop_1 and Pop_2 with variables x and y, Pop_1 is assigned a parameter flow with value k, and an expression corresponding to the ODE dx/dt = -kx. Pop_2 is also assigned the flow parameter with value k, and an expression corresponding to the ODE dy/dt = kx. The function link_populations takes a subset T of S and a list R of rates, and sequentially links the populations in T with the rates in R according to the above process.

When a population object Pop_1 is added to another population object Pop_2, the lists V,P,E of Pop_2 are updated with the lists V,P,E of Pop_1. Therefore both Pop_1 and Pop_2 describe the full behaviour of Pop_1, however, Pop_2 can obtain additional information, such as interactions of elements of Pop_1 with elements of Pop_2 \ Pop_1.