Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .github/workflows/badge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lines of code

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
run_tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Make the default shell a login shell, so that conda is initialised properly
defaults:
run:
shell: bash -el {0}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Make Code Badge
uses: shadowmoose/GHA-LoC-Badge@1.0.0
id: badge
with:
debug: true
directory: ./wakis/
badge: ./docs/img/badge.svg
patterns: '*.js' # Patterns in the format of a '.gitignore' file, separated by pipes.
ignore: 'node_modules'
34 changes: 31 additions & 3 deletions tests/test_007_mpi_lossy_cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TestMPILossyCavity:
'ymin': -0.25999999046325684, 'ymax': 0.25999999046325684,
'zmin': -0.25, 'zmax': 0.550000011920929,
'stl_solids': {'cavity': 'tests/stl/007_vacuum_cavity.stl', 'shell': 'tests/stl/007_lossymetal_shell.stl'},
'stl_materials': {'cavity': 'vacuum', 'shell': [30, 1.0, 30]},
'stl_materials': {'cavity': [1.0, 1.0], 'shell': [30, 1.0, 30]},
'gridInitializationTime': 0}

solverLogs = {'use_gpu': False, 'use_mpi': False, 'background': 'pec',
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_mpi_simulation(self):
for n in tqdm(range(Nt)):

beam.update(solver, n*solver.dt)
solver.mpi_one_step()
solver.one_step()

Ez = solver.mpi_gather('Ez', x=int(Nx/2), y=int(Ny/2))
if solver.rank == 0:
Expand Down Expand Up @@ -252,6 +252,33 @@ def test_mpi_plot1D(self):
xscale='linear', yscale='linear',
off_screen=True, title=self.img_folder+'Ez1d', n=3000)

def test_mpi_save_state(self):
# Test MPI savestate
global solver
filename = 'mpi_test_state.h5'
solver.save_state(filename)

if use_mpi:
solver.comm.Barrier() # Ensure all processes reach this point
assert os.path.exists(filename), "MPI savestate file not created"

def test_mpi_load_state(self):
global solver
E_slice = solver.E[int(solver.Nx/2), int(solver.Ny/2), :, 'z'].copy() # Save current field slice
solver.reset_fields() # Reset fields to zero

# Test MPI loadstate
filename = 'mpi_test_state.h5'
if use_mpi:
solver.comm.Barrier() # Ensure all processes reach this point
assert os.path.exists(filename), "MPI loadstate file not found"
solver.load_state(filename)

# Check if fields were restored correctly
E_slice_loaded = solver.E[int(solver.Nx/2), int(solver.Ny/2), :, 'z']
assert np.allclose(E_slice, E_slice_loaded), "MPI loadstate failed to restore fields correctly"

@pytest.mark.skip(reason="Long test, enable when needed")
def test_mpi_wakefield(self):
# Reset fields
global solver
Expand Down Expand Up @@ -284,7 +311,7 @@ def test_mpi_wakefield(self):
# Run simulation
solver.wakesolve(wakelength=wakelength,
wake=wake)

@pytest.mark.skip(reason="Long test, enable when needed")
def test_long_wake_potential(self):
global wake
global solver
Expand All @@ -301,6 +328,7 @@ def test_long_wake_potential(self):
assert np.allclose(wake.WP[::50], self.WP, rtol=0.1), "Wake potential samples failed"
assert np.cumsum(np.abs(wake.WP))[-1] == pytest.approx(184.43818552913254, 0.1), "Wake potential cumsum MPI failed"

@pytest.mark.skip(reason="Long test, enable when needed")
def test_long_impedance(self):
global wake
global solver
Expand Down
Loading
Loading