simulations.phonons

Classes

  • Phonon

  • PhononNum

class udkm1Dsim.simulations.phonons.Phonon(S, force_recalc, **kwargs)

Bases: udkm1Dsim.simulations.simulation.Simulation

Base class for phonon simulations.

Parameters
  • S (Structure) – sample to do simulations with.

  • force_recalc (boolean) – force recalculation of results.

Keyword Arguments
  • save_data (boolean) – true to save simulation results.

  • cache_dir (str) – path to cached data.

  • disp_messages (boolean) – true to display messages from within the simulations.

  • progress_bar (boolean) – enable tqdm progress bar.

  • only_heat (boolean) – true when including only thermal expanison without coherent phonon dynamics.

Attributes
  • S (Structure) – sample structure to calculate simulations on.

  • force_recalc (boolean) – force recalculation of results.

  • save_data (boolean) – true to save simulation results.

  • cache_dir (str) – path to cached data.

  • disp_messages (boolean) – true to display messages from within the simulations.

  • progress_bar (boolean) – enable tqdm progress bar.

  • only_heat (boolean) – true when including only thermal expanison without coherent phonon dynamics.

get_hash(delays, temp_map, delta_temp_map, **kwargs)

Calculates an unique hash given by the delays, and temp_map and delta_temp_map as well as the sample structure hash for relevant lattice parameters.

Parameters
  • delays (ndarray[float]) – delay grid for the simulation.

  • temp_map (ndarray[float]) – spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) – spatio-temporal temperature difference profile.

  • **kwargs (float, optional) – optional parameters.

Returns

hash (str) – unique hash.

get_all_strains_per_unique_layer(strain_map)
Parameters

strain_map (ndarray[float]) – spatio-temporal strain profile.

Returns

strains (list[ndarray[float]] – all strains per unique layer.

get_reduced_strains_per_unique_layer(strain_map, N=100)

Calculates all strains per unique layer that are given by the input strain_map, but with a reduced number. The reduction is done by equally spacing the strains between the min and max strain with a given number \(N\), which can be also an array of the \(len(N) = L\), where \(L\) is the number of unique layers.

Parameters
  • strain_map (ndarray[float]) – spatio-temporal strain profile.

  • N (int, optional) – number of reduced strains. Defaults to 100.

Returns

strains (list[ndarray[float]] – reduced strains per unique layer.

check_temp_maps(temp_map, delta_temp_map, delays)

Check temperature profiles for correct dimensions.

Parameters
  • temp_map (ndarray[float]) – spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) – spatio-temporal temperature difference profile.

  • delays (ndarray[float]) – delay grid for the simulation.

Returns

(tuple)

  • temp_map (ndarray[float]) - checked spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) - checked spatio-temporal differential temperature profile.

calc_sticks_from_temp_map(temp_map, delta_temp_map)

Calculates the sticks to insert into the layer springs which model the external force (thermal stress). The length of \(l_i\) of the \(i\)-th spacer stick is calculated from the temperature-dependent linear thermal expansion \(\alpha(T)\) of the layer:

\[\alpha(T) = \frac{1}{L} \frac{d L}{d T}\]

which results after integration in

\[l = \Delta L = L_1 \exp(A(T_2) - A(T_1)) - L_1\]

where \(A(T)\) is the integrated lin. therm. expansion coefficient in respect to the temperature \(T\). The indices 1 and 2 indicate the initial and final state.

Parameters
  • temp_map (ndarray[float]) – spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) – spatio-temporal temperature difference profile.

Returns

(tuple)

  • sticks (ndarray[float]) - summed spacer sticks.

  • sticks_sub_systems (ndarray[float]) - spacer sticks per sub-system.

conv_with_function(y, x, handle)

Convolutes the array \(y(x)\) with a function given by the handle on the argument array \(x\).

Parameters
  • y (ndarray[float]) – y data.

  • x (ndarray[float]) – x data.

  • handle (@lamdba) – convolution function.

Returns

y_conv (ndarray[float]) – convoluted data.

disp_message(message)

Wrapper to display messages for that class.

Parameters

message (str) – message to display.

save(full_filename, data, *args)

Save data to file. The variable name can be handed as variable argument.

Parameters
  • full_filename (str) – full file name to data file.

  • data (ndarray) – actual data to save.

  • *args (str, optional) – variable name within the data file.

class udkm1Dsim.simulations.phonons.PhononNum(S, force_recalc, **kwargs)

Bases: udkm1Dsim.simulations.phonons.Phonon

Base class for numerical phonon simulations.

Parameters
  • S (Structure) – sample to do simulations with.

  • force_recalc (boolean) – force recalculation of results.

Keyword Arguments
  • save_data (boolean) – true to save simulation results.

  • cache_dir (str) – path to cached data.

  • disp_messages (boolean) – true to display messages from within the simulations.

  • progress_bar (boolean) – enable tqdm progress bar.

  • only_heat (boolean) – true when including only thermal expanison without coherent phonon dynamics.

