# Simple bouncing molecules in a 3-D system, using particles and lattice

random_seed 1

graphics opengl

dim 3
species A B C

color A 1 0 0
color B 0 1 0
color C 0 0 1

difc all 0.1

time_start 0
time_stop 0.5
time_step 0.001

boundaries 0 0 1 
boundaries 1 0 1 p
boundaries 2 0 1 p

mol 1000 A 0.0-0.5 0.0-1.0 0.0-1.0
mol 1000 B 0.0-0.5 0.0-1.0 0.0-1.0
mol 1000 C 0.0-0.5 0.0-1.0 0.0-1.0

start_surface periodic_surface
action both all jump
polygon both edge
panel rect +1 0 0 0 1 1
panel rect -1 0 1 0 1 1
panel rect +2 0 0 0 1 1
panel rect -2 0 0 1 1 1
jump rect0 front <-> rect1 front
jump rect2 front <-> rect3 front
end_surface

start_surface portsurf
action front all port
color front 0.6 0 0 0.5
color back 0 0 0
polygon both face
panel rect -0 0.5 0 0 1 1
end_surface

start_surface reflective_surface
action front all reflect
color front 0.2 0 0 0.5
color back 0 0 0
polygon both face
panel rect +0 0 0 0 1 1
#panel rect -0 1 0 0 1 1
end_surface

reaction fwd  A + B -> C 0.01
reaction back C -> A + B 20.0

#reaction_representation fwd lattice + lattice -> particle

start_port testport
surface portsurf
face front
end_port

start_lattice testlattice
type nsv
port testport
boundaries 0 0 1
boundaries 1 0 1 p
boundaries 2 0 1 p
lengthscale 0.05 0.05 0.05
species all
make_particle back all
reactions all
mol 1000 A 0.5-1.0 0.0-1.0 0.0-1.0
mol 1000 B 0.5-1.0 0.0-1.0 0.0-1.0
mol 1000 C 0.5-1.0 0.0-1.0 0.0-1.0
end_lattice

ifdefine OUTFILE
  output_files OUTFILE
  cmd n 100 molcountspace A 0 0 1 20 0 1 0 1 500 stdout
  cmd a listmols OUTFILE
endif

end_file

