IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Base class for the charged particle potential problem. More...
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... | |
![]() | |
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 |
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;
|
inlineprivate |
Prevent argument-less constructor.
|
inline |
References IG.Num.ConstPhysical.ElectricConstant, and IG.Num.PhysicalConstant.Value.
|
inline |
Sets all particle charges to the specified value.
charge | Charge assigned to all particles. |
|
inline |
Sets all static particle charges to the specified value.
charge | Charge assigned to all static particles. |
|
inline |
Returns parameter index that corresponds to the specified particle index and to the specified particle coordinate.
particleIndex | Particle index. |
coordinateIndex | Index 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).
|
inline |
Returns index of the particle to which the specified element of the global parameter vector belongs.
parameterIndex | Index 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).
|
inline |
Returns coordinate index of the corresponding particle that is equivalent to the specified element of the global parameter vector.
parameterIndex | Index 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).
|
inline |
Extracts and returns the specified coordinate of the specified particle from the specified parameter vector.
particleIndex | Particle index. |
coordinateIndex | Index of particle coordinate. |
parameters | Vector of parameters where coordinates fo all particles are collected. |
|
inline |
Returns the Euclidean distance between the two particles with specified indices.
firstIndex | Index of the first particle. |
secondIndex | Index of the second particle. |
parameters | Vector of parameters. |
|
inlinevirtual |
Calculates and returns the distance between the specified static particle and the specified free particle of the particle arrangement.
staticParticleIndex | Index of the static particle. |
particleIndex | Index of free particle. |
parameters | Problem parameters, assembled vector of coordinated of all free particles. |
staticCoordinates | Array of coordinates of static particles. |
|
inlinevirtual |
Calculates and returns pairwise electrical potential energy of the specified static and the specified free particle, providing the necessary coefficiets through parameters.
staticParticleIndex | Index of the static particle. |
particleIndex | Index of the free particle. |
potentialFactor | Factor by which potential is multiplied. |
charges | Array of particle charges. |
potentialFunction | Function 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. |
parameters | Vector of parameters that contains coordinates of all particles. |
staticCharges | Array of static particle's charges. |
staticCoordinates | Array of coordinate vectors of static particles. |
References IG.Num.IRealFunction.Value().
|
inlinevirtual |
Calculates and returns electrical potential energy of the specified static and free particle.
All the necessary parameters are obteined from the object.
referenceIndex | Indx of the static particle. |
particleIndex | Index of the free particle. |
parameters | Vector of parameters that contains coordinates of all particles. |
|
inlinevirtual |
Calculates and returns pairwise electrical potential energy of two particles, providing the necessary coefficiets through parameters.
referenceIndex | Indx of the first particle. |
particleIndex | Index of the second particle. |
potentialFactor | Factor by which potential is multiplied. |
charges | Array of particle charges. |
potentialFunction | Function 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. |
parameters | Vector of parameters that contains coordinates of all particles. |
References IG.Num.IRealFunction.Value().
|
inlinevirtual |
Calculates and returns electrical potential energy of two particles.
referenceIndex | Indx of the first particle. |
particleIndex | Index of the second particle. |
parameters | Vector of parameters that contains coordinates of all particles. |
|
inlinevirtual |
Calculates and returns the total potential energy of all particles in the formation.
parameters | Vector of parameters that contains coordinates of all particles. |
|
inline |
Calculates the electrostatic force acting on the specified free particle by a single specified statitc particle.
staticParticleIndex | Index of the particle that is a source of electrostatic force. |
particleIndex | Index of the particle on which the calculated force acts. |
potentialFactor | Factor by which potential is multiplied. |
charges | Array of particle charges. |
parameters | Vector of parameters that contains coordinates of all particles. |
particleForce | Vector where particle force is stored to. |
References IG.Num.IRealFunction.Derivative(), and IG.Num.VectorBase.Resize().
|
inline |
Calculates the electrostatic force acting on the specified free particle by a single specified static particle.
staticParticleIndex | Index of the particle that is a source of electrostatic force. |
particleIndex | Index of the particle on which the calculated force acts. |
particleForce | Vector where particle force is stored to. |
Charges of other particles, potential factor and potential function are obtained
|
inlinevirtual |
Calculates the electrostatic force acting on the specified free particle by all static particles in the arrangement.
particleIndex | Index of the particle on which the calculated force acts. |
parameters | Vector of parameters that contains coordinates of all particles. |
particleForce | Vector where particle force is stored to. |
References IG.Num.VectorBase.Resize(), and IG.Num.VectorBase.SetZero().
|
inline |
Calculates the electrostatic force acting on the specified particle by a single specified another particle.
referenceIndex | Index of the particle that is a source of electrostatic force. |
particleIndex | Index of the particle on which the calculated force acts. |
potentialFactor | Factor by which potential is multiplied. |
charges | Array of particle charges. |
parameters | Vector of parameters that contains coordinates of all particles. |
particleForce | Vector where particle force is stored to. |
References IG.Num.IRealFunction.Derivative(), and IG.Num.VectorBase.Resize().
|
inline |
Calculates the electrostatic force acting on the specified particle by a single specified another free particle.
referenceIndex | Index of the particle that is a source of electrostatic force. |
particleIndex | Index of the particle on which the calculated force acts. |
particleForce | Vector where particle force is stored to. |
Charges of other particles, potential factor and potential function are obtained
|
inlinevirtual |
Calculates the electrostatic force acting on the specified particle by all other free particles in the arrangement.
particleIndex | Index of the particle on which the calculated force acts. |
parameters | Vector of parameters that contains coordinates of all particles. |
particleForce | Vector where particle force is stored to. |
References IG.Num.VectorBase.Resize(), and IG.Num.VectorBase.SetZero().
|
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 | Vector of problem parameters where coordinates of all free particles are gathered. |
gradient | Vector where gradient of potential energy is stored. |
References IG.Num.VectorBase.Resize().
|
inline |
Returns value of the constraint function for the specified particle in the arrangement.
Constraint is c_i(r_i) = ||r_i||-1 <= 0.
particleIndex | Index of the particle for which constraint function value is returned. |
parameters | Vector of parameters (global coordinates - assembly of coordinates of all free particles). |
|
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||.
particleIndex | Index of the particle for which constraint gradient is calculated. |
parameters | Vector of parameters (global coordinates - assembly of coordinates of all free particles). |
partConstraintGrad | Vector of the space dimension where constraint gradient is stored. |
References IG.Num.VectorBase.Resize().
|
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.
whichConstraint | Specifies Index of the constraint function (that corresponds the index of the related particle). |
parameters | Vector of parameters (global coordinates - assembly of coordinates of all free particles). |
|
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||.
whichConstraint | Specifies Index of the constraint function (that corresponds the index of the related particle). |
parameters | Vector of parameters (global coordinates - assembly of coordinates of all free particles). |
constraintGradient | Vector where constraint gradient is stored, dimension equals dimension of parameters . |
References IG.Num.VectorBase.Resize().
|
private |
|
protected |
|
protected |
|
protected |
|
private |
|
protected |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
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.
|
getprotected set |
Number of charged particles in the arrangement.
Once the object is created, this can not be changed.
|
getprotected set |
Dimension of space in which particles are positioned.
Once the object is created, this can not be changed.
|
get |
Dimension of the problem, product of the space dimension and the number of free particles.
|
getprotected set |
|
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.
|
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.
|
getprivate set |
Gets the number of static particles.
|
getset |
Array of coordinate vectors of staticle charges.
|
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.
|
get |
Returns the scalar function that represents the objective function of the current minimal particle potential energy problem.
|
getprotected set |
Returns an array of scalar functions that represent the constraint functions of the current minimal particle potential energy problem.