Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
TissueForge::Potential Struct Reference

A Potential object is a compiled interpolation of a given function. The Universe applies potentials to particles to calculate the net force on them. More...

#include <tfPotential.h>

Inheritance diagram for TissueForge::Potential:
Collaboration diagram for TissueForge::Potential:

Public Member Functions

FPTYPE operator() (const FPTYPE &r, const FPTYPE &r0=-1.0)
 
FPTYPE operator() (const std::vector< FPTYPE > &r)
 
FPTYPE operator() (struct ParticleHandle *pi, const FVector3 &pt)
 
FPTYPE operator() (struct ParticleHandle *pi, struct ParticleHandle *pj)
 
FPTYPE operator() (struct ParticleHandle *pi, struct ParticleHandle *pj, struct ParticleHandle *pk)
 
FPTYPE operator() (struct ParticleHandle *pi, struct ParticleHandle *pj, struct ParticleHandle *pk, struct ParticleHandle *pl)
 
FPTYPE force (FPTYPE r, FPTYPE ri=-1.0, FPTYPE rj=-1.0)
 
std::vector< FPTYPE > force (const std::vector< FPTYPE > &r)
 
std::vector< FPTYPE > force (struct ParticleHandle *pi, const FVector3 &pt)
 
std::vector< FPTYPE > force (struct ParticleHandle *pi, struct ParticleHandle *pj)
 
std::pair< std::vector< FPTYPE >, std::vector< FPTYPE > > force (struct ParticleHandle *pi, struct ParticleHandle *pj, struct ParticleHandle *pk)
 
std::pair< std::vector< FPTYPE >, std::vector< FPTYPE > > force (struct ParticleHandle *pi, struct ParticleHandle *pj, struct ParticleHandle *pk, struct ParticleHandle *pl)
 
std::vector< Potential * > constituents ()
 
Potentialoperator+ (const Potential &rhs)
 
virtual std::string toString ()
 Get a JSON string representation.
 
FPTYPE getMin ()
 
FPTYPE getMax ()
 
FPTYPE getCutoff ()
 
std::pair< FPTYPE, FPTYPE > getDomain ()
 
int getIntervals ()
 
bool getBound ()
 
void setBound (const bool &_bound)
 
FPTYPE getR0 ()
 
void setR0 (const FPTYPE &_r0)
 
bool getShifted ()
 
bool getPeriodic ()
 
bool getRSquare ()
 

Static Public Member Functions

static PotentialfromString (const std::string &str)
 Create from a JSON string representation.
 
static Potentiallennard_jones_12_6 (FPTYPE min, FPTYPE max, FPTYPE A, FPTYPE B, FPTYPE *tol=NULL)
 Creates a 12-6 Lennard-Jones potential.
 
static Potentiallennard_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 Potentialewald (FPTYPE min, FPTYPE max, FPTYPE q, FPTYPE kappa, FPTYPE *tol=NULL, unsigned int *periodicOrder=NULL)
 Creates a real-space Ewald potential.
 
static Potentialcoulomb (FPTYPE q, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL, unsigned int *periodicOrder=NULL)
 Creates a Coulomb potential.
 
static PotentialcoulombR (FPTYPE q, FPTYPE kappa, FPTYPE min, FPTYPE max, unsigned int *modes=NULL)
 Creates a Coulomb reciprocal potential.
 
static Potentialharmonic (FPTYPE k, FPTYPE r0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
 Creates a harmonic bond potential.
 
static Potentiallinear (FPTYPE k, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
 Creates a linear potential.
 
static Potentialharmonic_angle (FPTYPE k, FPTYPE theta0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
 Creates a harmonic angle potential.
 
static Potentialharmonic_dihedral (FPTYPE k, FPTYPE delta, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
 Creates a harmonic dihedral potential.
 
static Potentialcosine_dihedral (FPTYPE k, int n, FPTYPE delta, FPTYPE *tol=NULL)
 Creates a cosine dihedral potential.
 
static Potentialwell (FPTYPE k, FPTYPE n, FPTYPE r0, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
 Creates a well potential.
 
static Potentialglj (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 Potentialmorse (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 Potentialoverlapping_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 Potentialpower (FPTYPE *k=NULL, FPTYPE *r0=NULL, FPTYPE *alpha=NULL, FPTYPE *min=NULL, FPTYPE *max=NULL, FPTYPE *tol=NULL)
 Creates a power potential.
 
static Potentialdpd (FPTYPE *alpha=NULL, FPTYPE *gamma=NULL, FPTYPE *sigma=NULL, FPTYPE *cutoff=NULL, bool *shifted=NULL)
 Creates a Dissipative Particle Dynamics potential.
 
static Potentialcustom (FPTYPE min, FPTYPE max, FPTYPE(*f)(FPTYPE), FPTYPE(*fp)(FPTYPE), FPTYPE(*f6p)(FPTYPE), FPTYPE *tol=NULL, uint32_t *flags=NULL)
 Creates a custom potential.
 

Public Attributes

uint32_t kind
 
uint32_t flags
 
FPTYPE alpha [4]
 
FPTYPE * c
 
FPTYPE r0_plusone
 
FPTYPE a
 
FPTYPE b
 
FPTYPE mu
 
FPTYPE offset [3]
 
int n
 
PotentialCreate create_func
 
PotentialClear clear_func
 
PotentialEval_ByParticle eval_bypart
 
PotentialEval_ByParticles eval_byparts
 
PotentialEval_ByParticles3 eval_byparts3
 
PotentialEval_ByParticles4 eval_byparts4
 
Potentialpca
 
Potentialpcb
 
const char * name
 

Detailed Description

A Potential object is a compiled interpolation of a given function. The Universe applies potentials to particles to calculate the net force on them.

For performance reasons, Tissue Forge implements potentials as interpolations, which can be much faster than evaluating the function directly.

A potential can be treated just like any callable object.

Member Function Documentation

◆ cosine_dihedral()

static Potential * TissueForge::Potential::cosine_dihedral ( FPTYPE k,
int n,
FPTYPE delta,
FPTYPE * tol = NULL )
static

Creates a cosine dihedral potential.

The cosine dihedral potential has the form:

\[

     k \left( 1 + \cos( n \theta-\delta ) \right)

\]

Parameters
kenergy of the dihedral.
nmultiplicity of the dihedral.
deltaminimum energy dihedral.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.01.
Returns
Potential*

◆ coulomb()

static Potential * TissueForge::Potential::coulomb ( FPTYPE q,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL,
unsigned int * periodicOrder = NULL )
static

Creates a Coulomb potential.

The Coulomb potential has the form:

\[

     \frac{q}{r}

\]

Parameters
qThe charge scaling of the potential.
minThe smallest radius for which the potential will be constructed. Default is 0.01.
maxThe largest radius for which the potential will be constructed. Default is 2.0.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.001 * (max - min).
periodicOrderOrder of lattice periodicity along all periodic dimensions. Defaults to 0.
Returns
Potential*

◆ coulombR()

static Potential * TissueForge::Potential::coulombR ( FPTYPE q,
FPTYPE kappa,
FPTYPE min,
FPTYPE max,
unsigned int * modes = NULL )
static

Creates a Coulomb reciprocal potential.

The Coulomb reciprocal potential has the form:

\[

     \frac{\pi q}{V} \sum_{||\mathbf{m}|| \neq 0} \frac{1}{||\mathbf{m}||^2} \exp \left( \left( i \mathbf{r}_{jk} - \left( \frac{\pi}{\kappa} \right)^{2} \mathbf{m} \right) \cdot \mathbf{m} \right)

\]

Here $ V $ is the volume of the domain and $ \mathbf{m} $ is a reciprocal vector of the domain.

Parameters
qCharge scaling of the potential.
kappaScreening distance.
minSmallest radius for which the potential will be constructed.
maxLargest radius for which the potential will be constructed.
modesNumber of Fourier modes along each periodic dimension. Default is 1.
Returns
Potential*

◆ custom()

static Potential * TissueForge::Potential::custom ( FPTYPE min,
FPTYPE max,
FPTYPE(*)(FPTYPE) f,
FPTYPE(*)(FPTYPE) fp,
FPTYPE(*)(FPTYPE) f6p,
FPTYPE * tol = NULL,
uint32_t * flags = NULL )
static

Creates a custom potential.

Parameters
minThe smallest radius for which the potential will be constructed.
maxThe largest radius for which the potential will be constructed.
ffunction returning the value of the potential
fpfunction returning the value of first derivative of the potential
f6pfunction returning the value of sixth derivative of the potential
tolTolerance, defaults to 0.001.
Returns
Potential*

◆ dpd()

static Potential * TissueForge::Potential::dpd ( FPTYPE * alpha = NULL,
FPTYPE * gamma = NULL,
FPTYPE * sigma = NULL,
FPTYPE * cutoff = NULL,
bool * shifted = NULL )
static

Creates a Dissipative Particle Dynamics potential.

The Dissipative Particle Dynamics force has the form:

\[

     \mathbf{F}_{ij} = \mathbf{F}^C_{ij} + \mathbf{F}^D_{ij} + \mathbf{F}^R_{ij}

\]

The conservative force is:

\[

     \mathbf{F}^C_{ij} = \alpha \left(1 - \frac{r_{ij}}{r_c}\right) \mathbf{e}_{ij}

\]

The dissapative force is:

\[

     \mathbf{F}^D_{ij} = -\gamma \left(1 - \frac{r_{ij}}{r_c}\right)^{2}(\mathbf{e}_{ij} \cdot \mathbf{v}_{ij}) \mathbf{e}_{ij}

\]

The random force is:

\[

     \mathbf{F}^R_{ij} = \sigma \left(1 - \frac{r_{ij}}{r_c}\right) \xi_{ij}\Delta t^{-1/2}\mathbf{e}_{ij}

\]

Parameters
alphainteraction strength of the conservative force. Defaults to 1.0.
gammainteraction strength of dissapative force. Defaults to 1.0.
sigmastrength of random force. Defaults to 1.0.
cutoffcutoff distance. Defaults to 1.0.
shiftedFlag for whether using a shifted potential. Defaults to false.
Returns
Potential*

◆ ewald()

static Potential * TissueForge::Potential::ewald ( FPTYPE min,
FPTYPE max,
FPTYPE q,
FPTYPE kappa,
FPTYPE * tol = NULL,
unsigned int * periodicOrder = NULL )
static

Creates a real-space Ewald potential.

The Ewald potential has the form:

\[

     q \frac{\mathrm{erfc}\, ( \kappa r)}{r}

\]

Parameters
minThe smallest radius for which the potential will be constructed.
maxThe largest radius for which the potential will be constructed.
qThe charge scaling of the potential.
kappaThe screening distance of the Ewald potential.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.001 * (max - min).
periodicOrderOrder of lattice periodicity along all periodic dimensions. Defaults to 0.
Returns
Potential*

◆ fromString()

static Potential * TissueForge::Potential::fromString ( const std::string & str)
static

Create from a JSON string representation.

Parameters
str
Returns
Potential*

◆ glj()

static Potential * TissueForge::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 )
static

Creates a generalized Lennard-Jones potential.

The generalized Lennard-Jones potential has the form:

\[

     \frac{\epsilon}{n-m} \left[ m \left( \frac{r_0}{r} \right)^n - n \left( \frac{r_0}{r} \right)^m \right]

\]

Parameters
eeffective energy of the potential.
morder of potential. Defaults to 3
norder of potential. Defaults to 2*m.
kmimumum of the potential. Defaults to 1.
r0mimumum of the potential. Defaults to 1.
minThe smallest radius for which the potential will be constructed. Defaults to 0.05 * r0.
maxThe largest radius for which the potential will be constructed. Defaults to 5 * r0.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.01.
shiftedFlag for whether using a shifted potential. Defaults to true.
Returns
Potential*

◆ harmonic()

static Potential * TissueForge::Potential::harmonic ( FPTYPE k,
FPTYPE r0,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL )
static

Creates a harmonic bond potential.

The harmonic potential has the form:

\[

     k \left( r-r_0 \right)^2

\]

Parameters
kThe energy of the bond.
r0The bond rest length.
minThe smallest radius for which the potential will be constructed. Defaults to $ r_0 - r_0 / 2 $.
maxThe largest radius for which the potential will be constructed. Defaults to $ r_0 + r_0 /2 $.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to $ 0.01 \abs(max-min) $.
Returns
Potential*

◆ harmonic_angle()

static Potential * TissueForge::Potential::harmonic_angle ( FPTYPE k,
FPTYPE theta0,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL )
static

Creates a harmonic angle potential.

The harmonic angle potential has the form:

\[

     k \left(\theta-\theta_{0} \right)^2

\]

Parameters
kThe energy of the angle.
theta0The minimum energy angle.
minThe smallest angle for which the potential will be constructed. Defaults to zero.
maxThe largest angle for which the potential will be constructed. Defaults to PI.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.005 * (max - min).
Returns
Potential*

◆ harmonic_dihedral()

static Potential * TissueForge::Potential::harmonic_dihedral ( FPTYPE k,
FPTYPE delta,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL )
static

Creates a harmonic dihedral potential.

The harmonic dihedral potential has the form:

\[

     k \left( \theta - \delta \right) ^2

\]

Parameters
kenergy of the dihedral.
deltaminimum energy dihedral.
minThe smallest angle for which the potential will be constructed. Defaults to zero.
maxThe largest angle for which the potential will be constructed. Defaults to PI.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.005 * (max - min).
Returns
Potential*

◆ lennard_jones_12_6()

static Potential * TissueForge::Potential::lennard_jones_12_6 ( FPTYPE min,
FPTYPE max,
FPTYPE A,
FPTYPE B,
FPTYPE * tol = NULL )
static

Creates a 12-6 Lennard-Jones potential.

The Lennard Jones potential has the form:

\[

     \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) 

\]

Parameters
minThe smallest radius for which the potential will be constructed.
maxThe largest radius for which the potential will be constructed.
AThe first parameter of the Lennard-Jones potential.
BThe second parameter of the Lennard-Jones potential.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.001 * (max - min).
Returns
Potential*

◆ lennard_jones_12_6_coulomb()

static Potential * TissueForge::Potential::lennard_jones_12_6_coulomb ( FPTYPE min,
FPTYPE max,
FPTYPE A,
FPTYPE B,
FPTYPE q,
FPTYPE * tol = NULL )
static

Creates a potential of the sum of a 12-6 Lennard-Jones potential and a shifted Coulomb potential.

The 12-6 Lennard Jones - Coulomb potential has the form:

\[

     \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) + q \left( \frac{1}{r} - \frac{1}{max} \right)

\]

Parameters
minThe smallest radius for which the potential will be constructed.
maxThe largest radius for which the potential will be constructed.
AThe first parameter of the Lennard-Jones potential.
BThe second parameter of the Lennard-Jones potential.
qThe charge scaling of the potential.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.001 * (max - min).
Returns
Potential*

◆ linear()

static Potential * TissueForge::Potential::linear ( FPTYPE k,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL )
static

Creates a linear potential.

The linear potential has the form:

\[

     k r

\]

Parameters
kinteraction strength; represents the potential energy peak value.
minThe smallest radius for which the potential will be constructed. Defaults to 0.0.
maxThe largest radius for which the potential will be constructed. Defaults to 10.0.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.001.
Returns
Potential*

◆ morse()

static Potential * TissueForge::Potential::morse ( FPTYPE * d = NULL,
FPTYPE * a = NULL,
FPTYPE * r0 = NULL,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL,
bool * shifted = NULL )
static

Creates a Morse potential.

The Morse potential has the form:

\[

     d \left(1 - e^{ -a \left(r - r_0 \right) } \right)^2

\]

Parameters
dwell depth. Defaults to 1.0.
apotential width. Defaults to 6.0.
r0equilibrium distance. Defaults to 0.0.
minThe smallest radius for which the potential will be constructed. Defaults to 0.0001.
maxThe largest radius for which the potential will be constructed. Defaults to 3.0.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.001.
shiftedFlag for whether using a shifted potential. Defaults to true.
Returns
Potential*

◆ overlapping_sphere()

static Potential * TissueForge::Potential::overlapping_sphere ( FPTYPE * mu = NULL,
FPTYPE * kc = NULL,
FPTYPE * kh = NULL,
FPTYPE * r0 = NULL,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL )
static

Creates an overlapping-sphere potential from :cite:Osborne:2017hk.

The overlapping-sphere potential has the form:

\[
     \mu_{ij} s_{ij}(t) \hat{\mathbf{r}}_{ij} \log \left( 1 + \frac{||\mathbf{r}_{ij}|| - s_{ij}(t)}{s_{ij}(t)} \right) 
         \text{ if } ||\mathbf{r}_{ij}|| < s_{ij}(t) ,
\]

\[
     \mu_{ij}\left(||\mathbf{r}_{ij}|| - s_{ij}(t)\right) \hat{\mathbf{r}}_{ij} \exp \left( -k_c \frac{||\mathbf{r}_{ij}|| - s_{ij}(t)}{s_{ij}(t)} \right) 
         \text{ if } s_{ij}(t) \leq ||\mathbf{r}_{ij}|| \leq r_{max} ,
\]

\[
     0 \text{ otherwise} .
\]

Osborne refers to $ \mu_{ij} $ as a "spring constant", this controls the size of the force, and is the potential energy peak value. $ \hat{\mathbf{r}}_{ij} $ is the unit vector from particle $ i $ center to particle $ j $ center, $ k_C $ is a parameter that defines decay of the attractive force. Larger values of $ k_C $ result in a shaper peaked attraction, and thus a shorter ranged force. $ s_{ij}(t) $ is the is the sum of the radii of the two particles.

Parameters
muinteraction strength, represents the potential energy peak value. Defaults to 1.0.
kcdecay strength of long range attraction. Larger values make a shorter ranged function. Defaults to 1.0.
khOptionally add a harmonic long-range attraction, same as :meth:glj function. Defaults to 0.0.
r0Optional harmonic rest length, only used if kh is non-zero. Defaults to 0.0.
minThe smallest radius for which the potential will be constructed. Defaults to 0.001.
maxThe largest radius for which the potential will be constructed. Defaults to 10.0.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.001.
Returns
Potential*

◆ power()

static Potential * TissueForge::Potential::power ( FPTYPE * k = NULL,
FPTYPE * r0 = NULL,
FPTYPE * alpha = NULL,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL )
static

Creates a power potential.

The power potential the general form of many of the potential functions, such as :meth:linear, etc. power has the form:

\[

     k \lvert r-r_0 \rvert ^{\alpha}

\]

Parameters
kinteraction strength, represents the potential energy peak value. Defaults to 1
r0potential rest length, zero of the potential, defaults to 0.
alphaExponent, defaults to 1.
minminimal value potential is computed for, defaults to r0 / 2.
maxcutoff distance, defaults to 3 * r0.
tolTolerance, defaults to 0.01.
Returns
Potential*

◆ toString()

virtual std::string TissueForge::Potential::toString ( )
virtual

Get a JSON string representation.

Returns
std::string

Reimplemented in TissueForge::DPDPotential.

◆ well()

static Potential * TissueForge::Potential::well ( FPTYPE k,
FPTYPE n,
FPTYPE r0,
FPTYPE * min = NULL,
FPTYPE * max = NULL,
FPTYPE * tol = NULL )
static

Creates a well potential.

Useful for binding a particle to a region.

The well potential has the form:

\[

     \frac{k}{\left(r_0 - r\right)^{n}}

\]

Parameters
kpotential prefactor constant, should be decreased for larger n.
nexponent of the potential, larger n makes a sharper potential.
r0The extents of the potential, length units. Represents the maximum extents that a two objects connected with this potential should come apart.
minThe smallest radius for which the potential will be constructed. Defaults to zero.
maxThe largest radius for which the potential will be constructed. Defaults to r0.
tolThe tolerance to which the interpolation should match the exact potential. Defaults to 0.01 * abs(min-max).
Returns
Potential*

Member Data Documentation

◆ a

FPTYPE TissueForge::Potential::a

Interval edges.

◆ alpha

FPTYPE TissueForge::Potential::alpha[4]

Coefficients for the interval transform.

◆ c

FPTYPE* TissueForge::Potential::c

The coefficients.

◆ flags

uint32_t TissueForge::Potential::flags

Flags.

◆ mu

FPTYPE TissueForge::Potential::mu

potential scaling constant

◆ n

int TissueForge::Potential::n

Nr of intervals.

◆ name

const char* TissueForge::Potential::name

pointer to what kind of potential this is.

◆ offset

FPTYPE TissueForge::Potential::offset[3]

coordinate offset


The documentation for this struct was generated from the following file: