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.
Public interfaces
EquationsOfState.Find.findvolume
โ Methodfindvolume(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
andx0
must also have.prop::PhysicalProperty
: aPhysicalProperty
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 thex0
parameter must be an array or a tuple, of which only the maximum and minimum values will be used in the root-finding process.
All available method
s 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