RaulPPelaez / UAMMD

A CUDA project for Molecular Dynamics, Brownian Dynamics, Hydrodynamics... intended to simulate a very generic system constructing a simulation with modules.
GNU General Public License v3.0
51 stars 11 forks source link

Make DPD an Integrator instead of a Potential #34

Open RaulPPelaez opened 6 months ago

RaulPPelaez commented 6 months ago

Currently, DPD is encoded as a Potential that must be used in conjunction with VerletNVE. This can be confusing to the user and its awkward to explain. For instance, if you need DPD you need to include "VerletNVE.cuh":

#include<uammd.cuh>
#include<Integrator/VerletNVE.cuh>
#include<Interactor/PairForces.cuh>
#include<Interactor/Potential/DPD.cuh>
using namespace uammd;
//A function that creates and returns a DPD integrator
auto createIntegratorDPD(UAMMD sim){
  Potential::DPD::Parameters par;
  par.temperature = sim.par.temperature;
  //The cut off for the weight function
  par.cutOff = sim.par.cutOff;
  //The friction coefficient
  par.gamma = sim.par.friction;
  //The strength of the weight function
  par.A = sim.par.strength;
  par.dt = sim.par.dt;
  auto dpd = make_shared<Potential::DPD>(dpd);
  //From the example in PairForces
  auto interactor = createPairForcesWithPotential(sim, dpd);
  //From the example in the MD section
  // particle velocities should not be initialized
  // by VerletNVE (initVelocities=false)
  using NVE = VerletNVE;
  NVE::Parameters params;
  params.dt = par.dt;
  params.initVelocities=false;
  verlet = make_shared<NVE>(pd,  params);
  verlet->addInteractor(interactor);
  return verlet;
}

It would be great if instead one could

#include<uammd.cuh>
#include<Integrator/DPD.cuh>
using namespace uammd;
//A function that creates and returns a DPD integrator
auto createIntegratorDPD(UAMMD sim){
  DPDIntegrator::Parameters par;
  par.temperature = sim.par.temperature;
  //The cut off for the weight function
  par.cutOff = sim.par.cutOff;
  //The friction coefficient
  par.gamma = sim.par.friction;
  //The strength of the weight function
  par.A = sim.par.strength;
  par.dt = sim.par.dt;
  par.initVelocities=false;
  dpd = make_shared<DPDIntegrator>(pd,  params);
  return dpd;
}

This would also make it easier to improve/change the algorithm specifically for DPD should the need arise.

RaulPPelaez commented 6 months ago

cc @PabloIbannez @PabloPalaciosAlonso could you step in here?

PabloPalaciosAlonso commented 6 months ago

Sure, I can do it