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

Adding a Glue Type / N-Body Empirical Potential - the Finnis-Sinclair 1984 potential for single element systems #32

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
19f43d6
added packages
eschmidt42 Feb 2, 2021
a3f4b6a
added the finnis-sinclair variant of glue type potentials
eschmidt42 Feb 2, 2021
5b805ff
added documentation
eschmidt42 Feb 3, 2021
8942490
expanded potential energy and force tests to all vacancy free bcc cry…
eschmidt42 Feb 3, 2021
87e7d82
added potential energy and force checks for bcc crystal with a single…
eschmidt42 Feb 7, 2021
52f46b8
added tests for the finnis-sinclair type of glue potentials
eschmidt42 Feb 14, 2021
dd0881c
added section to run a longer simulation for the documentation
eschmidt42 Feb 14, 2021
221b690
added fields for forces, velocities and glue densities in Simulation
eschmidt42 Mar 10, 2021
eaacf33
refactored glue forces to work as general_inters
eschmidt42 Mar 10, 2021
a9d7ef1
modified potential_energy to pre-compute glue densities, if necessary
eschmidt42 Mar 10, 2021
fd93544
modified accelerations to allow for glue density update and calculati…
eschmidt42 Mar 10, 2021
95b9635
added GlueDensityLogger, VelocityLogger and ForcesLogger
eschmidt42 Mar 10, 2021
36457e0
fixed copy-paste error
eschmidt42 Mar 10, 2021
1808489
added ForwardDiff
eschmidt42 Mar 12, 2021
057b9a6
refactored reducing redundancy and replacing manually implemented der…
eschmidt42 Mar 12, 2021
acf7ce8
updated algebraic signs
eschmidt42 Mar 15, 2021
b99aca3
added convenience function to easily generate variables for the Finni…
eschmidt42 Mar 16, 2021
fd7cb6f
refactored the ground state energy, forces and vacancy formation ener…
eschmidt42 Mar 16, 2021
f80004e
refactored fs.ipynb: removed superfluous tests and reduced the math t…
eschmidt42 Mar 16, 2021
275c296
removed superfluous enumerate
eschmidt42 Mar 17, 2021
b136903
added docstrings
eschmidt42 Mar 17, 2021
931f214
cleaned
eschmidt42 Mar 17, 2021
4e2c73b
removed cell
eschmidt42 Mar 17, 2021
f88c5b2
removing comments
eschmidt42 Mar 20, 2021
3982887
Merge branch 'hotfix-removing-comments'
eschmidt42 Mar 20, 2021
b472fd9
Merge pull request #1 from eschmidt42/glue
eschmidt42 Mar 20, 2021
ee4d487
resolved merge conflict
eschmidt42 Mar 20, 2021
5a81002
replaced ForwardDiff.derivate with analytical derivatives and added k…
eschmidt42 Mar 27, 2021
c0d37fa
removed f comment in docstrings
eschmidt42 Mar 27, 2021
a71dc51
replaced dataframes with dicts
eschmidt42 Mar 27, 2021
4b55ae4
replaced another derivative forgotten earlier
eschmidt42 Mar 27, 2021
b332f60
updated tests
eschmidt42 Mar 27, 2021
825f1ad
minor change to improve readability of ForceLogger
eschmidt42 Mar 27, 2021
d646f9b
removed DataFrames reference
eschmidt42 Mar 27, 2021
945ddb0
removed DataFrames and Plots reference
eschmidt42 Mar 27, 2021
115adf2
relocated packages from Molly.jl to docs
eschmidt42 Mar 27, 2021
30a54b2
made notebook compatible with changes in in src/interactions/glue_fs.jl
eschmidt42 Mar 27, 2021
331cc70
removed because relocated to ./docs
eschmidt42 Mar 27, 2021
d87b4c6
removed superfluous cells
eschmidt42 Mar 27, 2021
bbc47f1
adjusted glue tests to changes in Crystal.jl and introduced more name…
eschmidt42 Apr 2, 2021
d073ef8
updated test: switched from Crystal to SingleCrystal package
eschmidt42 May 10, 2021
fbf2629
switched toml from Crystal to SingleCrystal
eschmidt42 May 10, 2021
d95cfbe
switched to toml SingleCrystal.jl
eschmidt42 May 10, 2021
b276156
updated notebook to work with the new data structure of the potential…
eschmidt42 May 10, 2021
71522fe
removed ForwardDiff
eschmidt42 May 10, 2021
b9ece8d
removed empty spaces and updated doc strings
eschmidt42 May 10, 2021
d1f113a
rm SingleCrystal package as direct dependency
eschmidt42 May 14, 2021
05d1990
replaced abstract types in structs
eschmidt42 May 14, 2021
12c5a31
wrapped glue tests in a testset
eschmidt42 May 14, 2021
996ed6e
kind of resolved conflict
eschmidt42 May 14, 2021
3b9ce51
welp...
eschmidt42 May 14, 2021
076ad3d
adjusted to renaming of Simnulation struct
eschmidt42 May 14, 2021
d2b3375
updated test to new Simulation
eschmidt42 May 14, 2021
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
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ BioStructures = "de9282ab-8554-53be-b2d6-f6c222edabfc"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
Crystal = "3c6eccdf-2a89-4c24-a1d4-ff210daa8476"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a need to use ForwardDiff for the derivatives introduced by this change. The derivatives expressions could be derived analytically and used directly. This might also be slightly more performant than doing them numerically.

