Skip to content

Commit

Permalink
Merge pull request #8 from xsuite/refactor/xwakes
Browse files Browse the repository at this point in the history
refactor to make xwakes comply with the xsuite standards
  • Loading branch information
lgiacome authored Jun 21, 2024
2 parents f59beb6 + 8b447cf commit 1fc05d8
Show file tree
Hide file tree
Showing 41 changed files with 3,838 additions and 3,736 deletions.
17 changes: 0 additions & 17 deletions LICENSE.txt

This file was deleted.

3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ include *.md

# Include the license file
include LICENSE

# Include the data files
include xwakes/wit/materials.json
62 changes: 19 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,31 @@
# PyWIT
####Python Wake and Impedance Toolbox

## Installation
**NB:** Though most of this PyWIT's functionality is available independently of any non-dependency package,
the installation of IW2D (https://gitlab.cern.ch/IRIS/IW2D) is *strongly recommended* in order to have full access to
all of the features of PyWIT. For this reason, this installation guide will include the installation process required by
IW2D. If you already have IW2D downloaded and installed on your system, you can skip directly to step 3. Please note that IW2D (at the time of writing) is only available on Linux systems.

1. Download the IW2D repository to your system by cloning the git repository. This can be done by executing the command

`git clone https://gitlab.cern.ch/IRIS/IW2D`

in a suitable directory. You may be prompted to enter your CERN log-in credentials for this step.


2. Perform the installation procedure for IW2D. This is explained in detail in the `README.md` file in the IW2D repository, but is summarized here:
1. Install the prerequisite libraries "MPFR" and "GSL" by running:
`sudo apt-get install libgsl-dev libmpfr-dev`
or alternatively, if you have anaconda/miniconda installed:
`conda install -c conda-forge gsl mpfr`
2. Compile the C++ code by running:
```
cd IW2D/cpp
cp ./Makefile_system_GMP_MPFR Makefile
make
```
# Xwakes

Python package for wakes and impedances handling.

3. In a new directory, where you want your PyWIT directory to be placed, Download the PyWIT repository to your system by
cloning the git repository. This can be done by executing the command
`git clone https://gitlab.cern.ch/IRIS/pywit`.
You may be prompted to enter your CERN log-in credentials for this step.
## Installation

4. Install PyWIT using pip by navigating to your pywit directory executing the command
Under a conda environment with Python 3.8+ it is simply installed via PyPI by doing `pip install xwakes`

`pip install .`.
## IW2D coupling

This section describes how to couple Xwakes to IW2D using the executables obtained compiling the C++ code.
When the Python interface of IW2D will be completed this will not be needed anymore.

5. Navigate to the directory `IW2D/IW2D/cpp` in the IW2D repository. Copy the following four
files from this folder:
To begin with, some folders need to be created in the user's home directory.
This can be automatically done by running the following command after Xwakes is installed:
```
python -c 'import xwakes; xwakes.initialize_pywit_directory()'
```
The IW2D executable are produced by following the [IW2D readme]([https://gitlab.cern.ch/IRIS/IW2D/-/tree/master?ref_type=heads)](https://gitlab.cern.ch/IRIS/IW2D/).
After this procedure is completed the following executable files will be created in `/path/to/iw2d/IW2D/cpp/`:
* `flatchamber.x`
* `roundchamber.x`
* `wake_flatchamber.x`
* `wake_roundchamber.x`
6. In your home directory, there will have appeared a new directory called 'pywit'. Navigate into this folder, then
into 'IW2D', then into 'bin'. Paste the four files copied in step 5 into this folder.

These files have to be copied in the newly created folder with the command

You should now be able to use PyWIT with your Python system interpreter.
```
cp /path/to/iw2d/IW2D/cpp/*.x ~/pywit/IW2D/bin
```
Now Xwakes can be used to launch IW2D calculations.
1 change: 1 addition & 0 deletions pywit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from xwakes.wit import *
14 changes: 14 additions & 0 deletions pywit/_generate_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'''
generate files to mirror in pywit the modules from xwakes.wit
'''

import os

fff = os.listdir('../xwakes/wit')

for nn in fff:
if not nn.endswith('.py') or nn.startswith('_'):
continue

with open(nn, 'w') as fid:
fid.write(f'from xwakes.wit.{nn.split(".py")[0]} import *\n')
Loading

0 comments on commit 1fc05d8

Please sign in to comment.