Usage example

In Jumos, one run simulations by writting specials Julia scripts. A primer intoduction to the Julia language can be found here, if needed.

Lennard-Jones fluid

Here is a simple simulation script for running a simulation of a Lennard-Jones fluid at \(300K\).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Loading the Jumos module before anything else
using Jumos

# Molecular Dynamics with 1.0fs timestep
sim = MolecularDynamic(1.0)

# Create the simulation cell : cubic simulation cell with a width of 10A
set_cell(sim, (10.0,))

# Create the initial topology, positions and velocities
read_topology(sim, "lennard-jones.xyz")
read_positions(sim, "lennard-jones.xyz")
create_velocities(sim, 300)  # Initialize at 300K

# Add Lennard-Jones interactions between He atoms
add_interaction(sim, LennardJones(0.8, 2.0), "He")

out_trajectory = TrajectoryOutput("LJ-trajectory.xyz", 1)
add_output(sim, out_trajectory)
add_output(sim, EnergyOutput("LJ-energy.dat", 10))

run!(sim, 500)

# It is really easy to change some parameters if you bind them to variables
out_trajectory.frequency = 10

run!(sim, 5000)

# Simulation scripts are normal Julia scripts !
println("All done")

Each simulation script should start by the using Jumos directive. This imports the module and the exported names in the current scope.

Then, in this script, we create a molecular dynamics simulation with a timestep of \(1.0\ \text{fs}\), and associated a cubic cell to this simulation. The topology and the original positions are read from the same file, as an .xyz file contains topological information (mainly the atomics names).

The only interaction — a Lennard-Jones interaction — is also added to the simulation before the run. The next lines add some outputs to the simulation, namely a trajectory and an energy output. Finally, the simulation runs for a first 500 steps.

Any parameter can easily be changed during the simulation: here, at the line 25, we change the output frequency of the trajectory output, and then run the simulation for another 5000 steps.