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

Wang frenkel #1970

Open
wants to merge 29 commits into
base: trunk-minor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
11bf777
Bump the actions-version group with 2 updates
dependabot[bot] Dec 1, 2024
98e7a3d
Bump the pip-version group with 2 updates
dependabot[bot] Dec 3, 2024
2b913eb
Merge pull request #1960 from glotzerlab/dependabot-github_actions-tr…
joaander Dec 3, 2024
ab1ba91
Merge pull request #1959 from glotzerlab/dependabot-pip-trunk-patch-p…
joaander Dec 3, 2024
34899f9
Validate that NEC integators can be executed.
joaander Dec 5, 2024
0b75683
Remove spurious future import.
joaander Dec 5, 2024
2b0b1d6
Fix and test Python initialization of NEC.
joaander Dec 5, 2024
1d72e14
Fix NEC integrators.
joaander Dec 5, 2024
5a06d24
Document NEC fix.
joaander Dec 5, 2024
661d39e
Execute NEC test in serial.
joaander Dec 5, 2024
58b7ba5
Merge pull request #1965 from glotzerlab/fix-nec
joaander Dec 5, 2024
bde251f
Potential compiles & runs, needs proper testing & variable names in s…
MartinGirard Dec 15, 2024
cb9142a
Merge branch 'glotzerlab:trunk-patch' into WangFrenkel
MartinGirard Dec 15, 2024
2c11f78
fix: bad powers, missing gpu export
MartinGirard Dec 16, 2024
4738b46
Merge remote-tracking branch 'origin/WangFrenkel' into WangFrenkel
MartinGirard Dec 16, 2024
5aa4f91
docfixes
MartinGirard Dec 16, 2024
7cc457f
integer
MartinGirard Dec 17, 2024
badf0be
Fix variable names, set exponent type to unsigned
MartinGirard Dec 17, 2024
3e6ddda
fix docs
MartinGirard Dec 17, 2024
7148627
fix potential negative integer powers
MartinGirard Dec 17, 2024
7816d7a
docfix
MartinGirard Dec 17, 2024
01fdc5a
type fix
MartinGirard Dec 17, 2024
6394406
more docfixes
MartinGirard Dec 17, 2024
d100612
citation & notes
MartinGirard Dec 17, 2024
ea2db28
Check that exponents are valid
MartinGirard Dec 18, 2024
0381337
missing exponent in docs
MartinGirard Dec 19, 2024
aaa503d
add pytests for Wang-Frenkel
MartinGirard Dec 19, 2024
965500e
fix names & bad exponent in shift
MartinGirard Dec 19, 2024
24ed54b
fix changelog
MartinGirard Dec 19, 2024
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: 2 additions & 2 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
submodules: true

- name: Create Python Environment
uses: mamba-org/setup-micromamba@617811f69075e3fd3ae68ca64220ad065877f246 # v2.0.0
uses: mamba-org/setup-micromamba@06375d89d211a1232ef63355742e9e2e564bc7f7 # v2.0.2
with:
micromamba-version: '2.0.2-2'
environment-name: test
Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
path: code

- name: Create Python Environment
uses: mamba-org/setup-micromamba@617811f69075e3fd3ae68ca64220ad065877f246 # v2.0.0
uses: mamba-org/setup-micromamba@06375d89d211a1232ef63355742e9e2e564bc7f7 # v2.0.2
with:
micromamba-version: '2.0.2-2'
environment-name: test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
name: release

- name: Create release
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
if: startsWith(github.ref, 'refs/tags/v')
with:
files: "*.tar.*"
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Change Log
5.x
---

*Added*
* Wang-Frenkel potential

5.0.1 (not yet released)
^^^^^^^^^^^^^^^^^^^^^^^^

*Fixed*

* Prevent ``missing 1 required positional argument: 'kT'`` errors when using NEC integrators
(`#1965 <https://github.com/glotzerlab/hoomd-blue/pull/1965>`__)


