blond-org / blond_common

Collection of common functions and interfaces
GNU General Public License v3.0
3 stars 5 forks source link

rf_functions package overhaul #17

Open alasheen opened 5 years ago

alasheen commented 5 years ago

Following issue #15

The functions require full documentation, unit-tests, exceptions handling, and to agree on the expected input/outputs of the functions.

This issue is opened to gather requests, suggestions, follow-ups.

scpalbright commented 5 years ago
scpalbright commented 5 years ago
scpalbright commented 5 years ago
alasheen commented 5 years ago
alasheen commented 5 years ago

We need to agree on the layout of the rf_functions package. Here is the present list of functions and their input/output:

rf_voltage_analytic(time_array, voltage, harmonic_number, phi_offset)

return time_array, voltage_array
rf_potential_analytic(time_array, voltage, harmonic_number,
                            phi_offset, eta_0, charge, energy_increment)

return time_array, potential_well
voltage_to_potential(time_array, voltage_array, eta_0, charge,
                                  t_rev, energy_increment, method='cubic',
                                  interpolated_voltage_minus_increment=None)

return time_array, potential_well, (voltage_minus_increment,
                                        interpolated_voltage_minus_increment)
find_potential_wells_cubic(time_array, potential_well,
                               precision=1e-6, n_max_guess=10,
                               edge_is_max=False, verbose=False)

return (potwell_max_locs, potwell_max_vals,
            potwell_inner_max, potwell_min_locs,
            potwell_min_vals)
potential_well_cut_cubic(time_array, potential_well,
                             potwell_max_locs)

return time_array_cut_list, potential_well_cut_list
trajectory_area_cubic(time_array, potential_array, eta_0, beta_rel,
                          tot_energy, min_potential_well=None)

return time_array, dEtraj, hamiltonian, calc_area, half_energy_height, \
        full_length_time
area_vs_hamiltonian_cubic(time_array, potential_array, eta_0, beta_rel,
                              tot_energy, min_potential_well=None,
                              inner_max_potential_well=None,
                              n_points_reinterp=None)

return time_array, \
        hamiltonian_scan, calc_area_scan, \
        half_energy_height_scan, \
        full_length_time_scan
synchrotron_frequency_cubic(time_array, potential_array, eta_0, beta_rel,
                                tot_energy, min_potential_well=None,
                                inner_max_potential_well=None,
                                n_points_reinterp=None)

return time_array_fs, \
        sync_freq, \
        hamiltonian_scan_fs, \
        calc_area_scan_fs, \
        half_energy_height_scan_fs, \
        full_length_time_scan_fs

Please comment on the changes you would like (function name change, changes in the default input/output, changes in the expected options), and on the missing functions to be added or present in other branches/repos.

MarkusSchwarz1980 commented 5 years ago

AL: I agree, I included function renaming in the comment. Indeed a _linear version is expected. However I think it could/should be handled by the same function, with a "method" option.

AL: The first implementation was thought to compute the function between [0, t_rf], or to values defined by time_bounds if needed. I agree that the input is not intuitive. This also goes along with the comments by @scpalbright in https://github.com/blond-org/blond_common/issues/17#issuecomment-522028830 and https://github.com/blond-org/blond_common/issues/17#issuecomment-522947333 . I put time_array as a mandatory input till we get more input from others.

AL: More generally, do we want time_array to be returned by these functions, knowing that it is a mandatory input for all these functions ? Do we also want to ensure that all share the same ouput format ?

AL: the reason is my compulsive disorder for long variable names :) . In fact, this is to make the distinction between the full potential well and the potential well cut at the location of the separatrices. To make the input uniform, I changed the output of potential_well_cut_cubic

AL: this is intended. The function computes fs on the left and right hand side of the minimum, and sorts the time_array_fs in the same order as the input time_array.

AL: in BLonD the convention is we call f for frequency and omega for angular frequency, then the input is often frequency (e.g. for impedance sources). I am interested in the idea to be able to have this governed by the rc object, but I think this will be for an other larger Github issue :)

AL: this is something under discussion. We can certainly use these functions to replace the one used in the bunch generation routines (this was the original intention). However for the calculation of phi_s, f_s etc, we need to find a reasonable compromise to not include to much unecessary complexity in the tracking code (e.g. present implementation of calc_phi_s is limited, but flawless for single rf cases)

alasheen commented 5 years ago
alasheen commented 4 years ago

Added edge_is_max option to find_potential_wells_cubic following https://github.com/blond-org/blond_common/issues/34

scpalbright commented 4 years ago

Set mest to a default large value in find_potential_wells_cubic