Introduction
Introduction Statistics Contact Development Disclaimer Help
tlogo.jl - Granular.jl - Julia package for granular dynamics simulation
git clone git://src.adamsgaard.dk/Granular.jl
Log
Files
Refs
README
LICENSE
---
tlogo.jl (5220B)
---
1 #!/usr/bin/env julia
2
3 import Granular
4 using Random
5
6 let
7
8 verbose = true
9
10 text = "Granular.jl"
11
12 #forcing = "gyres"
13 forcing = "down"
14 #forcing = "convergent"
15
16 # Font created with `figlet` and the font 'pebbles'.
17 #logo_string = read(`figlet -f pebbles "$text"`, String)
18
19 # If figlet is not installed on your system, use the string below:
20 logo_string =
21 """ .oOOOo. o o
22 .O o O O O
23 o o o
24 O O O
25 O .oOOo `OoOo. .oOoO' 'OoOo. O o o .oOoO' `OoOo. 'o o
26 o. O o O o o O o O O O o o O O
27 O. oO O o O O o O o o o O O oO o o
28 `OooO' o `OoO'o o O `OoO'o Oo `OoO'o o Oo O Oo
29 o
30 oO' """
31
32 dx = 1.
33 dy = dx
34
35 logo_string_split = split(logo_string, '\n')
36
37 ny = length(logo_string_split)
38 maxwidth = 0
39 for i=1:ny
40 if maxwidth < length(logo_string_split[i])
41 maxwidth = length(logo_string_split[i])
42 end
43 end
44 nx = maxwidth + 1
45
46 Lx = nx*dx
47 Ly = (ny + 1)*dy
48
49 x = 0.
50 y = 0.
51 r = 0.
52 c = ' '
53 h = .5
54 youngs_modulus = 2e6
55
56 sim = Granular.createSimulation(id="logo")
57
58 print(logo_string)
59 @info "nx = $nx, ny = $ny"
60
61 for iy=1:length(logo_string_split)
62 for ix=1:length(logo_string_split[iy])
63
64 c = logo_string_split[iy][ix]
65
66 if c == ' '
67 continue
68 elseif c == 'O'
69 x = ix*dx - .5*dx
70 y = Ly - (iy*dy - .5*dy)
71 r = .5*dx
72 elseif c == 'o'
73 x = ix*dx - .5*dx
74 y = Ly - (iy*dy - .33*dy)
75 r = .33*dx
76 elseif c == 'o'
77 x = ix*dx - .5*dx
78 y = Ly - (iy*dy - .25*dy)
79 r = .25*dx
80 elseif c == '\''
81 x = ix*dx - .75*dx
82 y = Ly - (iy*dy - .75*dy)
83 r = .25*dx
84 elseif c == '`'
85 x = ix*dx - .25*dx
86 y = Ly - (iy*dy - .75*dy)
87 r = .25*dx
88 end
89
90 if r > 0.
91 Granular.addGrainCylindrical!(sim, [x + dx, y - dy], r, h,
92 tensile_strength=200e3,
93 youngs_modulus=youngs_modulu…
94 verbose=verbose)
95 end
96 r = -1.
97 end
98 end
99
100 # set ocean forcing
101 sim.ocean = Granular.createRegularOceanGrid([nx, ny, 1], [Lx, Ly, 1.],
102 name="logo_ocean")
103
104 if forcing == "gyres"
105 epsilon = 0.25 # amplitude of periodic oscillations
106 t = 0.
107 a = epsilon*sin(2.0*pi*t)
108 b = 1.0 - 2.0*epsilon*sin(2.0*pi*t)
109 for i=1:size(sim.ocean.u, 1)
110 for j=1:size(sim.ocean.u, 2)
111
112 x = sim.ocean.xq[i, j]/(Lx*.5) # x in [0;2]
113 y = sim.ocean.yq[i, j]/Ly # y in [0;1]
114
115 f = a*x^2.0 + b*x
116 df_dx = 2.0*a*x + b
117
118 sim.ocean.u[i, j, 1, 1] = -pi/10.0*sin(pi*f)*cos(pi*y) * 2e1
119 sim.ocean.v[i, j, 1, 1] = pi/10.0*cos(pi*f)*sin(pi*y)*df_dx …
120 end
121 end
122
123 elseif forcing == "down"
124 Random.seed!(1)
125 sim.ocean.u[:, :, 1, 1] = (rand(nx+1, ny+1) .- 0.5) .* 0.1
126 sim.ocean.v[:, :, 1, 1] .= -5.0
127
128 elseif forcing == "convergent"
129 Random.seed!(1)
130 sim.ocean.u[:, :, 1, 1] = (rand(nx+1, ny+1) .- 0.5) .* 0.1
131 for j=1:size(sim.ocean.u, 2)
132 sim.ocean.v[:, j, 1, 1] .= -(j/ny - 0.5)*10.0
133 end
134
135 else
136 error("Forcing not understood")
137 end
138
139 # Initialize confining walls, which are ice floes that are fixed in space
140 r = dx/4.
141
142 ## N-S wall segments
143 for y in range(r, stop=Ly-r, length=Int(round((Ly - 2.0*r)/(r*2))))
144 Granular.addGrainCylindrical!(sim, [r, y], r, h, fixed=true,
145 youngs_modulus=youngs_modulus,
146 verbose=false)
147 Granular.addGrainCylindrical!(sim, [Lx-r, y], r, h, fixed=true,
148 youngs_modulus=youngs_modulus,
149 verbose=false)
150 end
151
152 ## E-W wall segments
153 for x in range(3.0*r, stop=Lx-3.0*r, length=Int(round((Lx - 6.0*r)/(r*2)…
154 Granular.addGrainCylindrical!(sim, [x, r], r, h, fixed=true,
155 youngs_modulus=youngs_modulus,
156 verbose=false)
157 Granular.addGrainCylindrical!(sim, [x, Ly-r], r, h, fixed=true,
158 youngs_modulus=youngs_modulus,
159 verbose=false)
160 end
161
162
163 # Finalize setup and start simulation
164 Granular.setTimeStep!(sim, verbose=verbose)
165
166 Granular.setTotalTime!(sim, 5.)
167 Granular.setOutputFileInterval!(sim, .1)
168
169 Granular.removeSimulationFiles(sim)
170
171 while sim.time < sim.time_total
172 for i=1:100
173 Granular.run!(sim, single_step=true, verbose=verbose)
174 end
175 Granular.plotGrains(sim, show_figure=false)
176 end
177
178 # Granular.render(sim, images=true, animation=false, reverse=true)
179
180 # run(`convert -delay 100 logo/logo.0000.png -delay 10 logo/logo.'*'.png…
181 # +repage -delay 10 -transparent-color white -quiet -layers Optimize…
182 # -loop 0 logo.gif`)
183 end
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.