5.0.0 (2024-12-02)
^^^^^^^^^^^^^^^^^^

Expand Down
44 changes: 44 additions & 0 deletions hoomd/HOOMDMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,50 @@ inline HOSTDEVICE double pow(double x, double y)
return ::exp(y * log(x));
}

//! Compute the pow of x,y in double precision when y is an integer using squaring
inline HOSTDEVICE double pow(double x, unsigned int y){
double result = 1.0;
for(;;){
if(y & 1)
result *= x;
y >>= 1;
if(!y)
break;
x *= x;
}
return result;
}

inline HOSTDEVICE double pow(double x, int y){
unsigned int _y = abs(y);
if(y < 0)
return 1.0 / pow(x, _y);
else
return pow(x,_y);
}

//! Compute the pow of x,y in single precision when y is an integer using squaring
inline HOSTDEVICE float pow(float x, unsigned int y){
float result = 1.0f;
for(;;){
if(y & 1)
result *= x;
y >>= 1;
if(!y)
break;
x *= x;
}
return result;
}

inline HOSTDEVICE float pow(float x, int y){
unsigned int _y = abs(y);
if(y < 0)
return 1.0f / pow(x, _y);
else
return pow(x,_y);
}

//! Compute the exp of x
inline HOSTDEVICE float exp(float x)
{
Expand Down
74 changes: 40 additions & 34 deletions hoomd/hpmc/IntegratorHPMCMonoNEC.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,12 @@ template<class Shape> void IntegratorHPMCMonoNEC<Shape>::update(uint64_t timeste
this->m_exec_conf->msg->notice(10) << "HPMCMonoEC update: " << timestep << std::endl;
IntegratorHPMC::update(timestep);

// get needed vars
ArrayHandle<hpmc_counters_t> h_counters(this->m_count_total,
access_location::host,
access_mode::readwrite);
hpmc_counters_t& counters = h_counters.data[0];

ArrayHandle<hpmc_nec_counters_t> h_nec_counters(m_nec_count_total,
access_location::host,
access_mode::readwrite);
hpmc_nec_counters_t& nec_counters = h_nec_counters.data[0];
m_nec_count_step_start = h_nec_counters.data[0];
{
ArrayHandle<hpmc_nec_counters_t> h_nec_counters(m_nec_count_total,
access_location::host,
access_mode::readwrite);
m_nec_count_step_start = h_nec_counters.data[0];
}

const BoxDim& box = this->m_pdata->getBox();
unsigned int ndim = this->m_sysdef->getNDimensions();
Expand All @@ -294,29 +289,6 @@ template<class Shape> void IntegratorHPMCMonoNEC<Shape>::update(uint64_t timeste
count_pressurevirial = 0.0;
count_movelength = 0.0;

// access interaction matrix
ArrayHandle<unsigned int> h_overlaps(this->m_overlaps,
access_location::host,
access_mode::read);
ArrayHandle<int3> h_image(this->m_pdata->getImages(),
access_location::host,
access_mode::readwrite);

// access particle data
ArrayHandle<Scalar4> h_postype(this->m_pdata->getPositions(),
access_location::host,
access_mode::readwrite);
ArrayHandle<Scalar4> h_velocities(this->m_pdata->getVelocities(),
access_location::host,
access_mode::readwrite);
ArrayHandle<Scalar4> h_orientation(this->m_pdata->getOrientationArray(),
access_location::host,
access_mode::readwrite);

// access move sizes
ArrayHandle<Scalar> h_d(this->m_d, access_location::host, access_mode::read);
ArrayHandle<Scalar> h_a(this->m_a, access_location::host, access_mode::read);

uint16_t seed = this->m_sysdef->getSeed();

// loop over local particles nselect times
Expand All @@ -333,6 +305,40 @@ template<class Shape> void IntegratorHPMCMonoNEC<Shape>::update(uint64_t timeste
// update the image list
this->updateImageList();

// get needed vars
ArrayHandle<hpmc_counters_t> h_counters(this->m_count_total,
access_location::host,
access_mode::readwrite);
hpmc_counters_t& counters = h_counters.data[0];

ArrayHandle<hpmc_nec_counters_t> h_nec_counters(m_nec_count_total,
access_location::host,
access_mode::readwrite);
hpmc_nec_counters_t& nec_counters = h_nec_counters.data[0];

// access interaction matrix
ArrayHandle<unsigned int> h_overlaps(this->m_overlaps,
access_location::host,
access_mode::read);
ArrayHandle<int3> h_image(this->m_pdata->getImages(),
access_location::host,
access_mode::readwrite);

// access particle data
ArrayHandle<Scalar4> h_postype(this->m_pdata->getPositions(),
access_location::host,
access_mode::readwrite);
ArrayHandle<Scalar4> h_velocities(this->m_pdata->getVelocities(),
access_location::host,
access_mode::readwrite);
ArrayHandle<Scalar4> h_orientation(this->m_pdata->getOrientationArray(),
access_location::host,
access_mode::readwrite);

// access move sizes
ArrayHandle<Scalar> h_d(this->m_d, access_location::host, access_mode::read);
ArrayHandle<Scalar> h_a(this->m_a, access_location::host, access_mode::read);

// loop through N particles in a shuffled order
for (unsigned int cur_chain = 0; cur_chain < this->m_pdata->getN() * m_update_fraction;
cur_chain++)
Expand Down
2 changes: 0 additions & 2 deletions hoomd/hpmc/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
particles and `SDF` samples the pressure.
"""

from __future__ import print_function

from hoomd import _hoomd
from hoomd.operation import Compute
from hoomd.hpmc import _hpmc
Expand Down
2 changes: 1 addition & 1 deletion hoomd/hpmc/nec/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
nselect=1,
):
# initialize base class
super().__init__(default_d, default_a, 0.5, nselect)
super().__init__(default_d, default_a, 0.5, nselect, 1.0)

# Set base parameter dict for hpmc chain integrators
param_dict = ParameterDict(
Expand Down
3 changes: 2 additions & 1 deletion hoomd/hpmc/pytest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ set(files __init__.py
test_shape_updater.py
test_shape_utils.py
test_move_size_tuner.py
test_nec.py
test_pair_lennard_jones.py
test_pair_expanded_gaussian.py
test_pair_lj_gauss.py
test_pair_lj_gauss.py
test_pair_opp.py
test_pair_step.py
test_pair_union.py
Expand Down
15 changes: 15 additions & 0 deletions hoomd/hpmc/pytest/test_nec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2009-2024 The Regents of the University of Michigan.
# Part of HOOMD-blue, released under the BSD 3-Clause License.

import hoomd
import pytest


@pytest.mark.serial
def test_nec(simulation_factory, lattice_snapshot_factory):
snap = lattice_snapshot_factory(particle_types=["A"])
simulation = simulation_factory(snap)
sphere = hoomd.hpmc.nec.integrate.Sphere()
sphere.shape["A"] = {"diameter": 1.0}
simulation.operations.integrator = sphere
simulation.run(10)
4 changes: 3 additions & 1 deletion hoomd/md/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ set(_md_headers ActiveForceComputeGPU.h
EvaluatorPairTable.h
EvaluatorPairTWF.h
EvaluatorPairYukawa.h
EvaluatorPairWangFrenkel.h
EvaluatorPairZBL.h
EvaluatorTersoff.h
EvaluatorWalls.h
Expand Down Expand Up @@ -556,7 +557,8 @@ set(_pair_evaluators Buckingham
LJGauss
ForceShiftedLJ
Table
ExpandedGaussian)
ExpandedGaussian
WangFrenkel)


foreach(_evaluator ${_pair_evaluators})
Expand Down
Loading
Loading