# Demonstration of compartments

ifdefine SUFFIX
  define OUTFILE output_SUFFIX/FILEROOT_SUFFIX_out.txt
  output_files OUTFILE
  cmd a listmols OUTFILE
endif
random_seed 1

graphics opengl

dim 2
boundaries x 0 100
boundaries y 0 100
frame_thickness 0

species red green blue

difc red 3
difc green 0
difc blue 3

color red red
color green green
color blue blue
display_size red 3
display_size green 5
display_size blue 3

time_start 0
time_stop 10
time_step 0.01

start_surface walls
action both all r
color both 0 0 0
panel rect +x 0 0 100
panel rect -x 100 0 100
panel rect +y 0 0 100
panel rect -y 0 100 100
end_surface

start_surface surf
action both red reflect
action both blue transmit
color front 1 0.7 0
color back 0.6 0 0.6
thickness 1
panel sphere 50 50 20 30
panel sphere 50 50 30 30
end_surface

start_compartment middle
surface surf
point 50 75
point 50 25
point 75 50
point 25 50
end_compartment

reaction compartment=middle r0 0 -> red 0.01
reaction compartment=middle r1 blue -> 0 0.5
reaction compartment=middle r2 blue + blue -> green 1
reaction r3 red -> 0 0.1

mol 500 blue u u

append_files stdout
cmd N 10 ifincmpt blue(solution) = 12 middle echo stdout "12 blue molecules in middle\n"
#cmd N 10 ifincmpt blue(solution) = 12 middle pause

end_file

