|
ROCK 1.9.1
Relativistic Oscillator Calculation Kit
|
CROCK API. More...
Go to the source code of this file.
Data Structures | |
| struct | cr_cache |
| Read the detailed description! More... | |
Macros | |
| #define | CROCK_API |
| #define | ROCK_MALLOC |
| #define | ROCK_PURE |
| #define | ROCK_CONST |
| #define | ROCK_NODISCARD |
| #define | ROCK_UNUSED |
| #define | ROCK_MASK_BLT_VAR_UZ |
| Beamlet option: consider variable axial velocity. | |
| #define | ROCK_MASK_BLT_TAYLOR |
| Beamlet option: consider 2nd term of Taylor expansion. | |
| #define | ROCK_MASK_BLT_CALI_CYC_PHASE |
| #define | ROCK_MASK_BLT_CALI_GC_AZI |
| #define | ROCK_MASK_BLT_CALI_GC_R |
| #define | ROCK_MASK_BLT_DOPPLER |
| #define | ROCK_MASK_BLT_SRC_MONOHARM |
| #define | ROCK_MASK_BLT_MONOGC |
| #define | ROCK_MASK_BLT_DEBUG |
| #define | ROCK_MASK_BLT_ALL_FEATURES |
| Beamlet option: All features except MONOGC and SRC_MONOHARM. Slowest option. | |
| #define | ROCK_FOREACH(X) |
| #define | ROCK_FOREACH_1(X) |
| Unified commonly used FOREACH, but stating from 1 instead of 0. | |
| #define | ROCK_IF_RETURN(IF_VAL, RET_VAL) |
| Trick the coverage test for handling errors. | |
| #define | CR_NUMA_BLESS(type, buf, ...) |
Functions | |
| CROCK_API int | cr_numa_bless (void *restrict buf, size_t sizeof_type, size_t dim_shape, const size_t *restrict shape) |
| Set the data of buf to zero. | |
| CROCK_API ROCK_CONST ROCK_NODISCARD int | cr_version_major (void) |
| CROCK_API ROCK_CONST ROCK_NODISCARD int | cr_version_minor (void) |
| CROCK_API ROCK_CONST ROCK_NODISCARD int | cr_version_patch (void) |
| CROCK_API ROCK_PURE ROCK_NODISCARD const char * | cr_errmsg (int err) |
| CROCK_API ROCK_PURE ROCK_NODISCARD size_t | cr_stride_real (size_t dim) |
| Calculate stride including padding. | |
| CROCK_API ROCK_PURE ROCK_NODISCARD size_t | cr_stride_cplx (size_t dim) |
| Calculate stride including padding. | |
| CROCK_API int | cr_make_mode_holl (size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, real *restrict mvn_mod) |
| CROCK_API int | cr_make_mode_coax (size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, const real *restrict vn_geo_rin, real *restrict mvn_mod) |
| CROCK_API int | cr_make_mode_corr_ins (size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, const real *restrict vn_geo_rin, const real *restrict vn_geo_rel_w, const real *restrict vn_geo_depth, real *restrict mvn_mod) |
| CROCK_API int | cr_make_mode_corr_holl_imp (size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_geo_rout, const real *restrict vn_geo_rel_w, const real *restrict vn_geo_depth, real *restrict mvn_mod) |
| CROCK_API int | cr_deprecated_search_cold_resonance (const real *restrict opt_ptr_ref_z, size_t dim_m, size_t dim_z, const real *restrict vn_z, const real *restrict mvn_mod, cplx *restrict vm_freq) |
| CROCK_API int | cr_find_cold_resonance (size_t dim_m, const real *restrict opt_vm_freq_init, size_t dim_z, size_t opt_iz_min_fcut, const real *restrict vn_z, const real *restrict mvn_mod, const real *restrict tdm_c, const real *restrict mv_tdm_zk, cplx *restrict vm_cfreq) |
| CROCK_API int | cr_find_all_cold_resonances (size_t dim_z, size_t opt_iz_min_fcut, const real *restrict vn_z, const real *restrict vn_mod, const real *restrict tdm_c, const real *restrict tdm_zk, size_t dim_freq, size_t *restrict out_dim_freq, cplx *restrict out_cfreq) |
| CROCK_API int | cr_make_cold_envelope (size_t dim_m, const cplx *restrict vm_rfc, size_t dim_z, const real *restrict vn_z, const real *restrict mvn_mod, cplx *restrict mvn_env) |
| CROCK_API ROCK_PURE ROCK_NODISCARD size_t | cr_guess_dim_cold_spectrum (size_t dim_z, const real *restrict vn_z, const real *restrict vn_mod) |
| CROCK_API int | cr_deprecated_make_cold_spectrum (size_t dim_z, const real *restrict vn_z, const real *restrict vn_mod, size_t dim_freq, real *restrict freq, real *restrict ampl) |
| CROCK_API int | cr_make_cold_spectrum (int max_iter, size_t dim_z, const real *restrict vn_z, const real *restrict vn_mod, const real *restrict tdm_c, const real *restrict tdm_zk, size_t dim_freq, real *restrict freq, real *restrict ampl) |
| CROCK_API int | cr_make_fem (size_t dim_m, size_t dim_z, const real *restrict vn_z, const real *restrict mvn_mod, real *restrict tdm_c, real *restrict mv_tdm_zk) |
| CROCK_API int | cr_step_field (real dt, size_t dim_m, const real *restrict vm_cf, const cplx *restrict vm_bc, size_t dim_z, const real *restrict tdm_c, const real *restrict mv_tdm_zk, const cplx *restrict mvn_src, cplx *restrict vm_bd, cplx *restrict mvn_env, real *restrict opt_vm_cp, real *restrict opt_vm_df, struct cr_cache *restrict *restrict opt_pp_cache) |
| CROCK_API void | cr_make_bc_simple (size_t dim_m, const real *restrict vm_freq, size_t dim_z, const real *restrict mvn_mod, cplx *restrict vm_bc) |
| CROCK_API void | cr_init_bp (size_t dim_m, size_t dim_z, const cplx *restrict mvn_env, real *restrict vm_bp) |
| CROCK_API void | cr_update_bc_simple (real dt, size_t dim_m, const real *restrict vm_cf, size_t dim_z, const real *restrict mvn_mod, const cplx *restrict mvn_env, real *restrict vm_bp, cplx *restrict vm_bc) |
| CROCK_API void | cr_init_bd (size_t dim_m, const cplx *restrict vm_bc, size_t dim_z, const cplx *restrict mvn_env, cplx *restrict vm_bd) |
| CROCK_API ROCK_MALLOC void * | cr_malloc (size_t size) |
| CROCK_API void | cr_free (void *ptr) |
| CROCK_API void | cr_make_potential (real pot_outer, real opt_pot_inner, const real *restrict beam_init, size_t dim_z, const real *restrict vn_mag_axis, const real *restrict vn_rhocd, const real *restrict vn_r_outer, const real *restrict opt_vn_r_inner, real *restrict vn_pot) |
| CROCK_API int | cr_make_bcc (real r_center, real r_span, size_t dim_m, const int16_t *restrict vm_num, size_t dim_z, const real *restrict vn_mag_axis, const real *restrict mvn_mod, size_t dim_bcc, real *restrict nvmh_bcc) |
| CROCK_API int | cr_shoot_beamlet (uint32_t options, const real *restrict beam_init, size_t dim_m, const int16_t *restrict vm_num, const real *restrict vm_cf, const real *restrict vm_cp, size_t dim_z, const real *restrict vn_z, const real *restrict vn_pot, const real *restrict vn_mag_axis, const real *restrict mvn_mod, const cplx *restrict mvn_env, size_t dim_b, size_t dim_bcc, real bcc_r_center, real bcc_r_span, const real *restrict nvmh_bcc, uint32_t *seed, real *restrict vn_rhocd, cplx *restrict mvn_src, real *restrict opt_vn_mrs, real *restrict opt_vn_blt_avg, real *restrict opt_bvn_blt_trj, struct cr_cache *restrict *restrict opt_pp_cache) |
| CROCK_API void | cr_make_power_out (size_t dim_m, const real *restrict vm_cf, size_t dim_z, const real *restrict mvn_mod, const cplx *restrict mvn_env, real *restrict opt_vm_pout_left, real *restrict opt_vm_pout_right) |
| CROCK_API real | cr_make_chi_TE_corr_ins (real r, real d, real w, int16_t num_azi, int16_t num_rad, real *restrict opt_array_chi) |
| CROCK_API real | cr_make_chi_TE_corr_holl_imp (real d, real w, int16_t num_azi, int16_t num_rad, real *restrict opt_array_chi) |
| CROCK_API void | cr_make_uload (size_t dim_m, size_t dim_z, const cplx *restrict mvn_env, const real *restrict mvn_uuload, real *restrict vn_uload) |
| CROCK_API void | cr_make_uuload (size_t dim_m, const int16_t *restrict vm_num, const real *restrict vm_freq, size_t dim_z, const real *restrict vn_radius, const real *restrict mvn_mod, real *restrict mvn_uuload) |
| CROCK_API int | cr_tdm_solve (size_t systems, size_t rows, const cplx *restrict multi_mat, const cplx *restrict multi_vec, cplx *restrict multi_x) |
| CROCK_API void | cr_make_df (real elapsed_time, size_t dim_m, size_t dim_z, const cplx *restrict mvn_new_env, real *restrict mvn_old_env_phase, real *restrict vm_df) |
| CROCK_API int | cr_refine_z (real weight, size_t dim_z, const real *restrict vn_z, const real *restrict vn_mrs, size_t dim_z_new, real *restrict vn_z_new) |
| Remap vn_z into vn_z_ne considering the mesh refinement score. | |
| CROCK_API int | cr_tdm_solve_offload (size_t systems, size_t rows, const cplx *restrict multi_mat, const cplx *restrict multi_vec, cplx *restrict multi_x) |
| CROCK_API int | cr_step_field_gpu (real dt, size_t dim_m, const real *restrict vm_cf, const cplx *restrict vm_bc, size_t dim_z, const real *restrict tdm_c, const real *restrict mv_tdm_zk, const cplx *restrict mvn_src, cplx *restrict vm_bd, cplx *restrict mvn_env, real *restrict opt_vm_cp, real *restrict opt_vm_df, struct cr_cache *restrict *restrict opt_pp_cache) |
| Doc see the CPU version. | |
| CROCK_API int | cr_step_field_offload (real dt, size_t dim_m, const real *restrict vm_cf, const cplx *restrict vm_bc, size_t dim_z, const real *restrict tdm_c, const real *restrict mv_tdm_zk, const cplx *restrict mvn_src, cplx *restrict vm_bd, cplx *restrict mvn_env, real *restrict opt_vm_cp, real *restrict opt_vm_df, struct cr_cache *restrict *restrict opt_pp_cache) |
| Doc see the CPU version. | |
CROCK API.
While the core functions are pure, the crock interface has side effects and is not thread-safe.
| #define CR_NUMA_BLESS | ( | type, | |
| buf, | |||
| ... ) |
| #define CROCK_API |
| #define ROCK_CONST |
| #define ROCK_FOREACH | ( | X | ) |
Unified commonly used FOREACH.
Use this wherever possible, in order to
Caveat: ROCK_FOREACH() in GPU offloading does not like dim_XXX=0
| #define ROCK_FOREACH_1 | ( | X | ) |
Unified commonly used FOREACH, but stating from 1 instead of 0.
| #define ROCK_IF_RETURN | ( | IF_VAL, | |
| RET_VAL ) |
Trick the coverage test for handling errors.
| #define ROCK_MALLOC |
| #define ROCK_MASK_BLT_ALL_FEATURES |
Beamlet option: All features except MONOGC and SRC_MONOHARM. Slowest option.
| #define ROCK_MASK_BLT_CALI_CYC_PHASE |
Beamlet option: consider calibration of cyclotron phase, reduce performance due to atan2()
| #define ROCK_MASK_BLT_CALI_GC_AZI |
Beamlet option: consider azimuthal motion (drift, oscillation etc.) of guiding center caused by RF field, reduce performance due to atan2()
| #define ROCK_MASK_BLT_CALI_GC_R |
Beamlet option: consider radial motion (drift, oscillation etc.) of guiding center caused by RF field.
| #define ROCK_MASK_BLT_DEBUG |
The name ROCK_MASK_BLT_DEBUG will be deprecated and will be removed in future versions, use ROCK_MASK_BLT_MONOGC instead.
| #define ROCK_MASK_BLT_DOPPLER |
Beamlet option: consider further Doppler effect caused by the transversal RF B field
| #define ROCK_MASK_BLT_MONOGC |
Beamlet option: Disable all spreads and randomizations, set all guiding centers to 0 degree
| #define ROCK_MASK_BLT_SRC_MONOHARM |
Beamlet option: Instead of summing all harmonical contributions, guess the harmonic numbers and apply only one harmonic for the source calculation. Enabling this causes less accurate exciation, but we get only the main frequency band of the field spectrum.
| #define ROCK_MASK_BLT_TAYLOR |
Beamlet option: consider 2nd term of Taylor expansion.
| #define ROCK_MASK_BLT_VAR_UZ |
Beamlet option: consider variable axial velocity.
| #define ROCK_NODISCARD |
| #define ROCK_PURE |
| #define ROCK_UNUSED |
| CROCK_API int cr_deprecated_make_cold_spectrum | ( | size_t | dim_z, |
| const real *restrict | vn_z, | ||
| const real *restrict | vn_mod, | ||
| size_t | dim_freq, | ||
| real *restrict | freq, | ||
| real *restrict | ampl ) |
Generate a spectrum of the cold resonance
| [out] | freq | is a 1D array with dimension [dim_freq] |
| [out] | ampl | is a 1D array with dimension [dim_freq]. |
| CROCK_API int cr_deprecated_search_cold_resonance | ( | const real *restrict | opt_ptr_ref_z, |
| size_t | dim_m, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | mvn_mod, | ||
| cplx *restrict | vm_freq ) |
Search resonance frequency for cold cavity
| [in] | opt_ptr_ref_z | An optional z-coordinate whose cut-off frequency will become the minimum frequency of the searching range. This is designed for gyrotron cavity simulation including up-taper, where the low-frequency resonances with profile maximum within the up-taper can be skipped. If NULL, the minimum cutoff of the whole geometry is the lower boundary of frequency range. |
| [out] | vm_freq | The scalar complex resonance frequency (in Hz). |
| CROCK_API ROCK_PURE ROCK_NODISCARD const char * cr_errmsg | ( | int | err | ) |
| CROCK_API int cr_find_all_cold_resonances | ( | size_t | dim_z, |
| size_t | opt_iz_min_fcut, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | vn_mod, | ||
| const real *restrict | tdm_c, | ||
| const real *restrict | tdm_zk, | ||
| size_t | dim_freq, | ||
| size_t *restrict | out_dim_freq, | ||
| cplx *restrict | out_cfreq ) |
| dim_freq | The maximum dim_freq allocated for the buffer |
| out_dim_freq | The number of actual resonance points |
| out_cfreq | Resonance frequencies, whose total dimension should be dim_freq, however, only contains *out_dim_freq number of valid resonances. |
| opt_iz_min_fcut | The index of grid node, whose cutoff frequency becomes lowest boundary of search interval. Ignored if opt_iz_min_fcut >= dim_z. |
| CROCK_API int cr_find_cold_resonance | ( | size_t | dim_m, |
| const real *restrict | opt_vm_freq_init, | ||
| size_t | dim_z, | ||
| size_t | opt_iz_min_fcut, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | mvn_mod, | ||
| const real *restrict | tdm_c, | ||
| const real *restrict | mv_tdm_zk, | ||
| cplx *restrict | vm_cfreq ) |
| [in] | opt_vm_freq_init | The initial frequencies for the searching. If opt_vm_freq_init == NULL or opt_vm_freq_init[im] <= 0, the resonances with the highest Q are searched; otherwise, for each mode, a resonance close to the given frequency is to be found. |
| [in] | tdm_c | The matrix Mc |
| [in] | mv_tdm_zk | The TDM (Mz-Mk) per mode |
| opt_iz_min_fcut | The index of grid node, whose cutoff frequency becomes lowest boundary of search interval. Ignored if opt_iz_min_fcut >= dim_z. opt_vm_freq_init overrides this parameter, if both are provided. |
| CROCK_API void cr_free | ( | void * | ptr | ) |
| CROCK_API ROCK_PURE ROCK_NODISCARD size_t cr_guess_dim_cold_spectrum | ( | size_t | dim_z, |
| const real *restrict | vn_z, | ||
| const real *restrict | vn_mod ) |
| CROCK_API void cr_init_bd | ( | size_t | dim_m, |
| const cplx *restrict | vm_bc, | ||
| size_t | dim_z, | ||
| const cplx *restrict | mvn_env, | ||
| cplx *restrict | vm_bd ) |
Initialize boundary data.
It assumes a stationary state a priori to the start of the simulation.
Since this function is used in all system simulations, instead of letting user manually initialize the vm_bd every time, CROCK provides a thin wrap of the process.
| [in] | vm_bc | Boundary conditions |
| [in] | mvn_env | Envelopes |
| [out] | vm_bd | Initialized boundary data |
| CROCK_API void cr_init_bp | ( | size_t | dim_m, |
| size_t | dim_z, | ||
| const cplx *restrict | mvn_env, | ||
| real *restrict | vm_bp ) |
| [out] | vm_bp | Previous boundary phase, has shape (2, dim_m). |
| CROCK_API void cr_make_bc_simple | ( | size_t | dim_m, |
| const real *restrict | vm_freq, | ||
| size_t | dim_z, | ||
| const real *restrict | mvn_mod, | ||
| cplx *restrict | vm_bc ) |
Single frequency boundary condition
| [in] | vm_freq | The frequency at which the boundary is perfectly matched |
| CROCK_API int cr_make_bcc | ( | real | r_center, |
| real | r_span, | ||
| size_t | dim_m, | ||
| const int16_t *restrict | vm_num, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_mag_axis, | ||
| const real *restrict | mvn_mod, | ||
| size_t | dim_bcc, | ||
| real *restrict | nvmh_bcc ) |
Make grid for Beam Coupling Coefficient (BCC)
The coupling coeffient is independent of frequency. This frequency is used to determine the harmonic number.
This is not an equi-flux grid, but equidistant grid, in order to make dim_bcc=1 at r_center rather than flux_center
| r_center | The center radius (in meter) of BCC grid, at the entrance of the cavity. Typically one can choose the radius of the norminal beam guiding center. |
| r_span | The relative span, should be larger than the beam radius span, otherwise the range of BCC grid will be cropped. |
| CROCK_API real cr_make_chi_TE_corr_holl_imp | ( | real | d, |
| real | w, | ||
| int16_t | num_azi, | ||
| int16_t | num_rad, | ||
| real *restrict | opt_array_chi ) |
List eigenvalues from TE(m,1) to TE(m,n) of hollow modes with corrugated outer wall.
| d | Ratio corrugation_depth / r_out |
| w | Ratio of (corrugation width) / (width of a period) |
| num_azi | Azimuthal number (i.e. the m) |
| num_rad | The maximum order of solution (i.e. the n) |
| opt_array_chi | The vector output, dimension = num_rad, whose zeroth element is the TE(m,1) mode. Ignored if NULL. |
| CROCK_API real cr_make_chi_TE_corr_ins | ( | real | r, |
| real | d, | ||
| real | w, | ||
| int16_t | num_azi, | ||
| int16_t | num_rad, | ||
| real *restrict | opt_array_chi ) |
List eigenvalues of coaxial modes with corrugated insert from TE(m,1) to TE(m,n).
| r | Ratio r_in / r_out |
| d | Ratio corrugation_depth / r_out |
| w | Ratio of (corrugation width) / (width of a period) |
| num_azi | Azimuthal number (i.e. the m) |
| num_rad | The maximum order of solution (i.e. the n) |
| opt_array_chi | The vector output, dimension = num_rad, whose zeroth element is the TE(m,1) mode. Ignored if NULL. |
| CROCK_API int cr_make_cold_envelope | ( | size_t | dim_m, |
| const cplx *restrict | vm_rfc, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | mvn_mod, | ||
| cplx *restrict | mvn_env ) |
Reconstruct profile for cold cavity
This function integrates the cold cavity wave equation once to obtain the field profile. It does not search resonance. Parameters see cr_search_cold_resonance().
| [in] | vm_rfc | The complex resonance frequency for cold cavity |
| [out] | mvn_env | The normalized complex envelope profile |
| CROCK_API int cr_make_cold_spectrum | ( | int | max_iter, |
| size_t | dim_z, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | vn_mod, | ||
| const real *restrict | tdm_c, | ||
| const real *restrict | tdm_zk, | ||
| size_t | dim_freq, | ||
| real *restrict | freq, | ||
| real *restrict | ampl ) |
Generate a spectrum of the cold resonance
| [in] | max_iter | 0 if no refinement is required, otherwise a positive number to get more accurate spectrum. |
| [out] | freq | is a 1D array with dimension [dim_freq] |
| [out] | ampl | is a 1D array with dimension [dim_freq]. |
| CROCK_API void cr_make_df | ( | real | elapsed_time, |
| size_t | dim_m, | ||
| size_t | dim_z, | ||
| const cplx *restrict | mvn_new_env, | ||
| real *restrict | mvn_old_env_phase, | ||
| real *restrict | vm_df ) |
Calculate delta frequency
| [in,out] | mvn_old_env_phase | carg(mvn_new_env) will be stored into mvn_old_env_phase. |
| [out] | vm_df | The frequency drift: new_freq = old_freq + df |
| CROCK_API int cr_make_fem | ( | size_t | dim_m, |
| size_t | dim_z, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | mvn_mod, | ||
| real *restrict | tdm_c, | ||
| real *restrict | mv_tdm_zk ) |
Create matrices for FEM
| [out] | tdm_c | The matrix Mc |
| [out] | mv_tdm_zk | The TDM (Mz-Mk) per mode |
| CROCK_API int cr_make_mode_coax | ( | size_t | dim_m, |
| const int16_t *restrict | vm_num, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_geo_rout, | ||
| const real *restrict | vn_geo_rin, | ||
| real *restrict | mvn_mod ) |
Eigenvalue solver for coaxial waveguide (without corrugation)
| [in] | vn_geo_rout | Waveguide outer radius |
| [in] | vn_geo_rin | Waveguide inner radius |
| CROCK_API int cr_make_mode_corr_holl_imp | ( | size_t | dim_m, |
| const int16_t *restrict | vm_num, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_geo_rout, | ||
| const real *restrict | vn_geo_rel_w, | ||
| const real *restrict | vn_geo_depth, | ||
| real *restrict | mvn_mod ) |
| [in] | vn_geo_rout | Waveguide outer radius in meter |
| [in] | vn_geo_rel_w | Carved width divided by width period |
| [in] | vn_geo_depth | Corrugation depth in meter |
| CROCK_API int cr_make_mode_corr_ins | ( | size_t | dim_m, |
| const int16_t *restrict | vm_num, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_geo_rout, | ||
| const real *restrict | vn_geo_rin, | ||
| const real *restrict | vn_geo_rel_w, | ||
| const real *restrict | vn_geo_depth, | ||
| real *restrict | mvn_mod ) |
| [in] | vn_geo_rout | Waveguide outer radius in meter |
| [in] | vn_geo_rin | Waveguide outer radius in meter |
| [in] | vn_geo_rel_w | Carved width divided by width period |
| [in] | vn_geo_depth | Corrugation depth in meter |
| CROCK_API int cr_make_mode_holl | ( | size_t | dim_m, |
| const int16_t *restrict | vm_num, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_geo_rout, | ||
| real *restrict | mvn_mod ) |
| [in] | vn_geo_rout | Waveguide outer radius |
| CROCK_API void cr_make_potential | ( | real | pot_outer, |
| real | opt_pot_inner, | ||
| const real *restrict | beam_init, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_mag_axis, | ||
| const real *restrict | vn_rhocd, | ||
| const real *restrict | vn_r_outer, | ||
| const real *restrict | opt_vn_r_inner, | ||
| real *restrict | vn_pot ) |
Make depression voltage from charge density and geometry
| pot_outer | Potential of outer boundary | |
| opt_pot_inner | Potential of coaxial insert (unused for hollow cavity) | |
| [in] | beam_init | From which the initial guiding center is extracted |
| [in] | vn_mag_axis | $B$ field on the axis |
| [in] | vn_rhocd | Charge density (which has negative values) |
| [in] | vn_r_outer | Radius of outer boundary |
| [in] | opt_vn_r_inner | Radius of coaxial insert (NULL for hollow cavity) |
| [out] | vn_pot | Electric potential |
| CROCK_API void cr_make_power_out | ( | size_t | dim_m, |
| const real *restrict | vm_cf, | ||
| size_t | dim_z, | ||
| const real *restrict | mvn_mod, | ||
| const cplx *restrict | mvn_env, | ||
| real *restrict | opt_vm_pout_left, | ||
| real *restrict | opt_vm_pout_right ) |
Calculate output power of each mode on each boundary, assuming zero reflection at frequency vm_cf.
| [out] | opt_vm_pout_left | If not NULL, the vector in shape [dim_m] will store the output power |
| [out] | opt_vm_pout_right | If not NULL, the vector in shape [dim_m] will store the output power |
| CROCK_API void cr_make_uload | ( | size_t | dim_m, |
| size_t | dim_z, | ||
| const cplx *restrict | mvn_env, | ||
| const real *restrict | mvn_uuload, | ||
| real *restrict | vn_uload ) |
Apply the field of each mode and sum the unscaled ohmic load. The final load is vn_uload / sigma at each node.
| [out] | vn_uload | The unscaled load |
| CROCK_API void cr_make_uuload | ( | size_t | dim_m, |
| const int16_t *restrict | vm_num, | ||
| const real *restrict | vm_freq, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_radius, | ||
| const real *restrict | mvn_mod, | ||
| real *restrict | mvn_uuload ) |
Make unscaled ohmic load per mode
| vm_freq | The frequency where the ohmic load is evaluated at | |
| vn_radius | The radius where the ohmic load is evaluated at, for example, the profile of outer wall or coaxial insert | |
| [out] | mvn_uuload | The very unscaled load |
| CROCK_API ROCK_MALLOC void * cr_malloc | ( | size_t | size | ) |
| CROCK_API int cr_numa_bless | ( | void *restrict | buf, |
| size_t | sizeof_type, | ||
| size_t | dim_shape, | ||
| const size_t *restrict | shape ) |
Set the data of buf to zero.
It performs the NUMA first-touch onto shape[0] static parallel nodes, but does not assert the alignment of page boundaries on shape[0].
| CROCK_API int cr_refine_z | ( | real | weight, |
| size_t | dim_z, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | vn_mrs, | ||
| size_t | dim_z_new, | ||
| real *restrict | vn_z_new ) |
Remap vn_z into vn_z_ne considering the mesh refinement score.
| weight | weight=0 means not using vn_mrs while keeping the original density; weight=1 is a moderate value which does not make the coarse segments too much coarser; weight=infinite means only weighted by vn_mrs. |
| CROCK_API int cr_shoot_beamlet | ( | uint32_t | options, |
| const real *restrict | beam_init, | ||
| size_t | dim_m, | ||
| const int16_t *restrict | vm_num, | ||
| const real *restrict | vm_cf, | ||
| const real *restrict | vm_cp, | ||
| size_t | dim_z, | ||
| const real *restrict | vn_z, | ||
| const real *restrict | vn_pot, | ||
| const real *restrict | vn_mag_axis, | ||
| const real *restrict | mvn_mod, | ||
| const cplx *restrict | mvn_env, | ||
| size_t | dim_b, | ||
| size_t | dim_bcc, | ||
| real | bcc_r_center, | ||
| real | bcc_r_span, | ||
| const real *restrict | nvmh_bcc, | ||
| uint32_t * | seed, | ||
| real *restrict | vn_rhocd, | ||
| cplx *restrict | mvn_src, | ||
| real *restrict | opt_vn_mrs, | ||
| real *restrict | opt_vn_blt_avg, | ||
| real *restrict | opt_bvn_blt_trj, | ||
| struct cr_cache *restrict *restrict | opt_pp_cache ) |
Simple beamlet model
Stochastic inputs are generated in GPU to save transfer of huge beam arrays
Assume:
| options | Bit pattern consists of ROCK_MASK_BLT_* | |
| beam_init | Beam initial data See enum BEAM_INIT. | |
| bcc_r_center | The same parameter used in cr_make_bcc() | |
| bcc_r_span | The same parameter used in cr_make_bcc() | |
| [in,out] | seed | Random seed |
| [in] | vn_pot | Relative electrical potential at guiding center. Since only its numerical derivative is needed, an arbitrary offset can be applied. |
| [out] | vn_rhocd | Charge density (of this MPI node) which will be used to calculate vn_pot for the next iteration. |
| [out] | mvn_src | Excitations (of this MPI node), which should be weighted by FEM matrix Mc |
| [out] | opt_vn_mrs | Mesh refinement score. The i'th index designates the mesh segment between i'th and (i+1)'th node, i.e., a new node should be added in the middle of this segment for refinement. |
| [out] | opt_vn_blt_avg | Optional averaged data, NULL if not required, see enum ROW_OF_BLT_AVG. |
| CROCK_API int cr_step_field | ( | real | dt, |
| size_t | dim_m, | ||
| const real *restrict | vm_cf, | ||
| const cplx *restrict | vm_bc, | ||
| size_t | dim_z, | ||
| const real *restrict | tdm_c, | ||
| const real *restrict | mv_tdm_zk, | ||
| const cplx *restrict | mvn_src, | ||
| cplx *restrict | vm_bd, | ||
| cplx *restrict | mvn_env, | ||
| real *restrict | opt_vm_cp, | ||
| real *restrict | opt_vm_df, | ||
| struct cr_cache *restrict *restrict | opt_pp_cache ) |
Step the field envelope profile
| [in] | vm_cf | Carrier frequency in Hz |
| [in] | vm_bc | Boundary condition |
| [in] | mvn_src | Non-weighted excitation per mode (unit: V/m^2) |
| [in,out] | vm_bd | Boundary data |
| [in,out] | mvn_env | Envelope profile |
| [in,out] | opt_vm_cp | Carrier phase, can be NULL |
| [out] | opt_vm_df | Frequency shift for vm_cf[:] += opt_vm_df[:]. Set to NULL to save computational efforts.. |
| CROCK_API int cr_step_field_gpu | ( | real | dt, |
| size_t | dim_m, | ||
| const real *restrict | vm_cf, | ||
| const cplx *restrict | vm_bc, | ||
| size_t | dim_z, | ||
| const real *restrict | tdm_c, | ||
| const real *restrict | mv_tdm_zk, | ||
| const cplx *restrict | mvn_src, | ||
| cplx *restrict | vm_bd, | ||
| cplx *restrict | mvn_env, | ||
| real *restrict | opt_vm_cp, | ||
| real *restrict | opt_vm_df, | ||
| struct cr_cache *restrict *restrict | opt_pp_cache ) |
Doc see the CPU version.
| CROCK_API int cr_step_field_offload | ( | real | dt, |
| size_t | dim_m, | ||
| const real *restrict | vm_cf, | ||
| const cplx *restrict | vm_bc, | ||
| size_t | dim_z, | ||
| const real *restrict | tdm_c, | ||
| const real *restrict | mv_tdm_zk, | ||
| const cplx *restrict | mvn_src, | ||
| cplx *restrict | vm_bd, | ||
| cplx *restrict | mvn_env, | ||
| real *restrict | opt_vm_cp, | ||
| real *restrict | opt_vm_df, | ||
| struct cr_cache *restrict *restrict | opt_pp_cache ) |
Doc see the CPU version.
| CROCK_API ROCK_PURE ROCK_NODISCARD size_t cr_stride_cplx | ( | size_t | dim | ) |
Calculate stride including padding.
| dim | Data dimension without padding |
| CROCK_API ROCK_PURE ROCK_NODISCARD size_t cr_stride_real | ( | size_t | dim | ) |
Calculate stride including padding.
| dim | Data dimension without padding |
| CROCK_API int cr_tdm_solve | ( | size_t | systems, |
| size_t | rows, | ||
| const cplx *restrict | multi_mat, | ||
| const cplx *restrict | multi_vec, | ||
| cplx *restrict | multi_x ) |
Solve x from mat*x == vec
| CROCK_API int cr_tdm_solve_offload | ( | size_t | systems, |
| size_t | rows, | ||
| const cplx *restrict | multi_mat, | ||
| const cplx *restrict | multi_vec, | ||
| cplx *restrict | multi_x ) |
Solve x from mat*x == vec
| CROCK_API void cr_update_bc_simple | ( | real | dt, |
| size_t | dim_m, | ||
| const real *restrict | vm_cf, | ||
| size_t | dim_z, | ||
| const real *restrict | mvn_mod, | ||
| const cplx *restrict | mvn_env, | ||
| real *restrict | vm_bp, | ||
| cplx *restrict | vm_bc ) |
| [in,out] | vm_bp | Previous boundary phase, has shape (2, dim_m). initialized by cr_init_bp() |
| [out] | vm_bc | Updated boundary condition |
| CROCK_API ROCK_CONST ROCK_NODISCARD int cr_version_major | ( | void | ) |
| CROCK_API ROCK_CONST ROCK_NODISCARD int cr_version_minor | ( | void | ) |
| CROCK_API ROCK_CONST ROCK_NODISCARD int cr_version_patch | ( | void | ) |