KernelDensity = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SingleCrystal = "3c6eccdf-2a89-4c24-a1d4-ff210daa8476"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is SingleCrystal added as a dependency of the package? Should it not be just a test dependency?

Copy link
Author

@eschmidt42 eschmidt42 May 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks, should be fixed, as soon as I push my changes.

SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

Expand Down
4 changes: 4 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[deps]
Crystal = "3c6eccdf-2a89-4c24-a1d4-ff210daa8476"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be SingleCrystal?

Suggested change
Crystal = "3c6eccdf-2a89-4c24-a1d4-ff210daa8476"
SingleCrystal = "3c6eccdf-2a89-4c24-a1d4-ff210daa8476"

DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Molly = "aa0f7f06-fcc0-5ec4-a7f3-a573f33f9c4c"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plots in the documentation could be generated during the docs build, but it would be ideal to use the same package for all the plots (preferably one of the Makie backends). @jgreener64 One idea would be to use CairoMakie, but it might also be possible to use WGLMakie (it would be a bit more complex, but we get interactive plots). For this to work, the visualize function should be available with AbstractPlotting. A more elegant solution would be to use recipes, but AbstractPlotting is not a light dependency right now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would indeed be better to use the same plotting package throughout, though at the minute the code in the docs is not run during the docs build and Makie plots are pasted as images into the doc files.

