-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_output.jl
74 lines (60 loc) · 1.64 KB
/
plot_output.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
include("/Users/cathji/Documents/GitHub/TwistRods/submit.jl")
"""
RUNNING SIMULATION
"""
n = 21 #vertices
#initialize parameters: # vertices, voronoi length, external forces @ ends of rod
p = (n,1.,[3.,0.,0.],[-3.,0.,0.])
#initialize rod configuration
q0 = Array{Float64}(undef,4*n + 3)
q0[1:3] = [0. 1. 0.]
for i = 1:n
q0[(3*(i - 1)) + 4:(3*(i - 1)) + 6] = [i*1. 0. 0.]
end #loop
j = 3
q0[(3*(j - 1)) + 4:(3*(j - 1)) + 6] += [0.,0.,0.1]
tot_thet = 5 * pi
q0[end-(n-1):end] = 0. : tot_thet/(n-1) : tot_thet
#init. fine and coarse solvers
algF = RK4()
algG = RK4()
dtF = 10^(-4)
dtC = 10^(-3)
#choosing diff. eq.
# f! = gTw!
f! = gTwF!
#init. ODE problem
tspan = (0.,10.)
tarr = 0.:0.1:10. #1 time-interval per processor
tcount = Int(round(tarr[2]/dtF)) + 1
tlen = length(tarr)
prob = ODEProblem(f!,q0,tspan,p)
#init. # of parareal iterations
kcount = 5
#initial estimate of U
solG_init = solve(prob,algG;dt = dtC,adaptive=false)
soln_plot = solG_init
# anim_xyzG = @animate for k ∈ 1:length(soln_plot)
# temp = soln_plot.u[k]
# temp_p = reshape(temp[1 + 3:3*n + 3],(3,n))
# plt1 = plot(temp_p[1,:],temp_p[2,:],temp_p[3,:],legend=false,linewidth = 3)
# title!("Twisted rod")
# xlims!(-1.,11.)
# ylims!(-2.,2.)
# zlims!(-2.,2.)
# plot(plt1)
# end every 100
#
# gif(anim_xyzG,"mygifXYZ_COARSE.gif", fps = 20)
#saving plotting data
"""
SAVING PLOTTING DATA
"""
using DelimitedFiles
using DataFrames, CSV
outWRAPPER = Array{Float64}(undef,(length(soln_plot),length(soln_plot[1])))
for i = 1:length(soln_plot)
outWRAPPER[i,:] = soln_plot[i][:]
end #loop
outWRAPPER = Tables.table(outWRAPPER)
CSV.write("out.csv",outWRAPPER)