Skip to content

Commit d7c2937

Browse files
authored
Merge branch 'main' into main
2 parents f36fac9 + 0989d3d commit d7c2937

24 files changed

+2763
-1455
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,25 @@ assignees: elenafuengar
99
## Bug report 🐛
1010
Create a bug report to help us improve Wakis robustness🦾💖
1111

12-
**💬 Describe the bug**
12+
#### 💬 Describe the bug
1313
A clear and concise description of what the bug is. What did you expect to happen, and what happened instead?
1414

15-
---
16-
17-
**🔁 To Reproduce**
18-
Steps to reproduce the behavior:
19-
20-
1. This version'...'
21-
2. This script '...'
22-
3. This line of code '...'
23-
4. See the error
24-
25-
---
2615

27-
**✅ Expected behavior**
28-
What did you expect to happen?
16+
#### 🔁 To Reproduce
17+
Steps to reproduce the behavior or paste your Python code here:
2918

30-
---
31-
32-
**🖼️ Screenshots (optional)**
33-
If applicable, add screenshots or logs to help explain your problem.
19+
```python
20+
# Your code
21+
```
3422

35-
---
36-
37-
**🖥️ System Info**
38-
Please complete the following:
23+
#### 🖥️ System Info
24+
If possible complete the following:
3925

4026
- 🧭 **OS**: [e.g. Ubuntu 22.04, macOS Ventura, Windows 11]
4127
- 🧩 **Python version**: [e.g. 3.10]
42-
- 💾 **Wakis version**: [e.g. 0.5.2]
43-
- ⚙️ **Environment**: [e.g. Conda, pip, Jupyter Notebook, MPI-enabled]
28+
- 💾 **Wakis version**: [e.g. 0.6.0]
29+
- ⚙️ **Environment**: [e.g. Running on CPU/GPU from Script, Jupyter Notebook, MPI-enabled...]
4430

45-
---
4631

47-
**📎 Additional context**
32+
#### 📎 Additional context
4833
Any other info that might help us reproduce or understand the issue. Logs, configurations, or even your simulation setup!

.github/ISSUE_TEMPLATE/feature-request.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,23 @@ assignees: elenafuengar
99
## Feature request 💡
1010
Suggest an idea that should be implemented in Wakis ⚙️💖
1111

12-
**🧩 Is your feature request related to a problem? Please describe.**
13-
A clear and concise description of the underlying problem or limitation.
14-
_Example: "I'm always frustrated when [...]"_
1512

16-
---
17-
18-
**🔍 Describe the solution you'd like**
13+
#### 🔍 Describe the solution you'd like
1914
What would the ideal solution look like? Be specific!
2015
_Example: "I wish I could [...], and the solver would automatically [...]"_
2116

22-
---
2317

24-
**🔄 Describe alternatives you've considered**
25-
Have you tried other workarounds, external tools, or existing features?
18+
#### 🔄 Describe alternatives you've considered
19+
Have you tried other workarounds, external tools, or existing features? You can include some Python code/pseudo-code here if you don't want to go through the Pull-Request hassle:
20+
21+
```python
22+
# your code idea
23+
```
2624

27-
---
2825

29-
**📎 Additional context**
30-
Include any extra information, screenshots, mockups, or use cases that help us understand your idea better.
3126

32-
---
3327

34-
**🙏 Thank you!**
35-
We're excited to hear your suggestions. Your feedback makes Wakis better for everyone! 🌟
3628

29+
>**🙏 PS: Thank you!**
30+
>We're excited to hear your suggestions. Your feedback makes Wakis better for everyone! 🌟
3731
38-
**Additional context**
39-
Add any other context or screenshots about the feature request here.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow runs on pull requests and nightly
2+
name: pull_request_CPU_python11
3+
4+
on:
5+
# Run tests for every pull request targeting main
6+
pull_request:
7+
branches:
8+
- main
9+
types: [opened, synchronize, reopened]
10+
11+
jobs:
12+
run_tests:
13+
runs-on: ubuntu-latest
14+
15+
defaults:
16+
run:
17+
shell: bash -el {0}
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
path: wakis
24+
25+
- name: Setup Miniforge
26+
uses: conda-incubator/setup-miniconda@v2
27+
with:
28+
miniforge-version: latest
29+
python-version: "3.11"
30+
31+
- name: Install wakis
32+
run: |
33+
cd wakis
34+
pip install .['notebook']
35+
36+
- name: Print installed packages
37+
run: conda list
38+
39+
- name: Run pytest
40+
run: |
41+
cd wakis
42+
python -m pytest --color=yes -v -s tests

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Check 📁 `examples/` and `notebooks/` for different physical applications:
4545
* Custom perturbation interacting with PEC geometry
4646
* Wakefield simulation of accelerator cavity on CPU, GPU and with MPI
4747

