-
Notifications
You must be signed in to change notification settings - Fork 0
/
eigenmodes.jl
54 lines (46 loc) · 1.52 KB
/
eigenmodes.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
PLOT = false
include("utils.jl")
using Printf
using DelimitedFiles
# ----------------------------------------------------------- #
# Constants and setup #
# ----------------------------------------------------------- #
LEVEL = 4
GRID_CONSTANT = 2
NUMBER_OF_MODES = 10
DATA_DIR = "datafiles/eigenmodes/"
STENCIL = :five
# End of setup - you shouldn't need to change anything below this linie
info = Dict([
("LEVEL", LEVEL),
("GRID CONSTANT", GRID_CONSTANT),
("NUMBER OF MODES", NUMBER_OF_MODES),
("DATA DIR", DATA_DIR),
("STENCIL", STENCIL),
])
print(format_info(info))
values, vectors, fractal, inner_list = solve_eigenproblem(
level=LEVEL,
grid_constant=GRID_CONSTANT,
number_of_modes=NUMBER_OF_MODES,
stencil=STENCIL,
return_inner_list=true
)
fractal_x, fractal_y = get_component_lists(fractal)
# Write to file
# In DATA_DIR, create a new folder containing three files, the modes, the eigenvalues, and the inner list
println(" .Writing to file")
dirname = @sprintf "level_%i_grid_%i_stencil_%s_modes_%i/" LEVEL GRID_CONSTANT STENCIL NUMBER_OF_MODES
dirname = string(DATA_DIR, dirname)
mkpath(dirname)
for (filename, data) in [
("inner_list", [index.I for index in inner_list]), # We want to have tuples, not CartesianIndex
("eigenvalues", values),
("eigenmodes", vectors),
("fractal", [fractal_x fractal_y])
]
open(string(dirname, filename, ".txt"), "w") do file
writedlm(file, data)
end
println(" .Wrote ", filename, ".txt")
end