Skip to content

Commit

Permalink
style: Restyle code
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Sep 30, 2019
1 parent 6a93cd8 commit 27cc892
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/Collections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ function apply(::EnergyForm, eos::BirchMurnaghan4th, v)

f = (cbrt(v0 / v)^2 - 1) / 2
h = b0 * bpp0 + bp0^2
return e0 + 3 / 8 * v0 * b0 * f^2 * ((9h - 63bp0 + 143) * f^2 + 12 * (bp0 - 4) * f + 12)
return e0 +
3 / 8 * v0 * b0 * f^2 * ((9h - 63bp0 + 143) * f^2 + 12 * (bp0 - 4) * f + 12)
end
"""
apply(EnergyForm(), eos::PoirierTarantola2nd, v)
Expand Down Expand Up @@ -664,9 +665,17 @@ fieldvalues(eos::EquationOfState) = [getfield(eos, i) for i in 1:nfields(eos)]

Base.eltype(T::Type{<:EquationOfState}) = promote_type(T.types...)

Unitful.upreferred(::Dimensions{(Dimension{:Length}(2//1),Dimension{:Mass}(1//1),Dimension{:Time}(-2//1))}) = u"eV"
Unitful.upreferred(::Dimensions{(Dimension{:Length}(3//1),)}) = u"angstrom^3"
Unitful.upreferred(::Dimensions{(Dimension{:Length}(-1//1),Dimension{:Mass}(1//1),Dimension{:Time}(-2//1))}) = u"eV/angstrom^3"
Unitful.upreferred(::Dimensions{(
Dimension{:Length}(2 // 1),
Dimension{:Mass}(1 // 1),
Dimension{:Time}(-2 // 1),
)}) = u"eV"
Unitful.upreferred(::Dimensions{(Dimension{:Length}(3 // 1),)}) = u"angstrom^3"
Unitful.upreferred(::Dimensions{(
Dimension{:Length}(-1 // 1),
Dimension{:Mass}(1 // 1),
Dimension{:Time}(-2 // 1),
)}) = u"eV/angstrom^3"
# =============================== Miscellaneous ============================== #

end
6 changes: 5 additions & 1 deletion src/Find.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ function findvolume(
eos::EquationOfState,
y::Real,
domain::Union{AbstractVector,Tuple},
method::Union{AbstractNonBracketing,AbstractHalleyLikeMethod,AbstractNewtonLikeMethod},
method::Union{
AbstractNonBracketing,
AbstractHalleyLikeMethod,
AbstractNewtonLikeMethod,
},
)
f(v) = apply(form, eos, v) - y
return find_zero(f, median(domain), method)
Expand Down
10 changes: 8 additions & 2 deletions src/NonlinearFitting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ function lsqfit(
)
T = promote_type(eltype(eos), eltype(xdata), eltype(ydata), Float64)
E = typeof(eos).name.wrapper
model(x, p) = map(apply(form, E(p...)), x)
fitted = curve_fit(model, T.(xdata), T.(ydata), T.(Collections.fieldvalues(eos)), kwargs...)
model = (x, p) -> map(apply(form, E(p...)), x)
fitted = curve_fit(
model,
T.(xdata),
T.(ydata),
T.(Collections.fieldvalues(eos)),
kwargs...,
)
return debug ? fitted : E(fitted.param...)
end # function lsqfit
function lsqfit(
Expand Down

0 comments on commit 27cc892

Please sign in to comment.