Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 solvers/NBody/mobility.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class NBody : public libmobility::Mobility {
real wallHeight; // location of the wall in z

// Batched functionality configuration
int Nbatch;
int NperBatch;
int Nbatch = -1;
int NperBatch = -1;

std::mt19937 rng;

Expand Down
6 changes: 4 additions & 2 deletions solvers/PSE/mobility.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "extra/uammd_interface.h"
#include <MobilityInterface/MobilityInterface.h>
#include <cmath>
#include <optional>
#include <type_traits>
#include <vector>

Expand Down Expand Up @@ -50,15 +51,16 @@ class PSE : public libmobility::Mobility {
}

struct PSEParameters {
real psi, Lx, Ly, Lz, shearStrain;
real psi, Lx, Ly, Lz;
std::optional<real> shearStrain = std::nullopt;
};

void setParametersPSE(PSEParameters i_par) {
psepar.psi = i_par.psi;
psepar.Lx = i_par.Lx;
psepar.Ly = i_par.Ly;
psepar.Lz = i_par.Lz;
psepar.shearStrain = i_par.shearStrain;
psepar.shearStrain = i_par.shearStrain ? i_par.shearStrain.value() : 0.0;
}

void setPositions(device_span<const real> ipositions) override {
Expand Down
16 changes: 8 additions & 8 deletions solvers/PSE/python_wrapper.cu
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ This module will only accept periodic boundary conditions in the three direction
)pbdoc";

MOBILITY_PYTHONIFY_WITH_EXTRA_CODE(
PSE,
solver.def(
"setParameters",
[](PSE &self, real psi, real Lx, real Ly, real Lz, real shearStrain) {
self.setParametersPSE({psi, Lx, Ly, Lz, shearStrain});
},
docstringSetParameters, "psi"_a, "Lx"_a, "Ly"_a, "Lz"_a,
"shearStrain"_a);
PSE, solver.def(
"setParameters",
[](PSE &self, real psi, real Lx, real Ly, real Lz,
std::optional<real> shearStrain) {
self.setParametersPSE({psi, Lx, Ly, Lz, shearStrain});
},
docstringSetParameters, "psi"_a, "Lx"_a, "Ly"_a, "Lz"_a,
"shearStrain"_a = std::nullopt);
, docstring);
18 changes: 18 additions & 0 deletions tests/test_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ def test_nbody_default_parameters():
solver.setPositions(positions)


def test_pse_no_shear():
solver = PSE("periodic", "periodic", "periodic")
solver.setParameters(psi=1.0, Lx=10.0, Ly=10.0, Lz=10.0)
solver.initialize(hydrodynamicRadius=1.0, viscosity=1.0)


# NBody should use default alg and all particles in one batch if no params set
def test_nbody_no_params():
solver = NBody("open", "open", "open")
solver.initialize(
viscosity=1.0,
hydrodynamicRadius=1.5,
)
positions = np.random.rand(10, 3)
solver.setPositions(positions)
mf, _ = solver.Mdot(positions)


@pytest.mark.parametrize(
("NBatch", "NperBatch", "numberParticles"),
[
Expand Down