Commit 06cebb9f authored by sjplimp's avatar sjplimp Committed by GitHub
Browse files

Merge pull request #445 from Pakketeretet2/extract_for_bond

Extract for bond
parents b9d844ca f19f5582
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -22,6 +22,11 @@ attribute = {pair} or {kspace} or {atom} :l
    pparam = parameter to adapt over time
    I,J = type pair(s) to set parameter for
    v_name = variable with name that calculates value of pparam
  {bond} args = bstyle bparam I v_name
    bstyle = bond style name, e.g. harmonic
    bparam = parameter to adapt over time
    I = type bond to set parameter for
    v_name = variable with name that calculates value of bparam
  {kspace} arg = v_name
    v_name = variable with name that calculates scale factor on K-space terms
  {atom} args = aparam v_name
@@ -42,7 +47,10 @@ keyword = {scale} or {reset} :l
fix 1 all adapt 1 pair soft a 1 1 v_prefactor
fix 1 all adapt 1 pair soft a 2* 3 v_prefactor
fix 1 all adapt 1 pair lj/cut epsilon * * v_scale1 coul/cut scale 3 3 v_scale2 scale yes reset yes
fix 1 all adapt 10 atom diameter v_size :pre
fix 1 all adapt 10 atom diameter v_size

variable ramp_up equal "ramp(0.01,0.5)"
fix stretch all adapt 1 bond harmonic r0 1 v_ramp_up :pre

[Description:]

@@ -192,6 +200,19 @@ fix 1 all adapt 1 pair soft a * * v_prefactor :pre

:line

The {bond} keyword uses the specified variable to change the value of
a bond coefficient over time, very similar to how the {pair} keyword
operates. The only difference is that now a bond coefficient for a
given bond type is adapted.

Currently {bond} does not support bond_style hybrid nor bond_style
hybrid/overlay as bond styles. The only bonds that currently are
working with fix_adapt are

"harmonic"_bond_harmonic.html: k,r0: type bonds :tb(c=3,s=:)

:line

The {kspace} keyword used the specified variable as a scale factor on
the energy, forces, virial calculated by whatever K-Space solver is
defined by the "kspace_style"_kspace_style.html command.  If the
+18 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@

#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "bond_harmonic.h"
#include "atom.h"
#include "neighbor.h"
@@ -26,7 +27,10 @@ using namespace LAMMPS_NS;

/* ---------------------------------------------------------------------- */

BondHarmonic::BondHarmonic(LAMMPS *lmp) : Bond(lmp) {}
BondHarmonic::BondHarmonic(LAMMPS *lmp) : Bond(lmp)
{
  reinitflag = 1;
}

/* ---------------------------------------------------------------------- */

@@ -196,3 +200,16 @@ double BondHarmonic::single(int type, double rsq, int i, int j,
  if (r > 0.0) fforce = -2.0*rk/r;
  return rk*dr;
}

/* ----------------------------------------------------------------------
    Return ptr to internal members upon request.
------------------------------------------------------------------------ */
void *BondHarmonic::extract( char *str, int &dim )
{
  dim = 1;
  if( strcmp(str,"kappa")==0) return (void*) k;
  if( strcmp(str,"r0")==0) return (void*) r0;
  return NULL;
}

+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ class BondHarmonic : public Bond {
  void read_restart(FILE *);
  void write_data(FILE *);
  double single(int, double, int, int, double &);
  virtual void *extract(char *, int &);

 protected:
  double *k,*r0;
+11 −0
Original line number Diff line number Diff line
@@ -292,3 +292,14 @@ double Bond::memory_usage()
  bytes += comm->nthreads*maxvatom*6 * sizeof(double);
  return bytes;
}

/* -----------------------------------------------------------------------
   Reset all type-based bond params via init.
-------------------------------------------------------------------------- */
void Bond::reinit()
{
  if (!reinitflag)
    error->all(FLERR,"Fix adapt interface to this bond style not supported");

  init();
}
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ class Bond : protected Pointers {
  double virial[6];               // accumulated virial
  double *eatom,**vatom;          // accumulated per-atom energy/virial

  int reinitflag;                // 1 if compatible with fix adapt and alike

  // KOKKOS host/device flag and data masks

  ExecutionSpace execution_space;
@@ -49,6 +51,8 @@ class Bond : protected Pointers {
  virtual void write_data(FILE *) {}
  virtual double single(int, double, int, int, double &) = 0;
  virtual double memory_usage();
  virtual void *extract(char *, int &) {return NULL;}
  virtual void reinit();

  void write_file(int, char**);

Loading