====== Tutorial 15 - Implementing using one compartment ====== ===== 3/3 ===== When implementing the Lotka-Volterra model using one [[Compartment|Compartment]] block (one for both the predator and prey), the compartment needs to be vectorized. I.e. the rabbit and fox species needs to be added as modelled materials or created as indexes from Index-list. Then either one can use the same approach as in the two Compartment solution, using Source/Sink and Transfer blocks as means to model the dynamic behaviour or just explicitly define the differential equation inside the Compartment. ====Option 1==== Create parameters according to table below: ^Parameter ^Unit ^Value ^Description ^ |a |1/year |0.04 |the natural growth rate of rabbits in the absence of predation | |c |1/year |0.2 |the natural death rate of foxes in the absence of food (rabbits)| |b |1/(year F)|5.0E-4|the death rate per encounter of rabbits due to predation | |e |F/R |0.1 |the efficiency of turning predated rabbits into foxes | |Init_population |n | |Initial animal population | Values for parameter Initial population: * //Init_population[Rabbits]= 1000// * //Init_population[Foxes]= 4// Create source, sink, compartments and transfer according to picture below: {{rabbitfoxmodel3.png?600}} Equations for Transfers: * //AnimalBirth[Rabbits]=Animals·a// * //AnimalBirth[Foxes]=Animals[Rabbits]·Animals[Foxes]·e·b// * //AnimalDeath[Rabbits]=b·Animals[Rabbits]·Animals[Foxes]// * //AnimalDeath[Foxes]=c·Animals// **Initial Conditions** for compartment: * For //Animals[Rabbits] = Init_population// * For //Animals[Foxes] = Init_population// ====Option 2==== Create parameters according to table below: ^Parameter ^Unit ^Value ^Description ^ |a |1/year |0.04 |the natural growth rate of rabbits in the absence of predation | |c |1/year |0.2 |the natural death rate of foxes in the absence of food (rabbits)| |b |1/(year F)|5.0E-4|the death rate per encounter of rabbits due to predation | |e |F/R |0.1 |the efficiency of turning predated rabbits into foxes | Create only one compartment with name //Animals//. {{rabbitfoxmodel4.png}} **Initial Conditions** for compartment: * For //Animals[Rabbits] = 1000// * For //Animals[Foxes] = 4// **dy/dt** for compartment: * Rabbits: //dAnimals/dt=Animals[Rabbits]·a-b·Animals[Rabbits]·Animals[Foxes]// * Foxes: //dAnimals/dt=Animals[Rabbits]·Animals[Foxes]·e·b-c·Animals[Foxes]// \\ **Solution to the excersise** * {{lotka-volterra.eco}} * old one {{tutorial:Lotka-Volterra.eco?linkonly}} **Previous** * [[Tutorial_15-Implementing_using_two_compartments|Implementing using two compartments (2/3)]] **References** * [[Tutorials|Back to Tutorials]] * [[start|Home]]