Skip to content

Commit

Permalink
[WIP] Adding SGBC validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lmdiazangulo committed Dec 20, 2024
1 parent 5a38ab8 commit 0d202b1
Show file tree
Hide file tree
Showing 9 changed files with 36,392 additions and 24,610 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pytest
numpy
matplotlib
pandas
pandas
pyvista
24 changes: 21 additions & 3 deletions src_pyWrapper/pyWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ def __init__(self, probe_filename):

mtln_probe_tags = ['_V_','_I_']
current_probe_tags = ['_Wx_', '_Wy_', '_Wz_']
point_probe_tags = ['_Ex_', '_Ey_', '_Ez_', '_Hx_', '_Hy_', '_Hz_']
far_field_tag = ['_FF_']
movie_tags = ['_ExC_', '_EyC_', '_EzC_', '_HxC_', '_HyC_', '_HzC_', '_ME_', '_MH_']
all_tags = current_probe_tags + far_field_tag + movie_tags + mtln_probe_tags


all_tags = mtln_probe_tags \
+ current_probe_tags \
+ point_probe_tags \
+ far_field_tag \
+ movie_tags

basename = os.path.basename(self.filename)
self.case_name, basename_with_no_case_name = basename.split('.fdtd_')
basename_with_no_case_name = os.path.splitext(basename_with_no_case_name)[0]
Expand All @@ -38,7 +43,18 @@ def __init__(self, probe_filename):
self.segment_tag = int(position_str.split('_s')[1])
self.df = pd.read_csv(self.filename, sep='\s+')
self.df = self.df.rename(columns={'t': 'time', self.df.columns[1]: 'current'})
# self.df = self.df.rename(columns={'t': 'time', basename: 'current'})
elif tag in point_probe_tags:
self.type = 'point'
self.name, position_str = basename_with_no_case_name.split(tag)
self.cell = positionStrToCell(position_str)
self.field = tag[1]
self.direction = tag[2]
self.df = pd.read_csv(self.filename, sep='\s+')
self.df = self.df.rename(columns = {
't': 'time',
self.df.columns[1]: 'field',
self.df.columns[2]: 'incident'
})
elif tag in far_field_tag:
self.type = 'farField'
self.name, positions_str = basename_with_no_case_name.split(tag)
Expand Down Expand Up @@ -77,6 +93,8 @@ def __init__(self, input_filename, path_to_exe, flags = []):
self.flags = flags

self.folder = os.path.dirname(self.filename)
if len(self.folder) == 0:
self.folder = './'
self.case = os.path.basename(self.filename).split('.json')[0]
self.hasRun = False

Expand Down
24 changes: 24 additions & 0 deletions test/pyWrapper/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@ def test_read_wire_probe():
assert len(p['current']) == 1001
assert p['current'][0] == 0.0
assert p['current'].iat[-1] == -0.513576742E-004


def test_read_point_probe():
p = Probe(OUTPUT_FOLDER + 'shieldingEffectiveness.fdtd_front_Ex_1_1_1.dat')

assert p.case_name == 'shieldingEffectiveness'
assert p.name == 'front'
assert p.type == 'point'
assert p.direction == 'x'
assert p.field == 'E'
assert np.all(p.cell == np.array([1, 1, 1]))

assert len(p['time']) == 5193
assert p['time'][0] == 0.0
assert np.isclose(p['time'].iat[-1], 0.19997851853637005E-007)

assert len(p['field']) == 5193
assert p['field'][0] == 0.0
assert np.isclose(p['field'].iat[-1], 0.120145380E+000)

assert len(p['incident']) == 5193
assert np.isclose(p['incident'][0], 0.134010895E-005)
assert p['incident'].iat[-1] == 0.0


def test_probes_output_exists(tmp_path):
Expand Down Expand Up @@ -166,6 +189,7 @@ def test_sgbc_can_launch(tmp_path):

assert solver.hasFinishedSuccessfully() == True


def test_sgbc_vtk_tags(tmp_path):
case = 'sgbc'
input_json = getCase(case)
Expand Down
5,194 changes: 5,194 additions & 0 deletions testData/outputs/shieldingEffectiveness.fdtd_front_Ex_1_1_1.dat

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions testData/validation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.dat
*.pl
*.txt
*.vtk
*.bin
Loading

0 comments on commit 0d202b1

Please sign in to comment.