Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging movies #78

Merged
merged 22 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/automatic-release-ubuntu-gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: automatic-release-ubuntu-gnu
on:
push:
branches:
- main

- main

jobs:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: windows-intelLLVM
name: windows

on:

Expand Down Expand Up @@ -32,7 +32,7 @@ jobs:

fail-fast: false

name: ${{matrix.build-type}}-mpi(${{matrix.mpi}})-mtln(${{matrix.mtln}})-hdf(${{matrix.hdf}})
name: ${{matrix.compiler.name}}-${{matrix.build-type}}-mpi(${{matrix.mpi}})-mtln(${{matrix.mtln}})-hdf(${{matrix.hdf}})

steps:

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ src_pyWrapper/__pycache__/*
tmp/
tmp_cases/
testData/outputs/paul/paul_8.6_square.txt
testing_hdf5_writing_and_reading.h5
7 changes: 4 additions & 3 deletions doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ You can compile HDF5 for your specific platform downloading the latest sources f
Extract to a folder and build and install with the following commands

```shell
cmake -S . -B build-ifx --fresh -DHDF5_BUILD_FORTRAN=YES
cmake --build build-ifx -j
cmake --install build-ifx --prefix ~/hdf5-installed
cmake -S . -B build -DHDF5_BUILD_FORTRAN=YES -DHDF5_ENABLE_Z_LIB_SUPPORT=NO --fresh
cmake --build build -j
cmake --install build --prefix ~/hdf5-installed
```

A specific HDF5 library can be set with the option `-DHDF5_ROOT=<path-to-library>`, e.g.
Expand Down Expand Up @@ -143,6 +143,7 @@ Once the environment is loaded, follow the steps in the next section.

2. **Generate the Project with CMake GUI**:
- In **CMake GUI**, select the option to create a project for **Visual Studio 2019** from the CMake files.
- Set `-T fortran=ifx` to use intelLLVM compiler.
- Specify the output folder where the `.sln` file for the project will be generated.

3. **Open the Project in Visual Studio**:
Expand Down
1 change: 1 addition & 0 deletions doc/smbjson.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ If not `magnitudeFile` is specified and only one `source` is defined, the `magni

Probes of type `movie` record a vector field in a volume region indicated by `elementIds`. `[field]` can be `electric`, `magnetic`, or `currentDensity`; defaults to `electric`.
`currentDensity` will store only the surface density currents on `pec` or lossy surfaces.
For movies in time domain, the `initialTime`, `finalTime`, and `samplingPeriod` must be specified by the user; there is no default value.
The stored values can be selected using the `[component]` entry, which stores one of the following labels `x`, `y`, `z`, or `magnitude`; if no component is specified, defaults to `magnitude`.

An example follows:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pytest
numpy
matplotlib
pandas
pyvista
pyvista
h5py
30 changes: 0 additions & 30 deletions set_precompiled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,6 @@ if (SEMBA_FDTD_ENABLE_MTLN)
MESSAGE(STATUS "Using lapack libraries at: " ${LAPACK_DIR})
endif()

# if (SEMBA_FDTD_ENABLE_MTLN)
# if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-gcc/ngspice/")
# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a)
# elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "NVHPC")
# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-gcc/ngspice/")
# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a)
# elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-intel/ngspice/")
# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a)
# elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "IntelLLVM")
# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-intelLLVM/ngspice/")
# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a)
# endif()
# elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# set(NGSPICE_DIR "${PRECOMPILED_DIR}/windows-intel/ngspice/")
# set(NGSPICE_LIB ${NGSPICE_DIR}ngspice.lib)
# add_library(ngspice SHARED IMPORTED)
# set_target_properties(ngspice PROPERTIES
# IMPORTED_LOCATION "${NGSPICE_DIR}ngspice.dll"
# IMPORTED_IMPLIB "${NGSPICE_DIR}ngspice.lib"
# )
# endif()
# if (NOT NGSPICE_DIR)
# message(FATAL_ERROR "ngspice libraries for this platform and/or compiler have not been found.")
# endif()
# MESSAGE(STATUS "Using ngspice libraries at: " ${NGSPICE_DIR})
# endif()

if (SEMBA_FDTD_ENABLE_HDF AND NOT HDF5_FOUND)
if (NOT HDF5_ROOT)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
Expand Down
1 change: 0 additions & 1 deletion src_json_parser/smbjson.F90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ module smbjson
procedure, private :: readThinSlots
!
!
!
procedure, private :: getLogicalAt
procedure, private :: getIntAt
procedure, private :: getIntsAt
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ target_link_libraries(fdtd_tests
${MTLN_TESTS_LIBRARY}
${SMBJSON_TESTS_LIBRARY}
${SYSTEM_TESTS_LIBRARY}
${HDF_TESTS_LIBRARY}
GTest::gtest_main
)
17 changes: 17 additions & 0 deletions test/pyWrapper/test_full_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,24 @@ def test_sphere(tmp_path):
assert len(electric_field_movie_files) == 3
p = Probe(electric_field_movie_files[0])
assert p.type == 'movie'

@no_hdf_skip
@pytest.mark.hdf
def test_movie_in_planewave_in_box(tmp_path):
fn = CASE_FOLDER + 'planewave/pw-in-box-with-movie.fdtd.json'
solver = FDTD(fn, path_to_exe=SEMBA_EXE, run_in_folder=tmp_path)
solver.run()
assert solver.hasFinishedSuccessfully()

h5file = solver.getSolvedProbeFilenames("electric_field_movie")[2]
with h5py.File(h5file, "r") as f:
time_key = list(f.keys())[0]
field_key = list(f.keys())[1]
time_ds = f[time_key][()]
field_ds = f[field_key][()]

assert np.isclose(np.max(field_ds), 1.0, rtol=1e-2)
assert np.min(field_ds) == 0.0

def test_planewave_in_box(tmp_path):
fn = CASE_FOLDER + 'planewave/pw-in-box.fdtd.json'
Expand Down
1 change: 1 addition & 0 deletions test/pyWrapper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import matplotlib.pyplot as plt
import pyvista as pv
import pytest
import h5py
from os import environ as env
from sys import platform

Expand Down
7 changes: 4 additions & 3 deletions test/smbjson/smbjson_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ extern "C" int test_read_dielectricslab();
extern "C" int test_read_thinslot();
extern "C" int test_read_holland1981();
extern "C" int test_read_towelhanger();
extern "C" int test_read_connectedwires();
extern "C" int test_read_currentinjection();
extern "C" int test_read_shieldedpair();
extern "C" int test_read_mtln();
extern "C" int test_read_sphere();
extern "C" int test_read_airplane();
extern "C" int test_read_mtln();
extern "C" int test_read_holland1981();
extern "C" int test_read_connectedwires();
extern "C" int test_read_shieldedpair();
extern "C" int test_read_large_airplane_mtln();

TEST(smbjson, idchildtable_fhash) {EXPECT_EQ(0, test_idchildtable_fhash()); }
Expand Down
3 changes: 1 addition & 2 deletions test/smbjson/test_read_holland1981.F90
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ function expectedProblemDescription() result (expected)

expected%tWires%n_tw = 1
expected%tWires%n_tw_max = 1

! expected mtln bundles

expected%mtln%time_step = 30e-12
expected%mtln%number_of_steps = 1000

Expand Down
5 changes: 4 additions & 1 deletion testData/cases/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
*.txt
*.vtk
*.bin
*.log
*.log
*.h5
*.xdmf
*.bin
56 changes: 56 additions & 0 deletions testData/cases/planewave/pw-in-box-with-movie.fdtd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"format": "FDTD Input file",
"__comments": "Planewave passing through an empty box.",

"general": {
"timeStep": 0.05e-9,
"numberOfSteps": 400
},

"boundary": {
"all": {"type": "mur"}
},

"mesh": {
"grid": {
"numberOfCells": [6, 6, 6],
"steps": { "x": [0.01], "y": [0.01], "z": [0.01] }
},
"elements": [
{"id": 1, "type": "cell", "name": "pw-box", "intervals": [ [ [2, 2, 2], [4, 4, 4] ] ]},
{"id": 2, "type": "cell", "name": "movie-box", "intervals": [ [ [0, 0, 0], [6, 6, 6] ] ]}
]
},

"sources": [
{
"type": "planewave",
"magnitudeFile": "gauss_1GHz.exc",
"elementIds": [1],
"direction": {
"theta": 0.0,
"phi": 0.0
},
"polarization": {
"theta": 1.5708,
"phi": 0.0
}
}
],

"probes": [
{
"name": "electric_field_movie",
"type": "movie",
"field": "electric",
"component": "magnitude",
"elementIds": [2],
"domain": {
"type": "time",
"initialTime": 0.0,
"finalTime": 5e-9,
"samplingPeriod": 1.5e-12
}
}
]
}
21 changes: 17 additions & 4 deletions testData/cases/planewave/pw_prepost.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@


# %% Prepare solver
# solver = FDTD(input_filename = 'pw-in-box.fdtd.json', path_to_exe=SEMBA_EXE)
solver = FDTD(input_filename = 'pw-with-periodic.fdtd.json', path_to_exe=SEMBA_EXE)
solver = FDTD(input_filename = 'pw-in-box.fdtd.json', path_to_exe=SEMBA_EXE)
solver.cleanUp()

# %% Run solver
solver.run()
assert solver.hasFinishedSuccessfully()

Expand All @@ -33,4 +30,20 @@
plt.xlim(0,4e-9)



# %%
# %% Prepare solver
solver = FDTD(input_filename = 'pw-in-box-with-movie.fdtd.json', path_to_exe=SEMBA_EXE)
solver.cleanUp()
solver.run()
assert solver.hasFinishedSuccessfully()

# %% Postprocess
import h5py
fn = solver.getSolvedProbeFilenames("electric_field_movie")[2]
with h5py.File(fn, "r") as f:
time_key = list(f.keys())[0]
field_key = list(f.keys())[1]
time_ds = f[time_key][()]
field_ds = f[field_key][()]
# %%
Loading