diff --git a/src/Find.jl b/src/Find.jl index fee7311..dc21afc 100644 --- a/src/Find.jl +++ b/src/Find.jl @@ -37,7 +37,14 @@ Find a volume which leads to the given pressure, energy, or bulk modulus based o an array or a tuple, of which only the maximum and minimum values will be used in the root-finding process. """ -findvolume(f, y, x0, method) = find_zero(v -> f(v) - y, x0, method) +function findvolume(f, y, x0, method) + v0 = find_zero(v -> f(v) - y, x0, method) + if v0 < zero(v0) + error("the volume found is negative!") + else + return v0 + end +end # function findvolume function findvolume(f, y, x0) for T in [subtypes(AbstractBisection); subtypes(AbstractAlefeldPotraShi)] @info("Using method \"$T\"...")