绒毛的吸收

绒毛的吸收 preview image

1 collaborator

Default-person hui min (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.2.2 • Viewed 165 times • Downloaded 16 times • Run 0 times
Download the '绒毛的吸收' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model explores the relationship between the amount of surface area in the small intestine and the rate at which it absorbs food particle into the circulatory system.

The model allows the user to vary the height/length of villi on the small intestine wall, thereby changing the amount of potential surface area that food particles traveling past this surface can interact with.

This model is part of the OpenSciEd curriculum for Middle School: http://www.openscied.org/ It is used in lesson 8 of unit 7.3 of that series.

HOW IT WORKS

In this model, food particles tend to flow from right to left, representing the movement of molecules through the small intestine as if they are suspended in a liquid. Particles wander some too in that liquid. If a particle reaches the left or right side of the world, they appear on the other side (the world wraps from left to right).

When large food particles (each represented as a series three circles connected together in a line) run into the intestinal wall they bounce off it, since they are too large to pass through it.

The intestinal walls are composed of interconnected cells, which have small pores/opening/gates in them that are semi-permeable to small food molecules.

When smaller food particles (each represented as a single circle) run into the intestinal wall of the small intestine they have a chance that they may either bounce off of the wall or may pass through it. They will do the later if they end up encountering a pore/opening/gate in the cell membranes that make up that surface of that cells that line the intestinal wall. The probability of encountering such an opening during a collision with a wall and passing through it is determined by a global variable (permeability). The current values for that variable is set to give a 50% chance of either outcome occurring.

Food molecules that pass through the small intestine wall, enter red patches on the other side of the \line of cells that make up the intestinal wall). They then follow a path through the blood flowing from left to right in the model, until the reach the right side of world. At that point they will either reappear on the left side of the model and continue recirculating through the blood until the model run is complete. This will happen if the setting for VISUALIZE-BLOOD-FLOW-AS is set to "circulating around unused". If that is variable is set to "going someplace else and used", then when a food molecule reaches the right side of the word it will be removed from the world. This represents that the food molecule was used up somewhere else in the body (e.g. as fuel, building blocks for growth, or long-term storage) and taken out of the blood stream when it was.

HOW TO USE IT

绒毛-高度 INITIAL-#-SMALL-FOOD-PARTICLES - is a slider that determines the number of small food particles put into the digestive track when SETUP is pressed.

INITIAL-#-LARGE-FOOD-PARTICLES - is slider that determines the number of large food particles put into the digestive track when SETUP is pressed.

END-SIMULATION-AT is a slider that determines the point in time at which the simulation automatically ends. This allows for comparing outcomes for different in initial conditions for similar lengths of experimental simulation runs.

绒毛-高度 - is a slider that controls the height/length of villi on the small intestine wall. Changing the value of this will change amount of potential surface area of the intestinal wall that food particles traveling past it can interact with. This can interactively be changed while the modeling in running (as GO/PAUSED is pressed) as well as before the model is initialized (when SETUP is pressed).

VISUALIZE-BLOOD-FLOW-AS - is a chooser that determines what happens to the small food molecules that are absorbed across the small intestinal wall. There are two settings for it, either "circulating around unused", or "going someplace else and used"

PARTICLES STILL IN THE SMALL INTESTINE - is a monitor that reports the total number of particles (small and large) that haven't crossed the cell membrane barrier. These are all the particles that in the black patches of the world.

PARTICLES ABSORBED INTO THE BLOOD - is a monitor that reports the total number of particles that have crossed the cell membrane barrier, or in the red patches (the blood), or that flowed through the blood and have been removed from the model when they reached the edge of the model.

SIMULATED # HRS - is a monitor that reports the amount of simulated time that has elapsed.

%微粒被吸收进入血液 - is a monitor that reports the percentage of particles absorbed into the blood.

% OF FOOD ABSORBED INTO OR NOT - is a graph that plots the percentage of particles absorbed into the blood over time and also plots the percentage of particles remaining unabsorbed over time (in the intestine).

THINGS TO TRY

Experiment with how villi height affects how many small food particles are absorbed over time.

EXTENDING THE MODEL

The model could be extended to show gas exchange between blood and the lungs in the alveoli.

CREDITS AND REFERENCES

