# sfepy.homogenization.coefs_phononic module

class sfepy.homogenization.coefs_phononic.AcousticMassLiquidTensor(name, problem, kwargs)
  get_coefs(freq)

    Get frequency-dependent coefficients.

class sfepy.homogenization.coefs_phononic.AcousticMassTensor(name, problem, kwargs)

  The acoustic mass tensor for a given frequency.

  Returns:
    self AcousticMassTensor instance

      This class instance whose evaluate() method computes for a given frequency the required tensor.

  Notes

  eigenmomenta, eigs should contain only valid resonances.

  evaluate(freq)
  get_coefs(freq)

    Get frequency-dependent coefficients.

  to_file_txt = None

class sfepy.homogenization.coefs_phononic.AppliedLoadTensor(name, problem, kwargs)

  The applied load tensor for a given frequency.

  Returns:
    self AppliedLoadTensor instance

      This class instance whose evaluate() method computes for a given frequency the required tensor.

  Notes

  eigenmomenta, ueigenmomenta, eigs should contain only valid resonances.

  evaluate(freq)
  to_file_txt = None

class sfepy.homogenization.coefs_phononic.BandGaps(name, problem, kwargs)

  Band gaps detection.

  Parameters:
    eigensolver str

      The name of the eigensolver for mass matrix eigenvalues.

    eig_range(int, int)

      The eigenvalues range (squared frequency) to consider.

    freq_margins(float, float)

      Margins in percents of initial frequency range given by eig_range by which the range is increased.

    fixed_freq_range(float, float)

      The frequency range to consider. Has precedence over eig_range and freq_margins.

    freq_step float

      The frequency step for tracing, in percent of the frequency range.

    freq_eps float

      The frequency difference smaller than freq_eps is considered zero.

    zero_eps float

      The tolerance for finding zeros of mass matrix eigenvalues.

    detect_fun callable

      The function for detecting the band gaps. Default is `detect_band_gaps()`.

    log_save_name str

      If not None, the band gaps log is to be saved under the given name.

    raw_log_save_name str

      If not None, the raw band gaps log is to be saved under the given name.

  fix_eig_range(n_eigs)
  process_options()

    Setup application-specific options.

    Subclasses should implement this method as needed.

    Returns:
      app_options Struct instance

        The application options.

  static save_log(filename, float_format, bg)

    Save band gaps, valid flags and eigenfrequencies.

  static to_file_txt(fd, float_format, bg)

class sfepy.homogenization.coefs_phononic.ChristoffelAcousticTensor(name, problem, kwargs)
  process_options()

    Setup application-specific options.

    Subclasses should implement this method as needed.

    Returns:
      app_options Struct instance

        The application options.

class sfepy.homogenization.coefs_phononic.DensityVolumeInfo(name, problem, kwargs)

  Determine densities of regions specified in region_to_material, and compute average density based on region volumes.

  static to_file_txt(fd, float_format, dv_info)

class sfepy.homogenization.coefs_phononic.Eigenmomenta(name, problem, kwargs)

  Eigenmomenta corresponding to eigenvectors.

  Parameters:
    var_name str

      The name of the variable used in the integral.

    threshold float

      The threshold under which an eigenmomentum is considered zero.

    threshold_is_relative bool

      If True, the threshold is relative w.r.t. max. norm of eigenmomenta.

    transform callable, optional

      Optional function for transforming the eigenvectors before computing the eigenmomenta.

  Returns:
    eigenmomenta Struct

      The resulting eigenmomenta. An eigenmomentum above threshold is marked by the attribute ‘valid’ set to True.

  process_options()

    Setup application-specific options.

    Subclasses should implement this method as needed.

    Returns:
      app_options Struct instance

        The application options.

class sfepy.homogenization.coefs_phononic.PhaseVelocity(name, problem, kwargs)

  Compute phase velocity.

  process_options()

    Setup application-specific options.

    Subclasses should implement this method as needed.

    Returns:
      app_options Struct instance

        The application options.

class sfepy.homogenization.coefs_phononic.PolarizationAngles(name, problem, kwargs)

  Compute polarization angles, i.e., angles between incident wave direction and wave vectors. Vector length does not matter - eigenvectors are used directly.

  process_options()

    Setup application-specific options.

    Subclasses should implement this method as needed.

    Returns:
      app_options Struct instance

        The application options.

