Skip to content

Commit

Permalink
update visualize
Browse files Browse the repository at this point in the history
  • Loading branch information
Amazingkivas committed Apr 23, 2024
1 parent 6b55fd2 commit a2da572
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Binary file modified PlotScript/src/Release/sample.exe
Binary file not shown.
7 changes: 4 additions & 3 deletions PlotScript/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import numpy as np

components_num = {"Ex": '1', "Ey": '2', "Ez": '3', "Bx": '4', "By": '5', "Bz": '6'}


def get_animation(component):
folder_path = f'OutFiles_{components_num[component]}'
file_names_base = sorted(glob.glob(folder_path + '/*.csv'))
Expand All @@ -15,10 +15,11 @@ def get_animation(component):
fig, ax = plt.subplots()

def update(frame):
mut = 0
ax.clear()
data = pd.read_csv(file_names[frame], sep=';')
data = data.apply(lambda x: x.str.replace(',', '.').astype(float) if x.dtype == 'object' else x)
ax.imshow(data, cmap='viridis', interpolation='nearest')
ax.imshow(data, cmap='RdBu', vmin=-0.5, vmax=0.5, interpolation='none')
ax.set_title('Frame {}'.format(frame + 1))

ani = FuncAnimation(fig, update, frames=len(file_names), interval=50)
Expand Down Expand Up @@ -49,6 +50,6 @@ def execute_cpp(grid_size, iters_num, single_iteration_flag=True):


if __name__ == '__main__':
# execute_cpp(50, 100, False)
execute_cpp(75, 410, False)
get_animation("Ex")
# get_heatmap("Ex", 86)
2 changes: 1 addition & 1 deletion samples/sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int main(int argc, char* argv[])
{
#ifdef __USE_SPHERICAL_WAVE__
int N = 70;
int Iterations = 300;
int Iterations = 10;
spherical_wave(N, Iterations, "../../PlotScript/");
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/FDTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <iostream>

#define __DEBUG_PML__
//#define __DEBUG_PML__
//#define __OUTPUT_SIGMA__

Field::Field(const int _Ni = 1, const int _Nj = 1, const int _Nk = 1)
Expand Down Expand Up @@ -481,7 +481,7 @@ std::vector<std::vector<Field>> FDTD::update_fields(const int time)
double max_val_1 = 0.0;
double max_val_2 = 0.0;
int t_start = 50;
int t_final = 280;
int t_final = 400;
#endif // __DEBUG_PML__

for (int t = 0; t < time; t++)
Expand Down

0 comments on commit a2da572

Please sign in to comment.