2.6. Interpolate on a dense volume mesh

This module contains a grid interpolation algorithm that integrates previous Birch–Murnaghan equation of state fitting, to get Helmholtz free energy on a denser volume mesh.

qha.grid_interpolation.calculate_eulerian_strain(*args, **kwargs)

Calculate the Eulerian strain (:math:`f`s) of a given volume vector vs with respect to a reference volume v0, where

\[f = \frac{ 1 }{ 2 } \bigg( \Big( \frac{ V_0 }{ V }^{2/3} \Big) -1 \bigg).\]
Parameters
  • v0 – The volume set as the reference for the Eulerian strain calculation.

  • vs – A volume vector, each item of which will be calculated the Eulerian strain with respect to v0.

Returns

A vector of the calculated Eulerian strain.

qha.grid_interpolation.from_eulerian_strain(*args, **kwargs)

Calculate the corresponding volumes \(V\), i.e.,

\[V = V_0 (2 f + 1)^{-3/2}.\]
Parameters
  • v0 – The volume set as a reference for volume calculation, i.e., \(V_0\) mentioned above.

  • fs – A vector of Eulerian strains with respect to \(V_0\).

Returns

A vector of calculated volume :math:`V`s.

class qha.grid_interpolation.VolumeExpander(in_volumes, out_volumes_num, ratio)[source]

Interpolate volumes on input volumes in_volumes, with ratio given. For the Eulerian strain, the larger the strain, the smaller the volume. So larger volume corresponds to smaller strain.

Algorithm:

  1. Find the maximum and minimum volumes of in_volumes.

  2. Expand the lower and upper bounds of the volumes to \(V_\text{lower}\) and \(V_\text{upper}\) by \(V_\text{lower} = \frac{ V_\text{min} }{ r }\) and \(V_\text{upper} = V_\text{max} r\), where \(r\) is the ratio, which is usually an empirical parameter.

  3. The Eulerian strains of \(V_\text{lower}\) and \(V_\text{upper}\) with respect to \(V_\text{max}\) is calculated. Then a linear sequence between the lower and upper bounds of the strains is generated. It is the strains attribute.

  4. The volumes corresponding to strains are generated by function from_eulerian_strain.

Note: To use this class, the method interpolate_volumes must be called immediately after instantiating it. Otherwise, the strains and out_volumes attributes are all None, which is usually not expected.

Parameters
  • in_volumes (array(float64, 1d, A)) – An input vector of volumes.

  • out_volumes_num (int) – Number of output volumes. It should be larger than the number of input volumes.

  • ratio (float) – The ratio of the upper bounds of expanded volumes with respect to the largest input volume in in_volumes. An empirical parameter, better lower than 1.5. Otherwise, the later result may not be reliable.

property in_volumes
Returns

Input volume vector, read only.

interpolate_volumes()[source]

The algorithm is described above. This method should be called immediately after an instance of the class is created, unless user is clear what is being done.

Return type

None

property out_volumes

The volumes interpolated by the algorithm described above.

Return type

Optional[array(float64, 1d, A)]

Returns

If method interpolate_volumes is called, a vector of output volumes is returned, otherwise None is returned.

property out_volumes_num
Return type

int

Returns

The number of output volumes user wants, usually greater than the number of input volumes.

property ratio

An empirical parameter, usually larger than 1 and lower than 1.5.

Return type

float

Returns

A floating-point number described in the algorithm above.

property strains

An arithmetic sequence starting from the lower bound to the upper bound of the expanded strain, the number of elements in it is specified by out_volumes_num attribute.

Return type

Optional[array(float64, 1d, A)]

Returns

A vector of strains if method interpolate_volumes is called, otherwise None is returned.

class qha.grid_interpolation.FinerGrid(desired_p_min, dense_volumes_amount, order=3)[source]

A class that will do the Birch–Murnaghan finite-strain equation of state fitting, moreover, evaluate the free energies on the denser volume vector.

Parameters
  • desired_p_min (float) – The desired minimum pressure to calculate for further steps.

  • dense_volumes_amount (int) – The number of volumes on a denser grid.

  • order (Optional[int]) – The order of the Birch–Murnaghan finite-strain equation of state fitting.

approach_to_best_ratio(volumes, free_energies, initial_ratio)[source]

Trying to find the best volume grids based on an a very large volume grids.

Parameters
  • volumes (array(float64, 1d, A)) – Volumes of these calculations were perform (sparse).

  • free_energies (array(float64, 1d, A)) – Free energies at the highest temperature (sparse).

  • initial_ratio (float) – Initial ratio, a guess value, which can be set to a very large number.

Return type

float

Returns

The suitable ratio for further calculation.

refine_grid(volumes, free_energies, ratio=None)[source]

Get the appropriate volume grid for interpolation. Avoid to use a too large volume grid to obtain data, which might lose accuracy.

Parameters
  • free_energies (array(float64, 2d, A)) – Calculated Helmholtz Free Energies for input volumes (sparse).

  • volumes (array(float64, 1d, A)) – Volumes of these calculations were performed (sparse).

  • ratio (Optional[float]) – This ratio is used to get a larger volume grid

Return type

Tuple[array(float64, 1d, A), array(float64, 2d, A), float]

Returns

volume, Helmholtz free energy at a denser vector, and the ratio used in this calculation