-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_leapfrog2d.jl
61 lines (55 loc) · 1.6 KB
/
test_leapfrog2d.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
# test leap-frogging vortex rings in 2d
include("vm2d.jl")
# create vortex ring geometry
radius1 = 0.1
radius2 = 0.1
spacing = 0.05
points = [[-spacing,radius1,0.0],[-spacing,-radius1,0.0],[0.0,radius2,0.0],[0.0,-radius2,0.0]]
# set vectorial vortex strengths
gamma = 0.1
gamma_upper = [0,0,gamma]
gamma_lower = [0,0,-gamma]
gammas = [gamma_upper,gamma_lower,gamma_upper,gamma_lower]
# set initial velocities
v0 = 0.0
vs = [[v0,0.0,0.0],[v0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]]
particles = place(points,gammas,vs)
# set simulation variables
name = "vortexrings"
global currenttime
currenttime = 0.0
timestep = 0.01
numtimesteps = 3 # try 150
if ~isdir("./sim")
mkdir("./sim")
end
# animate!
# set up plot
plt.plot()
plt.hot()
plt.axis("equal")
for particle in particles
plt.scatter(particle.x[1],particle.x[2],c=particle.gamma[3])
end
plt.title("time: "*string(round(currenttime; digits=3)))
if ~isdir("sim")
mkdir("sim")
end
# animate
for i in range(1,length=numtimesteps)
## advance timestep
advance(particles,timestep,Uinf)
currenttime += timestep
## evaluate velocity field
zs = range(-radius1, stop=radius1, length=6)
ys = [0.0] #range(-2*radius1,stop=2*radius1,length=20)
xs = range(particles[1].x[1] - 4*spacing,
stop = particles[1].x[1] + 4*spacing,
length = 11)
(x,y,z,u,v,w) = vfield(particles, xs, ys, zs)
## update plot
name = "leapfrog_2d_zx"*string(i)
plot_2d(particles, "zx"; velocity=true, xs=xs, ys=ys, zs=zs, title="time: "*string(round(currenttime; digits=3)), save=true, name=name)
# plt.quiver(x,y,u,v)
plt.pause(0.005)
end