-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm2d.jl
228 lines (194 loc) · 5.32 KB
/
vm2d.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# """
# 2-D vortex method.
# # AUTHORSHIP
# * Author : Ryan Anderson
# * Email : rymanderson@gmail.com
# * Created : 2019
# * License : MIT License
# """
# module vm2d
# Import Modules
# import GeometricTools
# gt = GeometricTools
import LinearAlgebra
la = LinearAlgebra
import PyPlot
plt = PyPlot
include("vm2d_geometry.jl")
include("vm2d_particle.jl")
include("vm2d_plottools.jl")
# set freestream
function Uinf(x::Array{Float64,1})
Uinf = [0.0,0.0,0.0]
return Uinf
end
# # plot x-y view
# function plot_xy(particles::Array{Particle,1}; title::String="", save::Bool=false, name::String="default_sim", pause::Float64=-1.0)
# # plot
# plt.clf()
# for particle in particles
# plt.scatter(particle.x[1],particle.x[2],c=la.norm(particle.gamma))
# end
# plt.title(title)
# plt.xlabel("x")
# plt.ylabel("y")
# plt.axis("equal")
# # save frame
# if save==true
# plt.savefig("sim/"*name*".png")
# end
# # pause frame
# if pause > 0.0
# plt.pause(pause)
# end
# end
# # plot y-z view
# function plot_yz(particles::Array{Particle,1}; title::String="", save::Bool=false, name::String="default_sim", pause::Float64=-1.0)
# # plot
# plt.clf()
# for particle in particles
# plt.scatter(particle.x[2],particle.x[3],c=la.norm(particle.gamma))
# end
# plt.title(title)
# plt.xlabel("y")
# plt.ylabel("z")
# plt.axis("equal")
# # save frame
# if save==true
# plt.savefig("sim/"*name*".png")
# end
# # pause frame
# if pause > 0.0
# plt.pause(pause)
# end
# end
# Uinf(x) = [0.0,0.0,0.0] # default freestream velocity function
# # animate
# function animate(particles,timestart,timestep,numtimesteps; Uinf=Uinf)
# currenttime = timestart
# # 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)))
# # animate
# for i in range(1,length=numtimesteps)
# ## advance timestep
# advance(particles,timestep,Uinf)
# currenttime += timestep
# ## update plot
# plot_xy(particles; title="time: "*string(round(currenttime; digits=3)))
# end
# end
# OPTION ONE: CIRCLE
# create circle geometry
# center = [0.0,0.0]
# radius = 0.1
# thetastart = 0.0
# thetaend = 2*pi
# refinement = 9
# points = circlexy(center,radius,refinement,thetastart,thetaend)
# # set vectorial vortex strengths
# gamma = [0,0,1.0]
# gammas = Array{Float64,1}[]
# for point in points
# push!(gammas,gamma)
# end
# # set initial particle velocities
# vs = Array{Float64,1}[]
# for point in points
# v = Uinf(point)
# push!(vs,v)
# end
# particles = place(points,gammas,vs)
# # set simulation variables
# name = "vortexrings"
# global currenttime
# currenttime = 0.0
# timestep = 0.01
# numtimesteps = 150
# END OPTION 1
# OPTION 2: 2D VORTEX RINGS
# # 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 = 150
# END OPTION 2
# # OPTION 3: 3D VORTEX RINGS
# # create vortex ring geometry
# ## required arguments
# radius1 = 0.1
# radius2 = 0.1
# spacing = 0.05
# refinement = 9
# ## build geometry
# thetastart = 0.0
# thetaend = 2*pi
# center = [0.0,0.0,0.0]
# radius = radius1
# ring1 = circlexy(center,radius,refinement,thetastart,thetaend)
# center = [0.0,0.0,spacing]
# radius = radius2
# ring1 = circlexy(center,radius,refinement,thetastart,thetaend)
# # 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 = 150
# # END OPTION 3
# # plot
# ## OPTION 1: toggle 2D x-y 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)))
# ## save frame
# plt.savefig("sim/"*name*"_"*string(currenttime)*".png")
# ## run simulation
# for i in range(1,length=numtimesteps)
# ## advance timestep
# advance(particles,timestep,Uinf)
# currenttime += timestep
# ## update plot
# plt.clf()
# 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)))
# plt.axis("equal")
# ## save frame
# plt.savefig("sim/"*name*"_"*string(i)*".png")
# println(particles)
# end