Skip to content

Commit

Permalink
Reverted back. Convergence study is not accurate because of inability…
Browse files Browse the repository at this point in the history
… to control mesh for now.
  • Loading branch information
Dark-Elektron committed Nov 14, 2024
1 parent c6a4bc7 commit 7867475
Show file tree
Hide file tree
Showing 9 changed files with 1,878 additions and 271,899 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ Or through the command line with
```
mkdir <root folder>/cavsim2d/solver/ABCI
copy <root folder>/ABCI_MP_12_5/ABCI_MP_12_5/ABCI_MP application for Windows/ABCI_MP64_12_5.exe <root folder>/cavsim2d/solver/ABCI
tar -xf <root folder>/ABCI_MP_12_5.zip
copy '<root folder>/ABCI_MP_12_5/ABCI_MP_12_5/ABCI_MP application for Windows/ABCI_MP64_12_5.exe' <root folder>/cavsim2d/solver/ABCI
cd <root folder>/cavsim2d/solver/ABCI
ren ABCI_MP64_12_5.exe ABCI.exe
```
Before diving in, I would install `pprintpp`. It is not necessay but it sure does makes the print readable.
```python
import pprint
pp = pprint.PrettyPrinter(indent=4)
Before diving in, I would install `pprintpp`. It is not necessary but it sure does make the print readable.
```
pip install pprintpp
```
If jupyter and ipywidgets are not already installed, now will be a good time to installl it.
--------------------------------------------
Examples - TESLA Elliptical Cavity
==================================
Expand All @@ -75,6 +78,9 @@ The core components of `cavsim2d` are `Cavities` and `Cavity` objects. `Cavities
instances, each representing a single RF cavity and its associated data. These objects are instantiated as follows:
```python
import pprint
pp = pprint.PrettyPrinter(indent=4)
from cavsim2d.cavity import Cavity, Cavities
cavs = Cavities()
Expand Down
1 change: 1 addition & 0 deletions cavsim2d/analysis/tune/pyTuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def tune(self, par_mid, par_end, tune_var, target_freq, cell_type, beampipes, bc
right = tuned_cell
beampipes = 'none'
elif cell_type.lower() == 'mid-end cell' or cell_type.lower() == 'mid-end-cell' or cell_type.lower() == 'mid_end_cell':
print(par_mid)
mid = par_mid
left = par_mid
tuned_cell = par_end
Expand Down
21 changes: 16 additions & 5 deletions cavsim2d/analysis/tune/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,17 @@ def tune_ngsolve(self, pseudo_shape_space, bc, parentDir, projectDir, filename,
tune_var, freq = 0, 0

if tune_var != 0 and freq != 0:
if cell_type.lower() == 'mid cell' or cell_type.lower() == 'mid-cell' or cell_type.lower() == 'mid_cell':
if (cell_type.lower() == 'mid cell' or cell_type.lower() == 'mid-cell'
or cell_type.lower() == 'mid_cell'):
print('it is in here', tune_variable, tune_var, freq)
tuned_mid_cell = pseudo_shape['IC'][:7]
tuned_mid_cell[VAR_TO_INDEX_DICT[tune_variable]] = tune_var
tuned_end_cell = pseudo_shape['OC'][:7]
# enforce equator continuity
tuned_end_cell[6] = tuned_mid_cell[6]
elif cell_type.lower() == 'mid-end cell' or cell_type.lower() == 'mid-end-cell' or cell_type.lower() == 'mid_end_cell':
elif (cell_type.lower() == 'mid-end cell' or cell_type.lower() == 'mid-end-cell'
or cell_type.lower() == 'mid_end_cell'):
print('it is in here', tune_variable, tune_var, freq)
tuned_mid_cell = pseudo_shape['IC'][:7]
tuned_end_cell = pseudo_shape['OC'][:7]
tuned_end_cell[VAR_TO_INDEX_DICT[tune_variable]] = tune_var
Expand All @@ -97,11 +101,18 @@ def tune_ngsolve(self, pseudo_shape_space, bc, parentDir, projectDir, filename,
tuned_end_cell = pseudo_shape['OC'][:7]
tuned_end_cell[VAR_TO_INDEX_DICT[tune_variable]] = tune_var
tuned_mid_cell = copy.deepcopy(tuned_end_cell)
else:
elif cell_type.lower() == 'single_cell' or cell_type.lower() == 'single cell':
tuned_mid_cell = pseudo_shape['IC'][:7]
tuned_end_cell = pseudo_shape['OC'][:7]
tuned_end_cell[VAR_TO_INDEX_DICT[tune_variable]] = tune_var
tuned_mid_cell = copy.deepcopy(tuned_end_cell)
else:
info('Valid cell_type not selected. Defaulting to end_cell')
tuned_mid_cell = pseudo_shape['IC'][:7]
tuned_mid_cell[VAR_TO_INDEX_DICT[tune_variable]] = tune_var
tuned_end_cell = pseudo_shape['OC'][:7]
# enforce equator continuity
tuned_end_cell[6] = tuned_mid_cell[6]

# # enforce equator continuity
# tuned_mid_cell[6] = tuned_end_cell[6]
Expand Down Expand Up @@ -133,8 +144,8 @@ def tune_ngsolve(self, pseudo_shape_space, bc, parentDir, projectDir, filename,
tuned_shape_space[key] = {"IC": inner_cell, "OC": outer_cell, "OC_R": outer_cell, "BP": 'both', 'FREQ': freq}

# write tune results
d_tune_res = {'IC': list(tuned_mid_cell), 'OC': list(tuned_end_cell),
'OC_R': list(tuned_end_cell),
d_tune_res = {'IC': list(inner_cell), 'OC': list(outer_cell),
'OC_R': list(outer_cell),
'TUNED VARIABLE': tune_variable, 'CELL TYPE': cell_type, 'FREQ': freq}

abs_err_dict = {'abs_err': abs_err_list}
Expand Down
Loading

0 comments on commit 7867475

Please sign in to comment.