Developed by Michael Novak. The model is part of the OpenSciEd Middle School curriculum. See http://www.openscied.org/.

HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software itself as:

COPYRIGHT AND LICENSE

This model is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License. It can run in a browser as an .html file without a local installation of NetLogo. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

NetLogo Modeling software is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Copyright 2006 Uri Wilensky.

CC BY-NC-SA 3.0

Commercial licenses for NetLogo are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
  tick-advance-amount               ; how much we advance the tick counter this time through
  max-tick-advance-amount           ; the largest tick-advance-amount is allowed to be
  init-avg-speed init-avg-energy    ; initial averages

  particle-size
  toggle-red-state
  toggle-green-state
  min-particle-energy
  max-particle-energy
  particles-to-add
  show-wall-hits?
  max-particles
  #particles
  #-green-particles
  #-purple-particles
  #-orange-particles
  villi-slider-moved?
  old-villi-slider-value
  bottom-wall-ycor
  tracker-init-particles
  permeability
  particle-to-watch
  total-initial-particles
  total-absorbed-particles
]


breed [ particles particle ]
breed [ flows flow ]
breed [ walls wall ]
breed [ edges edge ]



particles-own [
  speed mass energy          ; particles info
  last-collision
  color-type
  absorbed?
  swept?
  large?
]

patches-own [
  is-blood?
  blood-heading

]


walls-own [
  energy
  valve-1?
  valve-2?
  pressure?
  surface-energy
]

to setup
  clear-all
  reset-ticks
  ask patches [set pcolor white]
  set particle-size 2
  set max-tick-advance-amount 0.02
  set show-wall-hits? false
  set particles-to-add 2
  set old-villi-slider-value 绒毛-高度
  set villi-slider-moved? true
  set bottom-wall-ycor min-pycor + 3
  set-default-shape walls "cell"


  set tracker-init-particles 初始-小的-食物微粒
  set permeability 50
  set particle-to-watch nobody


  redraw-villi?
  draw-blood-stream
  draw-edges
  make-small-particles
  make-large-particles
  set  total-initial-particles count particles
  set  total-absorbed-particles 0



  do-plotting
end 

to go

  if ticks < 模型结束在 [
  redraw-villi?

    ask particles with [not absorbed?] [ bounce ]
    ask flows [move-flows]
    ask particles with [not absorbed?] [ move ]
    ask particles with [absorbed?  and pycor != min-pycor] [seep-toward-blood]
    ask particles with [swept?] [sweep-with-blood]
  ;  ask particles with [not absorbed?] [ check-for-collision ]
    ask particles with [not absorbed? and any? walls-here ] [ rewind-to-bounce ]
    ask particles with [not absorbed? and any? walls-here ] [ remove-from-walls ]

    check-watched-particle

  tick-advance tick-advance-amount
  calculate-tick-advance-amount
  check-particle-flow-out-of-system


  do-plotting
  display
  ]
end 

to check-watched-particle
  if particle-to-watch != nobody [
  ask particle-to-watch [
      if pycor = max-pycor [rp]
    ]

    ]
end 

to check-particle-flow-out-of-system
  ask particles [
    if pxcor = max-pxcor and visualize-food-in-blood-flow-as = "going someplace else" [set total-absorbed-particles total-absorbed-particles + 1 set hidden? true]
  ]
end 

to watch-a-particle
  set particle-to-watch one-of particles with [pycor < (max-pycor - 2)]
  if count particles > 0 [
    watch one-of particles

  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BUILD VILLI   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to shove-particles
  ask particles-here with [pycor <= (bottom-wall-ycor + 绒毛-高度)] [set ycor (bottom-wall-ycor + 绒毛-高度)]
end 

to add-wall
  shove-particles
          sprout 1 [
          set breed walls set color gray
          ;set is-blood? false
          initialize-this-wall
        ]
end 

to add-hidden-wall
  shove-particles
          sprout 1 [
          set breed walls set color gray
          set is-blood? false
          set hidden? true
          initialize-this-wall
        ]
end 

to initialize-blood
          set breed walls set color red
          set size 1.0
          set is-blood? true
          set heading 90
          set shape "square"
          set color [255 0 0 150]
end 

to add-blood-up
  shove-particles
  set blood-heading 0
  set is-blood? true
  sprout 1 [initialize-blood ]
end 

to add-blood-down
  shove-particles
  set blood-heading 180
  set is-blood? true
  sprout 1 [initialize-blood]
end 

to add-blood-right
  shove-particles
  set blood-heading 90
  set is-blood? true
  sprout 1 [initialize-blood]
end 

to redraw-villi?
  if old-villi-slider-value != 绒毛-高度 [set villi-slider-moved? true set old-villi-slider-value 绒毛-高度]
  if villi-slider-moved? [
     redraw-villi
     set villi-slider-moved? false
  ]
end 

to redraw-villi
  ask walls with [pycor >= (min-pycor + 3)] [die]
  ask patches with [pycor >= (min-pycor + 3)] [set is-blood? false]
   ;; draw horizontal line until reaching a point where a villi is... then call villi build...skip and continue

   let distance-between-villi 5

    ask patches with [pxcor >= min-pxcor and pxcor <= max-pxcor and pycor = max-pycor ]  [add-hidden-wall]


     let this-pxcor min-pxcor
     let this-pycor bottom-wall-ycor
     let villi-width 5
     let this-width-counter 0
     let this-lift false
   repeat (max-pxcor - min-pxcor + 1)  [

    ifelse ((this-pxcor mod 11 >= 0) and (this-pxcor mod 11 <= 4)) and (this-pxcor >= (min-pxcor + 3) and this-pxcor <= (max-pxcor - 5))
         [set this-pycor (bottom-wall-ycor + 绒毛-高度) set this-lift true]
         [set this-pycor bottom-wall-ycor]
    ask patches with [pxcor = this-pxcor and pycor = this-pycor] [add-wall]

    ;; draw-vertical wall
    if this-lift [
        ask patches with [pxcor = this-pxcor and pycor >= bottom-wall-ycor and pycor <= this-pycor] [
          if (this-pxcor mod 11 = 0 and pycor < (this-pycor)) [add-wall]
          if (this-pxcor mod 11 = 1 and pycor < (this-pycor - 1)) [add-blood-up]
          if (this-pxcor mod 11 = 2 and pycor < (this-pycor - 2))[add-wall]
          if ((this-pxcor mod 11 = 2 or this-pxcor mod 11 = 1) and (pycor = (this-pycor - 1) ))[add-blood-right]
         if ((this-pxcor mod 11 = 2 ) and ( pycor = (this-pycor - 2)))[add-blood-right]
          if (this-pxcor mod 11 = 3 and pycor <= (this-pycor - 1)) [add-blood-down]
          if (this-pxcor mod 11 = 4 and pycor < (this-pycor)) [add-wall]
        ]
      set this-lift false
      ]
    set this-pxcor this-pxcor + 1
   ]
end 

to draw-blood-stream
  let blood-patches patches with [pxcor >= min-pxcor and pxcor <= max-pxcor and pycor < bottom-wall-ycor and pycor >= min-pycor ]
  ask blood-patches [add-blood-right]
  ask n-of 30 blood-patches [
    make-a-floater
  ]
end 

to make-a-floater
  let this-color (5 + random-float 20)
  let this-list [0 0 0]
  set this-list lput  this-color this-list
  sprout 1 [
    set breed flows
  set color this-list
  set shape "square"
  ]
end 

to draw-edges
  ask patches with [pycor = (max-pycor) and pxcor < max-pxcor ][
    sprout 1 [
      set breed edges
      set shape "square 3"
      set size 1.05
      set color gray + 2
    ]
  ]
   ask patches with [pycor < (max-pycor) and pxcor = max-pxcor ][
    sprout 1 [
      set breed edges
      set shape "square 4"
      set size 1.05
      set color gray + 2
    ]
  ]
     ask patches with [pycor =(max-pycor) and pxcor = max-pxcor ][
     sprout 1 [
      set breed edges
      set shape "square"
      set size 1.05
      set color gray + 2
    ]
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WALL INTERACTION;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS MOLECULES MOVEMENT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to bounce  ; particles procedure
  ; get the coordinates of the patch we'll be on if we go forward 1
  let bounce-patch nobody
  let bounce-patches nobody
  let hit-angle 0
  let this-patch patch-here
  let new-px 0
  let new-py 0
  let visible-wall nobody

  set bounce-patch  min-one-of walls in-cone ((sqrt (2)) / 2) 180 with [ patch-here != this-patch ] [ distance myself ]

  if bounce-patch != nobody [
    set new-px [ pxcor ] of bounce-patch
    set new-py [ pycor ] of bounce-patch
    set visible-wall walls-on bounce-patch

    if any? visible-wall  [
      ifelse (random 100 > permeability or (pycor >= (max-pycor - 1) ) or large? ) [
      if bounce-patch != patch-here [ set hit-angle towards bounce-patch ] ;; new bounce patch code
      ifelse (hit-angle <= 135 and hit-angle >= 45) or (hit-angle <= 315 and hit-angle >= 225) [
        set heading (- heading)
      ][
        set heading (180 - heading)
      ]

      set absorbed? false]
      [set absorbed? true]
    ]


  ]
end 

to rewind-to-bounce  ; particles procedure
  ; attempts to deal with particle penetration by rewinding the particle path back to a point
  ; where it is about to hit a wall
  ; the particle path is reversed 49% of the previous tick-advance-amount it made,
  ; then particle collision with the wall is detected again.
  ; and the particle bounces off the wall using the remaining 51% of the tick-advance-amount.
  ; this use of slightly more of the tick-advance-amount for forward motion off the wall, helps
  ; insure the particle doesn't get stuck inside the wall on the bounce.

  let bounce-patch nobody
  let bounce-patches nobody
  let hit-angle 0
  let this-patch nobody
  let new-px 0
  let new-py 0
  let visible-wall nobody

  bk (speed) * tick-advance-amount * .49
  set this-patch  patch-here

  set bounce-patch  min-one-of walls in-cone ((sqrt (2)) / 2) 180 with [ self != this-patch ] [ distance myself ]

  if bounce-patch != nobody [

    set new-px [pxcor] of bounce-patch
    set new-py [pycor] of bounce-patch
    set visible-wall walls-on bounce-patch

    if any? visible-wall with [not hidden?] [
      set hit-angle towards bounce-patch

      ifelse (hit-angle <= 135 and hit-angle >= 45) or (hit-angle <= 315 and hit-angle >= 225) [
        set heading (- heading)
      ][
        set heading (180 - heading)
      ]


    ]
  ]
  fd (speed) * tick-advance-amount * 0.75
end 

to move  ; particles procedure
  if patch-ahead (speed * tick-advance-amount) != patch-here [ set last-collision nobody ]
  ifelse (not large?) [rt random 30 lt random 30][rt random 10 lt random 10]
  fd (speed * tick-advance-amount * 0.75)
  if ycor >  (bottom-wall-ycor + 绒毛-高度) [set xcor xcor - .05]
end 

to move-flows
  set heading 90
  fd (7 * tick-advance-amount * 0.75)
end 

to seep-toward-blood
  let flex-threshold .2 + random-float .05
  let all-blood patches with [is-blood?]
  let target-blood-patch min-one-of all-blood [distance myself  ]
 ; show distance target-blood
  let final-heading towards target-blood-patch
  let heading-difference ((final-heading - heading) / 20)
  set heading heading + heading-difference
  let blood-near-me all-blood with [distance myself < flex-threshold]
  ifelse not any? blood-near-me [fd (2 * tick-advance-amount) ][set swept? true]
end 

to sweep-with-blood
  let old-heading heading
  let heading-difference ((old-heading - heading) / 20)
  if (is-blood? and swept?)  [set heading blood-heading fd (3 * tick-advance-amount) set heading heading + heading-difference]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS MOLECULES COLLISIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;from GasLab

to calculate-tick-advance-amount
  ; tick-advance-amount is calculated in such way that even the fastest
  ; particles will jump at most 1 patch delta in a ticks tick. As
  ; particles jump (speed * tick-advance-amount) at every ticks tick, making
  ; tick delta the inverse of the speed of the fastest particles
  ; (1/max speed) assures that. Having each particles advance at most
  ; one patch-delta is necessary for it not to "jump over" a wall
  ; or another particles.
  ifelse any? particles with [ speed > 0 ] [
    set tick-advance-amount min list (1 / (ceiling max [speed] of particles )) max-tick-advance-amount
  ][
    set tick-advance-amount max-tick-advance-amount
  ]
end 

to check-for-collision  ; particles procedure
  ; Here we impose a rule that collisions only take place when there
  ; are exactly two particles per patch.  We do this because when the
  ; student introduces new particles from the side, we want them to
  ; form a uniform wavefront.
  ;
  ; Why do we want a uniform wavefront?  Because it is actually more
  ; realistic.  (And also because the curriculum uses the uniform
  ; wavefront to help teach the relationship between particles collisions,
  ; wall hits, and pressure.)
  ;
  ; Why is it realistic to assume a uniform wavefront?  Because in reality,
  ; whether a collision takes place would depend on the actual headings
  ; of the particles, not merely on their proximity.  Since the particles
  ; in the wavefront have identical speeds and near-identical headings,
  ; in reality they would not collide.  So even though the two-particles
  ; rule is not itself realistic, it produces a realistic result.  Also,
  ; unless the number of particles is extremely large, it is very rare
  ; for three or  particles to land on the same patch (for example,
  ; with 400 particles it happens less than 1% of the time).  So imposing
  ; this additional rule should have only a negligible effect on the
  ; aggregate behavior of the system.
  ;
  ; Why does this rule produce a uniform wavefront?  The particles all
  ; start out on the same patch, which means that without the only-two
  ; rule, they would all start colliding with each other immediately,
  ; resulting in much random variation of speeds and headings.  With
  ; the only-two rule, they are prevented from colliding with each other
  ; until they have spread out a lot.  (And in fact, if you observe
  ; the wavefront closely, you will see that it is not completely smooth,
  ; because  collisions eventually do start occurring when it thins out while fanning.)

  if count other particles-here  in-radius 1 = 1 [
    ; the following conditions are imposed on collision candidates:
    ;   1. they must have a lower who number than my own, because collision
    ;      code is asymmetrical: it must always happen from the point of view
    ;      of just one particles.
    ;   2. they must not be the same particles that we last collided with on
    ;      this patch, so that we have a chance to leave the patch after we've
    ;      collided with someone.
    let candidate one-of other particles-here with [ who < [ who ] of myself and myself != last-collision ]
    ;; we also only collide if one of us has non-zero speed. It's useless
    ;; (and incorrect, actually) for two particles with zero speed to collide.
    if (candidate != nobody) and (speed > 0 or [ speed ] of candidate > 0) [
      collide-with candidate
      set last-collision candidate
      ask candidate [ set last-collision myself ]
    ]
  ]
end 

; implements a collision with another particles.
;
; THIS IS THE HEART OF THE particles SIMULATION, AND YOU ARE STRONGLY ADVISED
; NOT TO CHANGE IT UNLESS YOU REALLY UNDERSTAND WHAT YOU'RE DOING!
;
; The two particles colliding are self and other-particles, and while the
; collision is performed from the point of view of self, both particles are
; modified to reflect its effects. This is somewhat complicated, so I'll
; give a general outline here:
;   1. Do initial setup, and determine the heading between particles centers
;      (call it theta).
;   2. Convert the representation of the velocity of each particles from
;      speed/heading to a theta-based vector whose first component is the
;      particle's speed along theta, and whose second component is the speed
;      perpendicular to theta.
;   3. Modify the velocity vectors to reflect the effects of the collision.
;      This involves:
;        a. computing the velocity of the center of mass of the whole system
;           along direction theta
;        b. updating the along-theta components of the two velocity vectors.
;   4. Convert from the theta-based vector representation of velocity back to
;      the usual speed/heading representation for each particles.
;   5. Perform final cleanup and update derived quantities.

to collide-with [ other-particles ] ;; particles procedure
  ; PHASE 1: initial setup

  ; for convenience, grab  quantities from other-particles
  let mass2 [ mass ] of other-particles
  let speed2 [ speed ] of other-particles
  let heading2 [ heading ] of other-particles

  ; since particles are modeled as zero-size points, theta isn't meaningfully
  ; defined. we can assign it randomly without affecting the model's outcome.
  let theta (random-float 360)

  ; PHASE 2: convert velocities to theta-based vector representation

  ; now convert my velocity from speed/heading representation to components
  ; along theta and perpendicular to theta
  let v1t (speed * cos (theta - heading))
  let v1l (speed * sin (theta - heading))

  ;; do the same for other-particles
  let v2t (speed2 * cos (theta - heading2))
  let v2l (speed2 * sin (theta - heading2))

  ; PHASE 3: manipulate vectors to implement collision

  ; compute the velocity of the system's center of mass along theta
  let vcm (((mass * v1t) + (mass2 * v2t)) / (mass + mass2) )

  ; now compute the new velocity for each particles along direction theta.
  ; velocity perpendicular to theta is unaffected by a collision along theta,
  ; so the next two lines actually implement the collision itself, in the
  ; sense that the effects of the collision are exactly the following changes
  ; in particles velocity.
  set v1t (2 * vcm - v1t)
  set v2t (2 * vcm - v2t)

  ; PHASE 4: convert back to normal speed/heading

  ; now convert my velocity vector into my new speed and heading
  set speed sqrt ((v1t ^ 2) + (v1l ^ 2))
  set energy (0.5 * mass * speed ^ 2)
  ; if the magnitude of the velocity vector is 0, atan is undefined. but
  ; speed will be 0, so heading is irrelevant anyway. therefore, in that
  ; case we'll just leave it unmodified.
  if v1l != 0 or v1t != 0 [ set heading (theta - (atan v1l v1t)) ]

  ;; and do the same for other-particle
  ask other-particles [
    set speed sqrt ((v2t ^ 2) + (v2l ^ 2))
    set energy (0.5 * mass * (speed ^ 2))
    if v2l != 0 or v2t != 0 [ set heading (theta - (atan v2l v2t)) ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  initialization procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to initialize-this-wall
;  set valve-1? false
 ; set valve-2? false
;  set pressure? false
  ifelse random 2 = 0 [set shape "cell"][set shape "cell2"]
  set color [255 255 255 120]
  let turn random 4
  rt (turn * 90)
end 

to make-small-particles
  create-particles 初始-小的-食物微粒 [
    setup-particles false
    set shape "small-molecule"
    random-position
  ]
end 

to make-large-particles
  create-particles 初始-大的-食物微粒 [
    setup-particles true
    set shape "large-molecule"
    random-position
  ]
end 

to setup-particles  [is-large]; particles procedure
 ; set shape "circle"
  set size particle-size
  set energy 150
  set color-type (violet - 3)
  set color color-type
  set mass (10)  ; atomic masses of oxygen atoms

  set speed speed-from-energy
  set last-collision nobody
  set absorbed? false
  set large? is-large
  set swept? false
end 


; Place particles at random, but they must not be placed on top of wall atoms.
; This procedure takes into account the fact that wall molecules could have two possible arrangements,
; i.e. high-surface area ot low-surface area.

to random-position ;; particles procedure
  let open-patches nobody
  let open-patch nobody
  set open-patches patches with [not any? turtles-here and pxcor != max-pxcor and pxcor != min-pxcor and pycor != min-pycor and pycor != max-pycor]
  set open-patch one-of open-patches

  ; Reuven added the following "if" so that we can get through setup without a runtime error.
  if open-patch = nobody [
    user-message "No open patches found.  Exiting."
    stop
  ]

  setxy ([ pxcor ] of open-patch) ([ pycor ] of open-patch)
  set heading random 360
  fd random-float .4
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; wall penetration error handling procedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; if particles actually end up within the wall

to remove-from-walls
  let this-wall walls-here with [ not hidden? ]

  if count this-wall != 0 [
    let available-patches patches with [ not any? walls-here ]
    let closest-patch nobody
    if (any? available-patches) [
      set closest-patch min-one-of available-patches [ distance myself ]
      set heading towards closest-patch
      setxy ([ pxcor ] of closest-patch)  ([ pycor ] of closest-patch)
    ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GRAPHS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to do-plotting
   update-plots
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;REPORTERS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to-report speed-from-energy
  report sqrt (2 * energy / mass)
end 

to-report energy-from-speed
  report (mass * speed * speed / 2)
end 

to-report limited-particle-energy
  let limited-energy energy
  if limited-energy > max-particle-energy [ set limited-energy max-particle-energy ]
  if limited-energy < min-particle-energy [ set limited-energy min-particle-energy ]
  report limited-energy
end 


; Copyright 2006 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created almost 3 years ago by hui min.

Attached files

File Type Description Last updated
绒毛的吸收.png preview Preview for '绒毛的吸收' almost 3 years ago, by hui min Download

This model does not have any ancestors.

This model does not have any descendants.