-
Notifications
You must be signed in to change notification settings - Fork 0
/
Placozoan_Perceiving_dev.jl
115 lines (97 loc) · 3.92 KB
/
Placozoan_Perceiving_dev.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Placozoan_Dev.jl
# function trichoplax_sim()
# MAIN
bodylayers = 12 # number of body cell layers
margin = 5 # number of layers in gut margin ("brain")
celldiameter = 10.0
skeleton_springconstant= 5.0e-2
cell_pressureconstant = 1.0e0
cell_surface_energy_density = 5.0e1
dt = .001
param = trichoplaxparameters( bodylayers,
margin,
skeleton_springconstant,
cell_pressureconstant,
cell_surface_energy_density,
celldiameter,
dt)
@time trichoplax = Trichoplax(param)
# trichoplax.param.k2[] = 5.0e-2 # cytoskeleton spring constant /2
# trichoplax.param.σ[] = 5.0e1 # cell surface energy density
# trichoplax.param.ρ[] = 1.0e0 #1.0e2 # cell turgor pressure energy per unit volume
# Draw
R = bodylayers*celldiameter # approx radius of Trichoplax (for scene setting)
D = 3*R # scene diameter
limits=FRect(-D/2, -D/2, D, D)
scene = Scene(resolution = (800,800), scale_plot = false,
show_axis = false, limits=limits)
# # scatter bacteria (point objects) over the scene
# nbacteria = 50
# bactrect = FRect(20,20, 30, 30)
# bacteria = growbacteria(nbacteria, bactrect)
# draw trichoplax cells
cells_handle = draw(scene, trichoplax, RGB(.25, .25, .25), 1)
# colour the cells
ch = potentialmap(scene, trichoplax)
display(scene)
# project
bodyCenter = colmeans(verticesofcell(1, trichoplax))
skinvertex = getskinvertexcoords(trichoplax)
bodyRadius = meanvec(distance(bodyCenter, skinvertex)[:])
plotcircle!(scene, bodyCenter, bodyRadius, color = :green)
viewRadius = 2.0*bodyRadius
plotcircle!(scene, bodyCenter, viewRadius, color = :red)
gutboundaryvertex = getgutboundaryvertexcoords(trichoplax)
gutRadius = meanvec(distance(bodyCenter, gutboundaryvertex)[:])
plotcircle!(scene, bodyCenter, gutRadius, color = :green)
x0 = fill(0.0, 1,2)
for i in (trichoplax.anatomy.stomach+1):(trichoplax.anatomy.ncells)
for j in 1:6
x0[:] = trichoplax.state.vertex[trichoplax.anatomy.cellvertexindex[i,j],:]
d = distance(bodyCenter, x0)[]
x = x0.*(2.0*bodyRadius - d)/d
scatter!(x, markersize = 2, color = :red)
end
end
# restvolume = copy(trichoplax.state.volume)
# i0 = 4
# i1 = vcat(i0, trichoplax.anatomy.neighbourcell[i0,:])
# # record(scene, "trichoplaxdev.mp4", 1:100) do tick
# for tick in 1:100
# global trichoplax
# global scene
# if tick < 50
# whichbacteriahere = bacteriahere(bacteria, trichoplax)
# for j in 1:trichoplax.anatomy.stomach
# for k in 1:length(whichbacteriahere[j])
# trichoplax.state.potential[j] = trichoplax.state.potential[j] -
# 1.0/(bacteria.deadticks[whichbacteriahere[j][k]] .+ 1)
# bacteria.deadticks[whichbacteriahere[j][k]] = bacteria.deadticks[whichbacteriahere[j][k]] .+ 1
# end
# end
# end
#
#
# trichoplax = diffusepotential(trichoplax,600)
#
# trichoplax.state.volume[:] =
# restvolume.*(1.0 .-
# sign.(trichoplax.state.potential).*
# sqrt.(abs.(trichoplax.state.potential/4.0)))
# trichoplax = morph(trichoplax, .0001, 25)
#
# redraw(trichoplax,cells_handle)
# potential_remap(trichoplax, ch, 1)
#
# println(tick)
# display(scene)
# sleep(.005)
# end
# end
# ch[12][:color] = [ RGB{Float64}(0.913603,0.0,0.0),
# RGB{Float64}(0.,0.,1.0),
# RGB{Float64}(0.913603,0.0,0.788739),
# RGB{Float64}(0.913603,0.61886,0.788739),
# RGB{Float64}(0.913603,0.61886,0.788739),
# RGB{Float64}(0.913603,0.61886,0.788739),
# RGB{Float64}(0.913603,0.61886,0.788739)]