Skip to content

Commit

Permalink
Merge branch 'python' into python
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jun 7, 2021
2 parents 1bad96b + 6369253 commit a43b610
Show file tree
Hide file tree
Showing 118 changed files with 1,697 additions and 1,471 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
jobs:
deploy_docs:
runs-on: ubuntu-20.04
if: github.repository == 'espressomd/espresso'
environment: deploy_documentation
steps:
- name: Install pandoc
Expand Down
14 changes: 8 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ canonical, isobaric-isothermal, (semi-)grand canonical, reaction, constant pH,
Gibbs ensemble) and non-equilibrium situations, using standard potentials
such as the Lennard-Jones or Morse potential. It contains many advanced
simulation algorithms, which take into account hydrodynamic
(lattice-Boltzmann) and electrostatic interactions (P3M, ELC, MMMxD).
(lattice-Boltzmann) and electrostatic interactions (P3M, ELC, MMM1D).
Rigid bodies can be modelled by virtual site interactions, and it can
integrate rotationally non-invariant particles.

Expand All @@ -53,14 +53,16 @@ contributors from all over the world.
The [user guide](https://espressomd.github.io/doc/index.html) will
walk you through the basic usage of ESPResSo. Advanced simulation
methods are extensively documented, with examples and links to the
relevant literature. Additional resources can be found on the
homepage at http://espressomd.org/wordpress/documentation/, such
as tutorials and doxygen documentation.
relevant literature. Additional resources such as tutorials and
doxygen documentation can be found on https://espressomd.github.io.
The official website is http://espressomd.org/wordpress/.

## Installation

Detailed installation instructions for Ubuntu and macOS can be found in the
documentation, section [Installation](https://espressomd.github.io/doc/installation.html).
user guide, section [Installation](https://espressomd.github.io/doc/installation.html).
Common installation issues are addressed in the
[FAQ](https://github.com/espressomd/espresso/wiki/Installation-FAQ).

For most users, we recommend downloading the latest release version of ESPResSo. You
can find it in the [release page](https://github.com/espressomd/espresso/releases),
Expand Down Expand Up @@ -88,7 +90,7 @@ publications, as indicated in the documentation. For detailed instructions, see

## License

Copyright (C) 2010-2019 The ESPResSo project
Copyright (C) 2010-2021 The ESPResSo project

Copyright (C) 2002-2010 Max-Planck-Institute for Polymer Research, Theory Group

Expand Down
11 changes: 11 additions & 0 deletions doc/doxygen/bibliography.bib
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,17 @@ @Article{ladd94a
doi = {10.1017/S0022112094001771},
}

@Article{landsgesell17b,
author = {Landsgesell, Jonas and Holm, Christian and Smiatek, Jens},
title = {{Simulation of weak polyelectrolytes: A comparison between the constant pH and the reaction ensemble method}},
journal = {European Physical Journal Special Topics},
year = {2017},
volume = {226},
number = {4},
pages = {725-736},
doi = {10.1140/epjst/e2016-60324-3},
}

@Article{marsili10a,
author = {Marsili, Simone and Signorini, Giorgio Federico and Chelli, Riccardo and Marchi, Massimo and Procacci, Piero},
title = {{{ORAC}: A molecular dynamics simulation program to explore free energy surfaces in biomolecular systems at the atomistic level}},
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx/analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ Ref. :cite:`ramirez10a`.

The choice of the compression function also influences the statistical
accuracy and can even lead to systematic errors. The default compression
function is which discards the second for the compressed values and
function discards the second value and
pushes the first one to the higher level. This is robust and can be
applied universally to any combination of observables and correlation
operation. On the other hand, it reduces the statistical accuracy as the
Expand Down
13 changes: 11 additions & 2 deletions doc/tutorials/ferrofluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ configure_tutorial_target(
ferrofluid_part3.ipynb figures/Electro-Steric_Stabilization.jpg
figures/Ferrofluid_Magnet_under_glass_edit.jpg figures/headtotailconf.png)

nb_export(TARGET tutorial_fe SUFFIX "1" FILE "ferrofluid_part1.ipynb" HTML_RUN
VAR_SUBST "EQUIL_STEPS=100;EQUIL_ROUNDS=10")
nb_export(
TARGET
tutorial_fe
SUFFIX
"1"
FILE
"ferrofluid_part1.ipynb"
HTML_RUN
VAR_SUBST
"EQUIL_STEPS=100;EQUIL_ROUNDS=10;\"CI_DP3M_PARAMS={'cao':3,'r_cut':8.34,'mesh':[8,8,8],'alpha':0.2115,'tune':False}\""
)
nb_export(TARGET tutorial_fe SUFFIX "2" FILE "ferrofluid_part2.ipynb" HTML_RUN
VAR_SUBST
"equil_steps=100;equil_rounds=10;alphas=[0,1,2,3,4.5,8];loops=100")
Expand Down
3 changes: 2 additions & 1 deletion doc/tutorials/ferrofluid/ferrofluid_part1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,9 @@
},
"outputs": [],
"source": [
"CI_DP3M_PARAMS = {} # debug variable for continuous integration, can be left empty\n",
"# Setup dipolar P3M and dipolar layer correction\n",
"dp3m = DipolarP3M(accuracy=5E-4, prefactor=DIP_LAMBDA * LJ_SIGMA**3 * KT)\n",
"dp3m = DipolarP3M(accuracy=5E-4, prefactor=DIP_LAMBDA * LJ_SIGMA**3 * KT, **CI_DP3M_PARAMS)\n",
"dlc = DLC(maxPWerror=1E-4, gap_size=BOX_SIZE - LJ_SIGMA)\n",
"system.actors.add(dp3m)\n",
"system.actors.add(dlc)\n",
Expand Down
4 changes: 4 additions & 0 deletions maintainer/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ python_benchmark(
FILE p3m.py ARGUMENTS
"--particles_per_core=10000;--volume_fraction=0.25;--prefactor=4")

python_benchmark(
FILE lb.py ARGUMENTS
"--particles_per_core=125;--volume_fraction=0.03;--lb_sites_per_core=28")

add_custom_target(
benchmark_python COMMAND ${CMAKE_CTEST_COMMAND} --timeout ${TEST_TIMEOUT}
${CTEST_ARGS} --output-on-failure)
Expand Down
183 changes: 183 additions & 0 deletions maintainer/benchmarks/lb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#
# Copyright (C) 2013-2019 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

"""
Benchmark Lattice-Boltzmann fluid + Lennard-Jones particles
"""
import os
import sys
import numpy as np
from time import time
import argparse

parser = argparse.ArgumentParser(description="Benchmark LB simulations. "
"Save the results to a CSV file.")
parser.add_argument("--particles_per_core", metavar="N", action="store",
type=int, default=125, required=False,
help="Number of particles in the simulation box")
parser.add_argument("--lb_sites_per_particle", metavar="N_LB", action="store",
type=float, default=28, required=False,
help="Number of particles in the simulation box")
parser.add_argument("--volume_fraction", metavar="FRAC", action="store",
type=float, default=0.03, required=False,
help="Fraction of the simulation box volume occupied by "
"particles (range: [0.01-0.74], default: 0.50)")
group = parser.add_mutually_exclusive_group()
group.add_argument("--output", metavar="FILEPATH", action="store",
type=str, required=False, default="benchmarks.csv",
help="Output file (default: benchmarks.csv)")

args = parser.parse_args()

# process and check arguments
n_iterations = 30
assert args.volume_fraction > 0, "volume_fraction must be a positive number"
assert args.volume_fraction < np.pi / (3 * np.sqrt(2)), \
"volume_fraction exceeds the physical limit of sphere packing (~0.74)"


import espressomd
required_features = ["LENNARD_JONES"]
espressomd.assert_features(required_features)


# System
#############################################################
system = espressomd.System(box_l=[1, 1, 1])

# Interaction parameters (Lennard-Jones)
#############################################################

lj_eps = 1.0 # LJ epsilon
lj_sig = 1.0 # particle diameter
lj_cut = lj_sig * 2**(1. / 6.) # cutoff distance

# System parameters
#############################################################

n_proc = system.cell_system.get_state()['n_nodes']
n_part = n_proc * args.particles_per_core
# volume of N spheres with radius r: N * (4/3*pi*r^3)
box_l = (n_part * 4. / 3. * np.pi * (lj_sig / 2.)**3
/ args.volume_fraction)**(1. / 3.)
lb_grid = int((round(n_part * args.lb_sites_per_particle)**(1. / 3)))
agrid = box_l / lb_grid
measurement_steps = int(max(120**3 / lb_grid**3, 50))

# System
#############################################################
system.box_l = 3 * (box_l,)

# PRNG seeds
#############################################################
# np.random.seed(1)

# Integration parameters
#############################################################
system.time_step = 0.01
system.cell_system.skin = 0.5
system.thermostat.turn_off()


#############################################################
# Setup System #
#############################################################

# Interaction setup
#############################################################
system.non_bonded_inter[0, 0].lennard_jones.set_params(
epsilon=lj_eps, sigma=lj_sig, cutoff=lj_cut, shift="auto")


# Particle setup
#############################################################

# Warmup Integration #
#############################################################

system.integrator.set_steepest_descent(
f_max=0,
gamma=0.001,
max_displacement=0.01)

# warmup
while system.analysis.energy()["total"] > 0.1 * n_part:
print("minimization: {:.1f}".format(system.analysis.energy()["total"]))
system.integrator.run(20)
print("minimization: {:.1f}".format(system.analysis.energy()["total"]))
print()
system.integrator.set_vv()

system.thermostat.set_langevin(kT=1.0, gamma=1.0, seed=42)

# tuning and equilibration
print("Tune skin: {}".format(system.cell_system.tune_skin(
min_skin=0.2, max_skin=1, tol=0.05, int_steps=100)))
system.integrator.run(500)
print("Tune skin: {}".format(system.cell_system.tune_skin(
min_skin=0.2, max_skin=1, tol=0.05, int_steps=100)))
system.integrator.run(500)


system.thermostat.turn_off()
print("lb sites", lb_grid, "agrid", agrid)
if "LBFluid" in dir(espressomd.lb):
LBClass = espressomd.lb.LBFluid
elif "LBFluidWalberla" in dir(espressomd.lb):
LBClass = espressomd.lb.LBFluidWalberla
else:
raise Exception("LB not built in")

lbf = LBClass(agrid=agrid, dens=1, visc=1, tau=system.time_step, kT=1, seed=1)
system.actors.add(lbf)
print("lb shape", lbf.shape)
system.thermostat.set_lb(gamma=10, LB_fluid=lbf, seed=2)


# time integration loop
print("Timing every {} steps".format(measurement_steps))
main_tick = time()
all_t = []
for i in range(n_iterations):
tick = time()
system.integrator.run(measurement_steps)
tock = time()
t = (tock - tick) / measurement_steps
print("step {}, time = {:.2e}, verlet: {:.2f}, energy: {:.2e}"
.format(i, t, system.cell_system.get_state()["verlet_reuse"],
system.analysis.energy()["total"]))
all_t.append(t)
main_tock = time()
# average time
all_t = np.array(all_t)
avg = np.average(all_t)
ci = 1.96 * np.std(all_t) / np.sqrt(len(all_t) - 1)
print("average: {:.3e} +/- {:.3e} (95% C.I.)".format(avg, ci))

cmd = " ".join(x for x in sys.argv[1:] if not x.startswith("--output"))
report = ('"{script}","{arguments}",{cores},{mean:.3e},'
'{ci:.3e},{n},{dur:.1f}\n'.format(
script=os.path.basename(sys.argv[0]), arguments=cmd,
cores=n_proc, dur=main_tock - main_tick, n=measurement_steps,
mean=avg, ci=ci))
if not os.path.isfile(args.output):
report = ('"script","arguments","cores","mean","ci",'
'"nsteps","duration"\n' + report)
with open(args.output, "a") as f:
f.write(report)
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ set(EspressoCore_SRC
forces.cpp
galilei.cpp
ghosts.cpp
global.cpp
grid.cpp
immersed_boundaries.cpp
interactions.cpp
Expand Down
4 changes: 1 addition & 3 deletions src/core/EspressoSystemStandAlone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "EspressoSystemStandAlone.hpp"
#include "communication.hpp"
#include "global.hpp"
#include "grid.hpp"
#include "integrate.hpp"
#include "virtual_sites.hpp"
Expand Down Expand Up @@ -66,6 +65,5 @@ void EspressoSystemStandAlone::set_time_step(double time_step) const {
void EspressoSystemStandAlone::set_skin(double new_skin) const {
if (!head_node)
return;
skin = new_skin;
mpi_bcast_parameter(FIELD_SKIN);
mpi_set_skin(new_skin);
}
Loading

0 comments on commit a43b610

Please sign in to comment.