class sfepy.homogenization.coefs_phononic.SchurEVP(name, problem, kwargs)

  Schur complement eigenvalue problem.

  post_process(eigs, mtx_s_phi, mtx_dib, problem)
  prepare_matrices(problem)

    A = K + B^T D^{-1} B

class sfepy.homogenization.coefs_phononic.SimpleEVP(name, problem, kwargs)

  Simple eigenvalue problem.

  post_process(eigs, mtx_s_phi, data, problem)
  prepare_matrices(problem)
  process_options()

    Setup application-specific options.

    Subclasses should implement this method as needed.

    Returns:
      app_options Struct instance

        The application options.

  save(eigs, mtx_phi, problem)

sfepy.homogenization.coefs_phononic.compute_cat_dim_dim(coef, iw_dir)

  Christoffel acoustic tensor part of dielectric tensor dimension.

sfepy.homogenization.coefs_phononic.compute_cat_dim_sym(coef, iw_dir)

  Christoffel acoustic tensor part of piezo-coupling tensor dimension.

sfepy.homogenization.coefs_phononic.compute_cat_sym_sym(coef, iw_dir)

  Christoffel acoustic tensor (part) of elasticity tensor dimension.

sfepy.homogenization.coefs_phononic.compute_eigenmomenta(em_equation, var_name, problem, eig_vectors, transform=None)

  Compute the eigenmomenta corresponding to given eigenvectors.

sfepy.homogenization.coefs_phononic.cut_freq_range(freq_range, eigs, valid, freq_margins, eig_range, fixed_freq_range, freq_eps)

  Cut off masked resonance frequencies. Margins are preserved, like no resonances were cut.

  Returns:
    freq_range array

      The new range of frequencies.

    freq_range_margins array

      The range of frequencies with prepended/appended margins equal to fixed_freq_range if it is not None.

sfepy.homogenization.coefs_phononic.describe_gaps(gaps)

sfepy.homogenization.coefs_phononic.detect_band_gaps(mass, freq_info, opts, gap_kind='normal', mtx_b=None)

  Detect band gaps given solution to eigenproblem (eigs, eig_vectors). Only valid resonance frequencies (e.i. those for which corresponding eigenmomenta are above a given threshold) are taken into account.

  Notes

  - make freq_eps relative to ]f0, f1[ size?

sfepy.homogenization.coefs_phononic.find_zero(f0, f1, callback, freq_eps, zero_eps, mode)

  For f in ]f0, f1[ find frequency f for which either the smallest (mode = 0) or the largest (mode = 1) eigenvalue of problem P given by callback is zero.

  Returns:
    flag 0, 1, or 2

      The flag, see Notes below.

    frequency float

      The found frequency.

    eigenvalue float

      The eigenvalue corresponding to the found frequency.

  Notes

  Meaning of the return value combinations:

  mode | flag | meaning
  --- | --- | ---
  0, 1 | 0 | eigenvalue -> 0 for f in ]f0, f1[
  0 | 1 | f -> f1, smallest eigenvalue < 0
  0 | 2 | f -> f0, smallest eigenvalue > 0 and -> -infty
  1 | 1 | f -> f1, largest eigenvalue < 0 and -> +infty
  1 | 2 | f -> f0, largest eigenvalue > 0

sfepy.homogenization.coefs_phononic.get_callback(mass, solver_kind, mtx_b=None, mode='trace')

  Return callback to solve band gaps or dispersion eigenproblem P.

  Notes

  Find zero callbacks return:

    eigenvalues

  Trace callbacks return:

    (eigenvalues,)

  or

    (eigenvalues, eigenvectors) (in full (dispoersion) mode)

  If mtx_b is None, the problem P is

    M w = lambda w,

  otherwise it is

    omega^2 M w = eta B w

sfepy.homogenization.coefs_phononic.get_gap_ranges(freq_range, gaps, kinds)

  For each (potential) band gap in gaps, return the frequency ranges of its parts according to kinds.

sfepy.homogenization.coefs_phononic.get_log_freqs(f0, f1, df, freq_eps, n_point_min, n_point_max)

  Get logging frequencies.

  The frequencies get denser towards the interval boundaries.

sfepy.homogenization.coefs_phononic.get_ranges(freq_range, eigs)

  Get an eigenvalue range slice and a corresponding initial frequency range within a given frequency range.

sfepy.homogenization.coefs_phononic.split_chunks(indx)

  Split index vector to chunks of consecutive numbers.