Skip to content

Commit adb78fb

Browse files
committed
Update documentation
Stylistic revision.
1 parent 5c249c9 commit adb78fb

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Build status](https://ci.appveyor.com/api/projects/status/1ofg9ianvcciq26v?svg=true)](https://ci.appveyor.com/project/Mikhail-Vaganov/nbodysimulator-jl)
55

66
This project is under development at the moment. The implementation of potential calculations is fairly experimental and has not been extensively verified yet.
7-
You can test simulation of different systems now but be aware of possible changes in future.
7+
You can test simulation of different systems now but be aware of possible changes in the future.
88

99
## Add Package
1010

@@ -15,12 +15,12 @@ In order to start simulating systems of N interacting bodies, it is necessary to
1515
using NBodySimulator
1616
```
1717

18-
If you cannot wait to start codding, try to run some scripts from `examples` folder. The number of particles `N` and the final timestep of simulations `t2` are the two parameters which will determine the time of script execution.
18+
If you cannot wait to start coding, try to run some scripts from the `examples` folder. The number of particles `N` and the final timestep of simulations `t2` are the two parameters which will determine the time of script execution.
1919

2020
## Basic Components
21-
There are three basic components required for any simulation of systems of N-bodies: `bodies`, `system` and `simulation`.
21+
There are three basic components required for any simulation of systems of N-bodies: `bodies`, `system`, and `simulation`.
2222

23-
**Bodies** or **Particles** are the objects which will interact with each other and for which the equations of Newton's 2nd law are solved during the simulation process. Three parameters of a body are necessary, they are initial location, initial velocity and mass. `MassBody` structure represents such particles:
23+
**Bodies** or **Particles** are the objects which will interact with each other and for which the equations of Newton's 2nd law are solved during the simulation process. Three parameters of a body are necessary, namely: initial location, initial velocity, and mass. `MassBody` structure represents such particles:
2424

2525
```julia
2626
using StaticArrays
@@ -29,7 +29,7 @@ v = SVector(.1,.2,.5)
2929
mass = 1.25
3030
body = MassBody(r,v,mass)
3131
```
32-
For the sake of simulation speed it is advised to use [static arrays](https://github.com/JuliaArrays/StaticArrays.jl).
32+
For the sake of simulation speed, it is advised to use [static arrays](https://github.com/JuliaArrays/StaticArrays.jl).
3333

3434
A **System** covers bodies and necessary parameters for correct simulation of interaction between particles. For example, to create an entity for a system of gravitationally interacting particles, one needs to use `GravitationalSystem` constructor:
3535

@@ -38,7 +38,7 @@ const G = 6.67e-11 # m^3/kg/s^2
3838
system = GravitationalSystem(bodies, G)
3939
```
4040

41-
**Simulation** is an entity determining parameters of the experiment: time span of simulation, global physical constants, borders of the simulation cell, external magnetic or electric fields, etc. The required arguments for `NBodySImulation` constructor are the system to be tested and the time span of simulation.
41+
**Simulation** is an entity determining parameters of the experiment: time span of simulation, global physical constants, borders of the simulation cell, external magnetic or electric fields, etc. The required arguments for `NBodySImulation` constructor are the system to be tested and the time span of the simulation.
4242

4343
```julia
4444
tspan = (.0, 10.0)
@@ -79,14 +79,14 @@ spc_water_paramters = SPCFwParameters(rOH, ∠HOH, k_bond, k_angle)
7979

8080
The Lennard-Jones potential is used in molecular dynamics simulations for approximating interactions between neutral atoms or molecules. The [SPC/Fw water model](http://www.sklogwiki.org/SklogWiki/index.php/SPC/Fw_model_of_water) is used in water simulations. The meaning of arguments for `SPCFwParameters` constructor will be clarified further in this documentation.
8181

82-
`PotentialNBodySystem` structure represents systems with a custom set of potentials. In other words, the user determines the ways in which the particles are allowed to interact. One can pass the bodies and parameters of interaction potentials into that system. In case the potential parameters are not set, during the simulation particles will move at constant velocities without acceleration.
82+
`PotentialNBodySystem` structure represents systems with a custom set of potentials. In other words, the user determines the ways in which the particles are allowed to interact. One can pass the bodies and parameters of interaction potentials into that system. In the case the potential parameters are not set, the particles will move at constant velocities without acceleration during the simulation.
8383

8484
```julia
8585
system = PotentialNBodySystem(bodies, Dict(:gravitational => g_parameters, electrostatic: => el_potential))
8686
```
8787

8888
### Custom Potential
89-
There exists an [example](http://docs.juliadiffeq.org/dev/models/physical.html) of simulation of an N-body system at absolutely custom potential.
89+
There exists an [example](http://docs.juliadiffeq.org/dev/models/physical.html) of a simulation of an N-body system at absolutely custom potential.
9090

9191
Here is shown how to create custom acceleration functions using tools of NBodySimulator.
9292

@@ -98,33 +98,33 @@ struct CustomPotentialParameters <: PotentialParameters
9898
end
9999
```
100100

101-
Next, the acceleration function for the potential is required. The custom potential defined here creates a force acting on all the particles proportionate to their masses. The first argument of the function determines the potential for which the acceleration should be calculated in this method.
101+
Next, the acceleration function for the potential is required. The custom potential defined here creates a force acting on all the particles proportionate to their masses. The first argument of the function determines the potential for which the acceleration should be calculated in this method.
102102

103103
```julia
104104
import NBodySimulator.get_accelerating_function
105105
function get_accelerating_function(p::CustomPotentialParameters, simulation::NBodySimulation)
106106
ms = get_masses(simulation.system)
107-
(dv, u, v, t, i) -> begin custom_accel = SVector(0.0, 0.0, p.a); dv .= custom_accel*ms[i] end
107+
(dv, u, v, t, i) -> begin custom_accel = SVector(0.0, 0.0, p.a); dv .= custom_accel*ms[i] end
108108
end
109109
```
110110

111-
After the parameters and acceleration function are created, one can instantiate a system of particles interacting with a set of potentials which includes the just created custom potential:
111+
After the parameters and acceleration function have been created, one can instantiate a system of particles interacting with a set of potentials which includes the just-created custom potential:
112112

113113
```julia
114114
parameters = CustomPotentialParameters(-9.8)
115115
system = PotentialNBodySystem(bodies, Dict(:custom_potential_params => parameters))
116116
```
117117

118118
### Gravitational Interaction
119-
Using NBodySimulator it is possible to simulate gravitational interaction of celestial bodies.
119+
Using NBodySimulator, it is possible to simulate gravitational interaction of celestial bodies.
120120
In fact, any structure for bodies can be used for simulation of gravitational interaction since all those structures are required to have mass as one of their parameters:
121121

122122
```julia
123123
body1 = MassBody(SVector(0.0, 1.0, 0.0), SVector( 5.775e-6, 0.0, 0.0), 2.0)
124124
body2 = MassBody(SVector(0.0,-1.0, 0.0), SVector(-5.775e-6, 0.0, 0.0), 2.0)
125125
```
126126

127-
Solving gravitational problem one needs to specify the gravitational constant G.
127+
When solving a gravitational problem, one needs to specify the gravitational constant G.
128128
```julia
129129
G = 6.673e-11
130130
```
@@ -135,7 +135,7 @@ Now we have enough parameters to create a GravitationalSystem object:
135135
system = GravitationalSystem([body1,body2], G)
136136
```
137137

138-
Usually we solve an N-body problem for a certain period of time:
138+
Usually, we solve an N-body problem for a certain period of time:
139139

140140
```julia
141141
tspan = (0.0, 1111150.0)
@@ -159,7 +159,7 @@ animate(sim_result, "path_to_animated_particles.gif")
159159
### Electrostatic Interaction
160160
Interaction between charged particles obeys Coulomb's law. The movement of such bodies can be simulated using `ChargedParticle` and `ChargedParticles` structures.
161161

162-
The following example shows how to model two oppositely charged particles. If one body is more massive that another, it will be possible to observe rotation of the light body around the heavy one without adjusting their positions in space. The constructor for `ChargedParticles` system requires bodies and Coulomb's constant `k` to be passed as arguments.
162+
The following example shows how to model two oppositely charged particles. If one body is more massive than another, it will be possible to observe rotation of the light body around the heavy one without adjusting their positions in space. The constructor for the `ChargedParticles` system requires bodies and Coulomb's constant `k` to be passed as arguments.
163163

164164
```julia
165165
r = 100.0 # m
@@ -179,7 +179,7 @@ sim_result = run_simulation(simulation)
179179
### Magnetic Interaction
180180
An N-body system consisting of `MagneticParticle`s can be used for simulation of interacting magnetic dipoles, though such dipoles cannot rotate in space. Such a model can represent single domain particles interacting under the influence of a strong external magnetic field.
181181

182-
In order to create a magnetic particle, one specifies its location in space, velocity and the vector of its magnetic moment. The following code shows how we can construct an iron particle:
182+
In order to create a magnetic particle, one specifies its location in space, velocity, and the vector of its magnetic moment. The following code shows how we can construct an iron particle:
183183

184184
```julia
185185
iron_dencity = 7800 # kg/m^3
@@ -193,13 +193,13 @@ magnetic_moment = SVector(0.0, 0.0, magnetization_saturation * mass / iron_denci
193193
p1 = MagneticParticle(r, v, mass, magnetic_moment)
194194
```
195195

196-
For the second particle we will use a shorter form:
196+
For the second particle, we will use a shorter form:
197197

198198
```julia
199199
p2 = MagneticParticle(SVector(0.005, 0.0, 0.0), SVector(0.0, 0.0, 0.0), 5e-6, SVector(0.0,0.0,0.00077))
200200
```
201201

202-
To calculate magnetic interactions properly one should also specify the value for the constant μ<sub>0</sub>/4π or its substitute. Having created parameters for the magnetostatic potential, one can now instantiate a system of particles which should interact magnetically. For that purpose we use `PotentialNBodySystem` and pass particles and potential parameters as arguments.
202+
To calculate magnetic interactions properly, one should also specify the value for the constant μ<sub>0</sub>/4π or its substitute. Having created parameters for the magnetostatic potential, one can now instantiate a system of particles which should interact magnetically. For that purpose, we use `PotentialNBodySystem` and pass particles and potential parameters as arguments.
203203

204204
```julia
205205
parameters = MagnetostaticParameters(μ_4π)
@@ -209,14 +209,14 @@ sim_result = run_simulation(simulation, VelocityVerlet(), dt=τ)
209209
```
210210

211211
## Molecular Dynamics (MD)
212-
NBodySimulator allows one to conduct molecular dynamic simulations for the Lennard-Jones liquids, SPC/Fw model of water and other molecular systems thanks to implementations of basic interaction potentials between atoms and molecules:
212+
NBodySimulator allows one to conduct molecular dynamic simulations for the Lennard-Jones liquids, SPC/Fw model of water, and other molecular systems thanks to implementations of basic interaction potentials between atoms and molecules:
213213

214214
- Lennard-Jones
215215
- electrostatic and magnetostatic
216216
- harmonic bonds
217-
- harmonic valence angle generated by pairs of bonds
217+
- harmonic valence angle generated by pairs of bonds
218218

219-
The comprehensive examples of liquid argon and water simulations can be found in `examples` folder.
219+
The comprehensive examples of liquid argon and water simulations can be found in the `examples` folder.
220220
Here only the basic principles of the molecular dynamics simulations using NBodySimulator are presented using liquid argon as a classical MD system for beginners.
221221

222222
First of all, one needs to define parameters of the simulation:
@@ -244,7 +244,7 @@ Liquid argon consists of neutral molecules so the Lennard-Jones potential runs t
244244

245245
```julia
246246
parameters = LennardJonesParameters(ϵ, σ, R)
247-
lj_system = PotentialNBodySystem(bodies, Dict(:lennard_jones => parameters));
247+
lj_system = PotentialNBodySystem(bodies, Dict(:lennard_jones => parameters));
248248
```
249249

250250
Then, a thermostat and boundary conditions should be selected and instantiated:
@@ -264,10 +264,10 @@ simulation = NBodySimulation(lj_system, (t1, t2), pbc, thermostat);
264264
simulation = NBodySimulation(lj_system, (t1, t2), pbc, thermostat, kb);
265265
```
266266

267-
The default boundary conditions are `InfiniteBox` without any limits, default thermostat is `NullThermostat` which does no thermostating and default Boltzmann constant `kb` equals its value in SI, i.e. 1.38e-23 J/K.
267+
The default boundary conditions are `InfiniteBox` without any limits, default thermostat is `NullThermostat` (which does no thermostating), and the default Boltzmann constant `kb` equals its value in SI, i.e., 1.38e-23 J/K.
268268

269269
## Water Simulations
270-
In NBodySImulator the [SPC/Fw water model](http://www.sklogwiki.org/SklogWiki/index.php/SPC/Fw_model_of_water) is implemented. For using this model, one has to specify parameters of the Lennard-Jones potential between the oxygen atoms of water molecules, parameters of the electrostatic potential for the corresponding interactions between atoms of different molecules and parameters for harmonic potentials representing bonds between atoms and the valence angle made from bonds between hydrogen atoms and the oxygen one.
270+
In NBodySImulator the [SPC/Fw water model](http://www.sklogwiki.org/SklogWiki/index.php/SPC/Fw_model_of_water) is implemented. For using this model, one has to specify parameters of the Lennard-Jones potential between the oxygen atoms of water molecules, parameters of the electrostatic potential for the corresponding interactions between atoms of different molecules and parameters for harmonic potentials representing bonds between atoms and the valence angle made from bonds between hydrogen atoms and the oxygen atom.
271271

272272
```julia
273273
bodies = generate_bodies_in_cell_nodes(N, mH2O, v, L)
@@ -279,14 +279,14 @@ water = WaterSPCFw(bodies, mH, mO, qH, qO, jl_parameters, e_parameters, spc_par
279279

280280
For each water molecule here, `rOH` is the equilibrium distance between a hydrogen atom and the oxygen atom, `∠HOH` denotes the equilibrium angle made of those two bonds, `k_bond` and `k_angle` are the elastic coefficients for the corresponding harmonic potentials.
281281

282-
Further, one pass the water system into `NBodySimulation` constructor as a usual system of N-bodies.
282+
Further, one can pass the water system into the `NBodySimulation` constructor as a usual system of N-bodies.
283283

284284
```julia
285285
simulation = NBodySimulation(water, (t1, t2), pbc, kb);
286286
```
287287

288288
## Thermostats
289-
Usually during simulation of a system is required to be at a particular temperature. NBodySimulator contains several thermostats for that purpose. Here the thermostating of liquid argon is presented, for thermostating of water one can refer to [this post](https://mikhail-vaganov.github.io/gsoc-2018-blog/2018/08/06/thermostating.html)
289+
Usually, during the simulation, a system is required to be at a particular temperature. NBodySimulator contains several thermostats for that purpose. Here the thermostating of liquid argon is presented, for thermostating of water one can refer to [this post](https://mikhail-vaganov.github.io/gsoc-2018-blog/2018/08/06/thermostating.html)
290290

291291
### [Andersen Thermostat](http://www.sklogwiki.org/SklogWiki/index.php/Andersen_thermostat)
292292
```julia
@@ -319,17 +319,17 @@ thermostat = LangevinThermostat(90, γ)
319319
![langevin thermostating](https://user-images.githubusercontent.com/16945627/44002505-0683c6b0-9e5d-11e8-8647-5b15b98eb0fa.png)
320320

321321
## Analyzing the Result of Simulation
322-
Once the simulation is completed, one can analyze the result and obtain some useful characteristics of the system.
322+
Once the simulation is completed, one can analyze the result and obtain some useful characteristics of the system.
323323

324-
Function `run_simulation` returns a structure containing the initial parameters of simulation and the solution of differential equation (DE) required for description of the corresponding system of particles. There are different functions which help to interpret solution of DEs into physical quantities.
324+
The function `run_simulation` returns a structure containing the initial parameters of the simulation and the solution of the differential equation (DE) required for the description of the corresponding system of particles. There are different functions which help to interpret the solution of DEs into physical quantities.
325325

326326
One of the main characteristics of a system during molecular dynamics simulations is its thermodynamic temperature. The value of the temperature at a particular time `t` can be obtained via calling this function:
327327

328328
```julia
329-
T = temperature(result, t)
329+
T = temperature(result, t)
330330
```
331331

332-
### [Radial distribution functions](https://en.wikipedia.org/wiki/Radial_distribution_function)
332+
### [Radial distribution functions](https://en.wikipedia.org/wiki/Radial_distribution_function)
333333
The RDF is another popular and essential characteristic of molecules or similar systems of particles. It shows the reciprocal location of particles averaged by the time of simulation.
334334

335335
```julia
@@ -346,35 +346,35 @@ The MSD characteristic can be used to estimate the shift of particles from their
346346
```julia
347347
(ts, dr2) = msd(result)
348348
```
349-
For a standard liquid argon system the displacement grows with time:
349+
For a standard liquid argon system, the displacement grows with time:
350350
![rdf for liquid argon](https://user-images.githubusercontent.com/16945627/43990362-9a67c0aa-9d74-11e8-9512-08840294d411.png)
351351

352352
### Energy Functions
353353

354354
Energy is a highly important physical characteristic of a system. The module provides four functions to obtain it, though the `total_energy` function just sums potential and kinetic energy:
355355

356356
```julia
357-
e_init = initial_energy(simualtion)
357+
e_init = initial_energy(simulation)
358358
e_kin = kinetic_energy(result, t)
359359
e_pot = potential_energy(result, t)
360360
e_tot = total_energy(result, t)
361361
```
362362

363363
## Plotting Images
364-
Using tools of NBodySimulator one can export results of simulation into a [Protein Database File](https://en.wikipedia.org/wiki/Protein_Data_Bank_(file_format)). [VMD](http://www.ks.uiuc.edu/Research/vmd/) is a well-known tool for visualizing molecular dynamics, which can read data from PDB files.
364+
Using tools of NBodySimulator, one can export the results of a simulation into a [Protein Database File](https://en.wikipedia.org/wiki/Protein_Data_Bank_(file_format)). [VMD](http://www.ks.uiuc.edu/Research/vmd/) is a well-known tool for visualizing molecular dynamics, which can read data from PDB files.
365365

366366
```julia
367367
save_to_pdb(result, "path_to_a_new_pdb_file.pdb" )
368368
```
369369

370-
In future it will be possible to export results via FileIO interface and its `save` function.
370+
In the future it will be possible to export results via FileIO interface and its `save` function.
371371

372-
Using Plots.jl one can draw positions of particles at any time of simulation or create an animation of moving particles, molecules of water:
372+
Using Plots.jl, one can draw positions of particles at any time of simulation or create an animation of moving particles, molecules of water:
373373

374374
```julia
375375
using Plots
376376
plot(result)
377377
animate(result, "path_to_file.gif")
378378
```
379379

380-
Makie.jl also has a recipe for plotting results of N-body simulations. The [example](http://makie.juliaplots.org/stable/examples-meshscatter.html#Type-recipe-for-molecule-simulation-1) is presented in the documentation.
380+
Makie.jl also has a recipe for plotting the results of N-body simulations. The [example](http://makie.juliaplots.org/stable/examples-meshscatter.html#Type-recipe-for-molecule-simulation-1) is presented in the documentation.

0 commit comments

Comments
 (0)