📄 bloodcells.nlogo
字号:
globals [number concentration] ;; global variables are the numbe of cells and concentration breeds [cells] ;; let's call them cells instead of turtles cells-own [state ticks] ;; each cell contain its current set ("young" or "mature") ;; and "internal" clock to setup clear-all set-default-shape cells "circle" ;; define cells as circles set number initial_concentration * 100.0 ;; initial number of cells from given conc. (in %) create-custom-cells number [ ;; create initial population of mature cells set ticks 0.0 set state "mature" set color red random-pos ] setup-plot end to move-cells locals [dt] set dt 1 ;; time step ask cells [ fd random-float 1.0 ;; move in random direction if ticks >= (delay * dt) and state = "young" ;; after some delay cells become mature [ set state "mature" set color red ;; mature cells are red ] set ticks ticks + dt ;; time increment ] cells-die ;; call cells-die procedure set number (count cells with [state = "mature"]) ;; count the number of mature cells cells-are-born ;; call cells-are-born procedure compute-concentration do-plot ;; plot concentration endto cells-die ;; cells die in proportion with decay constant alpha ask random-n-of (int (alpha * number)) cells with [state = "mature"] [ die ] end to cells-are-born ;; cells are produced depending on the number locals [n] set n int (prod number) create-custom-cells n [ ;; generate cells from production function set color green ;; young cells are green set state "young" set ticks 0.0 ;; internal clock initialization setxy (- screen-edge-x) 0 ;; cells are produced in the left side of the window set heading (random 180) ;; moving from left to right ] end to compute-concentration ;; compute concentrarion of blood cells set concentration (count cells with [state = "mature"]) / (initial_concentration * 100) end to random-pos ;; setup cells in random positions moving in random directions setxy (random-float 2 * screen-edge-x) (random-float 2 * screen-edge-y) set heading (random 360)end to-report prod [n] ;; production function of blood cells from Mackey-Glass (1977) locals [x] set x n / 100.0 ;; convert from number to concentration report (100 * (0.2 * x) / (1 + x ^ 10))end to do-plot ;; do the plot set-current-plot "Concentration of Blood Cells" set-current-plot-pen "mature" plot concentration endto setup-plot ;; set up plotting set-current-plot "Concentration of Blood Cells" set-plot-x-range 0 600 set-plot-y-range ymin ymaxend@#$#@#$#@GRAPHICS-WINDOW46415763034415155.0323110111CC-WINDOW144371629443Command CenterBUTTON2283936872SETUPsetupNIL1TOBSERVERTBUTTON3954053473START / STOPmove-cellsT1TOBSERVERTPLOT140154445344Concentration of Blood CellsTime (days)Concentration 0.0100.00.01.0truefalsePENS"mature" 1.0 0 -65536 falseSLIDER30699460132delaydelay0.01006.011daysSLIDER47599631132alphaalpha0.010.50.030.011NILSLIDER13798292131initial_concentrationinitial_concentration0.25.00.50.11NILSLIDER28306120339yminymin0100.00.11NILSLIDER28154120187ymaxymax0101.80.11NIL@#$#@#$#@WHAT IS IT?-----------This is a simulation of the control mechanism for the production of white blood cells based on Mackey-Glass (1977). Blood cells have a certain half-life but new replacements are produced continuosly. It takes about four days for a new cell to mature so there is a delay in the dynamics governing the number of mature blood cells. The goal of any control system is to keep a certain quantity at a constant level. However, in real systems the control mechanism is not activated inmediately but only after a certain delay corresponding to the period of maduration of the blood cells. The resulting dynamics is characterized by oscillations that for certain delays may turn chaotic. This simulation pretends to ilustrate this process where an initial population of blood cells are generated and new cells are produced in each time step depending of the concentration of mature cells. The "young" cells eventually are old enough to be mature and some of them die in proportion with a decay constant. The model also ilustrate the effect of a delayed mixed feedback in the dynamics of biological systems. HOW IT WORKS------------This simulation is an individual based model (IBM) version of the classic model of Mackey-Glass (1977) for phisiological control. The original model is formulated as a delay differential equation (DDE) containing a term corresponding to the production of new blood cells, P(x) and a decay term (alpha) proportional to the number of mature cells in circulation. The simulation was developed using the following procedure: - Generate inital population of cells - Each cell contain two parameters: an internal clock (ticks) initialized as zero and the initial state of the cells (young or mature). The initialized cells are located randomly in the graphics windows and in each time step the cells "move" in random directions. - In each time step the internal clock of each cell increases until it reachs the state of maturity where the cell changes from "young" to "mature". The time it takes to reach maturity is given by the delay parameter (in days).- In each time step we have to types of cells. Mature cells and young cells. The production of new cells are determined by the level of mature cells in circulation. For instance, if the total amount of mature cells is high the production of new cells is low. On the other hand, if the total amount of mature cells is low the production mechanism is high. In any case the model define a production function given by P(x) = (0.2 x)/(1 + x^10) which is the same used in the Mackey-Glass delay differential equation model. Since the argument in P(x) is a concentration the NetLogo codes works out the calculation of concentration by dividing the number of cells in each time step by an arbitrary normalization factor (100) that in general could be calibrated with experimental data. The cell production mechanism is represented by the procedure "cells-are-born". Also, and like the original Mackey-Glass, the model contains a decay constant (alpha) that correspond to the amount of cells dying in each time step represented by the procedure "cells-die". HOW TO USE IT-------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -