IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Lib.opt.opttest.ParticlePotentialProblem Class Reference

Base class for the charged particle potential problem. More...

+ Inheritance diagram for IG.Lib.opt.opttest.ParticlePotentialProblem:
+ Collaboration diagram for IG.Lib.opt.opttest.ParticlePotentialProblem:

Classes

class  ConstraintFunctionParticleConstraint
 Class that returns the objective function (total potential energy) of the specified particle potential problem. More...
 
class  ObjectiveFunctionPotentialEnergy
 Class that returns the objective function (total potential energy) of the specified particle potential problem. More...
 

Public Member Functions

double GetPotentialFactorPhysical ()
 
void SetCharges (double charge)
 Sets all particle charges to the specified value. More...
 
void SetStaticCharges (double charge)
 Sets all static particle charges to the specified value. More...
 
int ParameterIndex (int particleIndex, int coordinateIndex)
 Returns parameter index that corresponds to the specified particle index and to the specified particle coordinate. More...
 
int ParticleIndex (int parameterIndex)
 Returns index of the particle to which the specified element of the global parameter vector belongs. More...
 
int CoordinateIndex (int parameterIndex)
 Returns coordinate index of the corresponding particle that is equivalent to the specified element of the global parameter vector. More...
 
double ParticleCoordinate (int particleIndex, int coordinateIndex, IVector parameters)
 Extracts and returns the specified coordinate of the specified particle from the specified parameter vector. More...
 
double ParticleDistance (int firstIndex, int secondIndex, IVector parameters)
 Returns the Euclidean distance between the two particles with specified indices. More...
 
virtual double StaticParticleDistance (int staticParticleIndex, int particleIndex, IVector parameters, IVector[] staticCoordinates)
 Calculates and returns the distance between the specified static particle and the specified free particle of the particle arrangement. More...
 
virtual double StaticPairwisePotentialEnergy (int staticParticleIndex, int particleIndex, double potentialFactor, double[] charges, IRealFunction potentialFunction, IVector parameters, double[] staticCharges, IVector[] staticCoordinates)
 Calculates and returns pairwise electrical potential energy of the specified static and the specified free particle, providing the necessary coefficiets through parameters. More...
 
virtual double StaticPairwisePotentialEnergy (int staticParticleIndex, int particleIndex, IVector parameters)
 Calculates and returns electrical potential energy of the specified static and free particle. More...
 
virtual double PairwisePotentialEnergy (int referenceIndex, int particleIndex, double potentialFactor, double[] charges, IRealFunction potentialFunction, IVector parameters)
 Calculates and returns pairwise electrical potential energy of two particles, providing the necessary coefficiets through parameters. More...
 
virtual double PairwisePotentialEnergy (int referenceIndex, int particleIndex, IVector parameters)
 Calculates and returns electrical potential energy of two particles. More...
 
virtual double PotentialEnergy (IVector parameters)
 Calculates and returns the total potential energy of all particles in the formation. More...
 
void StaticParticleSingleForce (int staticParticleIndex, int particleIndex, double potentialFactor, double[] charges, IRealFunction potentialFunction, IVector parameters, double[] staticCharges, IVector[] staticCoordinates, ref IVector particleForce)
 Calculates the electrostatic force acting on the specified free particle by a single specified statitc particle. More...
 
void StaticParticleSingleForce (int staticParticleIndex, int particleIndex, IVector parameters, ref IVector particleForce)
 Calculates the electrostatic force acting on the specified free particle by a single specified static particle. More...
 
virtual void StaticParticleSingleForce (int particleIndex, IVector parameters, ref IVector particleForce)
 Calculates the electrostatic force acting on the specified free particle by all static particles in the arrangement. More...
 
void ParticleSingleForce (int referenceIndex, int particleIndex, double potentialFactor, double[] charges, IRealFunction potentialFunction, IVector parameters, ref IVector particleForce)
 Calculates the electrostatic force acting on the specified particle by a single specified another particle. More...
 