48+
Check 🌐📁 [`SWAN_tutorial/`](https://github.com/ImpedanCEI/SWAN_tutorial) for hands-on notebook examples ready to run on CERN's SWAN service's GPUs (A100, Tesla T4):
49+
50+
[<img class="open_in_swan" data-path="your_submodule_name" alt="Open this Gallery in SWAN" src="https://swanserver.web.cern.ch/swanserver/images/badge_swan_white_150.png">][gallery_url]
51+
52+
[gallery_url]:https://cern.ch/swanserver/cgi-bin/go?projurl=https://github.com/ImpedanCEI/SWAN_tutorial.git
53+
4854
Check 🌐📁 [`wakis-benchmarks/`](https://github.com/ImpedanCEI/wakis-benchmarks) for beam-coupling impedance calculations & comparisons to the commercial tool *CST® Wakefield solver*:
4955
* PEC cubic cavity below cutoff (mm) and above cutoff (cm)
5056
* Conductive cubic cavity below cutoff

docs/installation.md

Lines changed: 109 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,41 +139,80 @@ mamba install cudatoolkit=11.8.0
139139

140140
You can find the official CUDA Toolkit in the [NVIDIA development website](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Fedora&target_version=41&target_type=rpm_local)
141141

142-
## Python Notebooks troubleshooting
142+
### HTCondor with GPU submission
143143

144-
### Matplotlib interactive plots
145-
Within jupyter notebooks, in order to be able to zoom and interact with matplotlib figures, one needs to use notebook magic commands `%`.
146-
* The recommended one for Jupyter notebooks on the web is `%matplotlib widget`
147-
* The recommended one for Jupyter notebooks on VS Code in `%matplotlib ipympl`
144+
Your `config_condor.sub` file needs to request a GPU
145+
```
146+
if !defined FNAME
147+
FNAME = outputs
148+
endif
148149
149-
The package `ipympl`can be easily installed using `pip install ipympl`
150+
ID = $(Cluster).$(Process)
150151
151-
### PyVista interactive plots
152-
To be able to render 3D interactive plots in Jupyter notebooks, it is recommended to use the `wakis['notebook']` pip installation.
152+
output = ./logs/$(FNAME).$(ID).out
153+
error = ./logs/$(FNAME).$(ID).err
154+
log = ./logs/$(FNAME).$(Cluster).log
153155
154-
Some driver problems may arise depending on pre-installed versions. One way of solving common errors like `MESA-loader` or `libGL error` is installing a new driver within your conda environment with:
156+
should_transfer_files = YES
157+
when_to_transfer_output = ON_EXIT
158+
159+
request_GPUs = 1
160+
request_CPUs = 1
161+
+MaxRunTime = 100
162+
+AccountingGroup = your_acct_group
155163
164+
executable = simulation_run.sh
156165
```
157-
conda install conda-forge::libstdcxx-ng
166+
167+
Your `simulation_run.sh` file could optionally include:
168+
158169
```
170+
#!/bin/bash
171+
# source the miniforge
172+
source /afs/cern.ch/work/u/user/miniforge3/etc/profile.d/conda.sh
173+
conda activate /afs/cern.ch/work/u/user/SimulationProjects/wakis_simulation/wakis-env
159174
160-
If you're in a headless environment (e.g., remote server, openstack machine), forcing OSMesa (Off-Screen Mesa) rendering might help:
175+
# Fix for UCX errors
176+
export UCX_TLS=rc,tcp,cuda_copy,cuda_ipc
177+
178+
# Fix for HDF5 file locking issues, when overwriting to same directory
179+
export HDF5_USE_FILE_LOCKING=FALSE
180+
181+
python3.11 -m wakis_simulation.main
182+
```
183+
184+
An example python project for simulating on HTCondor, is shown here [BLonD Simulation Template](https://gitlab.cern.ch/blond/blond-simulation-template).
185+
The submission files are based on the approach used in this example project [^3], modified for GPU. The project can be modified for the wakis environment, it currently is set up
186+
for simulations with BLonD, the longitudinal beam dynamics code.
187+
188+
## CPU Multithreading
189+
To achieve multithreading for Wakis `sparse matrix x vector` operations, the Intel-MKL backend has been implemented as an alternative to single-threaded `scipy.sparse.dot`. To install it in your conda environment simply do:
190+
191+
```
192+
pip install mkl mkl-service sparse_dot_mkl
193+
```
194+
195+
Wakis will detect that the package is installed and use it as default backend. To control the number of threads and memory pinning, add the following lines to your python script **before** the imports:
161196

162197
```python
198+
# [!] Set before importing numpy/scipy/mkl modules
163199
import os
164-
os.environ['PYVISTA_USE_OSMESA'] = 'True'
200+
os.environ["OMP_NUM_THREADS"] = str(os.cpu_count()) # Number of OpenMP threads
201+
os.environ["KMP_AFFINITY"] = "balanced,granularity=fine" # Thread pinning
165202
```
166203

167-
## MPI setup
168-
To run multi-CPU parallelized simulations, Wakis needs the following packages:
204+
* 🔜 A domain decomposition multithreading is envisioned for future resleases
205+
206+
## CPU/GPU MPI setup
207+
To run multi-node CPU parallelized simulations, Wakis needs the following packages:
169208

170209
* OpenMPI installed in your operating system:
171210
* Python package [`mpi4py`](https://mpi4py.readthedocs.io/en/stable/)
172211
* Python package [`ipyparallel`](https://ipyparallel.readthedocs.io/en/latest/tutorial/intro.html) to start a MPI kernel inside notebooks
173212

174213
The preferred install method is through `conda-forge`:
175214

176-
```
215+
```bash
177216
# All at once [recommended]
178217
conda install -c conda-forge mpi4py openmpi
179218
```
@@ -205,6 +244,7 @@ CC=mpicc pip install --no-cache-dir mpi4py
205244
# For working on jupyter notebooks:
206245
pip install ipyparallel
207246
```
247+
### Checking multi-GPU compatibility
208248

209249
* `OpenMPI` is built in Linux with multi-GPU compatibility (provided `cupy` is correctly setup):
210250
```bash
@@ -224,6 +264,13 @@ Before launching an MPI simulation, make sure to set the environment variable `O
224264
# Set environment variable to use CUDA-aware before launching your MPI processes
225265
export OMPI_MCA_opal_cuda_support=true
226266
```
267+
Or from python, before importing `mpi4py`:
268+
```python
269+
import os
270+
os.environ['OMPI_MCA_opal_cuda_support']='true'
271+
```
272+
273+
### Running multi-GPU simulation
227274

228275
To run MPI simulations from the terminal:
229276
```bash
@@ -236,6 +283,52 @@ mpiexec --mca btl_smcuda_cuda_ipc_max 0 -n 4 python your_wakis_gpu_script.py
236283
mpiexec --mca opal_cuda_support 1 -n 4 python your_wakis_gpu_script.py
237284
```
238285

286+
It is also possible to run multi-GPU from **python notebooks** using `ipyparallel` and the notebook magic `%%px`:
287+
```python
288+
import ipyparallel as ipp
289+
cluster = ipp.Cluster(engines="mpi", n=2).start_and_connect_sync()
290+
```
291+
Once the cluster has initialized:
292+
```python
293+
%%px
294+
import os
295+
os.environ['OMPI_MCA_opal_cuda_support']='true' # multi GPU
296+
297+
from mpi4py import MPI
298+
comm = MPI.COMM_WORLD
299+
rank = comm.Get_rank()
300+
size = comm.Get_size()
301+
print(f"Process {rank} of {size} is running")
302+
303+
import cupy
304+
cupy.cuda.Device(rank).use()
305+
```
306+
307+
## Python Notebooks troubleshooting
308+
309+
### Matplotlib interactive plots
310+
Within jupyter notebooks, in order to be able to zoom and interact with matplotlib figures, one needs to use notebook magic commands `%`.
311+
* The recommended one for Jupyter notebooks on the web is `%matplotlib widget`
312+
* The recommended one for Jupyter notebooks on VS Code in `%matplotlib ipympl`
313+
314+
The package `ipympl`can be easily installed using `pip install ipympl`
315+
316+
### PyVista interactive plots
317+
To be able to render 3D interactive plots in Jupyter notebooks, it is recommended to use the `wakis['notebook']` pip installation.
318+
319+
Some driver problems may arise depending on pre-installed versions. One way of solving common errors like `MESA-loader` or `libGL error` is installing a new driver within your conda environment with:
320+
321+
```
322+
conda install conda-forge::libstdcxx-ng
323+
```
324+
325+
If you're in a headless environment (e.g., remote server, openstack machine), forcing OSMesa (Off-Screen Mesa) rendering might help:
326+
327+
```python
328+
import os
329+
os.environ['PYVISTA_USE_OSMESA'] = 'True'
330+
```
331+
239332
----
240333

241334
[PyVista](https://github.com/pyvista/pyvista) a python package for 3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK) [^1].
@@ -245,3 +338,4 @@ We rely on [PyVista](https://github.com/pyvista/pyvista) to import CAD/STL geome
245338

246339
[^1]: Sullivan and Kaszynski, (2019). PyVista: 3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK). Journal of Open Source Software, 4(37), 1450, https://doi.org/10.21105/joss.01450
247340
[^2]: Anaconda Software Distribution. (2020). Anaconda Documentation. Anaconda Inc. Retrieved from https://docs.anaconda.com/
341+
[^3]: S. Lauber, (2025). Blond Simulation Template. Retrieved from https://gitlab.cern.ch/blond/blond-simulation-template

docs/usersguide.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ from wakis import WakeSolver # Wake and Impedance calculation
4444

4545
### Simulation domain, geometry and materials setup
4646

47-
`wakis` is a numerical electromagnetic solver that uses the Finite Integration Technique. The grid used is a structured grid composed by rectangular cells. The simulation domain is a rectangular box that will be broken into cells where the electromagnetic fields will be computed.
47+
`wakis` is a numerical electromagnetic solver that uses the Finite Integration Technique. The grid used is a structured grid composed by rectangular cells. The simulation domain is a rectangular box that will be broken into cells where the electromagnetic fields will be computed. Notice that all the input parameters for Wakis must be in SI Base Units.
4848

4949
#### Number of mesh cells
5050

@@ -63,7 +63,7 @@ Note that the number of cells will heavily affect the simulation time (in partic
6363
```
6464

6565
### `STL` geometry importing
66-
In beam-coupling impedance simulations one is usually interested in the geometric impedance, together with the impedance coming from material properties. In `wakis`, the geometry to simulate (sometimes referred as Embedded boundaries) can be imported from a `.stl` file containing a CAD model.
66+
In beam-coupling impedance simulations one is usually interested in the geometric impedance, together with the impedance coming from material properties. In `wakis`, the geometry to simulate (sometimes referred as Embedded boundaries) can be imported from a `.stl` file containing a CAD model, and the units should be meters [m].
6767

6868
```python
6969
# stl geometry files (add path to them if necessary)
@@ -119,7 +119,7 @@ stl_materials = {'cavity': 'vacuum', # equivalent to [1.0, 1.0, 0]
119119
```
120120

121121
### Defining the `grid` object
122-
After this, the user needs to indicate the domain bounds to simulate. They can be calculated from the imported geometry or just hardcoded:
122+
After this, the user needs to indicate the domain bounds to simulate, in [m]. They can be calculated from the imported geometry or just hardcoded with `float` values:
123123

124124
``` python
125125
# Domain bounds
@@ -136,8 +136,8 @@ grid = GridFIT3D(xmin, xmax, ymin, ymax, zmin, zmax,
136136
stl_solids=stl_solids,
137137
stl_materials=stl_materials,
138138
stl_translate=stl_translate,
139-
stl_scale=stl_scale
140-
stl_rotate=stl_rotate
139+
stl_scale=stl_scale,
140+
stl_rotate=stl_rotate,
141141
)
142142
```
143143

0 commit comments

Comments
 (0)