Sim Utils

Simulation utility helpers from the sim_utils library.

Classes (Fortran Structures)

BicubicCmplxCoefStruct

Fortran struct: bicubic_cmplx_coef_struct (sim_utils/math/cubic_interpolation_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
coef 2D array of complex (shape: 0:3,0:3) Coefs
i_box 1D array of int (shape: 2) index at lower box corner.

NametableStruct

Fortran struct: nametable_struct (sim_utils/interfaces/sim_utils_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
name 1D array of str Array of names.
index 1D array of int Sorted index for names(:) array. names(an_index(i)) is in alphabetical order.
n_min int Set to 0 for use in a lattice.
n_max int Use only names(n_min:n_max) part of array.

QpAxisStruct

Fortran struct: qp_axis_struct (sim_utils/plot/quick_plot_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
label str
min float Axis min/max in data units.
max float Axis min/max in data units.
tick_min float Min tick location along axis in data units.
tick_max float Max tick location along axis in data units.
eval_min float For general use. Not set by quick_plot.
eval_max float For general use. Not set by quick_plot.
dtick float Distance between ticks. In data units. Ticks will be drawn between %min and %max.
number_offset float Offset from axis line in inches.
label_offset float Offset from numbers in inches.
major_tick_len float In inches.
minor_tick_len float In inches.
label_color str Color of the label.
major_div int Actual numbrer of major divisions
major_div_nominal int Nominal value.
minor_div int 0 = auto choose.
minor_div_max int Max number for auto choose.
places int Number of places after the decimal point to print.
type str Or 'LOG', or 'CUSTOM'
bounds str Or 'ZERO_AT_END' or 'ZERO_SYMMETRIC'
tick_side int +1 = Draw on the side inside the graph, 0 = both (longer tick), -1 = outside.
number_side int +1 = Draw to the side inside the graph, -1 = outside.
draw_label bool
draw_numbers bool

QpLegendStruct

Fortran struct: qp_legend_struct (sim_utils/plot/quick_plot_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
row_spacing float Spacing between rows.
line_length float Length of the line in points.
text_offset float Horizontal offset in points between the line and the text.
draw_line bool Draw lines?
draw_symbol bool Draw symbols?
draw_text bool Draw text?

QpLineStruct

Fortran struct: qp_line_struct (sim_utils/plot/quick_plot_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
width int
color str
pattern str

QpPointStruct

Fortran struct: qp_point_struct (sim_utils/plot/quick_plot_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x float
y float
units str

QpRectStruct

Fortran struct: qp_rect_struct (sim_utils/plot/quick_plot_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x1 float
x2 float
y1 float
y2 float
units str

QpSymbolStruct

Fortran struct: qp_symbol_struct (sim_utils/plot/quick_plot_struct.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
type str
height float in points (same as text height)
color str
fill_pattern str
line_width int

RandomStateStruct

Fortran struct: random_state_struct (sim_utils/math/random_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
ix int
iy int
number_stored bool
h_saved float
engine int Params
seed int
am float
gauss_converter int
gauss_sigma_cut float Only used if positive.
in_sobseq int
ix_sobseq 1D array of int (shape: sobseq_maxdim)
x_sobseq 1D array of float (shape: sobseq_maxdim)

SplineStruct

Fortran struct: spline_struct (sim_utils/math/spline_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
x0 float Point at start of spline
y0 float Point at start of spline
x1 float Point at end of spline
coef 1D array of float (shape: 0:3) coefficients for cubic spline

TricubicCmplxCoefStruct

Fortran struct: tricubic_cmplx_coef_struct (sim_utils/math/cubic_interpolation_mod.f90)

All attributes may be passed to the initializer as arguments:

Attribute Type Description
coef 3D array of complex (shape: 0:3,0:3,0:3) Coefs
i_box 1D array of int (shape: 3) index at lower box corner.

Procedures

allocate_thread_states

Fortran source: sim_utils/math/random_mod.f90

allocate_thread_states() -> None

Subroutine allocate_thread_states()

Routine to allocate random number state structures when openMP is used.

anomalous_moment_of

Fortran source: sim_utils/interfaces/particle_species_mod.f90

anomalous_moment_of(species: typing.SupportsInt | typing.SupportsIndex) -> float

Function anomalous_moment_of (species) result (moment)

Routine to return the anomolous moment for subatomic species type. Otherwise returns 0.

Parameters:
  • species (int) –

    Species ID.

Returns:
  • moment( float ) –

    Anomalous moment.

antiparticle

Fortran source: sim_utils/interfaces/particle_species_mod.f90

antiparticle(species: typing.SupportsInt | typing.SupportsIndex) -> int

Function antiparticle (species) result (anti_species)

Routine to return the antiparticle ID given the particle ID. For a molecule the anti-species is just the molecude with the charge reversed.

Parameters:
  • species (int) –

    Particle ID.

Returns:
  • anti_species( int ) –

    Antiparticle ID.

apfft

Fortran source: sim_utils/math/all_phase_fft.f90

apfft(rdata_in: pybmad._pybmad.RealArray1D, bounds: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], window: str, phase: typing.SupportsFloat | typing.SupportsIndex, diag: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

subroutine apfft(rdata_in, bounds, window, phase, diag)

Implements the All Phase FFT method for obtaining accurate phase from signal data.

The signal data is truncated to an odd length, and the phase is relative to the central point.

apfft_corr

Fortran source: sim_utils/math/all_phase_fft.f90

apfft_corr(rdata_in: pybmad._pybmad.RealArray1D, window: str, bounds: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"] | None = None, diag: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.ApfftCorr

subroutine apfft_corr(rdata_in, bounds, window, phase, amp, freq, diag)

For real signal rdata_in, computes phase, frequency, and amplitude of peak found within bounds. Algorithm is corrected all-phase FFT and should.

This routine finds only one peak: the largest amplitude within the bound. Signals with multiple components can be investigated by varying bounds appropriately.

Parameters:
  • rdata_in (1D array of float) –

    signal data.

  • window (str) –

    'rec' or 'han' for rectangular or Hann window.

  • bounds (1D array of float (shape: 2)) –

    range within which to search for peak.

  • diag (int) –

    causes low-level routine apfft_ext to produce a fort.X file where X=9000+fid containing diag information.

Returns:
  • phase( float ) –

    phase of peak found in signal.

  • amp( float ) –

    amplitude of peak

  • freq( float ) –

    frequency of peak

apfft_ext

Fortran source: sim_utils/math/all_phase_fft.f90

apfft_ext(rdata: pybmad._pybmad.RealArray1D, bounds: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], window: str, phase: typing.SupportsFloat | typing.SupportsIndex, amp: typing.SupportsFloat | typing.SupportsIndex, freq: typing.SupportsFloat | typing.SupportsIndex, diag: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

subroutine apfft_ext(rdata,bounds, window, phase, amp, freq, diag)

Implements the All Phase FFT method for obtaining accurate phase from signal data.

This "extended" apfft subroutine returns the amplitudes and frequency as well, for use by the corrected apfft subroutine in this module.

asinc

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

asinc(x: typing.SupportsFloat | typing.SupportsIndex, nd: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine asinc

Parameters:
  • x (float) –
  • nd (int) –

    Derivative order. nd = 0 (default) -> compute arcsin(x) / x NOTE: Currently only nd = 0 and nd = 1 are implemented.

Returns:
  • y( float ) –

    nd^th derivative. of arcsin(x)/x

assert_equal

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

assert_equal(int_arr: pybmad._pybmad.IntArray1D, err_str: str, ival: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine assert_equal

Parameters:
  • int_arr (1D array of int) –
  • err_str (str) –
  • ival (int) –

atomic_number

Fortran source: sim_utils/interfaces/particle_species_mod.f90

atomic_number(species: typing.SupportsInt | typing.SupportsIndex) -> int

Function atomic_number(species) result (atomic_num)

Routine to return the atomic number Z if species argument corresponds to an atomic particle or is a proton. Set to the charge for atomic particles. Set to zero for molecules.

Parameters:
  • species (int) –

    Spicies ID.

Returns:
  • atomic_num( int ) –

    Atomic index. Set to zero if a molecule

atomic_species_id

Fortran source: sim_utils/interfaces/particle_species_mod.f90

atomic_species_id(charge: typing.SupportsInt | typing.SupportsIndex, is_anti: bool, atomic_num: typing.SupportsInt | typing.SupportsIndex, n_nuc: typing.SupportsInt | typing.SupportsIndex) -> int

Function atomic_species_id(charge, is_anti, atomic_num, n_nuc) result (species_id)

Routine to return the species ID for an atom

Parameters:
  • charge (int) –

    Charge of the atom.

  • is_anti (bool) –

    Is an anti-atom.

  • atomic_num (int) –

    Atomic number.

  • n_nuc (int) –

    Number of nucleons.

Returns:
  • species_id( int ) –

    Species ID number.

axis_angle_to_quat

Fortran source: sim_utils/math/rotation_3d_mod.f90

axis_angle_to_quat(axis: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], angle: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[float], "FixedSize(4)"]

Function axis_angle_to_quat (axis, angle) result (quat)

Routine to convert from axis + angle representation to a quaternion.

Parameters:
  • axis (1D array of float (shape: 3)) –

    Axis of rotation.

  • angle (float) –

    angle of rotation.

Returns:
  • quat( 1D array of float (shape: 0:3) ) –

    Rotation quaternion.

axis_angle_to_w_mat

Fortran source: sim_utils/math/rotation_3d_mod.f90

axis_angle_to_w_mat(axis: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], angle: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(3)"]], "FixedSize(3)"]

Subroutine axis_angle_to_w_mat (axis, angle, w_mat)

Routine to construct the 3D rotation matrix w_mat given an axis of rotation and a rotation angle.

Parameters:
  • axis (1D array of float (shape: 3)) –

    Rotation axis. Does not have to be normalized.

  • angle (float) –

    Rotation angle in the range [-pi, pi].

Returns:
  • w_mat( 2D array of float (shape: 3,3) ) –

    Rotation matrix

bicubic_cmplx_eval

Fortran source: sim_utils/math/cubic_interpolation_mod.f90

bicubic_cmplx_eval(x_norm: typing.SupportsFloat | typing.SupportsIndex, y_norm: typing.SupportsFloat | typing.SupportsIndex, bi_coef: pybmad._pybmad.BicubicCmplxCoefStruct) -> pybmad._pybmad.BicubicCmplxEval

Function bicubic_cmplx_eval (x_norm, y_norm, bi_coef, df_dx, df_dy) result (f_val)

Routine to evaluate a bicubic interpolating complex function.

Use the routine bicubic_interpolation_cmplx_coefs to generate bi_coef.

Note: In the equations below, the four points of the grid box being interpolated range from (x0, y0) to (x0+dx, y0+dy).

Parameters:
  • x_norm (float) –

    x_norm = (x - x0) / dx

  • y_norm (float) –

    y_norm = (y - y0) / dy

  • bi_coef (BicubicCmplxCoefStruct) –

    Coefficients.

Returns:
  • f_val( complex ) –

    Value of f.

  • df_dx( (complex, optional) ) –

    Normalized first derivative: True df/dx = df_dx * dx

  • df_dy( (complex, optional) ) –

    Normalized first derivative: True df/dy = df_dy * dy

bin_index

Fortran source: sim_utils/math/bin_mod.f90

bin_index(x: typing.SupportsFloat | typing.SupportsIndex, bin1_x_min: typing.SupportsFloat | typing.SupportsIndex, bin_delta: typing.SupportsFloat | typing.SupportsIndex) -> int

Function bin_index(x, bin1_x_min, bin_delta) result (ix_bin)

Helper function to locate the appropriate histogram bin index.

Parameters:
  • x (float) –

    Input value to bin.

  • bin1_x_min (float) –

    Minimum value of bin with index 1.

  • bin_delta (float) –

    Bin width.

Returns:
  • ix_bin( int ) –

    Index of bin x is in.

bin_x_center

Fortran source: sim_utils/math/bin_mod.f90

bin_x_center(ix_bin: typing.SupportsInt | typing.SupportsIndex, bin1_x_min: typing.SupportsFloat | typing.SupportsIndex, bin_delta: typing.SupportsFloat | typing.SupportsIndex, x_center: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.BinXCenter

Function bin_x_center (ix_bin, bin1_x_min, bin_delta) result(x_center)

Helper function to locate the center of a histogram bin.

Parameters:
  • ix_bin (int) –

    Index of bin under question.

  • bin1_x_min (float) –

    Minimum value of bin with index 1.

  • bin_delta (float) –

    Bin width.

Returns:
  • ix_bin( int ) –

    Index of bin under question.

bit_set

Fortran source: sim_utils/math/bit_set_mod.f90

bit_set(word: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex, set_to_1: bool) -> pybmad._pybmad.BitSet

Subroutine bit_set (word, pos, set_to_1)

Routine to set a bit in a word.

Parameters:
  • word (int) –

    Input word This parameter is an input/output and is modified in-place. As an output, word: Word with bit set.

  • pos (int) –

    position to set.

  • set_to_1 (bool) –

    If True then bit is set to 1. If False bit is set to 0.

Returns:
  • word( int ) –

    Input word This parameter is an input/output and is modified in-place. As an output, word: Word with bit set.

bracket_index_for_spline

Fortran source: sim_utils/math/spline_mod.f90

bracket_index_for_spline(x_knot: pybmad._pybmad.RealArray1D, x: typing.SupportsFloat | typing.SupportsIndex, strict: bool | None = None, print_err: bool | None = None) -> pybmad._pybmad.BracketIndexForSpline

Function bracket_index_for_spline (x_knot, x, ix0, strict, print_err) result (ok)

Routine to find which interval to use for evaluating a spline. If strict = False (default), x is in range if x_knot(1) - (x_knot(2) - x_knot(1)) < x < x_knot(n) + (x_knot(n) - x_knot(n-1)) If stric = True, x is in range if x_knot(1) <= x <= x_knot(n) where n = size(x_knot)

Parameters:
  • x_knot (1D array of float) –

    Array of x values.

  • x (float) –

    Evaluation point.

  • strict (bool) –

    Default is False. Determines acceptible range.

  • print_err (bool) –

    Default is True. Print error message if out of range?

Returns:
  • ix0( int ) –

    If ok = True, x is in the interval [x_knot(ix0), x_knot(ix0+1)]

  • ok( bool ) –

    True if x is in range. False otherwise.

calc_file_number

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

calc_file_number(file_name: str, num_in: typing.SupportsInt | typing.SupportsIndex, num_out: typing.SupportsInt | typing.SupportsIndex, err_flag: bool) -> None

Wrapper for Fortran routine calc_file_number

Parameters:
  • file_name (str) –
  • num_in (int) –
  • num_out (int) –
  • err_flag (bool) –

celbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

celbd(mc: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Celbd

Wrapper for Fortran routine celbd

Parameters:
  • mc (float) –
Returns:
  • elb( float ) –
  • eld( float ) –

cesr_getarg

Fortran source: sim_utils/io/command_line_mod.f90

cesr_getarg(i_arg: typing.SupportsInt | typing.SupportsIndex) -> str

Subroutine cesr_getarg (i_arg, arg)

Platform independent function to return the i'th command line argument. Use this with cesr_iargc.

Note: The difference between this routine and the Fortran instrinsic get_command_argument is that for i_arg = 0, this routine returns the command line with the name of the executable removed from the beginning of the line. get_command_argument, on the other hand returns the name of the executable when the argument is 0.

Parameters:
  • i_arg (int) –

    Index of argument to return. i_arg = 0 => Entire line minus the executable string. i_arg = 1 => First argument.

Returns:
  • arg( str ) –

    i'th command line argument. If i_arg > number_of_args then arg is a blank string.

cesr_iargc

Fortran source: sim_utils/io/command_line_mod.f90

cesr_iargc(func_retval__: typing.SupportsInt | typing.SupportsIndex) -> None

Function cesr_iargc ()

Note: Use the Fortran intrinsic command_argument_count instead

Platform independent function to return the number of command line arguments. Use this with cesr_getarg.

change_file_number

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

change_file_number(file_name: str, change: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine change_file_number

Parameters:
  • file_name (str) –
  • change (int) –

charge_of

Fortran source: sim_utils/interfaces/particle_species_mod.f90

charge_of(species: typing.SupportsInt | typing.SupportsIndex, default_: typing.SupportsInt | typing.SupportsIndex | None = None) -> int

Function charge_of (species, default) result (charge)

Routine to return the charge, in units of e+, of a particle.

Parameters:
  • species (int) –

    Species ID.

Returns:
  • charge( int ) –

    particle charge.

charge_to_mass_of

Fortran source: sim_utils/interfaces/particle_species_mod.f90

charge_to_mass_of(species: typing.SupportsInt | typing.SupportsIndex) -> float

Function charge_to_mass_of (species) result (charge_mass_ratio)

Routine to return the charge (in units of e+) to mass (in units of eV) ratio of a particle.

Parameters:
  • species (int) –

    Species ID.

Returns:
  • charge_mass_ratio( float ) –

    particle charge to mass ratio. (1/eV)

coarse_frequency_estimate

Fortran source: sim_utils/math/fourier_mod.f90

coarse_frequency_estimate(data: pybmad._pybmad.RealArray1D, error: bool | None = None) -> float

Function coarse_frequency_estimate(data, error) result(frequency)

Simple function to take periodic data and estimate the most dominant frequency by FFT.

Parameters:
  • data (1D array of float) –

    data to analyze. Preferably size(data) is a power of 2 Otherwise the data is padded with zeros.

Returns:
  • frequency( float ) –

    Frequency corresponding to the largest FFT amplitude

complex_error_function

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

complex_error_function(wr: typing.SupportsFloat | typing.SupportsIndex, wi: typing.SupportsFloat | typing.SupportsIndex, zr: typing.SupportsFloat | typing.SupportsIndex, zi: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine complex_error_function

Parameters:
  • wr (float) –
  • wi (float) –
  • zr (float) –
  • zi (float) –

cos_one

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

cos_one(angle: typing.SupportsFloat | typing.SupportsIndex) -> float

Wrapper for Fortran routine cos_one

Parameters:
  • angle (float) –

    Angle.

Returns:
  • cos1( float ) –

    Result.

cosc

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

cosc(x: typing.SupportsFloat | typing.SupportsIndex, nd: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine cosc

Parameters:
  • x (float) –
  • nd (int) –

    Derivative order. nd = 0 (default) -> compute (1 - cos(x)) / x^2 NOTE: Currently only nd = 0 and nd = 1 are implemented.

Returns:
  • y( float ) –

    nd^th derivative of (1 - cos(x)) / x^2

create_a_spline

Fortran source: sim_utils/math/spline_mod.f90

create_a_spline(r0: pybmad._pybmad.RealArray1D, r1: pybmad._pybmad.RealArray1D, slope0: typing.SupportsFloat | typing.SupportsIndex, slope1: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.SplineStruct

Function create_a_spline (r0, r1, slope0, slope1) result (spline)

Routine to create a single spline given end point positions and slopes. The spline will pass through the data points and have the given slopes at these points.

Modules used: use spline_mod

Parameters:
  • r0 (1D array of float) –

    Start (x, y) point.

  • r1 (1D array of float) –

    End (x, y) point.

  • slope0 (float) –

    Starting slope.

  • slope1 (float) –

    End slope.

Returns:

cross_product

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

cross_product(a: pybmad._pybmad.RealArray1D, b: pybmad._pybmad.RealArray1D) -> typing.Annotated[list[float], "FixedSize(3)"]

Wrapper for Fortran routine cross_product

Parameters:
  • a (1D array of float) –

    Input vectors.

  • b (1D array of float) –

    Input vectors.

Returns:
  • c( 1D array of float (shape: 3) ) –

    Cross product: a X b.

date_and_time_stamp

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

date_and_time_stamp(string: str, numeric_month: bool | None = None, include_zone: bool | None = None) -> None

Wrapper for Fortran routine date_and_time_stamp

Parameters:
  • string (str) –
  • numeric_month (bool) –
  • include_zone (bool) –

destfixedwindowls

Fortran source: sim_utils/math/windowLS.f90

destfixedwindowls(id: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine destfixedwindowls

Parameters:
  • id (int) –

detab

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

detab(str: str) -> None

Wrapper for Fortran routine detab

Parameters:
  • str (str) –

display_size_and_resolution

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

display_size_and_resolution(ix_screen: typing.SupportsInt | typing.SupportsIndex, x_size: typing.SupportsFloat | typing.SupportsIndex, y_size: typing.SupportsFloat | typing.SupportsIndex, x_res: typing.SupportsFloat | typing.SupportsIndex, y_res: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine display_size_and_resolution

Parameters:
  • ix_screen (int) –
  • x_size (float) –
  • y_size (float) –
  • x_res (float) –
  • y_res (float) –

dj_bessel

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

dj_bessel(m: typing.SupportsInt | typing.SupportsIndex, arg: typing.SupportsFloat | typing.SupportsIndex) -> float

Wrapper for Fortran routine dj_bessel

Parameters:
  • m (int) –
  • arg (float) –

    Bessel argument.

Returns:
  • dj_bes( float ) –

    Bessel value.

djb_hash

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

djb_hash(str: str, hash: typing.SupportsInt | typing.SupportsIndex, old_hash: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine djb_hash

Parameters:
  • str (str) –
  • hash (int) –
  • old_hash (int) –

djb_str_hash

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

djb_str_hash(in_str: str, hash_str: str) -> None

Wrapper for Fortran routine djb_str_hash

Parameters:
  • in_str (str) –
  • hash_str (str) –

downcase_string

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

downcase_string(string: str) -> None

Wrapper for Fortran routine downcase_string

Parameters:
  • string (str) –

elbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

elbd(phi: typing.SupportsFloat | typing.SupportsIndex, phic: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Elbd

Wrapper for Fortran routine elbd

Parameters:
  • phi (float) –
  • phic (float) –
  • mc (float) –
Returns:
  • b( float ) –
  • d( float ) –

elcbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

elcbd(c0: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Elcbd

Wrapper for Fortran routine elcbd

Parameters:
  • c0 (float) –
  • mc (float) –
Returns:
  • b( float ) –
  • dx( float ) –

ellipinc

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

ellipinc(phi: typing.SupportsFloat | typing.SupportsIndex, m: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Ellipinc

subroutine ellipinc(phi, m, ellipkinc, ellipeinc)

Calculates the first and second incomplete elliptic integrals, using methods from T. Fukushima, (2011, 2018)

Uses classical transformations to handle negative m. This package needs a function for the third kind to use the new 2018 transformations.

elsbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

elsbd(s0: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Elsbd

Wrapper for Fortran routine elsbd

Parameters:
  • s0 (float) –
  • mc (float) –
Returns:
  • b( float ) –
  • d( float ) –

end_akima_spline_calc

Fortran source: sim_utils/math/spline_mod.f90

end_akima_spline_calc(spline: pybmad._pybmad.SplineStructArray1D, which_end: typing.SupportsInt | typing.SupportsIndex) -> None

Subroutine end_akima_spline_calc (spline, which_end)

Routine to calculate the slopes at the ends of a spline array

Parameters:
  • spline (1D array of SplineStruct) –

    Array of splines. This parameter is an input/output and is modified in-place. As an output, spline: Array with slopes at end calculated.

  • which_end (int) –

    0 => calculate slopes for the start end of the array. 1 => calculate slopes for the end end of the array.

err_exit

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

err_exit(err_str: str | None = None) -> None

Wrapper for Fortran routine err_exit

Parameters:
  • err_str (str) –

factorial

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

factorial(n: typing.SupportsInt | typing.SupportsIndex) -> float

Wrapper for Fortran routine factorial

Parameters:
  • n (int) –

    Must be non-negative

Returns:
  • fact( float ) –

    n!. Will return negative number if there is an error.

faddeeva_function

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

faddeeva_function(z: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], w: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], dw: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"]], "FixedSize(2)"]) -> None

Wrapper for Fortran routine faddeeva_function

Parameters:
  • z (1D array of float (shape: 2)) –
  • w (1D array of float (shape: 2)) –
  • dw (2D array of float (shape: 2,2)) –

fft_1d

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

fft_1d(arr: pybmad._pybmad.ComplexArray1D, isign: typing.SupportsInt | typing.SupportsIndex) -> None

no longer exists subroutine fff_sub(line, error) implicit none character(*) line logical error end subroutine

Parameters:
  • arr (1D array of complex) –

    Input array. This parameter is an input/output and is modified in-place. As an output, arr: FFT of array.

  • isign (int) –

    -1 => "Forward" transform, +1 => "Backwards" transform.

file_directorizer

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

file_directorizer(in_file: str, out_file: str, directory: str, add_switch: bool) -> None

Wrapper for Fortran routine file_directorizer

Parameters:
  • in_file (str) –
  • out_file (str) –
  • directory (str) –
  • add_switch (bool) –

file_get

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

file_get(string: str, dflt_file_name: str, file_name: str) -> None

Wrapper for Fortran routine file_get

Parameters:
  • string (str) –
  • dflt_file_name (str) –
  • file_name (str) –

file_get_open

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

file_get_open(string: str, dflt_file_name: str, file_name: str, file_unit: typing.SupportsInt | typing.SupportsIndex, readonly: bool) -> None

Wrapper for Fortran routine file_get_open

Parameters:
  • string (str) –
  • dflt_file_name (str) –
  • file_name (str) –
  • file_unit (int) –
  • readonly (bool) –

file_suffixer

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

file_suffixer(in_file_name: str, out_file_name: str, suffix: str, add_switch: bool) -> None

Wrapper for Fortran routine file_suffixer

Parameters:
  • in_file_name (str) –
  • out_file_name (str) –
  • suffix (str) –
  • add_switch (bool) –

find_location

Fortran sources (overloaded):

find_location(args, *kwargs) Overloaded function.

  1. find_location(arr: pybmad._pybmad.IntArray1D, value: typing.SupportsInt | typing.SupportsIndex, ix_match: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine find_location_int

Parameters:
  • arr (1D array of int) –
  • value (int) –
  • ix_match (int) –
  • Wrapper
Parameters:
  • arr (1D array of bool) –
  • value (bool) –
  • ix_match (int) –
  • Wrapper
Parameters:
  • arr (1D array of float) –

    real(rp), logical, or integer

  • value (float) –

    :).

Returns:
  • ix_match( int ) –

    Index of match. Zero if no match found.

  • 4. find_location(arr: pybmad._pybmad.CharacterAlloc1D, value: str, ix_match: typing.SupportsInt | typing.SupportsIndex) -> None
  • Wrapper for Fortran routine find_location_str
Parameters:
  • arr (1D array of str) –
  • value (str) –
  • ix_match (int) –

fine_frequency_estimate

Fortran source: sim_utils/math/fourier_mod.f90

fine_frequency_estimate(data: pybmad._pybmad.RealArray1D) -> float

Function fine_frequency_estimate(data) result(frequency)

Uses Laskar's method to accurately find the most dominant frequency A coarse estimate is first made by FFT.

Parameters:
  • data (1D array of float) –

    data to analyze

Returns:
  • frequency( float ) –

    Frequency corresponding to the largest FFT amplitude

fixedwindowls

Fortran source: sim_utils/math/windowLS.f90

fixedwindowls(ynew: typing.SupportsFloat | typing.SupportsIndex, id: typing.SupportsInt | typing.SupportsIndex, z: typing.SupportsFloat | typing.SupportsIndex) -> None

Function fixedWindowLS

Main function of the windowLS modult. Each call to this function adds a data point to the fit and returns the derivative evaluated at the end of the window. It is assumed that all data points are separeted by the same interval. This module is initialized with zeros for all data points, and so the results are unreliable until a number of data points equal to N has been entered.

initFixedWindowLS must be called prior to calling this function. destFixedWindowLS should be called when the instance is no longer needed.

fourier_amplitude

Fortran source: sim_utils/math/fourier_mod.f90

fourier_amplitude(data: pybmad._pybmad.RealArray1D, frequency: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.FourierAmplitude

Subroutine fourier_amplitude(data, frequency, cos_amp, sin_amp, dcos_amp, dsin_amp)

Computes cos_amp = (1/N) * sum_n=0^{N-1} data(n-1) cos(twopifrequencyn) and sin_amp = (1/N) * sum_n=0^{N-1} data(n-1) sin(twopifrequencyn) and optionally dcos_amp = d/dfrequency cos_amp dsin_amp = d/dfrequency sin_amp

Parameters:
  • data (1D array of float) –

    data to analyze

  • frequency (float) –

    frequency

Returns:
  • cos_amp( float ) –

    cosine amplitude

  • sin_amp( float ) –

    sine amplitude

  • dcos_amp( (float, optional) ) –

    cosine amplitude derivative

  • dsin_amp( (float, optional) ) –

    sine amplitude derivative

gelbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

gelbd(phi: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Gelbd

Wrapper for Fortran routine gelbd

Parameters:
  • phi (float) –
  • mc (float) –
Returns:
  • elb( float ) –
  • eld( float ) –

gen_complete_elliptic

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

gen_complete_elliptic(kc: typing.SupportsFloat | typing.SupportsIndex, p: typing.SupportsFloat | typing.SupportsIndex, c: typing.SupportsFloat | typing.SupportsIndex, s: typing.SupportsFloat | typing.SupportsIndex, err_tol: typing.SupportsFloat | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine gen_complete_elliptic

Parameters:
  • kc (float) –

    Fuction input values.

  • p (float) –

    Fuction input values.

  • c (float) –

    Fuction input values.

  • s (float) –

    Fuction input values.

  • err_tol (float) –

    Relative error tolerance. Default = 1d-12

Returns:
  • value( float ) –

    Output value.

get_a_char

Fortran source: sim_utils/io/input_mod.f90

get_a_char(wait: bool, ignore_this: pybmad._pybmad.CharacterAlloc1D | None = None) -> str

Subroutine get_a_char (this_char, wait, ignore_this)

Subroutine for getting a single character from the terminal. Also see: get_tty_char

System Libraries that need to be linked to: readline curses

Parameters:
  • wait (bool) –

    If True then routine will wait until a keystroke has occured. If False and no keystroke is in the buffer then achar(0) will be returned as this_char.

  • ignore_this (1D array of str) –

    List of characters to ignore. If a keystroke matches a character on this list the keystroke is ignored.

Returns:
  • this_char( str ) –

    Character returned

get_file_number

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

get_file_number(file_name: str, cnum_in: str, num_out: typing.SupportsInt | typing.SupportsIndex, err_flag: bool) -> None

Wrapper for Fortran routine get_file_number

Parameters:
  • file_name (str) –
  • cnum_in (str) –
  • num_out (int) –
  • err_flag (bool) –

get_file_time_stamp

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

get_file_time_stamp(file: str, time_stamp: str) -> None

no longer exists subroutine get_next_number (filein, cnum, digits) implicit none character() filein character() cnum integer digits end subroutine

get_tty_char

Fortran source: sim_utils/io/input_mod.f90

get_tty_char(wait: bool, flush: bool) -> str

Subroutine get_tty_char (this_char, wait, flush)

Subroutine for getting a single character from the terminal. Also see: get_a_char

System Libraries that need to be linked to: readline curses

Parameters:
  • wait (bool) –

    If True then routine will wait until a keystroke has occured. If False and no keystroke is in the buffer then achar(0) will be returned as this_char.

  • flush (bool) –

    If True then the keystroke buffer will be cleared first before any processing.

Returns:
  • this_char( str ) –

    Character returned

hanhan

Fortran source: sim_utils/math/all_phase_fft.f90

hanhan(N: typing.SupportsInt | typing.SupportsIndex, hh: pybmad._pybmad.RealArray1D) -> None

Wrapper for Fortran routine hanhan

Parameters:
  • N (int) –
  • hh (1D array of float) –

i_bessel

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

i_bessel(m: typing.SupportsInt | typing.SupportsIndex, arg: typing.SupportsFloat | typing.SupportsIndex) -> float

Wrapper for Fortran routine i_bessel

Parameters:
  • m (int) –

    Bessel order.

  • arg (float) –

    Bessel argument.

Returns:
  • i_bes( float ) –

    Bessel value.

i_bessel_extended

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

i_bessel_extended(m: typing.SupportsInt | typing.SupportsIndex, arg: typing.SupportsFloat | typing.SupportsIndex) -> complex

Wrapper for Fortran routine i_bessel_extended

Parameters:
  • m (int) –

    Bessel order.

  • arg (float) –

    Bessel argument.

Returns:
  • i_bes( complex ) –

    Bessel value.

increment_file_number

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

increment_file_number(file_name: str, digits: typing.SupportsInt | typing.SupportsIndex, number: typing.SupportsInt | typing.SupportsIndex, cnumber: str) -> None

Wrapper for Fortran routine increment_file_number

Parameters:
  • file_name (str) –
  • digits (int) –
  • number (int) –
  • cnumber (str) –

index_nocase

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

index_nocase(string1: str, string2: str, indx: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine index_nocase

Parameters:
  • string1 (str) –
  • string2 (str) –
  • indx (int) –

initfixedwindowls

Fortran source: sim_utils/math/windowLS.f90

initfixedwindowls(N: typing.SupportsInt | typing.SupportsIndex, dt: typing.SupportsFloat | typing.SupportsIndex, order: typing.SupportsInt | typing.SupportsIndex, der: typing.SupportsInt | typing.SupportsIndex, id: typing.SupportsInt | typing.SupportsIndex) -> None

Function initFixedWindowLS

Initializes an instance of the fixed window least squares module. See module documentation (getf windowLS_mod) for use details. Any instance of windowLS created with this module should be destroyed with destFixedWindowLS.

Parameters:
  • N (int) –

    Number of data points to fit over. aka window size.

  • dt (float) –

    Time interval between data points. It is assumed that the data is separated by fixed time intervals.

  • order (int) –

    Order of fit polynomial. Must be greater than or equal to der.

  • der (int) –

    Order of derivative to be returned. Set der=0 to obtain the fit.

initial_lmdif

Fortran source: sim_utils/optimizers/lmdif_mod.f90

initial_lmdif() -> None

Wrapper for Fortran routine initial_lmdif

int_str

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

int_str(int_: typing.SupportsInt | typing.SupportsIndex, str: str, width: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine int_str

Parameters:
  • str (str) –
  • width (int) –

interpolated_fft

Fortran source: sim_utils/math/naff.f90

interpolated_fft(cdata: pybmad._pybmad.ComplexArray1D, calc_ok: bool, this_fft: typing.SupportsFloat | typing.SupportsIndex, opt_dump_spectrum: typing.SupportsInt | typing.SupportsIndex | None = None, opt_dump_index: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Function interpolated_fft (cdata, calc_ok, opt_dump_spectrum, opt_dump_index) result (this_fft)

Windows the complex data and used Numerical Recipes four1 to find the peak in the spectrum. The result is interpolated to improve the accuracy. Hanning and Gaussian windowing are available.

interpolated_fft_gsl

Fortran source: sim_utils/math/naff.f90

interpolated_fft_gsl(cdata: pybmad._pybmad.ComplexArray1D, calc_ok: bool, this_fft: typing.SupportsFloat | typing.SupportsIndex, opt_dump_spectrum: typing.SupportsInt | typing.SupportsIndex | None = None, opt_dump_index: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

function interpolated_fft_gsl

Windows the complex data and uses a mixed-radix GSL routine to find the peak in the spectrum. The result is interpolated to improve the accuracy. Hanning and Gaussian windowing are available.

is_alphabetic

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

is_alphabetic(string: str, is_alpha: bool, valid_chars: str | None = None) -> None

no longer exists function inverse_prob (val) result (prob) import implicit none real(rp) prob real(rp) val end function

is_decreasing_sequence

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

is_decreasing_sequence(array: pybmad._pybmad.RealArray1D, strict: bool | None = None) -> bool

Wrapper for Fortran routine is_decreasing_sequence

Parameters:
  • array (1D array of float) –

    Sequence.

  • strict (bool) –

    If True (default) sequence must be strictly decreasing.

Returns:
  • is_decreasing( bool ) –

    Set True if sequence is decreasing.

is_false

Fortran source: sim_utils/interfaces/sim_utils_struct.f90

is_false(param: typing.SupportsFloat | typing.SupportsIndex) -> bool

Function is_false (param) result (this_false)

Routine to translate from a real number to a boolian True or False. Translation: 0 = False, nonzero = True

Also see: is_true and int_logic

The typical use of this routine is for parameters in ele_struct%value(:) which is a real array. Some of the elements in the %value array are used to specify boolian attributes. For example, quadrupoles use ele%value(scale_multipoles$).

Parameters:
  • param (float) –

    Real number to be translated

Returns:
  • this_false( bool ) –

    Set True if param is zero. False otherwise.

is_increasing_sequence

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

is_increasing_sequence(array: pybmad._pybmad.RealArray1D, strict: bool | None = None) -> bool

Wrapper for Fortran routine is_increasing_sequence

Parameters:
  • array (1D array of float) –

    Sequence.

  • strict (bool) –

    If True (default) sequence must be strictly increasing.

Returns:
  • is_increasing( bool ) –

    Set True if sequence is increasing.

is_integer

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

is_integer(string: str, valid: bool, int_: typing.SupportsInt | typing.SupportsIndex | None = None, delims: str | None = None, ix_word: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine is_integer

Parameters:
  • string (str) –
  • valid (bool) –
  • delims (str) –
  • ix_word (int) –

is_logical

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

is_logical(string: str, valid: bool, ignore: bool | None = None) -> None

Wrapper for Fortran routine is_logical

Parameters:
  • string (str) –
  • valid (bool) –
  • ignore (bool) –

is_real

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

is_real(string: str, valid: bool, ignore: bool | None = None, real_num: typing.SupportsFloat | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine is_real

Parameters:
  • string (str) –
  • valid (bool) –
  • ignore (bool) –
  • real_num (float) –

is_subatomic_species

Fortran source: sim_utils/interfaces/particle_species_mod.f90

is_subatomic_species(species: typing.SupportsInt | typing.SupportsIndex) -> bool

Function is_subatomic_species(species) result (is_subatomic)

Routine to return True if species argument corresponds to a subatomic particle.

Parameters:
  • species (int) –

    Spicies ID.

Returns:
  • is_subatomic( bool ) –

    Set True if species corresponds to a subatomic particle.

is_true

Fortran source: sim_utils/interfaces/sim_utils_struct.f90

is_true(param: typing.SupportsFloat | typing.SupportsIndex) -> bool

Function is_true (param) result (this_true)

Routine to translate from a real number to a boolian True or False. Translation: 0 = False, nonzero = True

Also see: is_false and int_logic

The typical use of this routine is for parameters in ele_struct%value(:) which is a real array. Some of the elements in the %value array are used to specify boolian attributes. For example, quadrupoles use ele%value(scale_multipoles$).

Parameters:
  • param (float) –

    Real number to be translated

Returns:
  • this_true( bool ) –

    Set False if param is zero. True otherwise.

j_bessel

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

j_bessel(m: typing.SupportsInt | typing.SupportsIndex, arg: typing.SupportsFloat | typing.SupportsIndex) -> float

Wrapper for Fortran routine j_bessel

Parameters:
  • m (int) –
  • arg (float) –

    Bessel argument.

Returns:
  • j_bes( float ) –

    Bessel value.

linear_fit

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

linear_fit(x: pybmad._pybmad.RealArray1D, y: pybmad._pybmad.RealArray1D, n_data: typing.SupportsInt | typing.SupportsIndex, a: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, sig_a: typing.SupportsFloat | typing.SupportsIndex, sig_b: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine linear_fit

Parameters:
  • x (1D array of float) –
  • y (1D array of float) –
  • n_data (int) –
  • a (float) –
  • b (float) –
  • sig_a (float) –
  • sig_b (float) –

linear_fit_2d

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

linear_fit_2d(x: pybmad._pybmad.RealArray1D, y: pybmad._pybmad.RealArray1D, z: pybmad._pybmad.RealArray1D) -> typing.Annotated[list[float], "FixedSize(3)"]

Wrapper for Fortran routine linear_fit_2d

Parameters:
  • x (1D array of float) –

    Array of x-values.

  • y (1D array of float) –

    Array of y-values.

  • z (1D array of float) –

    Array of z-values

Returns:
  • coef( 1D array of float (shape: 3) ) –

    Coefficients of the linear fit

logic_str

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

logic_str(logic: bool, str: str) -> None

Wrapper for Fortran routine logic_str

Parameters:
  • logic (bool) –
  • str (str) –

lunget

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

lunget(func_retval__: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine lunget

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

make_legal_comment(comment_in: str, comment_out: str) -> None

Wrapper for Fortran routine make_legal_comment

Parameters:
  • comment_in (str) –
  • comment_out (str) –

mass_of

Fortran source: sim_utils/interfaces/particle_species_mod.f90

mass_of(species: typing.SupportsInt | typing.SupportsIndex) -> float

Function mass_of (species) result (mass)

Routine to return the mass, in units of eV/c^2, of a particle. To convert to AMU divide mass_of value by the constant atomic_mass_unit.

Note: For atoms where the isotopic number is given, the mass is calculated using the neutral atomic mass adjusted by the weight of any added or missing electrons. The calculated mass is off very slightly due to binding energy effects. Exception: For #1H+ (proton) and #2H+ (deuteron) the exact mass is used since it is known.

Parameters:
  • species (int) –

    Species ID.

Returns:
  • mass( float ) –

    particle mass. Set to real_garbage$ if species value is invalid.

match_reg

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

match_reg(str: str, pat: str, is_match: bool) -> None

Wrapper for Fortran routine match_reg

Parameters:
  • str (str) –
  • pat (str) –
  • is_match (bool) –

match_wild

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

match_wild(string: str, template_: str, is_match: bool) -> None

Wrapper for Fortran routine match_wild

Parameters:
  • string (str) –
  • is_match (bool) –

match_word

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

match_word(string: str, names: pybmad._pybmad.CharacterAlloc1D, ix: typing.SupportsInt | typing.SupportsIndex, exact_case: bool | None = None, can_abbreviate: bool | None = None, matched_name: str | None = None) -> None

Wrapper for Fortran routine match_word

Parameters:
  • string (str) –
  • names (1D array of str) –
  • ix (int) –
  • exact_case (bool) –
  • can_abbreviate (bool) –
  • matched_name (str) –

maximize_projection

Fortran source: sim_utils/math/naff.f90

maximize_projection(seed: typing.SupportsFloat | typing.SupportsIndex, cdata: pybmad._pybmad.ComplexArray1D, func_retval__: typing.SupportsFloat | typing.SupportsIndex) -> None

function maximize_projection

Optimizer that uses Numerical Recipes brent to find a local maximum, which is the frequency that maximizes the projection.

milli_sleep

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

milli_sleep(milli_sec: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine milli_sleep

Parameters:
  • milli_sec (int) –

modulo2_dp

Fortran source: sim_utils/special_functions/modulo2_mod.f90

modulo2_dp(x: typing.SupportsFloat | typing.SupportsIndex, amp: typing.SupportsFloat | typing.SupportsIndex) -> float

Function modulo2 (x, amp) result (mod2)

Function to return mod2 = x + 2 * n * amp where n is an integer chosen such that -amp <= mod2 < amp

Parameters:
  • x (float) –

    Real(sp), Real(rp), or Integer

  • amp (float) –

    Must be positive.

Returns:
  • mod2( float ) –

    Result

modulo2_int

Fortran source: sim_utils/special_functions/modulo2_mod.f90

modulo2_int(x: typing.SupportsInt | typing.SupportsIndex, amp: typing.SupportsInt | typing.SupportsIndex) -> int

Function modulo2 (x, amp) result (mod2)

Function to return mod2 = x + 2 * n * amp where n is an integer chosen such that -amp <= mod2 < amp

Parameters:
  • x (int) –

    Real(sp), Real(rp), or Integer

  • amp (int) –

    Must be positive.

Returns:
  • mod2( int ) –

    Result

modulo2_qp

Fortran source: sim_utils/special_functions/modulo2_mod.f90

modulo2_qp(x: typing.SupportsFloat | typing.SupportsIndex, amp: typing.SupportsFloat | typing.SupportsIndex) -> float

Function modulo2 (x, amp) result (mod2)

Function to return mod2 = x + 2 * n * amp where n is an integer chosen such that -amp <= mod2 < amp

Parameters:
  • x (float) –

    Real(sp), Real(rp), or Integer

  • amp (float) –

    Must be positive.

Returns:
  • mod2( float ) –

    Result

modulo2_sp

Fortran source: sim_utils/special_functions/modulo2_mod.f90

modulo2_sp(x: typing.SupportsFloat | typing.SupportsIndex, amp: typing.SupportsFloat | typing.SupportsIndex) -> float

Function modulo2 (x, amp) result (mod2)

Function to return mod2 = x + 2 * n * amp where n is an integer chosen such that -amp <= mod2 < amp

Parameters:
  • x (float) –

    Real(sp), Real(rp), or Integer

  • amp (float) –

    Must be positive.

Returns:
  • mod2( float ) –

    Result

n_bins_automatic

Fortran source: sim_utils/math/bin_mod.f90

n_bins_automatic(n_data: typing.SupportsInt | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex) -> None

Function to automatically select the number of bins

n_choose_k

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

n_choose_k(n: typing.SupportsInt | typing.SupportsIndex, k: typing.SupportsInt | typing.SupportsIndex) -> float

Wrapper for Fortran routine n_choose_k

Parameters:
  • n (int) –

    Must be non-negative with n >= k.

  • k (int) –

    Must be non-negative with n >= k.

Returns:
  • nck( float ) –

    N choose K will return negative number if there is an error.

n_spline_create

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

n_spline_create(deriv0: pybmad._pybmad.RealArray1D, deriv1: pybmad._pybmad.RealArray1D, x1: typing.SupportsFloat | typing.SupportsIndex, n_spline: pybmad._pybmad.RealArray1D) -> None

Wrapper for Fortran routine n_spline_create

Parameters:
  • deriv0 (1D array of float) –

    Derivative vector from order 0 to some order n at x = 0.

  • deriv1 (1D array of float) –

    Derivative vector from order 0 to some order n at x = x1.

  • x1 (float) –

    Location where deriv1 derivatives have been evaluated.

  • n_spline (1D array of float) –

    real(rp), Derivative vector from order 0 to order 2*n+1 of the interpolation spline.

naff

Fortran source: sim_utils/math/naff.f90

naff(cdata: pybmad._pybmad.ComplexArray1D, freqs: pybmad._pybmad.RealArray1D, amps: pybmad._pybmad.ComplexArray1D, opt_dump_spectra: typing.SupportsInt | typing.SupportsIndex | None = None, opt_zero_first: bool | None = None) -> None

subroutine naff(cdata,freqs,amps,opt_dump_spectra,opt_zero_first)

This subroutine implements the NAFF algorithm for calculating the spectra of periodic data.

See naff_mod documentation for details.

Frequencies returned are in units of 2pi. That is, freqs ranges from 0 to 1.

freqs and amps must be allocated before hand. This subroutine will repeat the decomposition loop until all elements of freqs and amps are populated.

nametable_add

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

nametable_add(nametable: pybmad._pybmad.NametableStruct, name: str, ix_name: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine nametable_add

Parameters:

nametable_bracket_indexx

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

nametable_bracket_indexx(nametable: pybmad._pybmad.NametableStruct, name: str, ix_max: typing.SupportsInt | typing.SupportsIndex, n_match: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine nametable_bracket_indexx

Parameters:
  • nametable (NametableStruct) –
  • name (str) –
  • ix_max (int) –
  • n_match (int) –

nametable_change1

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

nametable_change1(nametable: pybmad._pybmad.NametableStruct, name: str, ix_name: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine nametable_change1

Parameters:

nametable_init

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

nametable_init(nametable: pybmad._pybmad.NametableStruct, n_min: typing.SupportsInt | typing.SupportsIndex | None = None, n_max: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine nametable_init

Parameters:

nametable_remove

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

nametable_remove(nametable: pybmad._pybmad.NametableStruct, ix_name: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine nametable_remove

Parameters:

negative_ampsquared

Fortran source: sim_utils/math/fourier_mod.f90

negative_ampsquared(frequency: typing.SupportsFloat | typing.SupportsIndex, amp: typing.SupportsFloat | typing.SupportsIndex, status: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine negative_ampsquared

Parameters:
  • frequency (float) –
  • amp (float) –
  • status (int) –

negative_dampsquared

Fortran source: sim_utils/math/fourier_mod.f90

negative_dampsquared(frequency: typing.SupportsFloat | typing.SupportsIndex, damp: typing.SupportsFloat | typing.SupportsIndex, status: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine negative_dampsquared

Parameters:
  • frequency (float) –
  • damp (float) –
  • status (int) –

omega_to_quat

Fortran source: sim_utils/math/rotation_3d_mod.f90

omega_to_quat(omega: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> typing.Annotated[list[float], "FixedSize(4)"]

Function omega_to_quat (omega) result (quat)

Routine to convert from omega + angle representation to a quaternion.

Parameters:
  • omega (1D array of float (shape: 3)) –

    Axis of rotation + magnitude = rotation angle.

Returns:
  • quat( 1D array of float (shape: 0:3) ) –

    Rotation quaternion.

openpmd_species_name

Fortran source: sim_utils/interfaces/particle_species_mod.f90

openpmd_species_name(species: typing.SupportsInt | typing.SupportsIndex) -> str

Function openpmd_species_name (species) result(pmd_name)

Routine to return the openPMD name of a particle species given the Bmad species ID. Note: the pmd_name does not include the particle charge. For example, if species corresponds to He+ then the pmd_name will be "He".

Parameters:
  • species (int) –

    Bmad species ID number.

Returns:
  • pmd_name( str ) –

    Name of the species. Will return 'INVALID!' (= invalid_name) if index is not valid.

ordinal_str

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

ordinal_str(n: typing.SupportsInt | typing.SupportsIndex, str: str) -> None

Wrapper for Fortran routine ordinal_str

Parameters:
  • n (int) –
  • str (str) –

out_io

Fortran sources (overloaded):

out_io(args, *kwargs) Overloaded function.

  1. out_io(level: typing.SupportsInt | typing.SupportsIndex, routine_name: str, line: str, i_num: typing.SupportsInt | typing.SupportsIndex, insert_tag_line: bool | None = None) -> None

Wrapper for Fortran routine out_io_int

Parameters:
  • level (int) –
  • routine_name (str) –
  • line (str) –
  • i_num (int) –
  • insert_tag_line (bool) –
  • Wrapper
Parameters:
  • level (int) –
  • routine_name (str) –
  • line1 (str) –
  • line2 (str) –
  • line3 (str) –
  • line4 (str) –
  • line5 (str) –
  • line6 (str) –
  • line7 (str) –
  • line8 (str) –
  • line9 (str) –
  • line10 (str) –
  • line11 (str) –
  • line12 (str) –
  • r_array (1D array of float) –
  • i_array (1D array of int) –
  • l_array (1D array of bool) –
  • insert_tag_line (bool) –
  • Wrapper
Parameters:
  • level (int) –
  • routine_name (str) –
  • lines (1D array of str) –
  • r_array (1D array of float) –
  • i_array (1D array of int) –
  • l_array (1D array of bool) –
  • insert_tag_line (bool) –
  • Wrapper
Parameters:
  • level (int) –
  • routine_name (str) –
  • line (str) –
  • l_num (bool) –
  • insert_tag_line (bool) –
  • Wrapper
Parameters:
  • level (int) –
  • routine_name (str) –
  • line (str) –
  • r_num (float) –
  • insert_tag_line (bool) –

out_io_buffer_get_line

Fortran source: sim_utils/io/output_mod.f90

out_io_buffer_get_line(ix_line: typing.SupportsInt | typing.SupportsIndex, line: str) -> None

Function out_io_buffer_get_line(ix_line) result (line)

Routine to return the nuber of lines in the internal buffer. See the output_direct documentation for more details.

out_io_buffer_num_lines

Fortran source: sim_utils/io/output_mod.f90

out_io_buffer_num_lines(n_lines: typing.SupportsInt | typing.SupportsIndex) -> None

Function out_io_buffer_num_lines() result (n_lines)

Routine to return the nuber of lines in the internal buffer. See the output_direct documentation for more details.

out_io_buffer_reset

Fortran source: sim_utils/io/output_mod.f90

out_io_buffer_reset() -> None

Subroutine out_io_buffer_reset ()

Routine to initialize the buffer used for capturing output.

out_io_print_and_capture_setup

Fortran source: sim_utils/io/output_mod.f90

out_io_print_and_capture_setup(print_on: bool | None = None, capture_state: str | None = None, capture_add_null: bool | None = None) -> None

Subroutine out_io_print_and_capture_setup (print_on, capture_state, capture_add_null)

Set whether a message from a call to out_io is sent to the terminal for printing and/or captured for program use.

Capture may be desired, for example, to display the output in a separate window or captured output could be passed to a python process for processing.

The procedure for how a message is handled is as follows: First: When out_io is called, the message level is used to determine if anything is to be printed or captured at all. When a program is started, everything will pass this test for printing and/or capturing. This behavior can be modified by calls to the output_direct routine. Second: If a message is to be printed and/or captured (passes the first step), then the internal print_on flag is used to determine if printing to the terminal and the internal capture_state flag is used to determine if capture is to be done. The initial setting of these flags is print_on = True and capture_state = 'OFF'. These internal flags can be set using the print_on and capture_state arguments of this routine.

Notice that whether a message is also written to a file is independent of print and capture logic (see output_direct for more details).

There are two capture modes. buffered (blocked) and unbuffered (unblocked) output. If a message is to be captured as outlined above, one and only one capture mode is used

Unbuffered output is used when running multithreaded so that the program does not have to wait for output. For example, with a GUI. With unbuffered output, out_io calls three routines: out_io_called(level, routine_name) ! Called at the start of a message. out_io_line(line) ! Called for each line of a message. out_io_end() ! Called at end of a message. The versions of these routines in the sim_utils library are just dummies. The idea is that modified versions of these routines can be used to capture the output.

Buffered output uses an internal buffer to store the output. Output that has been buffered is retrieved by using the routines: out_io_buffer_reset out_io_buffer_num_lines and out_io_buffer_get_line

Parameters:
  • print_on (bool) –

    If present, set the internal print_on flag to the value of this argument.

  • capture_state (str) –

    If present, set the internal capture_state to the value of this argument. Possible values:

  • capture_add_null (bool) –

    Is captured output null terminated (for interfacing with C/C++)?

parse_fortran_format

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

parse_fortran_format(format_str: str, n_repeat: typing.SupportsInt | typing.SupportsIndex, power: typing.SupportsInt | typing.SupportsIndex, descrip: str, width: typing.SupportsInt | typing.SupportsIndex, digits: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine parse_fortran_format

Parameters:
  • format_str (str) –
  • n_repeat (int) –
  • power (int) –
  • descrip (str) –
  • width (int) –
  • digits (int) –

pointer_to_locations

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

pointer_to_locations(string: str, array: pybmad._pybmad.IntAlloc1D, num: typing.SupportsInt | typing.SupportsIndex, ix_min: typing.SupportsInt | typing.SupportsIndex, ix_max: typing.SupportsInt | typing.SupportsIndex, names: pybmad._pybmad.CharacterAlloc1D | None = None, exact_case: bool | None = None, print_err: bool | None = None) -> None

Wrapper for Fortran routine pointer_to_locations

Parameters:
  • string (str) –
  • array (1D array of int) –
  • num (int) –
  • ix_min (int) –
  • ix_max (int) –
  • names (1D array of str) –
  • exact_case (bool) –
  • print_err (bool) –

pointer_to_ran_state

Fortran source: sim_utils/math/random_mod.f90

pointer_to_ran_state(ran_state: pybmad._pybmad.RandomStateStruct | None = None, ix_thread: typing.SupportsInt | typing.SupportsIndex | None = None) -> pybmad._pybmad.RandomStateStruct | None

Function pointer_to_ran_state(ran_state, ix_thread) result (ran_state_ptr)

Routine to point to the appropriate state structure for generating random numbers

Parameters:
  • ran_state (RandomStateStruct) –

    Point to this if present. Otherwise point to the global saved state.

  • ix_thread (int) –

    Thread index.

Returns:
  • ran_state_ptr( (RandomStateStruct, optional) ) –

    Pointer to the appropriate state.

poly_eval

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

poly_eval(poly: pybmad._pybmad.RealArray1D, x: typing.SupportsFloat | typing.SupportsIndex, diff_coef: bool | None = None) -> float

Wrapper for Fortran routine poly_eval

Parameters:
  • poly (1D array of float) –

    Polynomial

  • x (float) –

    Point to evaluate at.

  • diff_coef (bool) –

    poly(:) array are differentials? Default is False.

Returns:
  • y( float ) –

    Value of polynomial.

probability_funct

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

probability_funct(x: typing.SupportsFloat | typing.SupportsIndex, prob: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine probability_funct

Parameters:
  • x (float) –

    Function argument.

  • prob (float) –

projdd

Fortran source: sim_utils/math/naff.f90

projdd(a: pybmad._pybmad.ComplexArray1D, b: pybmad._pybmad.ComplexArray1D, func_retval__: typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine projdd

Parameters:
  • a (1D array of complex) –
  • b (1D array of complex) –

quadratic_roots

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

quadratic_roots(coefs: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> typing.Annotated[list[complex], "FixedSize(2)"]

Wrapper for Fortran routine quadratic_roots

Parameters:
  • coefs (1D array of float (shape: 3)) –

    Coefficients of the quadratic equation with 0 = coefs(1) + coefs(2) * x + coefs(3) * x^2

Returns:
  • root( 1D array of complex (shape: 2) ) –

    Complex roots.

quat_conj

Fortran sources (overloaded):

quat_conj(args, *kwargs) Overloaded function.

  1. quat_conj(q_in: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]) -> typing.Annotated[list[complex], "FixedSize(4)"]

Function quat_conj (q_in) result (q_out)

Overloaded name to create the conjugate of a quaternian. Overloaded functions are: Function quat_conj_real (q_in) result (q_out) Function quat_conj_complex (q_in) result (q_out)

Parameters:
  • q_in (1D array of complex (shape: 0:3)) –

    Quaternion input.

Returns:
  • q_out( 1D array of complex (shape: 0:3) ) –

    Conjugate quaternion.

  • 2. quat_conj(q_in: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]) -> typing.Annotated[list[float], "FixedSize(4)"]
  • Function quat_conj (q_in) result (q_out)
  • Overloaded name to create the conjugate of a quaternian.
  • Overloaded functions are:

    Function quat_conj_real (q_in) result (q_out) Function quat_conj_complex (q_in) result (q_out)

Parameters:
  • q_in (1D array of float (shape: 0:3)) –

    Quaternion input.

Returns:
  • q_out( 1D array of float (shape: 0:3) ) –

    Conjugate quaternion.

quat_inverse

Fortran source: sim_utils/math/rotation_3d_mod.f90

quat_inverse(q_in: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]) -> typing.Annotated[list[float], "FixedSize(4)"]

Function quat_inverse (q_in) result (q_out)

Routine to create the inverse of a quaternian.

Parameters:
  • q_in (1D array of float (shape: 0:3)) –

    Quaternion input.

Returns:
  • q_out( 1D array of float (shape: 0:3) ) –

    Inverse quaternion.

quat_mul

Fortran sources (overloaded):

quat_mul(args, *kwargs) Overloaded function.

  1. quat_mul(q1: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], q2: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], q3: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q4: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q5: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q6: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q7: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q8: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q9: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None) -> typing.Annotated[list[complex], "FixedSize(4)"]

Function quat_mul_real (q1, q2, q3, q4, q5, q6, q7, q8, q9) result (q_out)

Overloaded name to multiply quaternions q_out = q1 * q2 * q3 * q4 * ... Note: q_out = q1 * q2 represents a rotation of q2 first followed by q1. Overloaded functions are: Function quat_mul_real (q1, q2, q3, q4, q5, q6, q7, q8, q9) result (q_out) Function quat_mul_real (q1, q2, q3, q4, q5, q6, q7, q8, q9) result (q_out)

Parameters:
  • q1 (1D array of complex (shape: 0:3)) –

    Quaternions.

  • q2 (1D array of complex (shape: 0:3)) –

    Quaternions.

  • q3 (1D array of complex (shape: 0:3)) –

    More quaternions.

  • q9 (1D array of complex (shape: 0:3)) –

    More quaternions.

Returns:
  • q_out( 1D array of complex (shape: 0:3) ) –

    Resultant q1 * q2

  • 2. quat_mul(q1: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], q2: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], q3: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q4: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q5: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q6: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q7: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q8: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None, q9: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"] | None = None) -> typing.Annotated[list[float], "FixedSize(4)"]
  • Function quat_mul_real (q1, q2, q3, q4, q5, q6, q7, q8, q9) result (q_out)
  • Overloaded name to multiply quaternions q_out = q1 * q2 * q3 * q4 * ...
  • Note( q_out = q1 * q2 represents a rotation of q2 first followed by q1. ) –
  • Overloaded functions are:

    Function quat_mul_real (q1, q2, q3, q4, q5, q6, q7, q8, q9) result (q_out) Function quat_mul_real (q1, q2, q3, q4, q5, q6, q7, q8, q9) result (q_out)

Parameters:
  • q1 (1D array of float (shape: 0:3)) –

    Quaternions.

  • q2 (1D array of float (shape: 0:3)) –

    Quaternions.

  • q3 (1D array of float (shape: 0:3)) –

    More quaternions.

  • q9 (1D array of float (shape: 0:3)) –

    More quaternions.

Returns:
  • q_out( 1D array of float (shape: 0:3) ) –

    Resultant q1 * q2

quat_rotate

Fortran sources (overloaded):

quat_rotate(args, *kwargs) Overloaded function.

  1. quat_rotate(quat: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], vec_in: typing.Annotated[collections.abc.Sequence[typing.SupportsComplex | typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> typing.Annotated[list[complex], "FixedSize(3)"]

Function quat_rotate (quat, vec_in) result (vec_out)

Overloaded name to rotate a vector using a quaternion.. Overloaded functions are: Function quat_rotate_real (quat, vec_in) result (vec_out) Function quat_rotate_complex (quat, vec_in) result (vec_out)

Parameters:
  • quat (1D array of complex (shape: 0:3)) –

    Quaternion to rotate with. Does not have to be normalized.

  • vec_in (1D array of complex (shape: 3)) –

    Initial vector.

Returns:
  • vec_out( 1D array of complex (shape: 3) ) –

    Final vector.

  • 2. quat_rotate(quat: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], vec_in: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]) -> typing.Annotated[list[float], "FixedSize(3)"]
  • Function quat_rotate (quat, vec_in) result (vec_out)
  • Overloaded name to rotate a vector using a quaternion..
  • Overloaded functions are:

    Function quat_rotate_real (quat, vec_in) result (vec_out) Function quat_rotate_complex (quat, vec_in) result (vec_out)

Parameters:
  • quat (1D array of float (shape: 0:3)) –

    Quaternion to rotate with. Does not have to be normalized.

  • vec_in (1D array of float (shape: 3)) –

    Initial vector.

Returns:
  • vec_out( 1D array of float (shape: 3) ) –

    Final vector.

quat_to_axis_angle

Fortran source: sim_utils/math/rotation_3d_mod.f90

quat_to_axis_angle(quat: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]) -> pybmad._pybmad.QuatToAxisAngle

Subroutine quat_to_axis_angle (quat, axis, angle)

Routine to convert from quaternion to axis + angle representation. The angle will be in the range 0 <= angle <= pi.

Parameters:
  • quat (1D array of float (shape: 0:3)) –

    Rotation quaternion. Assumed normalized.

Returns:
  • axis( 1D array of float (shape: 3) ) –

    Axis of rotation.

  • angle( float ) –

    angle of rotation in range [0, pi].

quat_to_omega

Fortran source: sim_utils/math/rotation_3d_mod.f90

quat_to_omega(quat: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]) -> typing.Annotated[list[float], "FixedSize(3)"]

Function quat_to_omega (quat) result (omega)

Routine to convert rotation from quaternion representation to omega (axis + angle).

Parameters:
  • quat (1D array of float (shape: 0:3)) –

    Rotation quaternion. Assumed normalized.

Returns:
  • omega( 1D array of float (shape: 3) ) –

    Axis of rotation + magnitude = rotation angle.

quat_to_w_mat

Fortran source: sim_utils/math/rotation_3d_mod.f90

quat_to_w_mat(quat: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"]) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(3)"]], "FixedSize(3)"]

Function quat_to_w_mat (quat) result (w_mat)

Routine to construct the 3D rotation matrix w_mat given a rotation quaternion

Parameters:
  • quat (1D array of float (shape: 0:3)) –

    Quaternion.

Returns:
  • w_mat( 2D array of float (shape: 3,3) ) –

    Rotation matrix

query_string

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

query_string(query_str: str, upcase: bool, return_str: str, ix: typing.SupportsInt | typing.SupportsIndex, ios: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine query_string

Parameters:
  • query_str (str) –
  • upcase (bool) –
  • return_str (str) –
  • ix (int) –
  • ios (int) –

quote

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

quote(str: str, q_str: str) -> None

Wrapper for Fortran routine quote

Parameters:
  • str (str) –
  • q_str (str) –

quoten

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

quoten(str: pybmad._pybmad.CharacterAlloc1D, q_str: str, delim: str | None = None) -> None

Wrapper for Fortran routine quoten

Parameters:
  • str (1D array of str) –
  • q_str (str) –
  • delim (str) –

ran_default_state

Fortran source: sim_utils/math/random_mod.f90

ran_default_state(set_state: pybmad._pybmad.RandomStateStruct | None = None) -> pybmad._pybmad.RandomStateStruct

Subroutine ran_default_state (set_state, get_state)

Routine to set or get the state of the default random number generator. See the ran_seed_put documentation for more details

Parameters:
Returns:
  • get_state( (RandomStateStruct, optional) ) –

    Returns the state of the default generator.

ran_engine

Fortran source: sim_utils/math/random_mod.f90

ran_engine(set: str | None = None, get: str | None = None, ran_state: pybmad._pybmad.RandomStateStruct | None = None) -> None

Subroutine ran_engine (set, get, ran_state)

Routine to set what random number generator algorithm is used. If this routine is never called then pseudo_random$ is used. With sobseq quasi-random numbers the maximum dimension is 6.

Parameters:
  • set (str) –

    Set the random number engine. Possibilities are: 'pseudo' -> Uses ran from Numerical Recipies (F90). 'quasi' -> Uses sobseq from Numerical Recipes. '' -> Do nothing.

  • get (str) –

    Get the current (before any set) random number engine.

  • ran_state (RandomStateStruct) –

    Internal state. See the ran_seed_put documentation for more details.

ran_gauss_converter

Fortran source: sim_utils/math/random_mod.f90

ran_gauss_converter(set: str | None = None, set_sigma_cut: typing.SupportsFloat | typing.SupportsIndex | None = None, ran_state: pybmad._pybmad.RandomStateStruct | None = None) -> pybmad._pybmad.RanGaussConverter

Subroutine ran_gauss_converter (set, set_sigma_cut, get, get_sigma_cut, ran_state)

Routine to set what conversion routine is used for converting uniformly distributed random numbers to Gaussian distributed random numbers.

If this routine is not called then exact_gaussian$ is used.

exact_gaussian$ is a straight forward converter as explained in Numerical recipes.

quick_gaussian$ is a quick a dirty approximation with a cutoff so that no numbers will be generated beyound what is set for sigma_cut.

A negative sigma_cut means that the exact_gaussian$ will not be limited and the quick_gaussian$ will use a default of 10.0

Note: Because of technical issues, when using the quasi_random$ number generator (see the ran_engine routine), the quick_gaussian$ method will automatically be used independent of what was set with this routine.

Parameters:
  • set (str) –

    Set the random number engine. Possibilities are: 'exact' 'quick' ! Old deprecated: 'limited' 'ziggurat' '' ! Do nothing

  • set_sigma_cut (float) –

    Sigma cutoff. Initially: sigma_cut = -1.

  • ran_state (RandomStateStruct) –

    Internal state. See the ran_seed_put documentation for more details.

Returns:
  • get( (str, optional) ) –

    Get the current (before any set) gaussian converter.

  • get_sigma_cut( (float, optional) ) –

    Get the current (before any set) sigma cutoff.

ran_gauss_scalar

Fortran source: sim_utils/math/random_mod.f90

ran_gauss_scalar(ran_state: pybmad._pybmad.RandomStateStruct | None = None, sigma_cut: typing.SupportsFloat | typing.SupportsIndex | None = None, index_quasi: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Subroutine ran_gauss (harvest, ran_state, sigma_cut)

Routine to return a gaussian distributed random number with unit sigma. This routine uses the same algorithm as gasdev from Numerical Recipes.

Note: ran_gauss is an overloaded name for: ran_gauss_scalar ! harvest is a scalar ran_gauss_vector ! harvest is a 1-D array.

Note: Use ran_seed_put for initialization. Note: Use ran_engine to set which random number generator to use. Note: Use ran_gauss_converter to set which conversion routine to use.

Parameters:
  • ran_state (RandomStateStruct) –

    Internal state. See the ran_seed_put documentation for more details.

  • sigma_cut (float) –

    If present and positive will override setting of ran_state.gauss_sigma_cut.

Returns:
  • harvest( float ) –

    Random number. Or As an output, harvest: Random number array.

ran_gauss_vector

Fortran source: sim_utils/math/random_mod.f90

ran_gauss_vector(harvest: pybmad._pybmad.RealArray1D, ran_state: pybmad._pybmad.RandomStateStruct | None = None, sigma_cut: typing.SupportsFloat | typing.SupportsIndex | None = None) -> None

Subroutine ran_gauss (harvest, ran_state, sigma_cut)

Routine to return a gaussian distributed random number with unit sigma. This routine uses the same algorithm as gasdev from Numerical Recipes.

Note: ran_gauss is an overloaded name for: ran_gauss_scalar ! harvest is a scalar ran_gauss_vector ! harvest is a 1-D array.

Note: Use ran_seed_put for initialization. Note: Use ran_engine to set which random number generator to use. Note: Use ran_gauss_converter to set which conversion routine to use.

Parameters:
  • harvest (1D array of float) –

    Random number. Or As an output, harvest: Random number array.

  • ran_state (RandomStateStruct) –

    Internal state. See the ran_seed_put documentation for more details.

  • sigma_cut (float) –

    If present and positive will override setting of ran_state.gauss_sigma_cut.

ran_seed_get

Fortran source: sim_utils/math/random_mod.f90

ran_seed_get() -> int

Subroutine ran_seed_get (seed)

Routine to return the seed used for the random number generator.

Parameters:
  • Returns
  • seed (int) –

    Random number seed used.

ran_seed_put

Fortran source: sim_utils/math/random_mod.f90

ran_seed_put(seed: typing.SupportsInt | typing.SupportsIndex, mpi_offset: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Subroutine ran_seed_put (seed, mpi_offset)

Routine to seed a random number generator.

If a program never calls ran_seed_put, or ran_seed_put is called with seed = 0, the system clock will be used to generate the seed.

Note: The seed is only used with the pseudo_random$ engine. Note: Use the subroutine ran_seed_get(seed) to get the seed used. Note: Use pointer_to_ran_state() to access the ran state directly.

Parameters:
  • seed (int) –

    Seed number. If seed = 0 then a seed will be choosen based upon the system clock.

  • mpi_offset (int) –

    Offset added to seed. Default is zero. Used with MPI processes ensure different threads use different random numbers.

ran_uniform

Fortran sources (overloaded):

ran_uniform(args, *kwargs) Overloaded function.

  1. ran_uniform(ran_state: pybmad._pybmad.RandomStateStruct | None = None, index_quasi: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Subroutine ran_uniform (harvest, ran_state)

Routine to return a random number uniformly distributed in the interval [0, 1]. This routine uses the same algorithm as ran or sobseq from Numberical Recipes in Fortran90. See ran_engine.

Note: ran_uniform is an overloaded name for: ran_uniform_scalar ! harvest is a scalar ran_uniform_vector ! harvest is a 1-D array.

Note: Use ran_seed_put for initialization. Note: Use ran_engine to set which random number generator to use.

Parameters:
  • ran_state (RandomStateStruct) –

    Internal state. See the ran_seed_put documentation for more details.

Returns:
  • harvest( float ) –

    Random number. Or As an output, harvest: Random number array.

  • 2. ran_uniform(harvest: pybmad._pybmad.RealArray1D, ran_state: pybmad._pybmad.RandomStateStruct | None = None) -> None
  • Subroutine ran_uniform (harvest, ran_state)
  • Routine to return a random number uniformly distributed in the
  • interval [0, 1]. This routine uses the same algorithm as ran or sobseq
  • from Numberical Recipes in Fortran90.
  • See ran_engine.
  • Note( ran_uniform is an overloaded name for: ) –

    ran_uniform_scalar ! harvest is a scalar ran_uniform_vector ! harvest is a 1-D array.

  • Note( Use ran_seed_put for initialization. ) –
  • Note( Use ran_engine to set which random number generator to use. ) –
Parameters:
  • harvest (1D array of float) –

    Random number. Or As an output, harvest: Random number array.

  • ran_state (RandomStateStruct) –

    Internal state. See the ran_seed_put documentation for more details.

rcelbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

rcelbd(mc: typing.SupportsFloat | typing.SupportsIndex, elb: typing.SupportsFloat | typing.SupportsIndex, eld: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine rcelbd

Parameters:
  • mc (float) –
  • elb (float) –
  • eld (float) –

read_a_line

Fortran source: sim_utils/io/input_mod.f90

read_a_line(prompt: str, trim_prompt: bool | None = None, prompt_color: str | None = None, prompt_bold: bool | None = None, history_file: str | None = None) -> str

Subroutine read_a_line (prompt, line_out, trim_prompt, prompt_color, prompt_bold, history_file)

Subroutine to read a line of input from the terminal. The line is also add to the history buffer so that the up-arrow and down-arrow keys can be used to recall past commands.

Also see: readline_read_history readline_write_history

System Libraries that need to be linked to: readline curses

Parameters:
  • prompt (str) –

    Prompt string to use.

  • trim_prompt (bool) –

    If present and True then trim the prompt string and add a single blank before printing the prompt string. Default is True.

  • prompt_color (str) –

    Color of the prompt. Possibilities are: 'BLACK', 'RED', 'GREEN', 'YELLOW', 'BLUE', 'MAGENTA', 'CYAN', 'GRAY', 'DEFAULT'. The 'DEFAULT' setting (the default) does not set the prompt color.

  • prompt_bold (bool) –

    If present and True then the prompt will be printed in bold.

  • history_file (str) –

    If present, add line_out to a file whose name is given by history_file. History files are useful for saving the command history in between when a program is run multiple times.

Returns:
  • line_out( str ) –

    Line typed by the user. Note: If cntl-D is pressed, line_out = achar(24).

readline_read_history

Fortran source: sim_utils/io/input_mod.f90

readline_read_history(history_file: str) -> int

Subroutine readline_read_history (history_file, status)

Routine to add the contents of a file to the readline history list. Use this routine with the read_a_line routine.

Parameters:
  • history_file (str) –

    Name of the history file. EG: '~/.my_history'

Returns:
  • status( int ) –

    0 = Success, otherwise failure.

readline_write_history

Fortran source: sim_utils/io/input_mod.f90

readline_write_history(history_file: str) -> int

Subroutine readline_write_history (history_file, status)

Routine to write the contents of the readline history list to a file. Use this routine with the read_a_line routine.

Parameters:
  • history_file (str) –

    Name of the history file. EG: '~/.my_history'

Returns:
  • status( int ) –

    0 = Success, otherwise failure.

real_num_fortran_format

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

real_num_fortran_format(number: typing.SupportsFloat | typing.SupportsIndex, width: typing.SupportsInt | typing.SupportsIndex, fmt_str: str, n_blanks: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine real_num_fortran_format

Parameters:
  • number (float) –
  • width (int) –
  • fmt_str (str) –
  • n_blanks (int) –

real_path

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

real_path(path_in: str, path_out: str, is_ok: bool) -> None

Wrapper for Fortran routine real_path

Parameters:
  • path_in (str) –
  • path_out (str) –
  • is_ok (bool) –

real_str

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

real_str(r_num: typing.SupportsFloat | typing.SupportsIndex, str: str, n_signif: typing.SupportsInt | typing.SupportsIndex | None = None, n_decimal: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine real_str

Parameters:
  • r_num (float) –
  • str (str) –
  • n_signif (int) –
  • n_decimal (int) –

real_to_string

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

real_to_string(real_num: typing.SupportsFloat | typing.SupportsIndex, width: typing.SupportsInt | typing.SupportsIndex, str: str, n_signif: typing.SupportsInt | typing.SupportsIndex | None = None, n_decimal: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine real_to_string

Parameters:
  • real_num (float) –
  • width (int) –
  • str (str) –
  • n_signif (int) –
  • n_decimal (int) –

reallocate_spline

Fortran source: sim_utils/math/spline_mod.f90

reallocate_spline(spline: pybmad._pybmad.SplineStructAlloc1D, n: typing.SupportsInt | typing.SupportsIndex, n_min: typing.SupportsInt | typing.SupportsIndex | None = None, exact: bool | None = None) -> None

Subroutine reallocate_spline (spline, n, n_min, exact)

Subroutine to allocate an allocatable spline_struct array. The data of the array is preserved but data at the end of the array will be lost if n is less than the original size of the array

Parameters:
  • spline (1D array of SplineStruct) –

    Spline to reallocate. This parameter is an input/output and is modified in-place. As an output, spline: Allocated spline.

  • n (int) –

    Upper bound needed for 1-dimensional arrays.

  • n_min (int) –

    Lower bound of spline array. Default is 1.

  • exact (bool) –

    If present and False then the size of the output array is permitted to be larger than n. Default is True.

relbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

relbd(phi: typing.SupportsFloat | typing.SupportsIndex, phic: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, d: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine relbd

Parameters:
  • phi (float) –
  • phic (float) –
  • mc (float) –
  • b (float) –
  • d (float) –

relcbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

relcbd(c0: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, dx: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine relcbd

Parameters:
  • c0 (float) –
  • mc (float) –
  • b (float) –
  • dx (float) –

relsbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

relsbd(s0: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, d: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine relsbd

Parameters:
  • s0 (float) –
  • mc (float) –
  • b (float) –
  • d (float) –

rgelbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

rgelbd(phi: typing.SupportsFloat | typing.SupportsIndex, mc: typing.SupportsFloat | typing.SupportsIndex, elb: typing.SupportsFloat | typing.SupportsIndex, eld: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine rgelbd

Parameters:
  • phi (float) –
  • mc (float) –
  • elb (float) –
  • eld (float) –

rms_value

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

rms_value(val_arr: pybmad._pybmad.RealArray1D, good_val: pybmad._pybmad.BoolAlloc1D | None = None) -> pybmad._pybmad.RmsValue

Wrapper for Fortran routine rms_value

Parameters:
  • val_arr (1D array of float) –

    Array of reals.

  • good_val (1D array of bool) –

    If present, only calculate RMS where good_val(i) = True.

Returns:
  • rms_val( float ) –

    RMS value. Set to real_garbage$ if there is a problem.

  • ave_val( (float, optional) ) –

    average value.

rot_2d

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

rot_2d(vec_in: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(2)"], angle: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[float], "FixedSize(2)"]

Wrapper for Fortran routine rot_2d

Parameters:
  • vec_in (1D array of float (shape: 2)) –

    Init vec

  • angle (float) –

    angle in radians.

Returns:
  • vec_out( 1D array of float (shape: 2) ) –

    Rotated vec.

rotate_vec

Fortran source: sim_utils/math/rotation_3d_mod.f90

rotate_vec(vec: pybmad._pybmad.RealArray1D, axis: typing.SupportsInt | typing.SupportsIndex, angle: typing.SupportsFloat | typing.SupportsIndex) -> None

Subroutine rotate_vec (vec, axis, angle)

Basic routine to rotate vector components around the x, y, or z axis.

Parameters:
  • vec (1D array of float) –

    vector This parameter is an input/output and is modified in-place. As an output, vec: Rotated vector.

  • axis (int) –

    x_axis\(, y_axis\), or z_axis$

  • angle (float) –

    angle to rotate.

rotate_vec_given_axis_angle

Fortran source: sim_utils/math/rotation_3d_mod.f90

rotate_vec_given_axis_angle(vec_in: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"], axis: pybmad._pybmad.RealArray1D, angle: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[float], "FixedSize(3)"]

Function rotate_vec_given_axis_angle (vec_in, axis, angle) result (vec_out)

Routine to rotate a vector.

Parameters:
  • vec_in (1D array of float (shape: 3)) –

    Initial vector.

  • axis (1D array of float) –

    Axis of rotation. Must be normalized to 1.

  • angle (float) –

    Angle to rotate by

Returns:
  • vec_out( 1D array of float (shape: 3) ) –

    Final vector.

rp8

Fortran source: sim_utils/interfaces/precision_def.f90

rp8(int_in: typing.SupportsInt | typing.SupportsIndex) -> float

Function rp8(int_in) result (re_out)

Routine to convert from integer to real of type rp. This routine is used to avoid the implicit integer to single precision that happens when multiplying int*real(rp).

Parameters:
  • int_in (int) –

    Input integer.

Returns:
  • re_out( float ) –

    Equiv real.

rserbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

rserbd(y: typing.SupportsFloat | typing.SupportsIndex, m: typing.SupportsFloat | typing.SupportsIndex, b: typing.SupportsFloat | typing.SupportsIndex, d: typing.SupportsFloat | typing.SupportsIndex) -> None

Wrapper for Fortran routine rserbd

Parameters:
  • y (float) –
  • m (float) –
  • b (float) –
  • d (float) –

run_timer

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

run_timer(command: str, time: typing.SupportsFloat | typing.SupportsIndex | None = None, time0: typing.SupportsFloat | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine run_timer

Parameters:
  • command (str) –
  • time (float) –
  • time0 (float) –

serbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

serbd(y: typing.SupportsFloat | typing.SupportsIndex, m: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.Serbd

Wrapper for Fortran routine serbd

Parameters:
  • y (float) –
  • m (float) –
Returns:
  • b( float ) –
  • d( float ) –

set_env

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

set_env(env_name: str, env_value: str, err_flag: bool) -> None

Wrapper for Fortran routine set_env

Parameters:
  • env_name (str) –
  • env_value (str) –
  • err_flag (bool) –

set_parameter

Fortran sources (overloaded):

set_parameter(args, *kwargs) Overloaded function.

  1. set_parameter(param_val: typing.SupportsInt | typing.SupportsIndex, set_val: typing.SupportsInt | typing.SupportsIndex, save_val: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine set_parameter_int

Parameters:
  • param_val (int) –
  • set_val (int) –
  • save_val (int) –
  • Wrapper
Parameters:
  • param_val (bool) –
  • set_val (bool) –
  • save_val (bool) –
  • Wrapper
Parameters:
  • param_val (float) –
  • set_val (float) –
  • save_val (float) –

set_species_charge

Fortran source: sim_utils/interfaces/particle_species_mod.f90

set_species_charge(species_in: typing.SupportsInt | typing.SupportsIndex, charge: typing.SupportsInt | typing.SupportsIndex) -> int

Function set_species_charge(species_in, charge) result(species_charged)

Routine to return the ID for a particle of the same type as species_in but with a different charge. Exception: If species_in corresponds to a subatomic particle, the charge argument is ignored and species_charged will be set equal to species_in.

Parameters:
  • species_in (int) –

    Input species.

  • charge (int) –

    Charge to set species_charged to.

Returns:
  • species_charged( int ) –

    Species of the same type as species_in but with different charge.

sign_of

Fortran sources (overloaded):

sign_of(args, *kwargs) Overloaded function.

  1. sign_of(num: typing.SupportsInt | typing.SupportsIndex, zero_is_zero: bool | None = None) -> int

Function sign_of (num, zero_is_zero) result (num_sign)

Routine to return the sign of a number. Note: Fortran instrinsic sign function is similar to sign_of with zero_is_zero = False.

Parameters:
  • num (int) –

    Input number

  • zero_is_zero (bool) –

    If True (default), num = 0 gives num_sign = 0. If False, num = 0 gives num_sign = 1.

Returns:
  • num_sign( int ) –

    +1 if num is positive, -1 if num is negative, and 0 or +1 if num is zero depending upon setting of zero_is_zero.

  • 2. sign_of(num: typing.SupportsFloat | typing.SupportsIndex, zero_is_zero: bool | None = None) -> int
  • Function sign_of (num, zero_is_zero) result (num_sign)
  • Routine to return the sign of a number.
  • Note( Fortran instrinsic sign function is similar to sign_of with zero_is_zero = False. ) –
Parameters:
  • num (float) –

    Input number

  • zero_is_zero (bool) –

    If True (default), num = 0 gives num_sign = 0. If False, num = 0 gives num_sign = 1.

Returns:
  • num_sign( int ) –

    +1 if num is positive, -1 if num is negative, and 0 or +1 if num is zero depending upon setting of zero_is_zero.

sinc

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

sinc(x: typing.SupportsFloat | typing.SupportsIndex, nd: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine sinc

Parameters:
  • x (float) –

    Number.

  • nd (int) –

    Derivative order. nd = 0 (default) -> compute sin(x) / x NOTE: Currently only nd = 0 and nd = 1 are implemented.

Returns:
  • y( float ) –

    nd^th derivative of sin(x) / x

sincc

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

sincc(x: typing.SupportsFloat | typing.SupportsIndex, nd: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine sincc

Parameters:
  • x (float) –

    Number.

  • nd (int) –

    Derivative order. nd = 0 (default) -> compute (x - sin(x)) / x^3 NOTE: Currently only nd = 0 and nd = 1 are implemented.

Returns:
  • y( float ) –

    nd^th derivative of (x - sin(x)) / x^3

sinhx_x

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

sinhx_x(x: typing.SupportsFloat | typing.SupportsIndex, nd: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Wrapper for Fortran routine sinhx_x

Parameters:
  • x (float) –

    Number.

  • nd (int) –

    Derivative order. nd = 0 (default) -> compute sinh(x) / x NOTE: Currently only nd = 0 and nd = 1 are implemented.

Returns:
  • y( float ) –

    nd^th derivative of sinh(x) / x.

skip_header

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

skip_header(ix_unit: typing.SupportsInt | typing.SupportsIndex, error_flag: bool) -> None

Wrapper for Fortran routine skip_header

Parameters:
  • ix_unit (int) –
  • error_flag (bool) –

special_projection

Fortran source: sim_utils/math/naff.f90

special_projection(f: typing.SupportsFloat | typing.SupportsIndex, func_retval__: typing.SupportsFloat | typing.SupportsIndex, status: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

function special_projection

Calculates

Used only by maximize projection. Uses data global to the function to accomodate stock NR routine.

species_id

Fortran source: sim_utils/interfaces/particle_species_mod.f90

species_id(name: str, default_: typing.SupportsInt | typing.SupportsIndex | None = None, print_err: bool | None = None) -> int

Function species_id (name, default, print_err) result(species)

Routine to return the integer ID index of a particle species given the name.

For subatomic particles, the case does not matter. For all other types of particles, the case does matter.

Parameters:
  • name (str) –

    Name of the species.

  • print_err (bool) –

    Print error message? Default is True. If False, return species = invalid$,

Returns:
  • species( int ) –

    Species ID. Will return invalid$ if name is not valid. Will return not_set$ if name is blank

species_id_from_openpmd

Fortran source: sim_utils/interfaces/particle_species_mod.f90

species_id_from_openpmd(pmd_name: str, charge: typing.SupportsInt | typing.SupportsIndex) -> int

Function species_id_from_openpmd (pmd_name, charge) result(species)

Routine to return the Bmad species ID given the openPMD species name and given particle charge. Note: If pmd_name corresponds to a subatomic particle, the charge argument is ignored.

Parameters:
  • pmd_name (str) –

    OpenPMD species name.

  • charge (int) –

    Species charge. Ignored for subatomic particles.

Returns:
  • species( int ) –

    Bmad spicies ID number.

species_name

Fortran source: sim_utils/interfaces/particle_species_mod.f90

species_name(species: typing.SupportsInt | typing.SupportsIndex) -> str

Function species_name (species) result(name)

Routine to return the name of a particle species given the integer index.

Parameters:
  • species (int) –

    Species ID.

Returns:
  • name( str ) –

    Name of the species. Will return 'INVALID!' (= invalid_name) if index is not valid.

species_of

Fortran source: sim_utils/interfaces/particle_species_mod.f90

species_of(mass: typing.SupportsFloat | typing.SupportsIndex, charge: typing.SupportsInt | typing.SupportsIndex) -> int

Function species_of (mass, charge) result (species)

Routine to return the integer ID index of a particle species given the mass and charge. Note: Currently this routine only works for subatomic particles and is used for decoding PTC flat files.

Parameters:
  • mass (float) –

    Mass of the particle

  • charge (int) –

    Charge of the particle.

Returns:
  • species( int ) –

    Species ID. Will return invalid$ if name is not valid.

spin_of

Fortran source: sim_utils/interfaces/particle_species_mod.f90

spin_of(species: typing.SupportsInt | typing.SupportsIndex, non_subatomic_default: typing.SupportsFloat | typing.SupportsIndex | None = None) -> float

Function spin_of (species, non_subatomic_default) result (spin)

Routine to return the spin, in units of hbar, of a particle. This routine is only valid for subatomic particles. For all other particles, the returned spin value will be the value of non_subatomic_default.

Parameters:
  • species (int) –

    Species ID.

  • non_subatomic_default (float) –

    Default value to be used for non-subatomic species. Default value of this argument is zero.

Returns:
  • spin( float ) –

    Particle spin.

spline1

Fortran source: sim_utils/math/spline_mod.f90

spline1(a_spline: pybmad._pybmad.SplineStruct, x: typing.SupportsFloat | typing.SupportsIndex, n: typing.SupportsInt | typing.SupportsIndex | None = None) -> float

Function spline1 (a_spline, x, n) result (y)

Function for spline evaluation using a single spline (instead of a spline array). Also see: spline_evaluate spline_akima_interpolate

Modules used: use spline_mod

Parameters:
  • a_spline (SplineStruct) –

    Single spline structure.

  • x (float) –

    Point for evaluation.

  • n (int) –

    Output derivative order. May be -1, 0, 1, 2, or 3. Default is 0. n = -1 => output is integral of y from a_spline.x0 to x. n = 1 => output is dy/dx, n = 2 => output is d^2y/dx^2, etc.

Returns:
  • y( float ) –

    Interpolated spline value or derivative.

spline_akima

Fortran source: sim_utils/math/spline_mod.f90

spline_akima(spline: pybmad._pybmad.SplineStructArray1D) -> bool

Subroutine spline_akima (spline, ok)

Given a set of (x,y) points we want to interpolate between the points. This subroutine computes the semi-hermite cubic spline developed by Hiroshi Akima. The spline goes thorugh all the points (that is, it is not a smoothing spline). For interpolation use: spline_evaluate spline_akima_interpolate ! You do not need to call spline_akima if you use this routine.

Reference: H Akima, "A New Method of Interpolation and Smooth Curve Fitting Based on Local Procedures", J. Assoc. Comp. Mach., Vol 17(4), 589-602 (1970).

Modules used: use spline_mod

Parameters:
  • spline (1D array of SplineStruct) –
Returns:
  • ok( bool ) –

    Set .false. if something is wrong (like less than 2 points used).

spline_akima_interpolate

Fortran source: sim_utils/math/spline_mod.f90

spline_akima_interpolate(x_knot: pybmad._pybmad.RealArray1D, y_knot: pybmad._pybmad.RealArray1D, x: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.SplineAkimaInterpolate

Subroutine spline_akima_interpolate (x_knot, y_knot, x, ok, y, dy)

Routine to interpolate using an akima spline.

When evaluating at enough points, this routine is slower than calling spline_akima to first evaluate the spline coefficients and then repeatedly calling spline_evaluate.

The advantage of this routine is that only the (x, y) knot points need to be stored and it will be faster if the number of evaluations is small.

This routine will extrapolate past the range of x_knot(:) up to a distance equal to the length between an end point and the point just inside the end point.

Parameters:
  • x_knot (1D array of float) –

    Array of x values for the knot points. Must have more than 2 points and be in asending order.

  • y_knot (1D array of float) –

    Array of y values for the knot points. Must be same size as x_knot(:).

  • x (float) –

    Point to evaluate at.

Returns:
  • ok( bool ) –

    Set .true. if everything ok, That is, x is within the spline range.

  • y( (float, optional) ) –

    Spline interpolation.

  • dy( (float, optional) ) –

    Spline derivative interpolation.

spline_evaluate

Fortran source: sim_utils/math/spline_mod.f90

spline_evaluate(spline: pybmad._pybmad.SplineStructArray1D, x: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.SplineEvaluate

Subroutine spline_evaluate (spline, x, ok, y, dy)

Subroutine to evalueate a spline at a set of points.

A point outside of the range of knot points is an error. Also see: spline1 spline_akima_interpolate

A spline may be generated using, for example, the spline_akima routine.

Modules used: use spline_mod

Parameters:
  • spline (1D array of SplineStruct) –

    Spline structure.

  • x (float) –

    point for evaluation.

Returns:
  • ok( bool ) –

    Set .true. if everything ok. That is, x is within the spline range.

  • y( (float, optional) ) –

    Spline interpolation.

  • dy( (float, optional) ) –

    Spline derivative interpolation.

sqrt_alpha

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

sqrt_alpha(alpha: typing.SupportsFloat | typing.SupportsIndex, x: typing.SupportsFloat | typing.SupportsIndex) -> float

Wrapper for Fortran routine sqrt_alpha

Parameters:
  • alpha (float) –

    Number

  • x (float) –

    Number

Returns:
  • y( float ) –

    Result.

sqrt_one

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

sqrt_one(x: typing.SupportsFloat | typing.SupportsIndex, ds1: typing.SupportsFloat | typing.SupportsIndex, nd: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

Wrapper for Fortran routine sqrt_one

Parameters:
  • x (float) –

    Number

  • ds1 (float) –
  • nd (int) –

    Derivative order. nd = 0 (default) -> compute Sqrt[1+x] - 1. NOTE: Currently only nd = 0 and nd = 1 are implemented.

str_count

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_count(str: str, match_: str, num: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine str_count

Parameters:
  • str (str) –
  • match (str) –
  • num (int) –

str_downcase

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_downcase(src: str) -> str

Wrapper for Fortran routine str_downcase

Parameters:
  • src (str) –
Returns:
  • dst( str ) –

str_first_in_set

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_first_in_set(line: str, set: str, ix_match: typing.SupportsInt | typing.SupportsIndex, ignore_clauses: bool | None = None) -> None

Wrapper for Fortran routine str_first_in_set

Parameters:
  • line (str) –
  • set (str) –
  • ix_match (int) –
  • ignore_clauses (bool) –

str_first_not_in_set

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_first_not_in_set(line: str, set: str, ix_match: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine str_first_not_in_set

Parameters:
  • line (str) –
  • set (str) –
  • ix_match (int) –

str_last_in_set

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_last_in_set(line: str, set: str, ix_match: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine str_last_in_set

Parameters:
  • line (str) –
  • set (str) –
  • ix_match (int) –

str_last_not_in_set

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_last_not_in_set(line: str, set: str, ix_match: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine str_last_not_in_set

Parameters:
  • line (str) –
  • set (str) –
  • ix_match (int) –

str_match_wild

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_match_wild(str: str, pat: str, a_match: bool) -> None

Wrapper for Fortran routine str_match_wild

Parameters:
  • str (str) –
  • pat (str) –
  • a_match (bool) –

str_substitute

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_substitute(string: str, str_match: str | None = None, str_replace: str | None = None, do_trim: bool | None = None, ignore_escaped: bool | None = None) -> None

Wrapper for Fortran routine str_substitute

Parameters:
  • string (str) –
  • str_match (str) –
  • str_replace (str) –
  • do_trim (bool) –
  • ignore_escaped (bool) –

str_upcase

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

str_upcase(src: str) -> str

Wrapper for Fortran routine str_upcase

Parameters:
  • src (str) –
Returns:
  • dst( str ) –

string_to_int

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

string_to_int(line: str, default_: typing.SupportsInt | typing.SupportsIndex, err_flag: bool, value: typing.SupportsInt | typing.SupportsIndex, err_print_flag: bool | None = None) -> None

Wrapper for Fortran routine string_to_int

Parameters:
  • line (str) –
  • err_flag (bool) –
  • value (int) –
  • err_print_flag (bool) –

string_to_real

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

string_to_real(line: str, default_: typing.SupportsFloat | typing.SupportsIndex, err_flag: bool, value: typing.SupportsFloat | typing.SupportsIndex, err_print_flag: bool | None = None) -> None

Wrapper for Fortran routine string_to_real

Parameters:
  • line (str) –
  • err_flag (bool) –
  • value (float) –
  • err_print_flag (bool) –

string_trim

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

string_trim(in_string: str, out_string: str, word_len: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine string_trim

Parameters:
  • in_string (str) –
  • out_string (str) –
  • word_len (int) –

string_trim2

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

string_trim2(in_str: str, delimitors: str, out_str: str, ix_word: typing.SupportsInt | typing.SupportsIndex, delim: str, ix_next: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine string_trim2

Parameters:
  • in_str (str) –
  • delimitors (str) –
  • out_str (str) –
  • ix_word (int) –
  • delim (str) –
  • ix_next (int) –

suggest_lmdif

Fortran source: sim_utils/optimizers/lmdif_mod.f90

suggest_lmdif(XV: pybmad._pybmad.RealArray1D, FV: pybmad._pybmad.RealArray1D, eps: typing.SupportsFloat | typing.SupportsIndex, itermx: typing.SupportsInt | typing.SupportsIndex, reset_flag: bool | None = None) -> bool

subroutine suggest_lmdif (xv, fv, eps, itermx, at_end, reset_flag)

Reverse communication subroutine. It suggests values for your input variables based on the previous value of your merit function.

Use initial_lmdif to initialize internal variables

Parameters:
  • xv (1D array of float) –

    Array of variables This parameter is an input/output and is modified in-place. As an output, xv: Suggested new values

  • fv (1D array of float) –

    Array of function value/s that should be optimized to zero This parameter is an input/output and is modified in-place. As an output, fv: After the last optimization this returns the best values ever.

  • eps (float) –

    Desired accuracy with which the optimum should be found.

  • itermx (int) –

    Max number of iterations

  • reset_flag (bool) –

    Optional. Used by initial_lmdif to clear previous saved values

Returns:
  • at_end( bool ) –

    Set to False if more optimization is recommended. If set to True then xv(:) will be the minimum found.

super_bicubic_coef

Fortran source: sim_utils/math/super_recipes_mod.f90

super_bicubic_coef(y: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], y1: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], y2: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], y12: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], d1: typing.SupportsFloat | typing.SupportsIndex, d2: typing.SupportsFloat | typing.SupportsIndex) -> typing.Annotated[list[typing.Annotated[list[float], "FixedSize(4)"]], "FixedSize(4)"]

Subroutine super_bicubic_coef(y, y1, y2, y12, d1, d2, c)

Routine to compute coefficients for bicubic interpolation. This is from NR bcucof.

Parameters:
  • y (1D array of float (shape: 4)) –

    Function values at grid points.

  • y1 (1D array of float (shape: 4)) –

    dy/dx1 derivatives.

  • y2 (1D array of float (shape: 4)) –

    dy/dx2 derivatives.

  • y12 (1D array of float (shape: 4)) –

    d2y/dx1*dx2 second derivatives.

  • d1 (float) –

    Grid width in 1-direction.

  • d2 (float) –

    Grid width in 2-direction.

Returns:
  • c( 2D array of float (shape: 4,4) ) –

    Coefficients.

super_bicubic_interpolation

Fortran source: sim_utils/math/super_recipes_mod.f90

super_bicubic_interpolation(y: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], y1: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], y2: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], y12: typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(4)"], x1l: typing.SupportsFloat | typing.SupportsIndex, x1u: typing.SupportsFloat | typing.SupportsIndex, x2l: typing.SupportsFloat | typing.SupportsIndex, x2u: typing.SupportsFloat | typing.SupportsIndex, x1: typing.SupportsFloat | typing.SupportsIndex, x2: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.SuperBicubicInterpolation

Subroutine super_bicubic_interpolation(y, y1, y2, y12, x1l, x1u, x2l, x2u, x1, x2, ansy, ansy1, ansy2)

Routine to do bicubic interpolation. This is from NR bcuint.

Note! The four grid points are arrayed in counter-clockwise order beginning from the lower left. So, for example, y = [y_ll, y_lu, y_uu, y_ul] where "l" = lower, "u" = upper index.

Parameters:
  • y (1D array of float (shape: 4)) –

    Function values at grid points.

  • y1 (1D array of float (shape: 4)) –

    dy/dx1 derivatives.

  • y2 (1D array of float (shape: 4)) –

    dy/dx2 derivatives.

  • y12 (1D array of float (shape: 4)) –

    d2y/dx1*dx2 second derivatives.

  • x1l (float) –

    1-direction coordinate at lower points.

  • x1u (float) –

    1-direction coordinate at upper points

  • x2l (float) –

    2-direction coordinate at lower points.

  • x2u (float) –

    2-direction coordinate at upper points

  • x1 (float) –

    1-direction coordinate at point to evaluate.

  • x2 (float) –

    2-direction coordinate at point to evaluate.

Returns:
  • ansy( float ) –

    Interpolation value.

  • ansy1( float ) –

    1-direction derivative at interpolation point.

  • ansy2( float ) –

    2-direction derivative at interpolation point.

super_polint

Fortran source: sim_utils/math/super_recipes_mod.f90

super_polint(xa: pybmad._pybmad.RealArray1D, ya: pybmad._pybmad.RealArray1D, x: typing.SupportsFloat | typing.SupportsIndex) -> pybmad._pybmad.SuperPolint

Function super_polint (xa, ya, x, y, dy)

This is essentially polint from Numerical Recipes.

Parameters:
  • xa (1D array of float) –
  • ya (1D array of float) –
  • x (float) –
Returns:
  • y( float ) –
  • dy( float ) –

super_poly

Fortran source: sim_utils/math/super_recipes_mod.f90

super_poly(x: typing.SupportsFloat | typing.SupportsIndex, coeffs: pybmad._pybmad.RealArray1D) -> float

Function super_poly (x, coef) result (value)

Routine to compute Sum: coef(i)*x^i

Parameters:
  • x (float) –

    Variable.

Returns:
  • value( float ) –

    Polynomial value.

super_sobseq

Fortran source: sim_utils/math/random_mod.f90

super_sobseq(x: pybmad._pybmad.RealArray1D, ran_state: pybmad._pybmad.RandomStateStruct | None = None) -> None

Subroutine super_sobseq (x, ran_state)

Routine patterened after sobseq in Numerical Recipes. Difference is that this version has an argument for the internal state.

Parameters:
  • x (1D array of float) –

    Random vector.

  • ran_state (RandomStateStruct) –

    Generator state. See the ran_seed_put documentation for more details.

super_sort

Fortran source: sim_utils/math/super_recipes_mod.f90

super_sort(arr: pybmad._pybmad.IntArray1D) -> None

Subroutine super_sort(arr)

Routine to sort an integer array in place. This is the NR routine sort modified to sort integers.

Parameters:
  • arr (1D array of int) –

    Array of integers. This parameter is an input/output and is modified in-place. As an output, arr: Sorted array.

system_command

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

system_command(line: str) -> bool

Wrapper for Fortran routine system_command

Parameters:
  • line (str) –

    Command to pass to the system shell.

Returns:
  • err_flag( (bool, optional) ) –

    Set True if there is an error (bad command, etc.).

test_xgelbd

Fortran source: sim_utils/special_functions/elliptic_integral_mod.f90

test_xgelbd() -> None

Wrapper for Fortran routine test_xgelbd

to_str

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

to_str(num: typing.SupportsFloat | typing.SupportsIndex, string: str, max_signif: typing.SupportsInt | typing.SupportsIndex | None = None) -> None

no longer exists subroutine test_tune_tracker_lock (tracker_locked) implicit none logical tracker_locked(2) end subroutine

tricubic_cmplx_eval

Fortran source: sim_utils/math/cubic_interpolation_mod.f90

tricubic_cmplx_eval(x_norm: typing.SupportsFloat | typing.SupportsIndex, y_norm: typing.SupportsFloat | typing.SupportsIndex, z_norm: typing.SupportsFloat | typing.SupportsIndex, tri_coef: pybmad._pybmad.TricubicCmplxCoefStruct) -> pybmad._pybmad.TricubicCmplxEval

Function tricubic_cmplx_eval (x_norm, y_norm, z_norm, tri_coef, df_dx, df_dy, df_dz) result (f_val)

Routine to evaluate a tricubic interpolating complex function.

Use the routine tricubic_interpolation_cmplx_coefs to generate tri_coef.

Note: In the equations below, the eight points of the grid box being interpolated range from (x0, y0, z0) to (x0+dx, y0+dy, z0+dz).

Parameters:
  • x_norm (float) –

    x_norm = (x - x0) / dx

  • y_norm (float) –

    y_norm = (y - y0) / dy

  • z_norm (float) –

    z_norm = (z - z0) / dz

  • tri_coef (TricubicCmplxCoefStruct) –

    Coefficients.

Returns:
  • f_val( complex ) –

    Value of f.

  • df_dx( (complex, optional) ) –

    Normalized first derivative: True df/dx = df_dx * dx

  • df_dy( (complex, optional) ) –

    Normalized first derivative: True df/dy = df_dy * dy

  • df_dz( (complex, optional) ) –

    Normalized first derivative: True df/dz = df_dz * dz

type_this_file

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

type_this_file(filename: str) -> None

Wrapper for Fortran routine type_this_file

Parameters:
  • filename (str) –

upcase_string

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

upcase_string(string: str) -> None

Wrapper for Fortran routine upcase_string

Parameters:
  • string (str) –

virtual_memory_usage

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

virtual_memory_usage(usage: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine virtual_memory_usage

Parameters:
  • usage (int) –

w_mat_to_axis_angle

Fortran source: sim_utils/math/rotation_3d_mod.f90

w_mat_to_axis_angle(w_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"]) -> pybmad._pybmad.WMatToAxisAngle

Subroutine w_mat_to_axis_angle (w_mat, axis, angle)

Routine to find the rotation axis and rotation angle corresponding to a given 3D rotation matrix.

The rotation angle is chosen in the range [0, pi].

Parameters:
  • w_mat (2D array of float (shape: 3,3)) –

    Rotation matrix.

Returns:
  • axis( 1D array of float (shape: 3) ) –

    Rotation axis. Normalized to 1.

  • angle( float ) –

    Rotation angle in the range [0, pi].

w_mat_to_quat

Fortran source: sim_utils/math/rotation_3d_mod.f90

w_mat_to_quat(w_mat: typing.Annotated[collections.abc.Sequence[typing.Annotated[collections.abc.Sequence[typing.SupportsFloat | typing.SupportsIndex], "FixedSize(3)"]], "FixedSize(3)"]) -> typing.Annotated[list[float], "FixedSize(4)"]

Function w_mat_to_quat (w_mat) result (quat)

Routine to find the quaternion corresponding to a given 3D rotation matrix.

Parameters:
  • w_mat (2D array of float (shape: 3,3)) –

    Rotation matrix

Returns:
  • quat( 1D array of float (shape: 0:3) ) –

    Quaternion.

word_len

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

word_len(wording: str, wlen: typing.SupportsInt | typing.SupportsIndex) -> None

Wrapper for Fortran routine word_len

Parameters:
  • wording (str) –
  • wlen (int) –

word_read

Fortran source: sim_utils/interfaces/sim_utils_interface.f90

word_read(in_str: str, delim_list: str, word: str, ix_word: typing.SupportsInt | typing.SupportsIndex, delim: str, delim_found: bool, out_str: str, ignore_interior: bool | None = None) -> None

Wrapper for Fortran routine word_read

Parameters:
  • in_str (str) –
  • delim_list (str) –
  • word (str) –
  • ix_word (int) –
  • delim (str) –
  • delim_found (bool) –
  • out_str (str) –
  • ignore_interior (bool) –

x0_radiation_length

Fortran source: sim_utils/interfaces/particle_species_mod.f90

x0_radiation_length(species: typing.SupportsInt | typing.SupportsIndex) -> float

Function x0_radiation_length(species) result (x0)

Routine to return the X0 raidation length for atomes.

Parameters:
  • Species (int) –

    Species ID.

Returns:
  • x0( float ) –

    Radiation length in kg/m^2. Set to real_garbage$ if species is not atomic or has atomic index greater than 92.

zig_table_init

Fortran source: sim_utils/math/random_mod.f90

zig_table_init() -> None

Subroutine zig_table_init ()

Private routine to initialize the Ziggurat lookup tables on first use. Based on Marsaglia & Tsang (2000), "The Ziggurat Method for Generating Random Variables", Journal of Statistical Software 5(8).