void ParticleSingleForce (int referenceIndex, int particleIndex, IVector parameters, ref IVector particleForce)
 Calculates the electrostatic force acting on the specified particle by a single specified another free particle. More...
 
virtual void ParticleSingleForce (int particleIndex, IVector parameters, ref IVector particleForce)
 Calculates the electrostatic force acting on the specified particle by all other free particles in the arrangement. More...
 
virtual void PotentialEnergyGradient (IVector parameters, ref IVector gradient)
 Calculates gradient of total potential, which is effectively composed of forces acting on the individual particles by all other particles in the arrangement (and that equals to gradients of potential energy of individual particle in the field of other particles). More...
 
double ParticleConstraintValue (int particleIndex, IVector parameters)
 Returns value of the constraint function for the specified particle in the arrangement. More...
 
void ParticleConstraintGradient (int particleIndex, IVector parameters, ref IVector partConstraintGrad)
 Calculates and stores gradient of the constraint function related to the specified particle, in terms of particle coordinates. More...
 
double ConstraintFunction (int whichConstraint, IVector parameters)
 Returns value of the specified constraint function related to specified particle in the arrangement. More...
 
void ConstraintGradient (int whichConstraint, IVector parameters, ref IVector constraintGradient)
 Calculates and stores gradient of the specified constraint function that is related to the specified particle, in terms of global parameters (vector assembly of all particle coordinates). More...
 

Protected Attributes

int _numParticles = 8
 
int _spaceDimension = 2
 
double _potentialFactor = 1.0
 
IRealFunction _potentialFunction = Func.GetReciprocal()
 
IVector _auxParticleVector = null
 

Properties

object Lock [get]
 This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More...
 
int NumParticles [get, protected set]
 Number of charged particles in the arrangement. More...
 
int SpaceDimension [get, protected set]
 Dimension of space in which particles are positioned. More...
 
int ProblemDimension [get]
 Dimension of the problem, product of the space dimension and the number of free particles. More...
 
double PotentialFactor [get, protected set]
 
double[] Charges [get, set]
 Gets or sets the array of particle charges. Length of the array must be the same as the number of particles. If not set, getter will return the array in which all charges are equal to 1. More...
 
IRealFunction PotentialFunction [get, set]
 The potential function. More...
 
int NumStaticParticles [get, private set]
 Gets the number of static particles. More...
 
IVector[] StaticParticleCoordinates [get, set]
 Array of coordinate vectors of staticle charges. More...
 
double[] StaticParticleCharges [get, set]
 Gets or sets the array of static particle's charges. If not set, getter will return the array in which all charges are equal to 1. More...
 
ScalarFunctionBase ObjectiveFunction [get]
 Returns the scalar function that represents the objective function of the current minimal particle potential energy problem. More...
 
ScalarFunctionBase[] ConstraintFunctions [get, protected set]
 Returns an array of scalar functions that represent the constraint functions of the current minimal particle potential energy problem. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Private Member Functions

 ParticlePotentialProblem ()
 Prevent argument-less constructor. More...
 

Private Attributes

readonly object _mainLock = new object()
 
double[] _charges
 
int _numStaticParticles
 
IVector[] _staticParticleCoordinates
 
double[] _staticParticleCharges
 
ScalarFunctionBase _objectiveFunction
 
ScalarFunctionBase[] _constraintFunctions
 

Detailed Description

Base class for the charged particle potential problem.

Description of the problem:

This class represents the problem of minimal potential arrangement of a number of charged particles that are confined to the specified region of space (in the current case, this happens to be the hyperball with radius 1). The class represent methods for calculation of the total potential of particles and its gradienn with respect to parameters, as well as individual particle potentials and their gradients with respect to the particle coordinates.

Charges can be assigned to particles (by default, charges are eual to 1), as well as a factor in potential (that replaces 1/(4 Pi epsilon_0) in physical euation for charged particles potential; by default, this factor is also 1). By default, the potential funtion is equal to 1/r, but a customized potential function can also be provided.

<pare></pare>

Things to be done in the future:

Possibility of adding charged particles with fixed positions. These particles can contribute to the potential and thus influence the equilibrium positions of free particles, but can not change positions. Adding this possibility can be useful for calculating maximal distance arrangements of sampling points with a given number of already sampled points whose positions are fixed.

$A Igor xx Jul09 Apr10;

Constructor & Destructor Documentation

IG.Lib.opt.opttest.ParticlePotentialProblem.ParticlePotentialProblem ( )
inlineprivate

Prevent argument-less constructor.

Member Function Documentation

double IG.Lib.opt.opttest.ParticlePotentialProblem.GetPotentialFactorPhysical ( )
inline
void IG.Lib.opt.opttest.ParticlePotentialProblem.SetCharges ( double  charge)
inline

Sets all particle charges to the specified value.

Parameters
chargeCharge assigned to all particles.
void IG.Lib.opt.opttest.ParticlePotentialProblem.SetStaticCharges ( double  charge)
inline

Sets all static particle charges to the specified value.

Parameters
chargeCharge assigned to all static particles.
int IG.Lib.opt.opttest.ParticlePotentialProblem.ParameterIndex ( int  particleIndex,
int  coordinateIndex 
)
inline

Returns parameter index that corresponds to the specified particle index and to the specified particle coordinate.

Parameters
particleIndexParticle index.
coordinateIndexIndex of particle coordinate.

Coordinates of all particles are collected in a single parameter vector. Individual particle coordinates are elements of this vector, and there exist an unique transformation between the parameter index and the pair (particle index, particle coordinate).

int IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleIndex ( int  parameterIndex)
inline

Returns index of the particle to which the specified element of the global parameter vector belongs.

Parameters
parameterIndexIndex of the element of the global parameter vector.

Coordinates of all particles are collected in a single parameter vector. Individual particle coordinates are elements of this vector, and there exist an unique transformation between the parameter index and the pair (particle index, particle coordinate).

int IG.Lib.opt.opttest.ParticlePotentialProblem.CoordinateIndex ( int  parameterIndex)
inline

Returns coordinate index of the corresponding particle that is equivalent to the specified element of the global parameter vector.

Parameters
parameterIndexIndex of the element of the global parameter vector.

Coordinates of all particles are collected in a single parameter vector. Individual particle coordinates are elements of this vector, and there exist an unique transformation between the parameter index and the pair (particle index, particle coordinate).

double IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleCoordinate ( int  particleIndex,
int  coordinateIndex,
IVector  parameters 
)
inline

Extracts and returns the specified coordinate of the specified particle from the specified parameter vector.

Parameters
particleIndexParticle index.
coordinateIndexIndex of particle coordinate.
parametersVector of parameters where coordinates fo all particles are collected.
double IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleDistance ( int  firstIndex,
int  secondIndex,
IVector  parameters 
)
inline

Returns the Euclidean distance between the two particles with specified indices.

Parameters
firstIndexIndex of the first particle.
secondIndexIndex of the second particle.
parametersVector of parameters.
virtual double IG.Lib.opt.opttest.ParticlePotentialProblem.StaticParticleDistance ( int  staticParticleIndex,
int  particleIndex,
IVector  parameters,
IVector[]  staticCoordinates 
)
inlinevirtual

Calculates and returns the distance between the specified static particle and the specified free particle of the particle arrangement.

Parameters
staticParticleIndexIndex of the static particle.
particleIndexIndex of free particle.
parametersProblem parameters, assembled vector of coordinated of all free particles.
staticCoordinatesArray of coordinates of static particles.
virtual double IG.Lib.opt.opttest.ParticlePotentialProblem.StaticPairwisePotentialEnergy ( int  staticParticleIndex,
int  particleIndex,
double  potentialFactor,
double[]  charges,
IRealFunction  potentialFunction,
IVector  parameters,
double[]  staticCharges,
IVector[]  staticCoordinates 
)
inlinevirtual

Calculates and returns pairwise electrical potential energy of the specified static and the specified free particle, providing the necessary coefficiets through parameters.

Parameters
staticParticleIndexIndex of the static particle.
particleIndexIndex of the free particle.
potentialFactorFactor by which potential is multiplied.
chargesArray of particle charges.
potentialFunctionFunction of distance between two particles that defines electrostatic potential energy contributed by these two particles when multiplied by a product of particle charges and a multiplicative constant.
parametersVector of parameters that contains coordinates of all particles.
staticChargesArray of static particle's charges.
staticCoordinatesArray of coordinate vectors of static particles.

References IG.Num.IRealFunction.Value().

virtual double IG.Lib.opt.opttest.ParticlePotentialProblem.StaticPairwisePotentialEnergy ( int  staticParticleIndex,
int  particleIndex,
IVector  parameters 
)
inlinevirtual

Calculates and returns electrical potential energy of the specified static and free particle.

All the necessary parameters are obteined from the object.

Parameters
referenceIndexIndx of the static particle.
particleIndexIndex of the free particle.
parametersVector of parameters that contains coordinates of all particles.
virtual double IG.Lib.opt.opttest.ParticlePotentialProblem.PairwisePotentialEnergy ( int  referenceIndex,
int  particleIndex,
double  potentialFactor,
double[]  charges,
IRealFunction  potentialFunction,
IVector  parameters 
)
inlinevirtual

Calculates and returns pairwise electrical potential energy of two particles, providing the necessary coefficiets through parameters.

Parameters
referenceIndexIndx of the first particle.
particleIndexIndex of the second particle.
potentialFactorFactor by which potential is multiplied.
chargesArray of particle charges.
potentialFunctionFunction of distance between two particles that defines electrostatic potential energy contributed by these two particles when multiplied by a product of particle charges and a multiplicative consrant.
parametersVector of parameters that contains coordinates of all particles.

References IG.Num.IRealFunction.Value().

virtual double IG.Lib.opt.opttest.ParticlePotentialProblem.PairwisePotentialEnergy ( int  referenceIndex,
int  particleIndex,
IVector  parameters 
)
inlinevirtual

Calculates and returns electrical potential energy of two particles.

Parameters
referenceIndexIndx of the first particle.
particleIndexIndex of the second particle.
parametersVector of parameters that contains coordinates of all particles.
virtual double IG.Lib.opt.opttest.ParticlePotentialProblem.PotentialEnergy ( IVector  parameters)
inlinevirtual

Calculates and returns the total potential energy of all particles in the formation.

Parameters
parametersVector of parameters that contains coordinates of all particles.
void IG.Lib.opt.opttest.ParticlePotentialProblem.StaticParticleSingleForce ( int  staticParticleIndex,
int  particleIndex,
double  potentialFactor,
double[]  charges,
IRealFunction  potentialFunction,
IVector  parameters,
double[]  staticCharges,
IVector[]  staticCoordinates,
ref IVector  particleForce 
)
inline

Calculates the electrostatic force acting on the specified free particle by a single specified statitc particle.

Parameters
staticParticleIndexIndex of the particle that is a source of electrostatic force.
particleIndexIndex of the particle on which the calculated force acts.
potentialFactorFactor by which potential is multiplied.
chargesArray of particle charges.
parametersVector of parameters that contains coordinates of all particles.
particleForceVector where particle force is stored to.

References IG.Num.IRealFunction.Derivative(), and IG.Num.VectorBase.Resize().

void IG.Lib.opt.opttest.ParticlePotentialProblem.StaticParticleSingleForce ( int  staticParticleIndex,
int  particleIndex,
IVector  parameters,
ref IVector  particleForce 
)
inline

Calculates the electrostatic force acting on the specified free particle by a single specified static particle.

Parameters
staticParticleIndexIndex of the particle that is a source of electrostatic force.
particleIndexIndex of the particle on which the calculated force acts.
particleForceVector where particle force is stored to.

Charges of other particles, potential factor and potential function are obtained

virtual void IG.Lib.opt.opttest.ParticlePotentialProblem.StaticParticleSingleForce ( int  particleIndex,
IVector  parameters,
ref IVector  particleForce 
)
inlinevirtual

Calculates the electrostatic force acting on the specified free particle by all static particles in the arrangement.

Parameters
particleIndexIndex of the particle on which the calculated force acts.
parametersVector of parameters that contains coordinates of all particles.
particleForceVector where particle force is stored to.

References IG.Num.VectorBase.Resize(), and IG.Num.VectorBase.SetZero().

void IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleSingleForce ( int  referenceIndex,
int  particleIndex,
double  potentialFactor,
double[]  charges,
IRealFunction  potentialFunction,
IVector  parameters,
ref IVector  particleForce 
)
inline

Calculates the electrostatic force acting on the specified particle by a single specified another particle.

Parameters
referenceIndexIndex of the particle that is a source of electrostatic force.
particleIndexIndex of the particle on which the calculated force acts.
potentialFactorFactor by which potential is multiplied.
chargesArray of particle charges.
parametersVector of parameters that contains coordinates of all particles.
particleForceVector where particle force is stored to.

References IG.Num.IRealFunction.Derivative(), and IG.Num.VectorBase.Resize().

void IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleSingleForce ( int  referenceIndex,
int  particleIndex,
IVector  parameters,
ref IVector  particleForce 
)
inline

Calculates the electrostatic force acting on the specified particle by a single specified another free particle.

Parameters
referenceIndexIndex of the particle that is a source of electrostatic force.
particleIndexIndex of the particle on which the calculated force acts.
particleForceVector where particle force is stored to.

Charges of other particles, potential factor and potential function are obtained

virtual void IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleSingleForce ( int  particleIndex,
IVector  parameters,
ref IVector  particleForce 
)
inlinevirtual

Calculates the electrostatic force acting on the specified particle by all other free particles in the arrangement.

Parameters
particleIndexIndex of the particle on which the calculated force acts.
parametersVector of parameters that contains coordinates of all particles.
particleForceVector where particle force is stored to.

References IG.Num.VectorBase.Resize(), and IG.Num.VectorBase.SetZero().

virtual void IG.Lib.opt.opttest.ParticlePotentialProblem.PotentialEnergyGradient ( IVector  parameters,
ref IVector  gradient 
)
inlinevirtual

Calculates gradient of total potential, which is effectively composed of forces acting on the individual particles by all other particles in the arrangement (and that equals to gradients of potential energy of individual particle in the field of other particles).

Parameters
parametersVector of problem parameters where coordinates of all free particles are gathered.
gradientVector where gradient of potential energy is stored.

References IG.Num.VectorBase.Resize().

double IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleConstraintValue ( int  particleIndex,
IVector  parameters 
)
inline

Returns value of the constraint function for the specified particle in the arrangement.

Constraint is c_i(r_i) = ||r_i||-1 <= 0.

Parameters
particleIndexIndex of the particle for which constraint function value is returned.
parametersVector of parameters (global coordinates - assembly of coordinates of all free particles).
void IG.Lib.opt.opttest.ParticlePotentialProblem.ParticleConstraintGradient ( int  particleIndex,
IVector  parameters,
ref IVector  partConstraintGrad 
)
inline

Calculates and stores gradient of the constraint function related to the specified particle, in terms of particle coordinates.

Constraint gradient related to particle i is ∇c_i(r_i) = r_i/||r_i||.

Parameters
particleIndexIndex of the particle for which constraint gradient is calculated.
parametersVector of parameters (global coordinates - assembly of coordinates of all free particles).
partConstraintGradVector of the space dimension where constraint gradient is stored.

References IG.Num.VectorBase.Resize().

double IG.Lib.opt.opttest.ParticlePotentialProblem.ConstraintFunction ( int  whichConstraint,
IVector  parameters 
)
inline

Returns value of the specified constraint function related to specified particle in the arrangement.

Constraint is c_i(r_i) = ||r_i||-1 <= 0.

Parameters
whichConstraintSpecifies Index of the constraint function (that corresponds the index of the related particle).
parametersVector of parameters (global coordinates - assembly of coordinates of all free particles).
void IG.Lib.opt.opttest.ParticlePotentialProblem.ConstraintGradient ( int  whichConstraint,
IVector  parameters,
ref IVector  constraintGradient 
)
inline

