Merge branch 'coryab/code' into janitaws/latex
This commit is contained in:
commit
e7a32bebab
2
.clangd
2
.clangd
@ -1,2 +1,2 @@
|
||||
CompileFlags:
|
||||
Add: [-I../include]
|
||||
Add: [-I../include, -std=c++11]
|
||||
|
||||
45
Makefile
45
Makefile
@ -1,5 +1,5 @@
|
||||
# The compiler
|
||||
CC=mpicxx
|
||||
CC=g++
|
||||
|
||||
# Flags
|
||||
CFLAGS=-Wall -larmadillo -std=c++11 -O3 -fopenmp
|
||||
@ -26,19 +26,26 @@ LATEXDIR=./latex
|
||||
|
||||
# Source directories
|
||||
SRC=./src
|
||||
LIB=./lib
|
||||
INCLUDE=./include
|
||||
|
||||
# Source files and object file locations
|
||||
SRCFILES=utils.cpp testlib.cpp data_type.cpp IsingModel.cpp monte_carlo.cpp
|
||||
SRCS=$(addprefix $(SRC)/, $(SRCS))
|
||||
BINOBJS=$(addprefix $(BINOBJDIR)/, $(SRCFILES:.cpp=.o))
|
||||
PROFOBJS=$(addprefix $(PROFOBJDIR)/, $(SRCFILES:.cpp=.o))
|
||||
DEBUGOBJS=$(addprefix $(DEBUGOBJDIR)/, $(SRCFILES:.cpp=.o))
|
||||
#SRCFILES=utils.cpp testlib.cpp
|
||||
#SRCS=$(addprefix $(SRC)/, $(SRCS))
|
||||
#BINOBJS=$(addprefix $(BINOBJDIR)/, $(SRCFILES:.cpp=.o))
|
||||
#PROFOBJS=$(addprefix $(PROFOBJDIR)/, $(SRCFILES:.cpp=.o))
|
||||
#DEBUGOBJS=$(addprefix $(DEBUGOBJDIR)/, $(SRCFILES:.cpp=.o))
|
||||
|
||||
# Lib files
|
||||
LIBSRCS=$(notdir $(shell find $(LIB) -type f))
|
||||
LIBBINOBJS=$(addprefix $(BINOBJDIR)/, $(LIBSRCS:.cpp=.o))
|
||||
LIBPROFOBJS=$(addprefix $(PROFOBJDIR)/, $(LIBSRCS:.cpp=.o))
|
||||
LIBDEBUGOBJS=$(addprefix $(DEBUGOBJDIR)/, $(LIBSRCS:.cpp=.o))
|
||||
|
||||
# Location for Binaries
|
||||
EXEC=main test_suite phase_transition phase_transition_mpi time pd_estimate mcmc_progression
|
||||
EXEC=$(basename $(notdir $(shell find $(SRC) -type f)))
|
||||
BINS=$(addprefix $(BINDIR)/, $(EXEC))
|
||||
PROFBINS=$(PROFDIR)/phase_transition_mpi
|
||||
PROFBINS=$(addprefix $(PROFDIR)/, $(EXEC))
|
||||
DEBUGBINS=$(addprefix $(DEBUGDIR)/, $(EXEC))
|
||||
|
||||
# List phony targets
|
||||
@ -56,23 +63,24 @@ latex:
|
||||
$(MAKE) -C $(LATEXDIR)
|
||||
|
||||
# Rule for binaries
|
||||
$(BINDIR)/%: $(BINOBJDIR)/%.o $(BINOBJS)
|
||||
$(BINDIR)/%: $(BINOBJDIR)/%.o $(LIBBINOBJS)
|
||||
$(MKDIR) $(BINDIR)
|
||||
$(CC) $^ -o $@ $(CFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Rule for profiling binaries
|
||||
$(PROFDIR)/%: $(PROFOBJDIR)/%.o $(PROFOBJS)
|
||||
$(PROFDIR)/%: $(PROFOBJDIR)/%.o $(LIBPROFOBJS)
|
||||
$(MKDIR) $(PROFDIR)
|
||||
$(INSTRUMENT) $(CC) $^ -o $@ $(CFLAGS) $(PROFFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Rule for debug binaries
|
||||
$(DEBUGDIR)/%: $(DEBUGOBJDIR)/%.o $(DEBUGOBJS)
|
||||
$(DEBUGDIR)/%: $(DEBUGOBJDIR)/%.o $(LIBDEBUGOBJS)
|
||||
$(MKDIR) $(DEBUGDIR)
|
||||
$(CC) $^ -o $@ $(CFLAGS) $(DBGFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Rule for object files
|
||||
$(BINOBJDIR)/%.o: $(SRC)/%.cpp
|
||||
$(MKDIR) $(BINOBJDIR)
|
||||
echo $(LIBBINOBJS)
|
||||
$(CC) -c $^ -o $@ $(CFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Rule for instrumented object files
|
||||
@ -85,6 +93,21 @@ $(DEBUGOBJDIR)/%.o: $(SRC)/%.cpp
|
||||
$(MKDIR) $(DEBUGOBJDIR)
|
||||
$(CC) -c $^ -o $@ $(CFLAGS) $(DBGFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Rule for object files
|
||||
$(BINOBJDIR)/%.o: $(LIB)/%.cpp
|
||||
$(MKDIR) $(BINOBJDIR)
|
||||
$(CC) -c $^ -o $@ $(CFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Rule for instrumented object files
|
||||
$(PROFOBJDIR)/%.o: $(LIB)/%.cpp
|
||||
$(MKDIR) $(PROFOBJDIR)
|
||||
$(INSTRUMENT) $(CC) -c $^ -o $@ $(CFLAGS) $(PROFFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Rule for debug object files
|
||||
$(DEBUGOBJDIR)/%.o: $(LIB)/%.cpp
|
||||
$(MKDIR) $(DEBUGOBJDIR)
|
||||
$(CC) -c $^ -o $@ $(CFLAGS) $(DBGFLAGS) -I$(INCLUDE)
|
||||
|
||||
# Cleaning
|
||||
clean: objclean binclean latexclean
|
||||
|
||||
|
||||
4
data/color_map.txt
Normal file
4
data/color_map.txt
Normal file
File diff suppressed because one or more lines are too long
320
data/probability_deviation.txt
Normal file
320
data/probability_deviation.txt
Normal file
@ -0,0 +1,320 @@
|
||||
0, 1.0000000000e+00, 1.0000000000e+00
|
||||
1, 1.0000000000e+00, 1.0000000000e+00
|
||||
2, 1.0000000000e+00, 1.0000000000e+00
|
||||
3, 1.0000000000e+00, 1.0000000000e+00
|
||||
4, 1.0000000000e+00, 1.0000000000e+00
|
||||
5, 1.0000000000e+00, 1.0000000000e+00
|
||||
6, 1.0000000000e+00, 1.0000000000e+00
|
||||
7, 1.0000000000e+00, 1.0000000000e+00
|
||||
8, 1.0000000000e+00, 1.0000000000e+00
|
||||
9, 1.0000000000e+00, 1.0000000000e+00
|
||||
10, 1.0000000000e+00, 1.0000000000e+00
|
||||
11, 1.0000000000e+00, 1.0000000000e+00
|
||||
12, 1.0000000000e+00, 1.0000000000e+00
|
||||
13, 1.0000000000e+00, 1.0000000000e+00
|
||||
14, 1.0000000000e+00, 1.0000000000e+00
|
||||
15, 1.0000000000e+00, 1.0000000000e+00
|
||||
16, 1.0000000000e+00, 1.0000000000e+00
|
||||
17, 1.0000000000e+00, 1.0000000000e+00
|
||||
18, 1.0000000000e+00, 1.0000000000e+00
|
||||
19, 1.0000000000e+00, 1.0000000000e+00
|
||||
20, 1.0000000000e+00, 1.0000000000e+00
|
||||
21, 1.0000000000e+00, 1.0000000000e+00
|
||||
22, 1.0000000000e+00, 1.0000000000e+00
|
||||
23, 1.0000000000e+00, 1.0000000000e+00
|
||||
24, 1.0000000000e+00, 1.0000000000e+00
|
||||
25, 1.0000000000e+00, 1.0000000000e+00
|
||||
26, 1.0000000000e+00, 1.0000000000e+00
|
||||
27, 1.0000000000e+00, 1.0000000000e+00
|
||||
28, 1.0000000000e+00, 1.0000000000e+00
|
||||
29, 1.0000000000e+00, 1.0000000000e+00
|
||||
30, 1.0000000000e+00, 1.0000000000e+00
|
||||
31, 1.0000000000e+00, 1.0000000000e+00
|
||||
32, 1.0000000000e+00, 1.0000000000e+00
|
||||
33, 1.0000000000e+00, 1.0000000000e+00
|
||||
34, 1.0000000000e+00, 1.0000000000e+00
|
||||
35, 1.0000000000e+00, 1.0000000000e+00
|
||||
36, 1.0000000000e+00, 1.0000000000e+00
|
||||
37, 1.0000000000e+00, 1.0000000000e+00
|
||||
38, 1.0000000000e+00, 1.0000000000e+00
|
||||
39, 1.0000000000e+00, 1.0000000000e+00
|
||||
40, 1.0000000000e+00, 1.0000000000e+00
|
||||
41, 1.0000000000e+00, 1.0000000000e+00
|
||||
42, 1.0000000000e+00, 1.0000000000e+00
|
||||
43, 1.0000000000e+00, 1.0000000000e+00
|
||||
44, 1.0000000000e+00, 1.0000000000e+00
|
||||
45, 1.0000000000e+00, 1.0000000000e+00
|
||||
46, 1.0000000000e+00, 1.0000000000e+00
|
||||
47, 1.0000000000e+00, 1.0000000000e+00
|
||||
48, 1.0000000000e+00, 1.0000000000e+00
|
||||
49, 1.0000000000e+00, 1.0000000000e+00
|
||||
50, 1.0000000000e+00, 1.0000000000e+00
|
||||
51, 1.0000000000e+00, 1.0000000000e+00
|
||||
52, 1.0000000000e+00, 1.0000000000e+00
|
||||
53, 1.0000000000e+00, 1.0000000000e+00
|
||||
54, 1.0000000000e+00, 1.0000000000e+00
|
||||
55, 1.0000000000e+00, 1.0000000000e+00
|
||||
56, 1.0000000000e+00, 1.0000000000e+00
|
||||
57, 1.0000000000e+00, 1.0000000000e+00
|
||||
58, 1.0000000000e+00, 1.0000000000e+00
|
||||
59, 1.0000000000e+00, 1.0000000000e+00
|
||||
60, 1.0000000000e+00, 1.0000000000e+00
|
||||
61, 1.0000000000e+00, 1.0000000000e+00
|
||||
62, 1.0000000000e+00, 1.0000000000e+00
|
||||
63, 1.0000000000e+00, 1.0000000000e+00
|
||||
64, 1.0000000000e+00, 1.0000000000e+00
|
||||
65, 1.0000000000e+00, 1.0000000000e+00
|
||||
66, 1.0000000000e+00, 1.0000000000e+00
|
||||
67, 1.0000000000e+00, 1.0000000000e+00
|
||||
68, 1.0000000000e+00, 1.0000000000e+00
|
||||
69, 1.0000000000e+00, 1.0000000000e+00
|
||||
70, 1.0000000000e+00, 1.0000000000e+00
|
||||
71, 1.0000000000e+00, 1.0000000000e+00
|
||||
72, 1.0000000000e+00, 1.0000000000e+00
|
||||
73, 1.0000000000e+00, 1.0000000000e+00
|
||||
74, 1.0000000000e+00, 1.0000000000e+00
|
||||
75, 1.0000000000e+00, 1.0000000000e+00
|
||||
76, 1.0000000000e+00, 1.0000000000e+00
|
||||
77, 1.0000000000e+00, 1.0000000000e+00
|
||||
78, 1.0000000000e+00, 1.0000000000e+00
|
||||
79, 1.0000000000e+00, 1.0000000000e+00
|
||||
80, 1.0000000000e+00, 1.0000000000e+00
|
||||
81, 1.0000000000e+00, 1.0000000000e+00
|
||||
82, 1.0000000000e+00, 1.0000000000e+00
|
||||
83, 1.0000000000e+00, 1.0000000000e+00
|
||||
84, 1.0000000000e+00, 1.0000000000e+00
|
||||
85, 1.0000000000e+00, 1.0000000000e+00
|
||||
86, 1.0000000000e+00, 1.0000000000e+00
|
||||
87, 1.0000000000e+00, 1.0000000000e+00
|
||||
88, 1.0000000000e+00, 1.0000000000e+00
|
||||
89, 1.0000000000e+00, 1.0000000000e+00
|
||||
90, 1.0000000000e+00, 1.0000000000e+00
|
||||
91, 1.0000000000e+00, 1.0000000000e+00
|
||||
92, 1.0000000000e+00, 1.0000000000e+00
|
||||
93, 1.0000000000e+00, 1.0000000000e+00
|
||||
94, 1.0000000000e+00, 1.0000000000e+00
|
||||
95, 1.0000000000e+00, 1.0000000000e+00
|
||||
96, 1.0000000000e+00, 1.0000000000e+00
|
||||
97, 1.0000000000e+00, 1.0000000000e+00
|
||||
98, 1.0000000000e+00, 1.0000000000e+00
|
||||
99, 1.0000000000e+00, 1.0000000000e+00
|
||||
100, 1.0000000000e+00, 1.0000000000e+00
|
||||
101, 1.0000000000e+00, 1.0000000000e+00
|
||||
102, 1.0000000000e+00, 1.0000000000e+00
|
||||
103, 1.0000000000e+00, 1.0000000000e+00
|
||||
104, 1.0000000000e+00, 1.0000000000e+00
|
||||
105, 1.0000000000e+00, 1.0000000000e+00
|
||||
106, 1.0000000000e+00, 1.0000000000e+00
|
||||
107, 1.0000000000e+00, 1.0000000000e+00
|
||||
108, 1.0000000000e+00, 1.0000000000e+00
|
||||
109, 1.0000000000e+00, 1.0000000000e+00
|
||||
110, 1.0000000000e+00, 1.0000000000e+00
|
||||
111, 1.0000000000e+00, 1.0000000000e+00
|
||||
112, 1.0000000000e+00, 1.0000000000e+00
|
||||
113, 1.0000000000e+00, 1.0000000000e+00
|
||||
114, 1.0000000000e+00, 1.0000000000e+00
|
||||
115, 1.0000000000e+00, 1.0000000000e+00
|
||||
116, 1.0000000000e+00, 1.0000000000e+00
|
||||
117, 1.0000000000e+00, 1.0000000000e+00
|
||||
118, 1.0000000000e+00, 1.0000000000e+00
|
||||
119, 1.0000000000e+00, 1.0000000000e+00
|
||||
120, 1.0000000000e+00, 1.0000000000e+00
|
||||
121, 1.0000000000e+00, 1.0000000000e+00
|
||||
122, 1.0000000000e+00, 1.0000000000e+00
|
||||
123, 1.0000000000e+00, 1.0000000000e+00
|
||||
124, 1.0000000000e+00, 1.0000000000e+00
|
||||
125, 1.0000000000e+00, 1.0000000000e+00
|
||||
126, 1.0000000000e+00, 1.0000000000e+00
|
||||
127, 1.0000000000e+00, 1.0000000000e+00
|
||||
128, 1.0000000000e+00, 1.0000000000e+00
|
||||
129, 1.0000000000e+00, 1.0000000000e+00
|
||||
130, 1.0000000000e+00, 1.0000000000e+00
|
||||
131, 1.0000000000e+00, 1.0000000000e+00
|
||||
132, 1.0000000000e+00, 1.0000000000e+00
|
||||
133, 1.0000000000e+00, 1.0000000000e+00
|
||||
134, 1.0000000000e+00, 1.0000000000e+00
|
||||
135, 1.0000000000e+00, 1.0000000000e+00
|
||||
136, 1.0000000000e+00, 1.0000000000e+00
|
||||
137, 1.0000000000e+00, 1.0000000000e+00
|
||||
138, 1.0000000000e+00, 1.0000000000e+00
|
||||
139, 1.0000000000e+00, 1.0000000000e+00
|
||||
140, 1.0000000000e+00, 1.0000000000e+00
|
||||
141, 1.0000000000e+00, 1.0000000000e+00
|
||||
142, 1.0000000000e+00, 1.0000000000e+00
|
||||
143, 1.0000000000e+00, 1.0000000000e+00
|
||||
144, 1.0000000000e+00, 1.0000000000e+00
|
||||
145, 1.0000000000e+00, 1.0000000000e+00
|
||||
146, 1.0000000000e+00, 1.0000000000e+00
|
||||
147, 1.0000000000e+00, 1.0000000000e+00
|
||||
148, 1.0000000000e+00, 1.0000000000e+00
|
||||
149, 1.0000000000e+00, 1.0000000000e+00
|
||||
150, 1.0000000000e+00, 1.0000000000e+00
|
||||
151, 1.0000000000e+00, 1.0000000000e+00
|
||||
152, 1.0000000000e+00, 1.0000000000e+00
|
||||
153, 1.0000000000e+00, 1.0000000000e+00
|
||||
154, 1.0000000000e+00, 1.0000000000e+00
|
||||
155, 1.0000000000e+00, 1.0000000000e+00
|
||||
156, 1.0000000000e+00, 1.0000000000e+00
|
||||
157, 1.0000000000e+00, 1.0000000000e+00
|
||||
158, 1.0000000000e+00, 1.0000000000e+00
|
||||
159, 1.0000000000e+00, 1.0000000000e+00
|
||||
160, 1.0000000000e+00, 1.0000000000e+00
|
||||
161, 1.0000000000e+00, 1.0000000000e+00
|
||||
162, 1.0000000000e+00, 1.0000000000e+00
|
||||
163, 1.0000000000e+00, 1.0000000000e+00
|
||||
164, 1.0000000000e+00, 1.0000000000e+00
|
||||
165, 1.0000000000e+00, 1.0000000000e+00
|
||||
166, 1.0000000000e+00, 1.0000000000e+00
|
||||
167, 1.0000000000e+00, 1.0000000000e+00
|
||||
168, 1.0000000000e+00, 1.0000000000e+00
|
||||
169, 1.0000000000e+00, 1.0000000000e+00
|
||||
170, 1.0000000000e+00, 1.0000000000e+00
|
||||
171, 1.0000000000e+00, 1.0000000000e+00
|
||||
172, 1.0000000000e+00, 1.0000000000e+00
|
||||
173, 1.0000000000e+00, 1.0000000000e+00
|
||||
174, 1.0000000000e+00, 1.0000000000e+00
|
||||
175, 1.0000000000e+00, 1.0000000000e+00
|
||||
176, 1.0000000000e+00, 1.0000000000e+00
|
||||
177, 1.0000000000e+00, 1.0000000000e+00
|
||||
178, 1.0000000000e+00, 1.0000000000e+00
|
||||
179, 1.0000000000e+00, 1.0000000000e+00
|
||||
180, 1.0000000000e+00, 1.0000000000e+00
|
||||
181, 1.0000000000e+00, 1.0000000000e+00
|
||||
182, 1.0000000000e+00, 1.0000000000e+00
|
||||
183, 1.0000000000e+00, 1.0000000000e+00
|
||||
184, 1.0000000000e+00, 1.0000000000e+00
|
||||
185, 1.0000000000e+00, 1.0000000000e+00
|
||||
186, 1.0000000000e+00, 1.0000000000e+00
|
||||
187, 1.0000000000e+00, 1.0000000000e+00
|
||||
188, 1.0000000000e+00, 1.0000000000e+00
|
||||
189, 1.0000000000e+00, 1.0000000000e+00
|
||||
190, 1.0000000000e+00, 1.0000000000e+00
|
||||
191, 1.0000000000e+00, 1.0000000000e+00
|
||||
192, 1.0000000000e+00, 1.0000000000e+00
|
||||
193, 1.0000000000e+00, 1.0000000000e+00
|
||||
194, 1.0000000000e+00, 1.0000000000e+00
|
||||
195, 1.0000000000e+00, 1.0000000000e+00
|
||||
196, 1.0000000000e+00, 1.0000000000e+00
|
||||
197, 1.0000000000e+00, 1.0000000000e+00
|
||||
198, 1.0000000000e+00, 1.0000000000e+00
|
||||
199, 1.0000000000e+00, 1.0000000000e+00
|
||||
200, 1.0000000000e+00, 1.0000000000e+00
|
||||
201, 1.0000000000e+00, 1.0000000000e+00
|
||||
202, 1.0000000000e+00, 1.0000000000e+00
|
||||
203, 1.0000000000e+00, 1.0000000000e+00
|
||||
204, 1.0000000000e+00, 1.0000000000e+00
|
||||
205, 1.0000000000e+00, 1.0000000000e+00
|
||||
206, 1.0000000000e+00, 1.0000000000e+00
|
||||
207, 1.0000000000e+00, 1.0000000000e+00
|
||||
208, 1.0000000000e+00, 1.0000000000e+00
|
||||
209, 1.0000000000e+00, 1.0000000000e+00
|
||||
210, 1.0000000000e+00, 1.0000000000e+00
|
||||
211, 1.0000000000e+00, 1.0000000000e+00
|
||||
212, 1.0000000000e+00, 1.0000000000e+00
|
||||
213, 1.0000000000e+00, 1.0000000000e+00
|
||||
214, 1.0000000000e+00, 1.0000000000e+00
|
||||
215, 1.0000000000e+00, 1.0000000000e+00
|
||||
216, 1.0000000000e+00, 1.0000000000e+00
|
||||
217, 1.0000000000e+00, 1.0000000000e+00
|
||||
218, 1.0000000000e+00, 1.0000000000e+00
|
||||
219, 1.0000000000e+00, 1.0000000000e+00
|
||||
220, 1.0000000000e+00, 1.0000000000e+00
|
||||
221, 1.0000000000e+00, 1.0000000000e+00
|
||||
222, 1.0000000000e+00, 1.0000000000e+00
|
||||
223, 1.0000000000e+00, 1.0000000000e+00
|
||||
224, 1.0000000000e+00, 1.0000000000e+00
|
||||
225, 1.0000000000e+00, 1.0000000000e+00
|
||||
226, 1.0000000000e+00, 1.0000000000e+00
|
||||
227, 1.0000000000e+00, 1.0000000000e+00
|
||||
228, 1.0000000000e+00, 1.0000000000e+00
|
||||
229, 1.0000000000e+00, 1.0000000000e+00
|
||||
230, 1.0000000000e+00, 1.0000000000e+00
|
||||
231, 1.0000000000e+00, 1.0000000000e+00
|
||||
232, 1.0000000000e+00, 1.0000000000e+00
|
||||
233, 1.0000000000e+00, 1.0000000000e+00
|
||||
234, 1.0000000000e+00, 1.0000000000e+00
|
||||
235, 1.0000000000e+00, 1.0000000000e+00
|
||||
236, 1.0000000000e+00, 1.0000000000e+00
|
||||
237, 1.0000000000e+00, 1.0000000000e+00
|
||||
238, 1.0000000000e+00, 1.0000000000e+00
|
||||
239, 1.0000000000e+00, 1.0000000000e+00
|
||||
240, 1.0000000000e+00, 1.0000000000e+00
|
||||
241, 1.0000000000e+00, 1.0000000000e+00
|
||||
242, 1.0000000000e+00, 1.0000000000e+00
|
||||
243, 1.0000000000e+00, 1.0000000000e+00
|
||||
244, 1.0000000000e+00, 1.0000000000e+00
|
||||
245, 1.0000000000e+00, 1.0000000000e+00
|
||||
246, 1.0000000000e+00, 1.0000000000e+00
|
||||
247, 1.0000000000e+00, 1.0000000000e+00
|
||||
248, 1.0000000000e+00, 1.0000000000e+00
|
||||
249, 1.0000000000e+00, 1.0000000000e+00
|
||||
250, 1.0000000000e+00, 1.0000000000e+00
|
||||
251, 1.0000000000e+00, 1.0000000000e+00
|
||||
252, 1.0000000000e+00, 1.0000000000e+00
|
||||
253, 1.0000000000e+00, 1.0000000000e+00
|
||||
254, 1.0000000000e+00, 1.0000000000e+00
|
||||
255, 1.0000000000e+00, 1.0000000000e+00
|
||||
256, 1.0000000000e+00, 1.0000000000e+00
|
||||
257, 1.0000000000e+00, 1.0000000000e+00
|
||||
258, 1.0000000000e+00, 1.0000000000e+00
|
||||
259, 1.0000000000e+00, 1.0000000000e+00
|
||||
260, 1.0000000000e+00, 1.0000000000e+00
|
||||
261, 1.0000000000e+00, 1.0000000000e+00
|
||||
262, 1.0000000000e+00, 1.0000000000e+00
|
||||
263, 1.0000000000e+00, 1.0000000000e+00
|
||||
264, 1.0000000000e+00, 1.0000000000e+00
|
||||
265, 1.0000000000e+00, 1.0000000000e+00
|
||||
266, 1.0000000000e+00, 1.0000000000e+00
|
||||
267, 1.0000000000e+00, 1.0000000000e+00
|
||||
268, 1.0000000000e+00, 1.0000000000e+00
|
||||
269, 1.0000000000e+00, 1.0000000000e+00
|
||||
270, 1.0000000000e+00, 1.0000000000e+00
|
||||
271, 1.0000000000e+00, 1.0000000000e+00
|
||||
272, 1.0000000000e+00, 1.0000000000e+00
|
||||
273, 1.0000000000e+00, 1.0000000000e+00
|
||||
274, 1.0000000000e+00, 1.0000000000e+00
|
||||
275, 1.0000000000e+00, 1.0000000000e+00
|
||||
276, 1.0000000000e+00, 1.0000000000e+00
|
||||
277, 1.0000000000e+00, 1.0000000000e+00
|
||||
278, 1.0000000000e+00, 1.0000000000e+00
|
||||
279, 1.0000000000e+00, 1.0000000000e+00
|
||||
280, 1.0000000000e+00, 1.0000000000e+00
|
||||
281, 1.0000000000e+00, 1.0000000000e+00
|
||||
282, 1.0000000000e+00, 1.0000000000e+00
|
||||
283, 1.0000000000e+00, 1.0000000000e+00
|
||||
284, 1.0000000000e+00, 1.0000000000e+00
|
||||
285, 1.0000000000e+00, 1.0000000000e+00
|
||||
286, 1.0000000000e+00, 1.0000000000e+00
|
||||
287, 1.0000000000e+00, 1.0000000000e+00
|
||||
288, 1.0000000000e+00, 1.0000000000e+00
|
||||
289, 1.0000000000e+00, 1.0000000000e+00
|
||||
290, 1.0000000000e+00, 1.0000000000e+00
|
||||
291, 1.0000000000e+00, 1.0000000000e+00
|
||||
292, 1.0000000000e+00, 1.0000000000e+00
|
||||
293, 1.0000000000e+00, 1.0000000000e+00
|
||||
294, 1.0000000000e+00, 1.0000000000e+00
|
||||
295, 1.0000000000e+00, 1.0000000000e+00
|
||||
296, 1.0000000000e+00, 1.0000000000e+00
|
||||
297, 1.0000000000e+00, 1.0000000000e+00
|
||||
298, 1.0000000000e+00, 1.0000000000e+00
|
||||
299, 1.0000000000e+00, 1.0000000000e+00
|
||||
300, 1.0000000000e+00, 1.0000000000e+00
|
||||
301, 1.0000000000e+00, 1.0000000000e+00
|
||||
302, 1.0000000000e+00, 1.0000000000e+00
|
||||
303, 1.0000000000e+00, 1.0000000000e+00
|
||||
304, 1.0000000000e+00, 1.0000000000e+00
|
||||
305, 1.0000000000e+00, 1.0000000000e+00
|
||||
306, 1.0000000000e+00, 1.0000000000e+00
|
||||
307, 1.0000000000e+00, 1.0000000000e+00
|
||||
308, 1.0000000000e+00, 1.0000000000e+00
|
||||
309, 1.0000000000e+00, 1.0000000000e+00
|
||||
310, 1.0000000000e+00, 1.0000000000e+00
|
||||
311, 1.0000000000e+00, 1.0000000000e+00
|
||||
312, 1.0000000000e+00, 1.0000000000e+00
|
||||
313, 1.0000000000e+00, 1.0000000000e+00
|
||||
314, 1.0000000000e+00, 1.0000000000e+00
|
||||
315, 1.0000000000e+00, 1.0000000000e+00
|
||||
316, 1.0000000000e+00, 1.0000000000e+00
|
||||
317, 1.0000000000e+00, 1.0000000000e+00
|
||||
318, 1.0000000000e+00, 1.0000000000e+00
|
||||
319, 1.0000000000e+00, 1.0000000000e+00
|
||||
2
data/screen/double_slit.txt
Normal file
2
data/screen/double_slit.txt
Normal file
File diff suppressed because one or more lines are too long
2
data/screen/single_slit.txt
Normal file
2
data/screen/single_slit.txt
Normal file
File diff suppressed because one or more lines are too long
2
data/screen/triple_slit.txt
Normal file
2
data/screen/triple_slit.txt
Normal file
File diff suppressed because one or more lines are too long
51
include/WaveSimulation.hpp
Normal file
51
include/WaveSimulation.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
/** @file WaveSimulation.hpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 0.1
|
||||
*
|
||||
* @brief The definition of the WaveSimulation class
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#ifndef __WAVE_SIMULATION__
|
||||
#define __WAVE_SIMULATION__
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "literals.hpp"
|
||||
|
||||
#include <armadillo>
|
||||
#include <cstdint>
|
||||
|
||||
class WaveSimulation {
|
||||
protected:
|
||||
uint32_t M;
|
||||
arma::sp_cx_mat B;
|
||||
double h;
|
||||
double dt;
|
||||
double T;
|
||||
|
||||
void build_A();
|
||||
void build_B();
|
||||
void initialize_U(double x_c, double y_c, double sigma_x, double sigma_y,
|
||||
double p_x, double p_y);
|
||||
void build_V(double thickness, double pos_x, double aperture_separation,
|
||||
double aperture, uint32_t slits);
|
||||
public:
|
||||
int32_t N;
|
||||
arma::cx_mat V;
|
||||
arma::cx_mat U;
|
||||
arma::sp_cx_mat A;
|
||||
WaveSimulation(double h, double dt, double T, double x_c, double y_c,
|
||||
double sigma_x, double sigma_y, double p_x, double p_y,
|
||||
double thickness, double pos_x, double ap_sep, double ap,
|
||||
uint32_t slits);
|
||||
WaveSimulation(double h, double dt, double T, double x_c, double y_c,
|
||||
double sigma_x, double sigma_y, double p_x, double p_y);
|
||||
virtual void solve(std::ofstream &ofile);
|
||||
void write_U(std::ofstream &ofile);
|
||||
void step();
|
||||
};
|
||||
|
||||
#endif
|
||||
17
include/constants.hpp
Normal file
17
include/constants.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
/** @file constants.hpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 1.0
|
||||
*
|
||||
* @brief Library of constants
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#ifndef __CONST__
|
||||
#define __CONST__
|
||||
|
||||
#define I std::complex<double>{0., 1.}
|
||||
|
||||
#endif
|
||||
19
include/literals.hpp
Normal file
19
include/literals.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
/** @file literals.hpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 1.0
|
||||
*
|
||||
* @brief Useful literals
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#ifndef __LITERALS__
|
||||
#define __LITERALS__
|
||||
|
||||
#include <complex>
|
||||
|
||||
std::complex<double> operator ""_i(long double magnitude);
|
||||
|
||||
#endif
|
||||
@ -117,10 +117,10 @@ std::string dirname(const std::string &path);
|
||||
/** @brief Take 2 strings and concatenate them and make sure there is a
|
||||
* directory separator (/) between them.
|
||||
*
|
||||
* @details This function doesn't care whether or not the values given as
|
||||
* parameters are valid path strings. It is the responsibility of the user to make
|
||||
* sure that the values given are valid path strings.
|
||||
* The function only guarantees that the output string is a valid path string.
|
||||
* @details This function doesn't care whether or not the values given as
|
||||
* parameters are valid path strings. It is the responsibility of the user to
|
||||
* make sure that the values given are valid path strings. The function only
|
||||
* guarantees that the output string is a valid path string.
|
||||
*
|
||||
* @param left The left hand side of the result string
|
||||
* @param right The right hand side of the result string
|
||||
@ -129,6 +129,8 @@ std::string dirname(const std::string &path);
|
||||
* */
|
||||
std::string concatpath(const std::string &left, const std::string &right);
|
||||
|
||||
// A function that prints the structure of a sparse matrix to screen.
|
||||
void print_sp_matrix_structure(const arma::sp_cx_mat &A);
|
||||
} // namespace utils
|
||||
|
||||
#endif
|
||||
|
||||
BIN
latex/images/color_map_0.pdf
Normal file
BIN
latex/images/color_map_0.pdf
Normal file
Binary file not shown.
BIN
latex/images/color_map_1.pdf
Normal file
BIN
latex/images/color_map_1.pdf
Normal file
Binary file not shown.
BIN
latex/images/color_map_2.pdf
Normal file
BIN
latex/images/color_map_2.pdf
Normal file
Binary file not shown.
BIN
latex/images/double_slit_detector.pdf
Normal file
BIN
latex/images/double_slit_detector.pdf
Normal file
Binary file not shown.
BIN
latex/images/probability_deviation.pdf
Normal file
BIN
latex/images/probability_deviation.pdf
Normal file
Binary file not shown.
BIN
latex/images/single_slit_detector.pdf
Normal file
BIN
latex/images/single_slit_detector.pdf
Normal file
Binary file not shown.
BIN
latex/images/triple_slit_detector.pdf
Normal file
BIN
latex/images/triple_slit_detector.pdf
Normal file
Binary file not shown.
217
lib/WaveSimulation.cpp
Normal file
217
lib/WaveSimulation.cpp
Normal file
@ -0,0 +1,217 @@
|
||||
/** @file WaveSimulation.cpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 0.1
|
||||
*
|
||||
* @brief Implementation of the WaveSimulation class.
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#include "WaveSimulation.hpp"
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
WaveSimulation::WaveSimulation(double h, double dt, double T, double x_c,
|
||||
double y_c, double sigma_x, double sigma_y,
|
||||
double p_x, double p_y, double thickness,
|
||||
double pos_x, double ap_sep, double ap,
|
||||
uint32_t slits)
|
||||
{
|
||||
this->dt = dt;
|
||||
this->h = h;
|
||||
this->T = T;
|
||||
this->M = 1. / h;
|
||||
this->N = M - 2;
|
||||
this->build_V(thickness, pos_x, ap_sep, ap, slits);
|
||||
this->initialize_U(x_c, y_c, sigma_x, sigma_y, p_x, p_y);
|
||||
this->build_A();
|
||||
this->build_B();
|
||||
}
|
||||
|
||||
WaveSimulation::WaveSimulation(double h, double dt, double T, double x_c, double y_c,
|
||||
double sigma_x, double sigma_y, double p_x, double p_y)
|
||||
{
|
||||
this->dt = dt;
|
||||
this->h = h;
|
||||
this->T = T;
|
||||
this->M = 1. / h;
|
||||
this->N = M - 2;
|
||||
this->build_V(0.,0.,0.,0., 0);
|
||||
this->initialize_U(x_c, y_c, sigma_x, sigma_y, p_x, p_y);
|
||||
this->build_A();
|
||||
this->build_B();
|
||||
|
||||
}
|
||||
|
||||
void WaveSimulation::solve(std::ofstream &ofile)
|
||||
{
|
||||
ofile << this->N << '\n';
|
||||
uint32_t iterations = this->T / this->dt;
|
||||
for (size_t i = 0; i < iterations; i++) {
|
||||
this->write_U(ofile);
|
||||
this->step();
|
||||
}
|
||||
}
|
||||
|
||||
void WaveSimulation::step()
|
||||
{
|
||||
arma::cx_vec tmp = this->B * this->U.as_col();
|
||||
arma::spsolve(this->U, this->A, tmp);
|
||||
}
|
||||
|
||||
void WaveSimulation::build_A()
|
||||
{
|
||||
// Create the diagonal
|
||||
arma::cx_vec diagonal(this->N * this->N);
|
||||
|
||||
// Set diagonal values
|
||||
std::complex<double> r = (1._i * this->dt) / (2 * h * h);
|
||||
for (size_t i = 0; i < diagonal.size(); i++) {
|
||||
diagonal(i) = 1. + 4. * r + (1._i * this->dt / 2.) * this->V(i);
|
||||
}
|
||||
|
||||
// Create the submatrix
|
||||
arma::cx_mat sub_matrix(this->N, this->N, arma::fill::zeros);
|
||||
sub_matrix.diag(-1).fill(-r);
|
||||
sub_matrix.diag(1).fill(-r);
|
||||
|
||||
// Set the size of A
|
||||
this->A.set_size(this->N * this->N, this->N * this->N);
|
||||
|
||||
// Fill in the values in the submatrix diagonal
|
||||
for (size_t i = 0; i < this->A.n_cols; i += this->N) {
|
||||
this->A.submat(i, i, i + this->N - 1, i + this->N - 1) = sub_matrix;
|
||||
}
|
||||
|
||||
// Fill the last sub/sup-diagonals
|
||||
this->A.diag() = diagonal;
|
||||
this->A.diag(-this->N).fill(-r);
|
||||
this->A.diag(this->N).fill(-r);
|
||||
}
|
||||
|
||||
void WaveSimulation::build_B()
|
||||
{
|
||||
std::complex<double> r = (1._i * this->dt) / (2 * h * h);
|
||||
|
||||
// Create the diagonal
|
||||
arma::cx_vec diagonal(this->N * this->N);
|
||||
|
||||
for (size_t i = 0; i < diagonal.size(); i++) {
|
||||
diagonal(i) = 1. - 4. * r - (1._i * this->dt / 2.) * this->V(i);
|
||||
}
|
||||
|
||||
// Create the submatrix
|
||||
arma::cx_mat sub_matrix(this->N, this->N, arma::fill::zeros);
|
||||
sub_matrix.diag(-1).fill(r);
|
||||
sub_matrix.diag(1).fill(r);
|
||||
|
||||
// Set the size of B
|
||||
this->B.set_size(this->N * this->N, this->N * this->N);
|
||||
|
||||
// Fill in the values in the submatrix diagonal
|
||||
for (size_t i = 0; i < this->B.n_cols; i += this->N) {
|
||||
this->B.submat(i, i, i + this->N - 1, i + this->N - 1) = sub_matrix;
|
||||
}
|
||||
|
||||
// Fill the last sub/sup-diagonals
|
||||
this->B.diag() = diagonal;
|
||||
this->B.diag(-this->N).fill(r);
|
||||
this->B.diag(this->N).fill(r);
|
||||
}
|
||||
|
||||
void WaveSimulation::initialize_U(double x_c, double y_c, double sigma_x,
|
||||
double sigma_y, double p_x, double p_y)
|
||||
{
|
||||
this->U.set_size(this->N, this->N);
|
||||
double x, y, diff_x, diff_y;
|
||||
std::complex<double> sum = 0.;
|
||||
for (size_t j = 0; j < this->U.n_cols; j++) {
|
||||
x = j * h;
|
||||
diff_x = x - x_c;
|
||||
for (size_t i = 0; i < this->U.n_rows; i++) {
|
||||
y = i * h;
|
||||
diff_y = y - y_c;
|
||||
this->U(i, j) =
|
||||
std::exp(-(diff_x * diff_x) / (2. * sigma_x * sigma_x)
|
||||
- (diff_y * diff_y) / (2. * sigma_y * sigma_y)
|
||||
+ p_x * x * 1._i + p_y * y * 1._i);
|
||||
sum += this->U(i, j) * std::conj(this->U(i, j));
|
||||
}
|
||||
}
|
||||
if (std::abs(sum.imag()) > 1e-7) {
|
||||
abort();
|
||||
}
|
||||
double norm = 1. / std::sqrt(sum.real());
|
||||
|
||||
this->U.for_each([norm](std::complex<double> &el) { el *= norm; });
|
||||
}
|
||||
|
||||
void WaveSimulation::write_U(std::ofstream &ofile)
|
||||
{
|
||||
this->U.for_each(
|
||||
[&ofile](std::complex<double> el) { ofile << el << '\t'; });
|
||||
ofile << '\n';
|
||||
}
|
||||
|
||||
void WaveSimulation::build_V(double thickness, double pos_x,
|
||||
double aperture_separation, double aperture,
|
||||
uint32_t slits)
|
||||
{
|
||||
this->V.set_size(this->N, this->N);
|
||||
this->V.fill(0.);
|
||||
if (slits == 0) {
|
||||
return;
|
||||
}
|
||||
arma::cx_vec res;
|
||||
|
||||
if (slits % 2 == 0) {
|
||||
res = arma::cx_vec(aperture_separation / this->h,
|
||||
arma::fill::value(1e10));
|
||||
for (size_t i = 0; i < slits; i += 2) {
|
||||
res = arma::join_cols(
|
||||
res, arma::cx_vec(aperture / this->h, arma::fill::zeros));
|
||||
res = arma::join_cols(
|
||||
arma::cx_vec(aperture / this->h, arma::fill::zeros), res);
|
||||
res =
|
||||
arma::join_cols(res, arma::cx_vec(aperture_separation / this->h,
|
||||
arma::fill::value(1e10)));
|
||||
res = arma::join_cols(arma::cx_vec(aperture_separation / this->h,
|
||||
arma::fill::value(1e10)),
|
||||
res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = arma::cx_vec(aperture / this->h, arma::fill::value(0));
|
||||
for (size_t i = 0; i < slits - 1; i += 2) {
|
||||
res =
|
||||
arma::join_cols(res, arma::cx_vec(aperture_separation / this->h,
|
||||
arma::fill::value(1e10)));
|
||||
res = arma::join_cols(arma::cx_vec(aperture_separation / this->h,
|
||||
arma::fill::value(1e10)),
|
||||
res);
|
||||
res = arma::join_cols(
|
||||
res, arma::cx_vec(aperture / this->h, arma::fill::zeros));
|
||||
res = arma::join_cols(
|
||||
arma::cx_vec(aperture / this->h, arma::fill::zeros), res);
|
||||
}
|
||||
}
|
||||
if (res.size() > this->N) {
|
||||
abort();
|
||||
}
|
||||
uint32_t fill = (this->N - res.size()) / 2;
|
||||
res = arma::join_cols(arma::cx_vec(fill, arma::fill::value(1e10)), res);
|
||||
res = arma::join_cols(res, arma::cx_vec(fill + ((this->N - res.size()) % 2),
|
||||
arma::fill::value(1e10)));
|
||||
|
||||
uint32_t start = pos_x / this->h - thickness / this->h / 2;
|
||||
for (size_t i = 0; i < thickness / this->h; i++) {
|
||||
this->V.col(start + i) = res;
|
||||
}
|
||||
}
|
||||
17
lib/literals.cpp
Normal file
17
lib/literals.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
/** @file literals.cpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 1.0
|
||||
*
|
||||
* @brief The implementation of the literals.
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#include "literals.hpp"
|
||||
|
||||
std::complex<double> operator""_i(long double magnitude)
|
||||
{
|
||||
return std::complex<double>(0.,magnitude);
|
||||
}
|
||||
@ -70,4 +70,47 @@ std::string concatpath(const std::string &left, const std::string &right)
|
||||
}
|
||||
}
|
||||
|
||||
void print_sp_matrix_structure(const arma::sp_cx_mat &A)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace arma;
|
||||
|
||||
// Declare a C-style 2D array of strings.
|
||||
string S[A.n_rows][A.n_cols];
|
||||
|
||||
// Initialise all the strings to " ".
|
||||
for (int i = 0; i < A.n_rows; i++) {
|
||||
for (int j = 0; j < A.n_cols; j++) {
|
||||
S[i][j] = " ";
|
||||
}
|
||||
}
|
||||
|
||||
// Next, we want to set the string to a dot at each non-zero element.
|
||||
// To do this we use the special loop iterator from the sp_cx_mat class
|
||||
// to help us loop over only the non-zero matrix elements.
|
||||
sp_cx_mat::const_iterator it = A.begin();
|
||||
sp_cx_mat::const_iterator it_end = A.end();
|
||||
|
||||
int nnz = 0;
|
||||
for (; it != it_end; ++it) {
|
||||
S[it.row()][it.col()] = "•";
|
||||
nnz++;
|
||||
}
|
||||
|
||||
// Finally, print the matrix to screen.
|
||||
cout << endl;
|
||||
for (int i = 0; i < A.n_rows; i++) {
|
||||
cout << "| ";
|
||||
for (int j = 0; j < A.n_cols; j++) {
|
||||
cout << S[i][j] << " ";
|
||||
}
|
||||
cout << "|\n";
|
||||
}
|
||||
|
||||
cout << endl;
|
||||
cout << "matrix size: " << A.n_rows << "x" << A.n_cols << endl;
|
||||
cout << "non-zero elements: " << nnz << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
|
||||
26
python_scripts/colormap.py
Normal file
26
python_scripts/colormap.py
Normal file
@ -0,0 +1,26 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import ast
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
|
||||
def plot():
|
||||
with open("data/color_map.txt") as f:
|
||||
lines = f.readlines();
|
||||
size = int(lines[0])
|
||||
for i, line in enumerate(lines[1:]):
|
||||
fig, ax = plt.subplots()
|
||||
arr = line.strip().split("\t")
|
||||
arr = np.asarray(list(map(lambda x: ((a := complex(*ast.literal_eval(x)))*a.conjugate()).real, arr)))
|
||||
|
||||
arr = arr.reshape(size,size)
|
||||
|
||||
ax.imshow(arr.T, interpolation="nearest")
|
||||
plt.savefig(f"latex/images/color_map_{i}.pdf")
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot()
|
||||
|
||||
41
python_scripts/detector.py
Normal file
41
python_scripts/detector.py
Normal file
@ -0,0 +1,41 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import ast
|
||||
import seaborn as sns
|
||||
|
||||
sns.set_theme()
|
||||
|
||||
def plot():
|
||||
files = [
|
||||
"data/screen/single_slit.txt",
|
||||
"data/screen/double_slit.txt",
|
||||
"data/screen/triple_slit.txt",
|
||||
]
|
||||
outputs = [
|
||||
"latex/images/single_slit_detector.pdf",
|
||||
"latex/images/double_slit_detector.pdf",
|
||||
"latex/images/triple_slit_detector.pdf",
|
||||
]
|
||||
for file, output in zip(files, outputs):
|
||||
with open(file) as f:
|
||||
lines = f.readlines();
|
||||
size = int(lines[0])
|
||||
column = int(.8 * size)
|
||||
fig, ax = plt.subplots()
|
||||
arr = lines[1].strip().split("\t")
|
||||
arr = np.asarray(list(map(lambda x: complex(*ast.literal_eval(x)), arr)))
|
||||
|
||||
arr = arr.reshape(size,size)
|
||||
x = np.linspace(0,1, size)
|
||||
slice = arr[column, :]
|
||||
norm = 1. / np.sqrt(sum([(i*i.conjugate()).real for i in slice]))
|
||||
slice *= norm
|
||||
slice = np.asarray([i * i.conjugate() for i in slice])
|
||||
|
||||
ax.plot(x, slice)
|
||||
plt.savefig(output)
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot()
|
||||
43
python_scripts/heat_map.py
Normal file
43
python_scripts/heat_map.py
Normal file
@ -0,0 +1,43 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib
|
||||
from matplotlib.animation import FuncAnimation
|
||||
import ast
|
||||
|
||||
wave_arr = []
|
||||
fig = plt.figure()
|
||||
ax = plt.gca()
|
||||
img = ax.imshow([[]])
|
||||
|
||||
def plot():
|
||||
with open("test.txt") as f:
|
||||
lines = f.readlines();
|
||||
size = int(lines[0])
|
||||
for line in lines[1:]:
|
||||
arr = line.strip().split("\t")
|
||||
arr = np.asarray(list(map(lambda x: ((a := complex(*ast.literal_eval(x)))*a.conjugate()).real, arr)))
|
||||
|
||||
# print(sum(arr))
|
||||
arr = arr.reshape(size,size)
|
||||
wave_arr.append(arr.T)
|
||||
# print(arr)
|
||||
|
||||
# plt.imshow(arr, cmap="hot", interpolation="nearest")
|
||||
# plt.show()
|
||||
|
||||
|
||||
def animation(i):
|
||||
norm = matplotlib.cm.colors.Normalize(vmin=0, vmax=np.max(wave_arr[i]))
|
||||
img.set_norm(norm)
|
||||
img.set_data(wave_arr[i])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot()
|
||||
|
||||
norm = matplotlib.cm.colors.Normalize(vmin=0, vmax=np.max(wave_arr[0]))
|
||||
img = ax.imshow(wave_arr[0], extent=[0,1,0,1], cmap=plt.get_cmap("viridis"), norm=norm)
|
||||
anim = FuncAnimation(fig, animation, interval=1, frames=np.arange(0,len(wave_arr)), repeat=True, blit=0)
|
||||
# plt.show()
|
||||
|
||||
anim.save("./animation.mp4", writer="ffmpeg", bitrate=10000, fps=15)
|
||||
25
python_scripts/normalization.py
Normal file
25
python_scripts/normalization.py
Normal file
@ -0,0 +1,25 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib
|
||||
from matplotlib.animation import FuncAnimation
|
||||
import ast
|
||||
|
||||
def plot():
|
||||
with open("data/probability_deviation.txt") as f:
|
||||
lines = f.readlines();
|
||||
x = []
|
||||
arr_narrow = []
|
||||
arr_wide = []
|
||||
for line in lines:
|
||||
tmp = line.strip().split(",")
|
||||
x.append(float(tmp[0]))
|
||||
arr_narrow.append(float(tmp[1]))
|
||||
arr_wide.append(float(tmp[2]))
|
||||
|
||||
plt.plot(x,arr_narrow)
|
||||
plt.plot(x,arr_wide)
|
||||
plt.savefig("latex/images/probability_deviation.pdf")
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot()
|
||||
|
||||
27
python_scripts/plot_v.py
Normal file
27
python_scripts/plot_v.py
Normal file
@ -0,0 +1,27 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib
|
||||
from matplotlib.animation import FuncAnimation
|
||||
import ast
|
||||
|
||||
|
||||
def plot():
|
||||
with open("v.txt") as f:
|
||||
lines = f.readlines();
|
||||
size = int(lines[0])
|
||||
for line in lines[1:]:
|
||||
arr = line.strip().split("\t")
|
||||
arr = np.asarray(list(map(lambda x: ((a := complex(*ast.literal_eval(x)))*a.conjugate()).real, arr)))
|
||||
|
||||
# print(sum(arr))
|
||||
arr = arr.reshape(size,size)
|
||||
# print(arr)
|
||||
|
||||
plt.imshow(arr.T, cmap="hot", interpolation="nearest")
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plot()
|
||||
120
src/main.cpp
120
src/main.cpp
@ -0,0 +1,120 @@
|
||||
/** @file main.cpp
|
||||
*
|
||||
* @author Cory Alexander Balaton (coryab)
|
||||
* @author Janita Ovidie Sandtrøen Willumsen (janitaws)
|
||||
*
|
||||
* @version 1.0
|
||||
*
|
||||
* @brief Implementation of the testing library
|
||||
*
|
||||
* @bug No known bugs
|
||||
* */
|
||||
#include "WaveSimulation.hpp"
|
||||
#include "utils.hpp"
|
||||
#include <fstream>
|
||||
|
||||
void probability_deviation()
|
||||
{
|
||||
WaveSimulation sim_narrow(.005, 2.5e-5, .008, .25, .5, .05, .05, 200., 0.);
|
||||
|
||||
WaveSimulation sim_wide(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
|
||||
0.02, .5, .05, .05, 2);
|
||||
|
||||
std::ofstream ofile;
|
||||
utils::mkpath("data");
|
||||
ofile.open("data/probability_deviation.txt");
|
||||
|
||||
double sum_narrow, sum_wide;
|
||||
|
||||
for (size_t i = 0; i < 320; i++) {
|
||||
sum_narrow = 0;
|
||||
sum_wide = 0;
|
||||
for (size_t j = 0; j < sim_narrow.U.n_elem; j++) {
|
||||
sum_narrow += (sim_narrow.U(j) * std::conj(sim_narrow.U(j))).real();
|
||||
sum_wide += (sim_wide.U(j) * std::conj(sim_wide.U(j))).real();
|
||||
}
|
||||
|
||||
sim_narrow.step();
|
||||
sim_wide.step();
|
||||
ofile << i << ',' << utils::scientific_format(sum_narrow) << ','
|
||||
<< utils::scientific_format(sum_wide) << '\n';
|
||||
}
|
||||
|
||||
ofile.close();
|
||||
}
|
||||
|
||||
void color_map()
|
||||
{
|
||||
WaveSimulation sim(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02,
|
||||
.5, .05, .05, 2);
|
||||
|
||||
std::ofstream ofile;
|
||||
ofile.open("data/color_map.txt");
|
||||
ofile << sim.N << '\n';
|
||||
sim.write_U(ofile);
|
||||
for (size_t i = 0; i < 40; i++) {
|
||||
sim.step();
|
||||
}
|
||||
sim.write_U(ofile);
|
||||
for (size_t i = 0; i < 40; i++) {
|
||||
sim.step();
|
||||
}
|
||||
sim.write_U(ofile);
|
||||
ofile.close();
|
||||
}
|
||||
|
||||
void detector_screen()
|
||||
{
|
||||
WaveSimulation *sim = new WaveSimulation(
|
||||
.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0., 0.02, .5, .05, .05, 1);
|
||||
|
||||
std::ofstream ofile;
|
||||
utils::mkpath("data/screen");
|
||||
ofile.open("data/screen/single_slit.txt");
|
||||
ofile << sim->N << '\n';
|
||||
for (size_t i = 0; i < 80; i++) {
|
||||
sim->step();
|
||||
}
|
||||
sim->write_U(ofile);
|
||||
ofile.close();
|
||||
|
||||
delete sim;
|
||||
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
|
||||
0.02, .5, .05, .05, 2);
|
||||
|
||||
ofile.open("data/screen/double_slit.txt");
|
||||
ofile << sim->N << '\n';
|
||||
for (size_t i = 0; i < 80; i++) {
|
||||
sim->step();
|
||||
}
|
||||
sim->write_U(ofile);
|
||||
ofile.close();
|
||||
|
||||
delete sim;
|
||||
sim = new WaveSimulation(.005, 2.5e-5, .002, .25, .5, .05, .20, 200., 0.,
|
||||
0.02, .5, .05, .05, 3);
|
||||
|
||||
ofile.open("data/screen/triple_slit.txt");
|
||||
ofile << sim->N << '\n';
|
||||
for (size_t i = 0; i < 80; i++) {
|
||||
sim->step();
|
||||
}
|
||||
sim->write_U(ofile);
|
||||
ofile.close();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
//probability_deviation();
|
||||
//color_map();
|
||||
detector_screen();
|
||||
|
||||
//std::ofstream ofile;
|
||||
//ofile.open("test.txt");
|
||||
//WaveSimulation sim(.005, 2.5e-5, .008, .25, .5, .05, .10, 200., 0.,
|
||||
//0.02, .5, .05, .05, 2);
|
||||
//sim.solve(ofile);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user