Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename a lot of things #82

Merged
merged 17 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using EquationsOfState
using Documenter

DocMeta.setdocmeta!(EquationsOfState, :DocTestSetup, :(using EquationsOfState, EquationOfState.Collections, Unitful); recursive=true)
makedocs(;
modules=[EquationsOfState],
authors="Qi Zhang <[email protected]>",
Expand Down
19 changes: 9 additions & 10 deletions docs/src/Collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

```@meta
CurrentModule = EquationsOfState.Collections
DocTestSetup = quote
using EquationsOfState.Collections
using Unitful
using UnitfulAtomic
end
```

The current `EquationOfState`s contain
Expand Down Expand Up @@ -257,9 +262,12 @@ The $B(V)$ relation of equations of state are listed as below:
B(V) = \beta\left(\frac{V}{V_{0}}\right)^{n}\left[1+n \ln \frac{V}{V_{0}}\right].
```

## Types
## Public interfaces

```@docs
Energy
Pressure
BulkModulus
EquationOfState
FiniteStrainEquationOfState
Murnaghan
Expand All @@ -271,12 +279,3 @@ PoirierTarantola3rd
PoirierTarantola4th
Vinet
```

## Public interfaces

```@docs
(eos::EquationOfState)(eq::EquationForm)
(f::EquationOfStateOnVolume{<:Murnaghan,EnergyForm})(v)
(f::EquationOfStateOnVolume{<:Murnaghan,PressureForm})(v)
(f::EquationOfStateOnVolume{<:BirchMurnaghan2nd,BulkModulusForm})(v)
```
9 changes: 5 additions & 4 deletions docs/src/Find.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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
`PressureForm` to find the corresponding volume.
`Pressure` to find the corresponding volume.

## Usage

Expand All @@ -21,7 +21,7 @@ julia> pressures = collect(0:20:200) .* u"GPa";
julia> eos = BirchMurnaghan3rd(167u"angstrom^3", 2600u"kbar", 4.0);

julia> volumes = map(
p -> findvolume(PressureForm(), eos, p, (eps() * u"bohr^3", eos.v0 * 1.3)),
p -> findvolume(Pressure(), eos, p, (eps() * u"bohr^3", eos.v0 * 1.3)),
pressures
)
[ Info: Using method "Roots.Bisection"...
Expand Down Expand Up @@ -58,8 +58,9 @@ A figure is plotted below to verify our results, and it fits very well.

## Public interfaces

```@docs
findvolume(form::EquationForm, eos::EquationOfState, y, x0, method)
```@autodocs
Modules = [Find]
Order = [:type, :function]
```

All available `method`s are the leaves of the tree below (Remember to add a `Roots.` prefix):
Expand Down
13 changes: 7 additions & 6 deletions docs/src/NonlinearFitting.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,26 @@ energies = [
-9.73155247952,
];

julia> lsqfit(EnergyForm(), BirchMurnaghan3rd(40, 0.5, 4, 0), volumes, energies)
julia> lsqfit(Energy(), BirchMurnaghan3rd(40, 0.5, 4, 0), volumes, energies)
BirchMurnaghan3rd{Float64}(40.989265727925826, 0.5369258245608038, 4.1786442319302015, -10.842803908298968)

julia> lsqfit(EnergyForm(), Murnaghan(41, 0.5, 4, 0), volumes, energies)
julia> lsqfit(Energy(), Murnaghan(41, 0.5, 4, 0), volumes, energies)
Murnaghan{Float64}(41.13757924894751, 0.5144967655882123, 3.912386317519504, -10.836794511015869)

julia> lsqfit(EnergyForm(), PoirierTarantola3rd(41, 0.5, 4, 0), volumes, energies)
julia> lsqfit(Energy(), PoirierTarantola3rd(41, 0.5, 4, 0), volumes, energies)
PoirierTarantola3rd{Float64}(40.86770643567383, 0.5667729960008705, 4.331688934942696, -10.851486685029547)

julia> lsqfit(EnergyForm(), Vinet(41, 0.5, 4, 0), volumes, energies)
julia> lsqfit(Energy(), Vinet(41, 0.5, 4, 0), volumes, energies)
Vinet{Float64}(40.91687567368755, 0.5493839427734198, 4.30519294991197, -10.846160810968053)
```

Then 4 different equations of state will be fitted.

## Public interfaces

```@docs
lsqfit(form::EquationForm, eos::EquationOfState{<:Real}, xdata::AbstractVector{<:Real}, ydata::AbstractVector{<:Real}; debug::Bool, kwargs...)
```@autodocs
Modules = [NonlinearFitting]
Order = [:type, :function]
```

## References
Expand Down
28 changes: 13 additions & 15 deletions docs/src/Python.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,31 @@ writing too much code. Luckily, Julia provides such a feature.
```python
In [1]: from julia import Unitful

In [2]: from julia.EquationsOfState import *
In [2]: from julia.EquationsOfState.Collections import *

In [3]: from julia.EquationsOfState.Collections import *
In [3]: from julia.EquationsOfState import *

In [4]: from julia.EquationsOfState import *
In [4]: Murnaghan(1, 2, 3.0, 4)
Out[4]: <PyCall.jlwrap EquationsOfState.Collections.Murnaghan{Float64}(1.0, 2.0, 3.0, 4.0)>

In [5]: Murnaghan(1, 2, 3.0, 4)
Out[5]: <PyCall.jlwrap EquationsOfState.Collections.Murnaghan{Float64}(1.0, 2.0, 3.0, 4.0)>

In [6]: result = lsqfit(
...: PressureForm(),
In [5]: result = lsqfit(
...: Pressure(),
...: BirchMurnaghan3rd(1, 2, 3.0, 0),
...: [1, 2, 3, 4, 5],
...: [5, 6, 9, 8, 7],
...: )

In [7]: result.v0, result.b0, result.bp0
Out[7]: (1.1024687826913997, 29.308616965851673, 12.689089874230556)
In [6]: result.v0, result.b0, result.bp0
Out[6]: (1.1024687826913997, 29.308616965851673, 12.689089874230556)

In [8]: from julia import Main
In [7]: from julia import Main

In [9]: volumes = Main.eval("data[:, 1] .* UnitfulAtomic.bohr^3")
In [8]: volumes = Main.eval("data[:, 1] .* UnitfulAtomic.bohr^3")

In [10]: energies = Main.eval("data[:, 2] .* UnitfulAtomic.Ry")
In [9]: energies = Main.eval("data[:, 2] .* UnitfulAtomic.Ry")

In [11]: Main.eval("EquationsOfState.NonlinearFitting.lsqfit(EquationsOfState.EnergyForm(), EquationsOfState.Collections.Murnaghan(224.445371 * UnitfulAtomic.bohr^3, 9.164446 * Unitful.GPa, 3.752432, -161.708856 * UnitfulAtomic.hartree), volumes, energies)")
Out[11]: <PyCall.jlwrap EquationsOfState.Collections.Murnaghan{Unitful.Quantity{Float64,D,U} where U where D}(224.5018173532159 a₀^3, 8.896845579229117 GPa, 3.7238388137735674, -161.70884303138902 Eₕ)>
In [10]: Main.eval("EquationsOfState.NonlinearFitting.lsqfit(EquationsOfState.Energy(), EquationsOfState.Collections.Murnaghan(224.445371 * UnitfulAtomic.bohr^3, 9.164446 * Unitful.GPa, 3.752432, -161.708856 * UnitfulAtomic.hartree), volumes, energies)")
Out[10]: <PyCall.jlwrap EquationsOfState.Collections.Murnaghan{Unitful.Quantity{Float64,D,U} where U where D}(224.5018173532159 a₀^3, 8.896845579229117 GPa, 3.7238388137735674, -161.70884303138902 Eₕ)>
```

where `data` is copied from Julia:
Expand Down
9 changes: 4 additions & 5 deletions scripts/findvolume.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ plotlyjs()

pressures = collect(0:20:200) .* u"GPa"
eos = BirchMurnaghan3rd(167 * u"angstrom^3", 2600 * u"kbar", 4.0)
volumes = map(
p -> findvolume(PressureForm(), eos, p, (eps() * u"bohr^3", eos.v0 * 1.3)),
pressures,
)
volumes = map(pressures) do p
findvolume(eos(Pressure()), p, (eps(1.0 * u"bohr^3"), eos.v0 * 1.3))
end
plot(ustrip.(volumes), ustrip.(pressures), label = "pressures")
scatter!(
ustrip.(volumes),
ustrip.(u"GPa", eos(PressureForm()).(volumes)),
ustrip.(u"GPa", eos(Pressure()).(volumes)),
label = "P(V)",
dpi = 400,
)
Expand Down
Loading