Calculates and stores gradient of the specified constraint function that is related to the specified particle, in terms of global parameters (vector assembly of all particle coordinates).

Constraint gradient related to particle i is ∇c_i(r_i) = r_i/||r_i||.

Parameters
whichConstraintSpecifies Index of the constraint function (that corresponds the index of the related particle).
parametersVector of parameters (global coordinates - assembly of coordinates of all free particles).
constraintGradientVector where constraint gradient is stored, dimension equals dimension of parameters .

References IG.Num.VectorBase.Resize().

Member Data Documentation

readonly object IG.Lib.opt.opttest.ParticlePotentialProblem._mainLock = new object()
private
int IG.Lib.opt.opttest.ParticlePotentialProblem._numParticles = 8
protected
int IG.Lib.opt.opttest.ParticlePotentialProblem._spaceDimension = 2
protected
double IG.Lib.opt.opttest.ParticlePotentialProblem._potentialFactor = 1.0
protected
double [] IG.Lib.opt.opttest.ParticlePotentialProblem._charges
private
IRealFunction IG.Lib.opt.opttest.ParticlePotentialProblem._potentialFunction = Func.GetReciprocal()
protected
int IG.Lib.opt.opttest.ParticlePotentialProblem._numStaticParticles
private
IVector [] IG.Lib.opt.opttest.ParticlePotentialProblem._staticParticleCoordinates
private
double [] IG.Lib.opt.opttest.ParticlePotentialProblem._staticParticleCharges
private
IVector IG.Lib.opt.opttest.ParticlePotentialProblem._auxParticleVector = null
protected
ScalarFunctionBase IG.Lib.opt.opttest.ParticlePotentialProblem._objectiveFunction
private
ScalarFunctionBase [] IG.Lib.opt.opttest.ParticlePotentialProblem._constraintFunctions
private

Property Documentation

object IG.Lib.opt.opttest.ParticlePotentialProblem.Lock
get

This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.

int IG.Lib.opt.opttest.ParticlePotentialProblem.NumParticles
getprotected set

Number of charged particles in the arrangement.

Once the object is created, this can not be changed.

int IG.Lib.opt.opttest.ParticlePotentialProblem.SpaceDimension
getprotected set

Dimension of space in which particles are positioned.

Once the object is created, this can not be changed.

int IG.Lib.opt.opttest.ParticlePotentialProblem.ProblemDimension
get

Dimension of the problem, product of the space dimension and the number of free particles.

double IG.Lib.opt.opttest.ParticlePotentialProblem.PotentialFactor
getprotected set
double [] IG.Lib.opt.opttest.ParticlePotentialProblem.Charges
getset

Gets or sets the array of particle charges. Length of the array must be the same as the number of particles. If not set, getter will return the array in which all charges are equal to 1.

IRealFunction IG.Lib.opt.opttest.ParticlePotentialProblem.PotentialFunction
getset

The potential function.

As function of distance between two particles, this function defines electrostatic potential energy contributed by these two particles when multiplied by a product of particle charges and a multiplicative consrant (defined by the property PotentialFactor).

Set to f(x)=1/x by default.

int IG.Lib.opt.opttest.ParticlePotentialProblem.NumStaticParticles
getprivate set

Gets the number of static particles.

IVector [] IG.Lib.opt.opttest.ParticlePotentialProblem.StaticParticleCoordinates
getset

Array of coordinate vectors of staticle charges.

double [] IG.Lib.opt.opttest.ParticlePotentialProblem.StaticParticleCharges
getset

Gets or sets the array of static particle's charges. If not set, getter will return the array in which all charges are equal to 1.

ScalarFunctionBase IG.Lib.opt.opttest.ParticlePotentialProblem.ObjectiveFunction
get

Returns the scalar function that represents the objective function of the current minimal particle potential energy problem.

ScalarFunctionBase [] IG.Lib.opt.opttest.ParticlePotentialProblem.ConstraintFunctions
getprotected set

Returns an array of scalar functions that represent the constraint functions of the current minimal particle potential energy problem.


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