It would be good if the docs notebook appeared in the docs - perhaps it could go in the examples section as markdown. Then these docs dependencies can be removed until we deal with doctests later, as the examples can assume that users have the package installed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried using Makie before but had some problem I can't remember. Plots is mostly required for the docs/fs.ipynb notebook. Can try to replace Plots there though if required.

Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Documenter = "0.25"
84 changes: 53 additions & 31 deletions fs.ipynb → docs/fs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,26 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import Pkg\n",
"\n",
"Pkg.activate(\".\")\n",
"Pkg.instantiate()\n",
"\n",
"# Pkg.add(url=\"https://github.com/eschmidt42/crystal\")\n",
"\n",
"# Pkg.add(url=\"https://github.com/eschmidt42/crystal\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using Molly\n",
"using DataFrames\n",
"using Plots\n",
"using Test\n",
"using Crystal"
Expand Down Expand Up @@ -194,7 +203,6 @@
"metadata": {},
"outputs": [],
"source": [
"kb = Molly.kb \n",
"fs84, elements, masses, bcc_lattice_constants, reference_energies = Molly.get_finnissinclair1984(true)"
]
},
Expand Down Expand Up @@ -224,7 +232,17 @@
"metadata": {},
"outputs": [],
"source": [
"element_pair, d, A, β, c, c₀, c₁, c₂ = fs84.params[1,:] # parameters for Vanadium"
"el = \"V\"\n",
"el_pair = string(el,el)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d, β = fs84.singles[el].d, fs84.singles[el].β"
]
},
{
Expand All @@ -244,12 +262,13 @@
"outputs": [],
"source": [
"ɸs = [ɸ]\n",
"element_pairs = [element_pair]\n",
"for i in 2:nrow(fs84.params)\n",
" element_pair, d, A, β, c, c₀, c₁, c₂ = fs84.params[i,:]\n",
"element_pairs = [el_pair]\n",
"for el in elements[2:end]\n",
" el_pair = string(el,el)\n",
" d, β = fs84.singles[el].d, fs84.singles[el].β\n",
" ɸ = Molly.glue.(r, β, d)\n",
" append!(ɸs,[ɸ])\n",
" element_pairs = hcat(element_pairs, string(element_pair))\n",
" element_pairs = hcat(element_pairs, el_pair)\n",
"end"
]
},
Expand Down Expand Up @@ -311,18 +330,16 @@
"metadata": {},
"outputs": [],
"source": [
"ρ = collect(range(0, stop=50, length=100))\n",
"A = fs84.params.A[1] # Va\n",
"uₙ = Molly.Uglue.(ρ, A)\n",
"element_pair = fs84.params.element_pair[1];\n",
"el = \"V\"\n",
"ρ = collect(range(0, stop=50, length=100)) \n",
"uₙ = Molly.Uglue.(ρ, fs84.singles[el].A)\n",
"\n",
"uₙs = [uₙ]\n",
"element_pairs = [element_pair]\n",
"for i in 2:nrow(fs84.params)\n",
" element_pair, d, A, β, c, c₀, c₁, c₂ = fs84.params[i,:]\n",
" uₙ = Molly.Uglue.(ρ, A)\n",
"els = [el]\n",
"for el in elements[2:end]\n",
" uₙ = Molly.Uglue.(ρ, fs84.singles[el].A)\n",
" append!(uₙs,[uₙ])\n",
" element_pairs = hcat(element_pairs, string(element_pair))\n",
" els = hcat(els,el)\n",
"end"
]
},
Expand All @@ -332,7 +349,7 @@
"metadata": {},
"outputs": [],
"source": [
"plot(ρ, uₙs, label=element_pairs, xlabel=\"Glue density\", ylabel=\"Glue energy\", title=\"Glue energy varying with glue density\")"
"plot(ρ, uₙs, label=els, xlabel=\"Glue density\", ylabel=\"Glue energy\", title=\"Glue energy varying with glue density\")"
]
},
{
Expand Down Expand Up @@ -369,17 +386,20 @@
"metadata": {},
"outputs": [],
"source": [
"element_pair, d, A, β, c, c₀, c₁, c₂ = fs84.params[1,:] # parameters for Vanadium\n",
"el = \"V\"\n",
"el_pair = string(el,el)\n",
"c, c₀, c₁, c₂ = fs84.pairs[el_pair].c, fs84.pairs[el_pair].c₀, fs84.pairs[el_pair].c₁, fs84.pairs[el_pair].c₂\n",
"\n",
"V = Molly.Upair.(r, c, c₀, c₁, c₂)\n",
"\n",
"Vs = [V]\n",
"element_pairs = [element_pair]\n",
"for i in 2:nrow(fs84.params)\n",
" element_pair, d, A, β, c, c₀, c₁, c₂ = fs84.params[i,:]\n",
"element_pairs = [el_pair]\n",
"for el in elements[2:end]\n",
" el_pair = string(el,el)\n",
" c, c₀, c₁, c₂ = fs84.pairs[el_pair].c, fs84.pairs[el_pair].c₀, fs84.pairs[el_pair].c₁, fs84.pairs[el_pair].c₂\n",
" V = Molly.Upair.(r, c, c₀, c₁, c₂)\n",
" append!(Vs,[V])\n",
" element_pairs = hcat(element_pairs, string(element_pair))\n",
" element_pairs = hcat(element_pairs, string(el_pair))\n",
"end\n",
"\n",
"plot(r, Vs, label=element_pairs, xlabel=\"r\", ylabel=\"Pair energy contribution\", title=\"Pair energy vs separation\")"
Expand Down Expand Up @@ -415,10 +435,12 @@
"nx = 3\n",
"ny = 3\n",
"nz = 3\n",
"element = \"W\"\n",
"el = \"W\"\n",
"\n",
"a = bcc_lattice_constants[element]\n",
"atoms, coords, box, box_size, box_vectors = Crystal.make_bcc_unitcell(element, a=a)\n",
"a = bcc_lattice_constants[el]\n",
"el2atom_map = Dict(el=>Atom(name=el, mass=masses[el]))\n",
"elements = [el for _ in 1:2]\n",
"atoms, coords, box, box_size, box_vectors = Crystal.make_bcc_unitcell(elements, a=a, el2atom_map=el2atom_map)\n",
"sc_atoms, sc_coords, sc_box, sc_box_size = Crystal.make_supercell(atoms, coords, box, box_size, nx=nx, ny=ny, nz=nz)\n",
"n_atoms = length(sc_atoms)"
]
Expand All @@ -437,12 +459,12 @@
"outputs": [],
"source": [
"T = 300. # Kelvin\n",
"T *= kb\n",
"T *= fs84.kb\n",
"n_steps = 5000\n",
"dt = .002 # ps; ns = 1e-9, ps = 1e-12, fs = 1e-15\n",
"\n",
"general_inters = (fs84,)\n",
"velocities = [velocity(sc_atoms[i].mass, T, dims=3) for i in 1:n_atoms]\n",
"velocities = [velocity(atom.mass, T, dims=3) for atom in sc_atoms]\n",
"nb_matrix = trues(n_atoms,n_atoms)\n",
"dist_cutoff = 2 * a\n",
"nf = DistanceNeighbourFinder(nb_matrix, 1, dist_cutoff)\n",
Expand Down Expand Up @@ -515,7 +537,7 @@
"outputs": [],
"source": [
"x = collect(1:length(s.loggers[\"temperature\"].temperatures))\n",
"y = s.loggers[\"temperature\"].temperatures/kb\n",
"y = s.loggers[\"temperature\"].temperatures/fs84.kb\n",
"plot(x,y,title=\"Temperature\",legend=false)"
]
},
Expand Down
Loading