Find

This module contains a function findvolume, which is used to find an approximate volume at a given pressure, energy, or bulk modulus based on an equation of state. A result is not always guaranteed, especially when the equation of state is not a monotonic function of volume. However, according to experience, P(V) relation is usually a monotonic function. So we suggest using Pressure to find the corresponding volume.

Usage

julia> using EquationsOfState.Collections, EquationsOfState.Find, Unitful, UnitfulAtomic

julia> pressures = collect(0:20:200) .* u"GPa";

julia> eos = BirchMurnaghan3rd(167u"angstrom^3", 2600u"kbar", 4.0);

julia> volumes = map(pressures) do p
           findvolume(eos(Pressure()), p, (eps() * u"bohr^3", eos.v0 * 1.3))
       end
[...]
11-element Array{Quantity{Float64,๐‹^3,Unitful.FreeUnits{(โ„ซ^3,),๐‹^3,nothing}},1}:
              167.0 โ„ซ^3
 156.14036210727835 โ„ซ^3
 147.99803635986564 โ„ซ^3
 141.51093713795865 โ„ซ^3
 136.13864615965332 โ„ซ^3
 131.56784031939347 โ„ซ^3
 127.60046278645824 โ„ซ^3
 124.10332447387113 โ„ซ^3
 120.98257680606459 โ„ซ^3
 118.16962836248427 โ„ซ^3
 115.61284838696814 โ„ซ^3

Here we let the algorithm choose the bisection root-finding method to find the volumes corresponding to pressures.

A figure is plotted below to verify our results, and it fits very well.

findvolume

Public interfaces

EquationsOfState.Find.findvolume โ€” Method
findvolume(eos(prop), y, x0, method)
findvolume(eos(prop), y, x0::Union{AbstractVector,Tuple})

Find a volume which leads to the given pressure, energy, or bulk modulus based on an eos.

Arguments

  • eos::EquationOfState: an equation of state. If it has units, y and x0 must also have.
  • prop::PhysicalProperty: a PhysicalProperty instance.
  • y: a pressure, energy, or bulk modulus.
  • x0: can be either a range of volumes (Vector, Tuple, etc.) or just a single volume. Units can be provided if necessary.
  • method::Roots.AbstractUnivariateZeroMethod: a method used to find the root of an equation. If it is omitted, the algorithm will traverse all possible methods of Roots.jl. And the x0 parameter must be an array or a tuple, of which only the maximum and minimum values will be used in the root-finding process.
source

All available methods are the leaves of the tree below (Remember to add a Roots. prefix):

AbstractUnivariateZeroMethod
โ”œโ”€ AbstractBracketing
โ”‚  โ”œโ”€ AbstractAlefeldPotraShi
โ”‚  โ”‚  โ”œโ”€ A42
โ”‚  โ”‚  โ””โ”€ AlefeldPotraShi
โ”‚  โ”œโ”€ AbstractBisection
โ”‚  โ”‚  โ”œโ”€ Bisection
โ”‚  โ”‚  โ”œโ”€ FalsePosition
โ”‚  โ”‚  โ””โ”€ BisectionExact
โ”‚  โ””โ”€ Brent
โ”œโ”€ AbstractHalleyLikeMethod
โ”‚  โ”œโ”€ Halley
โ”‚  โ””โ”€ Schroder
โ”œโ”€ AbstractNewtonLikeMethod
โ”‚  โ””โ”€ Newton
โ””โ”€ AbstractNonBracketing
   โ””โ”€ AbstractSecant
      โ”œโ”€ Order0
      โ”œโ”€ Order16
      โ”œโ”€ Order2
      โ”œโ”€ Order5
      โ”œโ”€ Order8
      โ”œโ”€ Esser
      โ”œโ”€ King
      โ”œโ”€ KumarSinghAkanksha
      โ”œโ”€ Order1B
      โ”œโ”€ Order2B
      โ”œโ”€ Secant
      โ”œโ”€ Steffensen
      โ”œโ”€ Thukral16
      โ””โ”€ Thukral8

The usage is like

findvolume(eos(prop), y, (3, 4))                     # Try all possible methods
findvolume(eos(prop), y, (3, 4), Order1())           # Specify two starting points for secant method
findvolume(eos(prop), y, 3.0, Order2())              # Use Steffensen method
findvolume(eos(prop), y, big(3.0), Order16())        # Rapid convergence
findvolume(eos(prop), y, (3, 4), Roots.A42())        # Fewer function calls than Bisection(), in this case
findvolume(eos(prop), y, (3, 4), FalsePosition(8))   # 1 of 12 possible algorithms for false position
findvolume(eos(prop), y, 3.0, Roots.Newton())        # Use Newton's method
findvolume(eos(prop), y, 3.0, Roots.Halley())        # Use Halley's method