Attributes
  • S (Structure) – sample structure to calculate simulations on.

  • force_recalc (boolean) – force recalculation of results.

  • save_data (boolean) – true to save simulation results.

  • cache_dir (str) – path to cached data.

  • disp_messages (boolean) – true to display messages from within the simulations.

  • progress_bar (boolean) – enable tqdm progress bar.

  • only_heat (boolean) – true when including only thermal expanison without coherent phonon dynamics.

  • ode_options (dict) – options for scipy solve_ivp ode solver.

References

7

A. Bojahr, M. Herzog, D. Schick, I. Vrejoiu, & M. Bargheer, Calibrated real-time detection of nonlinearly propagating strain waves, Phys. Rev. B, 86(14), 144306 (2012).

get_strain_map(delays, temp_map, delta_temp_map)

Returns a strain profile for the sample structure for given temperature profile. The result can be saved using an unique hash of the sample and the simulation parameters in order to reuse it.

Parameters
  • delays (ndarray[Quantity]) – delays range of simulation [s].

  • temp_map (ndarray[float]) – spatio-temporal temperature map.

  • delta_temp_map (ndarray[float]) – spatio-temporal differential

  • map. (temperature) –

Returns

strain_map (ndarray[float]) – spatio-temporal strain profile.

calc_strain_map(delays, temp_map, delta_temp_map)

Calculates the strain_map of the sample structure for a given temp_map and delta_temp_map and delay array. Further details are given in Ref. 7. The coupled differential equations are solved for each oscillator in a linear chain of masses and springs:

\[\begin{split}m_i\ddot{x}_i = & -k_i(x_i-x_{i-1})-k_{i+1}(x_i-x_{i+1}) \\ & + m_i\gamma_i(\dot{x}_i-\dot{x}_{i-1}) + F_i^{heat}(t)\end{split}\]

where \(x_i(t) = z_{i}(t) - z_i^0\) is the shift of each layer. \(m_i\) is the mass and \(k_i = m_i\, v_i^2/c_i^2\) is the spring constant of each layer. Furthermore an empirical damping term \(F_i^{damp} = \gamma_i(\dot{x}_i-\dot{x}_{i-1})\) is introduced and the external force (thermal stress) \(F_i^{heat}(t)\). The thermal stresses are modelled as spacer sticks which are calculated from the linear thermal expansion coefficients. The equation of motion can be reformulated as:

\[m_i\ddot{x}_i = F_i^{spring} + F_i^{damp} + F_i^{heat}(t)\]

The numerical solution also allows for non-harmonic inter-atomic potentials of up to the order \(M\). Accordingly \(k_i = (k_i^1 \ldots k_i^{M-1})\) can be an array accounting for higher orders of the potential which is in the harmonic case purely quadratic (\(k_i = k_i^1\)). The resulting force from the displacement of the springs

\[F_i^{spring} = -k_i(x_i-x_{i-1})-k_{i+1}(x_i-x_{i+1})\]

includes:

\[k_i(x_i-x_{i-1}) = \sum_{j=1}^{M-1} k_i^j (x_i-x_{i-1})^j\]
Parameters
  • delays (ndarray[Quantity]) – delays range of simulation [s].

  • temp_map (ndarray[float]) – spatio-temporal temperature map.

  • delta_temp_map (ndarray[float]) – spatio-temporal differential temperature map.

Returns

(tuple)

  • strain_map (ndarray[float]) - spatio-temporal strain profile.

  • sticks_sub_systems (ndarray[float]) - spacer sticks per sub-system.

  • velocities (ndarray[float]) - spatio-temporal velocity profile.

static ode_func(t, X, delays, force_from_heat, damping, spring_consts, masses, L, pbar=None, state=None)

Provides the according ode function for the ode solver which has to be solved. The ode function has the input \(t\) and \(X(t)\) and calculates the temporal derivative \(\dot{X}(t)\) where the vector

\[X(t) = [x(t) \; \dot{x}(t)] \quad \mbox{and } \quad \dot{X}(t) = [\dot{x}(t) \; \ddot{x}(t)] .\]

\(x(t)\) is the actual shift of each layer.

Parameters
  • t (ndarray[float]) – internal time steps of the ode solver.

  • X (ndarray[float]) – internal variable of the ode solver.

  • delays (ndarray[float]) – delays range of simulation [s].

  • force_from_heat (ndarray[float]) – force due to thermal expansion.

  • damping (ndarray[float]) – phonon damping.

  • spring_consts (ndarray[float]) – spring constants of masses.

  • masses (ndarray[float]) – masses of layers.

  • L (int) – number of layers.

  • pbar (tqdm) – tqdm progressbar.

  • state (list[float]) – state variables for progress bar.

Returns

X_prime (ndarray[float]) – velocities and accelerations of masses.

static calc_force_from_spring(d_X1, d_X2, spring_consts)

