Skip to content

Commit

Permalink
fix visualization & add report
Browse files Browse the repository at this point in the history
  • Loading branch information
Amazingkivas committed Dec 30, 2023
1 parent 7649c9f commit 348ffb4
Show file tree
Hide file tree
Showing 14 changed files with 788 additions and 227 deletions.
960 changes: 768 additions & 192 deletions PlotScript/OutFile.csv

Large diffs are not rendered by default.

Binary file modified PlotScript/Plots/plt_Bx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PlotScript/Plots/plt_By.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PlotScript/Plots/plt_Bz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PlotScript/Plots/plt_Ex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PlotScript/Plots/plt_Ey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PlotScript/Plots/plt_Ez.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions PlotScript/Reserve.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
4.0
4.0
16.0
16.0
0.0
1.0
0.0
1.0
2e-13
1e-11
16.0
5e-13
7 changes: 4 additions & 3 deletions PlotScript/Source.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
32
32
16.0
16.0
0.0
1.0
0.0
1.0
32
16.0
5e-13
13 changes: 2 additions & 11 deletions PlotScript/convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ def update_sources():
with open("Source.txt", "w") as file:
for component in input_list:
file.write(input(component + ": ") + "\n")
else:
with open("Source.txt", "r+") as file:
lines = file.readlines()
lines[-1] = input("t : ") + "\n"
file.seek(0)
file.writelines(lines)
file.truncate()


def save_source_into_reserve():
with open('Source.txt', 'r') as file1, open('Reserve.txt', 'w') as file2:
Expand Down Expand Up @@ -84,9 +76,8 @@ def analyze_convergence(numbers, mult_2, iterations, shifts):
file.write(str(numbers[4]) + "\n")
file.write(str(numbers[5]) + "\n")

tmp_n_6 = numbers[6] / (mult_2 ** n)
tmp_n_6 = numbers[6] * (mult_2 ** n)
file.write(str(tmp_n_6) + "\n")

file.write(str(numbers[7]) + "\n")

convergences.append(float(execute_cpp("Ex", "Bz", "Ex", flag)))
Expand All @@ -101,7 +92,7 @@ def analyze_convergence(numbers, mult_2, iterations, shifts):
if __name__ == '__main__':
update_sources()
loaded_numbers = save_source_into_reserve()
nums, convergence = analyze_convergence(loaded_numbers, 2, 6, True)
nums, convergence = analyze_convergence(loaded_numbers, 4, 4, False)
reload_source()

print(convergence)
Expand Down
9 changes: 1 addition & 8 deletions PlotScript/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def execute_cpp(field_1, field_2, field_to_plot, source_nums):


if __name__ == '__main__':
input_list = ["Ni", "Nj", "ax", "bx", "ay", "by", "dt", "t"]
input_list = ["Ni", "Nj", "ax", "bx", "ay", "by", "Nt", "t"]

print("Update parameters? \n \
1 - Yes \n \
Expand All @@ -78,13 +78,6 @@ def execute_cpp(field_1, field_2, field_to_plot, source_nums):
with open("Source.txt", "w") as file:
for component in input_list:
file.write(input(component + ": ") + "\n")
else:
with open("Source.txt", "r+") as file:
lines = file.readlines()
lines[-1] = input("t : ") + "\n"
file.seek(0)
file.writelines(lines)
file.truncate()

with open('Source.txt', 'r') as file:
numbers = [float(line.strip()) for line in file]
Expand Down
Binary file modified PlotScript/src/Release/sample.exe
Binary file not shown.
Binary file added Report_FDTD.docx
Binary file not shown.
18 changes: 9 additions & 9 deletions samples/sample.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define _USE_MATH_DEFINES
#define __DEBUG__
//#define __DEBUG__

#include <iostream>
#include <iomanip>
Expand Down Expand Up @@ -108,9 +108,9 @@ int main()
double arr_y[2] = { numbers[4], numbers[5] };
double arr_d[2] = { (arr_x[1] - arr_x[0]) / arr_N[0], (arr_y[1] - arr_y[0]) / arr_N[1] };

double courant_condtition = 0.25;
double dt;
double t;
double t = numbers[7];
int iter_nums = static_cast<int>(numbers[6]);
double dt = t / static_cast<double>(iter_nums);

Component flds_selected[2] = { static_cast<Component>(std::atoi(argv[1])), static_cast<Component>(std::atoi(argv[2])) };
Component fld_tested = static_cast<Component>(std::atoi(argv[3]));
Expand All @@ -129,15 +129,15 @@ int main()
flds_selected[0] == Component::EZ && flds_selected[1] == Component::BY)
{
selected_axis = 'x';
dt = courant_condtition * arr_d[0] / FDTD_Const::C;
t = courant_condtition * (arr_x[1] - arr_x[0]) / FDTD_Const::C;
//dt = courant_condtition * arr_d[0] / FDTD_Const::C;
//t = courant_condtition * (arr_x[1] - arr_x[0]) / FDTD_Const::C;
}
else if (flds_selected[0] == Component::EX && flds_selected[1] == Component::BZ ||
flds_selected[0] == Component::EZ && flds_selected[1] == Component::BX)
{
selected_axis = 'y';
dt = courant_condtition * arr_d[1] / FDTD_Const::C;
t = courant_condtition * (arr_y[1] - arr_y[0]) / FDTD_Const::C;
//dt = courant_condtition * arr_d[1] / FDTD_Const::C;
//t = courant_condtition * (arr_y[1] - arr_y[0]) / FDTD_Const::C;
}
else
{
Expand All @@ -149,7 +149,7 @@ int main()
FDTD test_1(arr_N, arr_x, arr_y, dt);


int iter_nums = static_cast<int>(numbers[6]);

Test_FDTD test(test_1, flds_selected, fld_tested, arr_x, arr_y, arr_d, t, iter_nums, initial_func, true_func, shifted_flag);
std::cout << test.get_max_abs_error() << std::endl;

Expand Down

0 comments on commit 348ffb4

Please sign in to comment.