GithubHelp home page GithubHelp logo

eco_functions's Introduction

Eco_functions

Simulations for Consumer-Resource Models

How to install the package

Type in the terminal.

git clone https://github.com/Wenping-Cui/Eco_functions
cd Eco_functions
pip install -e .

An example to do simulations

### Import the package in the code:
from Eco_function.eco_lib import *
from Eco_function.eco_plot import *
from Eco_function.eco_func import *
import time
import pandas as pd
import matplotlib
from matplotlib import cm
from matplotlib import colors
import matplotlib.ticker as ticker
import matplotlib.pyplot as plt
import numpy as np
import pdb
import os.path
import pickle
import seaborn as sns
 
## Initial the number of species and resources
S=500;
M=100;
flag='linear'#'constant', 'linear', 'quadratic' for different dynamics
flag_crossfeeding = False; # simulation with crossfeeding or not.
K =np.random.normal(5, 1, M)  # Initial the number of species and resources
C=np.random.normal(5, 2,[S,M]) # Initial the consumer matrix
energies = np.ones(M)
tau_inv = np.ones(M)
#Ode solver parameter
t0 = 0;
t1 = 1000;
N_t = 10000;
T_par = [t0, t1, N_t];
T = np.linspace(t0, t1, num=N_t);
R_ini = 0.2 * np.ones(M);
N_ini =  0.2 * np.ones(S);
# Start to simulate
costs=np.ones(S)  # Initial the cost
growth=np.ones(S) # Initial the growth rate
# Start to simulate
if flag=='constant':
    flag_nonvanish=True;
    flag_renew=True;
    label='constant'
elif flag=='linear':
    flag_renew=True;
    flag_nonvanish=False;
    label='linear'
elif flag=='quadratic':
    flag_renew=False;
    flag_nonvanish=False;
    label='quadratic'
sim_par = [flag_crossfeeding, M, S, R_ini, N_ini,T_par, C, energies, tau_inv, costs, growth, K] 
Model =Ecology_simulation(sim_par)
Model.flag_renew=flag_renew;
Model.flag_nonvanish=flag_nonvanish;
Rt, Nt=Model.simulation()

eco_functions's People

Contributors

wenping-cui avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.