Calculates the force \(F_i^{spring}\) acting on each mass due to the displacement between the left and right site of that mass.

\[F_i^{spring} = -k_i(x_i-x_{i-1})-k_{i+1}(x_i-x_{i+1})\]

We introduce-higher order inter-atomic potentials by

\[k_i(x_i-x_{i-1}) = \sum_{j=1}^{M} k_i^j (x_i-x_{i-1})^j\]

where \(M\) is the order of the spring constants.

Parameters
  • d_X1 (ndarray[float]) – left displacements.

  • d_X2 (ndarray[float]) – right displacements.

  • spring_consts (ndarray[float]) – spring constants of masses.

Returns

F (ndarray[float]) – force from springs.

static calc_force_from_heat(sticks, spring_consts)

Calculates the force acting on each mass due to the heat expansion, which is modeled by spacer sticks.

Parameters
  • stciks (ndarray[float]) – spacer sticks.

  • spring_consts (ndarray[float]) – spring constants of masses.

Returns

F (ndarray[float]) – force from thermal expansion.

static calc_force_from_damping(v, damping, masses)

Calculates the force acting on each mass in a linear spring due to damping (\(\gamma_i\)) according to the shift velocity difference \(v_{i}-v_{i-1}\) with \(v_i(t) = \dot{x}_i(t)\):

\[F_i^{damp} = \gamma_i(\dot{x}_i-\dot{x}_{i-1})\]
Parameters
  • v (ndarray[float]) – velocity of masses.

  • damping (ndarray[float]) – phonon damping.

  • masses (ndarray[float]) – masses.

Returns

F (ndarray[float]) – force from damping.

calc_sticks_from_temp_map(temp_map, delta_temp_map)

Calculates the sticks to insert into the layer springs which model the external force (thermal stress). The length of \(l_i\) of the \(i\)-th spacer stick is calculated from the temperature-dependent linear thermal expansion \(\alpha(T)\) of the layer:

\[\alpha(T) = \frac{1}{L} \frac{d L}{d T}\]

which results after integration in

\[l = \Delta L = L_1 \exp(A(T_2) - A(T_1)) - L_1\]

where \(A(T)\) is the integrated lin. therm. expansion coefficient in respect to the temperature \(T\). The indices 1 and 2 indicate the initial and final state.

Parameters
  • temp_map (ndarray[float]) – spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) – spatio-temporal temperature difference profile.

Returns

(tuple)

  • sticks (ndarray[float]) - summed spacer sticks.

  • sticks_sub_systems (ndarray[float]) - spacer sticks per sub-system.

check_temp_maps(temp_map, delta_temp_map, delays)

Check temperature profiles for correct dimensions.

Parameters
  • temp_map (ndarray[float]) – spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) – spatio-temporal temperature difference profile.

  • delays (ndarray[float]) – delay grid for the simulation.

Returns

(tuple)

  • temp_map (ndarray[float]) - checked spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) - checked spatio-temporal differential temperature profile.

conv_with_function(y, x, handle)

Convolutes the array \(y(x)\) with a function given by the handle on the argument array \(x\).

Parameters
  • y (ndarray[float]) – y data.

  • x (ndarray[float]) – x data.

  • handle (@lamdba) – convolution function.

Returns

y_conv (ndarray[float]) – convoluted data.

disp_message(message)

Wrapper to display messages for that class.

Parameters

message (str) – message to display.

get_all_strains_per_unique_layer(strain_map)
Parameters

strain_map (ndarray[float]) – spatio-temporal strain profile.

Returns

strains (list[ndarray[float]] – all strains per unique layer.

get_hash(delays, temp_map, delta_temp_map, **kwargs)

Calculates an unique hash given by the delays, and temp_map and delta_temp_map as well as the sample structure hash for relevant lattice parameters.

Parameters
  • delays (ndarray[float]) – delay grid for the simulation.

  • temp_map (ndarray[float]) – spatio-temporal temperature profile.

  • delta_temp_map (ndarray[float]) – spatio-temporal temperature difference profile.

  • **kwargs (float, optional) – optional parameters.

Returns

hash (str) – unique hash.

get_reduced_strains_per_unique_layer(strain_map, N=100)

Calculates all strains per unique layer that are given by the input strain_map, but with a reduced number. The reduction is done by equally spacing the strains between the min and max strain with a given number \(N\), which can be also an array of the \(len(N) = L\), where \(L\) is the number of unique layers.

Parameters
  • strain_map (ndarray[float]) – spatio-temporal strain profile.

  • N (int, optional) – number of reduced strains. Defaults to 100.

Returns

strains (list[ndarray[float]] – reduced strains per unique layer.

save(full_filename, data, *args)

Save data to file. The variable name can be handed as variable argument.

Parameters
  • full_filename (str) – full file name to data file.

  • data (ndarray) – actual data to save.

  • *args (str, optional) – variable name within the data file.