50 influenceDistance_(8.1500),
51 cutoff_(influenceDistance_),
52 cutoffSq_(cutoff_ * cutoff_),
53 modelWillNotRequestNeighborsOfNoncontributingParticles_(1)
55 *
error = ConvertUnits(modelCreate,
59 requestedTemperatureUnit,
67 1, &cutoff_, &modelWillNotRequestNeighborsOfNoncontributingParticles_);
73 = LennardJones_Ar::ComputeArgumentsCreate;
76 = LennardJones_Ar::ComputeArgumentsDestroy;
129#undef KIM_LOGGER_OBJECT_NAME
130#define KIM_LOGGER_OBJECT_NAME modelCompute
136 int const * numberOfParticlesPointer;
137 int const * particleSpeciesCodes;
138 int const * particleContributing;
139 double const * coordinates;
140 double * partialEnergy;
141 double * partialForces;
145 double const epsilon = lj->epsilon_;
146 double const sigma = lj->sigma_;
147 double const cutoffSq = lj->cutoffSq_;
151 &numberOfParticlesPointer)
154 &particleSpeciesCodes)
157 &particleContributing)
160 (
double const **) &coordinates)
165 (
double const **) &partialForces);
168 LOG_ERROR(
"Unable to get argument pointers");
172 int const numberOfParticles = *numberOfParticlesPointer;
175 *partialEnergy = 0.0;
176 int const extent = numberOfParticles *
DIMENSION;
177 for (
int i = 0; i < extent; ++i) { partialForces[i] = 0.0; }
180 int i, j, jj, numberOfNeighbors;
181 int const * neighbors;
183 double xcoord, ycoord, zcoord;
184 double xrij, yrij, zrij;
186 double r2inv, r6inv, dphiByR, dEidrByR;
187 double xdf, ydf, zdf;
188 double const fortyEight = 48.0 * epsilon * pow(sigma, 12.0);
189 double const twentyFour = 24.0 * epsilon * pow(sigma, 6.0);
190 double const four12 = 4.0 * epsilon * pow(sigma, 12.0);
191 double const four6 = 4.0 * epsilon * pow(sigma, 6.0);
192 for (i = 0; i < numberOfParticles; ++i)
194 if (particleContributing[i])
201 0, i, &numberOfNeighbors, &neighbors);
203 for (jj = 0; jj < numberOfNeighbors; ++jj)
206 jContributing = particleContributing[j];
208 if (!(jContributing && (j < i)))
210 xrij = coordinates[j *
DIMENSION + 0] - xcoord;
211 yrij = coordinates[j *
DIMENSION + 1] - ycoord;
212 zrij = coordinates[j *
DIMENSION + 2] - zcoord;
214 rij2 = xrij * xrij + yrij * yrij + zrij * zrij;
219 r6inv = r2inv * r2inv * r2inv;
220 phi = 0.5 * r6inv * (four12 * r6inv - four6);
221 dphiByR = r6inv * (twentyFour - fortyEight * r6inv) * r2inv;
223 *partialEnergy += phi;
226 *partialEnergy += phi;
231 dEidrByR = 0.5 * dphiByR;
234 xdf = dEidrByR * xrij;
235 ydf = dEidrByR * yrij;
236 zdf = dEidrByR * zrij;
289 double influenceDistance_;
292 int const modelWillNotRequestNeighborsOfNoncontributingParticles_;
295#undef KIM_LOGGER_OBJECT_NAME
296#define KIM_LOGGER_OBJECT_NAME modelCreate
315 double convertLength = 1.0;
324 requestedTemperatureUnit,
334 LOG_ERROR(
"Unable to convert length unit");
337 influenceDistance_ *= convertLength;
338 cutoff_ = influenceDistance_;
339 cutoffSq_ = cutoff_ * cutoff_;
340 sigma_ *= convertLength;
343 double convertEnergy = 1.0;
352 requestedTemperatureUnit,
362 LOG_ERROR(
"Unable to convert energy unit");
365 epsilon_ *= convertEnergy;
368 ier = modelCreate->
SetUnits(requestedLengthUnit,
375 LOG_ERROR(
"Unable to set units to requested values");
398 LennardJones_Ar *
const model =
new LennardJones_Ar(modelCreate,
402 requestedTemperatureUnit,
#define LOG_ERROR(message)
Convenience macro for ERROR Log entries with compile-time optimization.
int model_create(KIM::ModelCreate *const modelCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit)
An Extensible Enumeration for the ChargeUnit's supported by the KIM API.
An Extensible Enumeration for the EnergyUnit's supported by the KIM API.
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
int SetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus const supportStatus)
Set the SupportStatus of a ComputeArgumentName.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
int GetNeighborList(int const neighborListIndex, int const particleNumber, int *const numberOfNeighbors, int const **const neighborsOfParticle) const
Get the neighbor list for a particle of interest corresponding to a particular neighbor list cutoff d...
int GetArgumentPointer(ComputeArgumentName const computeArgumentName, int const **const ptr) const
Get the data pointer for a ComputeArgumentName.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
void SetInfluenceDistancePointer(double const *const influenceDistance)
Set the Model's influence distance data pointer.
int SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function *const fptr)
Set the function pointer for the ModelRoutineName of interest.
int SetSpeciesCode(SpeciesName const speciesName, int const code)
Set integer code for supported SpeciesName.
int SetModelNumbering(Numbering const numbering)
Set the Model's particle Numbering.
void SetNeighborListPointers(int const numberOfNeighborLists, double const *const cutoffs, int const *const modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model's neighbor list data pointers.
void SetModelBufferPointer(void *const ptr)
Set the Model's buffer pointer within the Model object.
static int ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double *const conversionFactor)
Get the multiplicative factor to convert between a derived unit represented in two different sets of ...
int SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit)
Set the Model's base unit values.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::D...
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
LennardJones_Ar(KIM::ModelCreate *const modelCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int *const error)
static int Compute(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArguments const *const modelComputeArguments)
static int Destroy(KIM::ModelDestroy *const modelDestroy)
static int ComputeArgumentsDestroy(KIM::ModelCompute const *const, KIM::ModelComputeArgumentsDestroy *const)
static int ComputeArgumentsCreate(KIM::ModelCompute const *const, KIM::ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
ChargeUnit const unused
Indicates that a ChargeUnit is not used.
ComputeArgumentName const coordinates
The standard coordinates argument.
ComputeArgumentName const numberOfParticles
The standard numberOfParticles argument.
ComputeArgumentName const particleSpeciesCodes
The standard particleSpeciesCodes argument.
ComputeArgumentName const partialEnergy
The standard partialEnergy argument.
ComputeArgumentName const partialForces
The standard partialForces argument.
ComputeArgumentName const particleContributing
The standard particleContributing argument.
EnergyUnit const eV
The standard electronvolt unit of energy.
LanguageName const cpp
The standard cpp language.
LengthUnit const A
The standard angstrom unit of length.
ModelRoutineName const Destroy
The standard Destroy routine.
ModelRoutineName const Compute
The standard Compute routine.
ModelRoutineName const ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
ModelRoutineName const ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
Numbering const zeroBased
The standard zeroBased numbering.
SpeciesName const Ar
The standard Argon species.
SupportStatus const required
The standard required status.
TemperatureUnit const unused
Indicates that a TemperatureUnit is not used.
TimeUnit const unused
Indicates that a TimeUnit is not used.
int ModelComputeFunction(ModelCompute const *const modelCompute, ModelComputeArguments const *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::Compute routine.
int ModelComputeArgumentsCreateFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine.
int ModelDestroyFunction(ModelDestroy *const modelDestroy)
Prototype for MODEL_ROUTINE_NAME::Destroy routine.
void() Function(void)
Generic function type.
int ModelComputeArgumentsDestroyFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine.