Skip to content
Snippets Groups Projects
Commit 9ef2970d authored by Philippe Piot's avatar Philippe Piot
Browse files

Update README.md to include instructions on how to modify (essentially copied...

Update README.md to include instructions on how to modify (essentially copied from an e-mail sent to B.  Leung)
parent 67274e8a
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,26 @@ implements the DEAP framework to optimize beam dynamics problem
### how to run?
After cloning the repo, and after loading the correct module ```module load anaconda3/2020.11``` and ```export PYTHONPATH=/lcrc/project/Bright-Beams/software/opal/pyOPALTools:$PYTHONPATH``` you should be able to run using ```python easySend_bebop_OPAL.py ga.py $NCPU``` where ```$NCPU``` is the number of CPU you request. On bebop this should be a multiple of 36.
### how to customize?
In its current implementation the optimization has four objective function (transverse and longitudinal emittances, number of macroparticle, and energy). Although the number of macroparticle and energy are set as objective function there are introduce through functions that implements them as constraints (so the output of these function is 0 (minimum) around or above a give values and larger elsewhere). In the current configuration 10 parameters are varied.
### To change the objective function:
- open ```optimize.py```
- edit the line
```python
#build fitness function:
fitness = (emit_x, emit_s, Nfit, Kfit)
```
- save/close ```optimize.py```
### To change the control variables:
- open the OPAL input file ```input.ref.in``` (it can be any opal input file you have but should be renamed as ```input.ref.in```)
- define the control variables you want to optimize. These variable should appear with a ```__``` (double underscore) appended at the beginning of the variable ```python __myvariable```.
- save/close the ```input.ref.in``` file.
- run the following command ```bash python getvariable.py input.ref.in > tmpVar.txt``` this will generate a block for the optimize.py deck stored in ```tmpVar.txt```
- edit/customise the ```tmpVar.txt``` as you want (you may want to have mathematical operation etc...). Also in its current version the parser is very primitive so that a line like ```python REAL Ibuck = __Ibuck_scale*(Ifocu*2.545263e-02+Imain*6.481346e-05)/2.526366e-02``` in the OPAL deck will appear as ```python __Ibuck_scale*(Ifocu*2.545263e-02+Imain*6.481346e-05)/2.526366e-02;``` in tmpVar.txt and you will have to remove by hand the extra expression on the right of (and including) the ```*```.
- edit the ```python myRanges``` section (line 24 in ```optimize.py```). Eeach couple correspond to one variable in the ```python X[]``` array. For instance the first couple element of ```python myRanges``` is currently ```(40,50)``` and implied that ```python X[0]``` (thich corresponds to the gun amplitude) will be varied between 40 and 50 during the optimization.
### List of files:
- easySend_bebop_OPAL.py: scripts to run the optimization with scoop (note that this directory was tested with '''anaconda3/2020.11''' module, DEAP version 1.3.1 and SCOOP version 0.7.1.1 (use ``` pip install deap=1.31```, use ```pip install scoop=0.7.1.1```.
- ga.py and optimize.py: contains function to set parameter for the optimization parameters, and function for input/output control
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment