27#ifndef _MDCORE_INCLUDE_TFPOTENTIAL_H_
28#define _MDCORE_INCLUDE_TFPOTENTIAL_H_
30#include "tf_platform.h"
39#define potential_degree 5
40#define potential_chunk (potential_degree+3)
41#define potential_ivalsa 1
42#define potential_ivalsb 10
43#define potential_N 100
44#define potential_align 64
45#define potential_ivalsmax 3048
47#define potential_escale (0.079577471545947667882)
58 POTENTIAL_LJ126 = 1 << 0,
59 POTENTIAL_EWALD = 1 << 1,
60 POTENTIAL_COULOMB = 1 << 2,
61 POTENTIAL_SINGLE = 1 << 3,
75 POTENTIAL_DIHEDRAL = 1 << 8,
80 POTENTIAL_REACTIVE = 1 << 10,
101 POTENTIAL_SUM = 1 << 14,
107 POTENTIAL_COULOMBR = 1 << 16
112 POTENTIAL_KIND_POTENTIAL,
118 POTENTIAL_KIND_BYPARTICLES,
121 POTENTIAL_KIND_COMBINATION
191 typedef struct Potential* (*PotentialCreate) (
213 struct CAPI_EXPORT Potential {
240 PotentialCreate create_func;
248 Potential *pca, *pcb;
257 FPTYPE operator()(
const FPTYPE &r,
const FPTYPE &r0=-1.0);
258 FPTYPE operator()(
const std::vector<FPTYPE>& r);
263 FPTYPE force(FPTYPE r, FPTYPE ri=-1.0, FPTYPE rj=-1.0);
264 std::vector<FPTYPE> force(
const std::vector<FPTYPE>& r);
265 std::vector<FPTYPE> force(
struct ParticleHandle* pi,
const FVector3 &pt);
270 std::vector<Potential*> constituents();
272 Potential& operator+(
const Potential& rhs);
349 static Potential *
ewald(FPTYPE min, FPTYPE max, FPTYPE q, FPTYPE kappa, FPTYPE *tol=NULL,
unsigned int *periodicOrder=NULL);
369 static Potential *
coulomb(FPTYPE q, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL,
unsigned int *periodicOrder=NULL);
391 static Potential*
coulombR(FPTYPE q, FPTYPE kappa, FPTYPE min, FPTYPE max,
unsigned int* modes=NULL);
411 static Potential *
harmonic(FPTYPE k, FPTYPE r0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL);
430 static Potential *
linear(FPTYPE k, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL);
450 static Potential *
harmonic_angle(FPTYPE k, FPTYPE theta0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL);
470 static Potential *
harmonic_dihedral(FPTYPE k, FPTYPE delta, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL);
512 static Potential *
well(FPTYPE k, FPTYPE
n, FPTYPE r0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL);
536 static Potential *
glj(FPTYPE e, FPTYPE *m=NULL, FPTYPE *
n=NULL, FPTYPE *k=NULL, FPTYPE *r0=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL,
bool *shifted=NULL);
558 static Potential *
morse(FPTYPE *d=NULL, FPTYPE *
a=NULL, FPTYPE *r0=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL,
bool *shifted=NULL);
597 static Potential *
overlapping_sphere(FPTYPE *
mu=NULL, FPTYPE *kc=NULL, FPTYPE *kh=NULL, FPTYPE *r0=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL);
619 static Potential *
power(FPTYPE *k=NULL, FPTYPE *r0=NULL, FPTYPE *
alpha=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL);
663 static Potential *
dpd(FPTYPE *
alpha=NULL, FPTYPE *gamma=NULL, FPTYPE *sigma=NULL, FPTYPE *cutoff=NULL,
bool *shifted=NULL);
680 FPTYPE (*fp)(FPTYPE),
681 FPTYPE (*f6p)(FPTYPE),
689 std::pair<FPTYPE, FPTYPE> getDomain();
692 void setBound(
const bool &_bound);
694 void setR0(
const FPTYPE &_r0);
739 FPTYPE (*fp)(FPTYPE),
740 FPTYPE (*f6p)(FPTYPE),
746 CAPI_FUNC(
HRESULT) potential_getcoeffs(
748 FPTYPE (*fp)(FPTYPE),
755 CAPI_FUNC(FPTYPE) potential_getalpha(FPTYPE (*f6p)(FPTYPE), FPTYPE a, FPTYPE b);
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
HRESULT potential_init(struct Potential *p, FPTYPE(*f)(FPTYPE), FPTYPE(*fp)(FPTYPE), FPTYPE(*f6p)(FPTYPE), FPTYPE a, FPTYPE b, FPTYPE tol)
Construct a #potential from the given function.
void(* PotentialEval_ByParticle)(struct Potential *p, struct Particle *part_i, FPTYPE *dx, FPTYPE r2, FPTYPE *e, FPTYPE *f)
Potential function on a particle.
Definition tfPotential.h:133
void(* PotentialClear)(struct Potential *p)
Callback issues when potential is cleared.
Definition tfPotential.h:201
void potential_clear(struct Potential *p)
Free the memory associated with the given potential.
void(* PotentialEval_ByParticles)(struct Potential *p, struct Particle *part_i, struct Particle *part_j, FPTYPE *dx, FPTYPE r2, FPTYPE *e, FPTYPE *f)
Pair potential function.
Definition tfPotential.h:150
PotentialFlags
Definition tfPotential.h:56
@ POTENTIAL_SHIFTED
Definition tfPotential.h:92
@ POTENTIAL_ANGLE
Definition tfPotential.h:70
@ POTENTIAL_R2
Definition tfPotential.h:64
@ POTENTIAL_R
Definition tfPotential.h:67
@ POTENTIAL_SCALED
Definition tfPotential.h:87
@ POTENTIAL_HARMONIC
Definition tfPotential.h:73
@ POTENTIAL_SWITCH
Definition tfPotential.h:78
@ POTENTIAL_BOUND
Definition tfPotential.h:98
@ POTENTIAL_PERIODIC
Definition tfPotential.h:104
struct Potential potential_null
Definition tfPotential.h:703
void(* PotentialEval_ByParticles4)(struct Potential *p, struct Particle *part_i, struct Particle *part_j, struct Particle *part_k, struct Particle *part_l, FPTYPE cphi, FPTYPE *e, FPTYPE *fi, FPTYPE *fl)
Like PotentialEval_ByParticles, but with four particles.
Definition tfPotential.h:179
void(* PotentialEval_ByParticles3)(struct Potential *p, struct Particle *part_i, struct Particle *part_j, struct Particle *part_k, FPTYPE ctheta, FPTYPE *e, FPTYPE *fi, FPTYPE *fk)
Like PotentialEval_ByParticles, but with three particles.
Definition tfPotential.h:164
A handle to a particle.
Definition tfParticle.h:313
Definition tfParticle.h:101
Structure containing information on each particle type.
Definition tfParticle.h:768
A Potential object is a compiled interpolation of a given function. The Universe applies potentials t...
Definition tfPotential.h:213
static Potential * lennard_jones_12_6(FPTYPE min, FPTYPE max, FPTYPE A, FPTYPE B, FPTYPE *tol=NULL)
Creates a 12-6 Lennard-Jones potential.
static Potential * ewald(FPTYPE min, FPTYPE max, FPTYPE q, FPTYPE kappa, FPTYPE *tol=NULL, unsigned int *periodicOrder=NULL)
Creates a real-space Ewald potential.
static Potential * glj(FPTYPE e, FPTYPE *m=NULL, FPTYPE *n=NULL, FPTYPE *k=NULL, FPTYPE *r0=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL, bool *shifted=NULL)
Creates a generalized Lennard-Jones potential.
static Potential * dpd(FPTYPE *alpha=NULL, FPTYPE *gamma=NULL, FPTYPE *sigma=NULL, FPTYPE *cutoff=NULL, bool *shifted=NULL)
Creates a Dissipative Particle Dynamics potential.
uint32_t flags
Definition tfPotential.h:217
static Potential * power(FPTYPE *k=NULL, FPTYPE *r0=NULL, FPTYPE *alpha=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
Creates a power potential.
static Potential * coulomb(FPTYPE q, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL, unsigned int *periodicOrder=NULL)
Creates a Coulomb potential.
static Potential * morse(FPTYPE *d=NULL, FPTYPE *a=NULL, FPTYPE *r0=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL, bool *shifted=NULL)
Creates a Morse potential.
static Potential * cosine_dihedral(FPTYPE k, int n, FPTYPE delta, FPTYPE *tol=NULL)
Creates a cosine dihedral potential.
FPTYPE * c
Definition tfPotential.h:224
FPTYPE alpha[4]
Definition tfPotential.h:221
FPTYPE mu
Definition tfPotential.h:232
static Potential * well(FPTYPE k, FPTYPE n, FPTYPE r0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
Creates a well potential.
const char * name
Definition tfPotential.h:253
virtual std::string toString()
Get a JSON string representation.
static Potential * lennard_jones_12_6_coulomb(FPTYPE min, FPTYPE max, FPTYPE A, FPTYPE B, FPTYPE q, FPTYPE *tol=NULL)
Creates a potential of the sum of a 12-6 Lennard-Jones potential and a shifted Coulomb potential.
static Potential * fromString(const std::string &str)
Create from a JSON string representation.
static Potential * custom(FPTYPE min, FPTYPE max, FPTYPE(*f)(FPTYPE), FPTYPE(*fp)(FPTYPE), FPTYPE(*f6p)(FPTYPE), FPTYPE *tol=NULL, uint32_t *flags=NULL)
Creates a custom potential.
int n
Definition tfPotential.h:238
static Potential * linear(FPTYPE k, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
Creates a linear potential.
static Potential * overlapping_sphere(FPTYPE *mu=NULL, FPTYPE *kc=NULL, FPTYPE *kh=NULL, FPTYPE *r0=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
Creates an overlapping-sphere potential from :cite:Osborne:2017hk.
static Potential * harmonic_angle(FPTYPE k, FPTYPE theta0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
Creates a harmonic angle potential.
FPTYPE a
Definition tfPotential.h:229
FPTYPE offset[3]
Definition tfPotential.h:235
static Potential * harmonic_dihedral(FPTYPE k, FPTYPE delta, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
Creates a harmonic dihedral potential.
static Potential * coulombR(FPTYPE q, FPTYPE kappa, FPTYPE min, FPTYPE max, unsigned int *modes=NULL)
Creates a Coulomb reciprocal potential.
static Potential * harmonic(FPTYPE k, FPTYPE r0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
Creates a harmonic bond potential.
int32_t HRESULT
Definition tf_port.h:255