51 influenceDistance_(8.1500),
52 cutoff_(influenceDistance_),
53 cutoffSq_(cutoff_ * cutoff_),
54 modelWillNotRequestNeighborsOfNoncontributingParticles_(1)
56 *error = ConvertUnits(modelCreate,
60 requestedTemperatureUnit,
68 1, &cutoff_, &modelWillNotRequestNeighborsOfNoncontributingParticles_);
84 reinterpret_cast<KIM::Function *>(CACreate))
89 reinterpret_cast<KIM::Function *>(compute))
94 reinterpret_cast<KIM::Function *>(CADestroy))
99 reinterpret_cast<KIM::Function *>(destroy));
130 #undef KIM_LOGGER_OBJECT_NAME 131 #define KIM_LOGGER_OBJECT_NAME modelCompute 137 int const * numberOfParticlesPointer;
146 double const epsilon = lj->epsilon_;
147 double const sigma = lj->sigma_;
148 double const cutoffSq = lj->cutoffSq_;
152 &numberOfParticlesPointer)
155 &particleSpeciesCodes)
158 &particleContributing)
161 (
double const **) &coordinates)
166 (
double const **) &partialForces);
169 LOG_ERROR(
"Unable to get argument pointers");
176 *partialEnergy = 0.0;
177 int const extent = numberOfParticles *
DIMENSION;
178 for (
int i = 0; i < extent; ++i) { partialForces[i] = 0.0; }
181 int i, j, jj, numberOfNeighbors;
182 int const * neighbors;
184 double xcoord, ycoord, zcoord;
185 double xrij, yrij, zrij;
187 double r2inv, r6inv, dphiByR, dEidrByR;
188 double xdf, ydf, zdf;
189 double const fortyEight = 48.0 * epsilon * pow(sigma, 12.0);
190 double const twentyFour = 24.0 * epsilon * pow(sigma, 6.0);
191 double const four12 = 4.0 * epsilon * pow(sigma, 12.0);
192 double const four6 = 4.0 * epsilon * pow(sigma, 6.0);
195 if (particleContributing[i])
197 xcoord = coordinates[i * DIMENSION + 0];
198 ycoord = coordinates[i * DIMENSION + 1];
199 zcoord = coordinates[i * DIMENSION + 2];
202 0, i, &numberOfNeighbors, &neighbors);
204 for (jj = 0; jj < numberOfNeighbors; ++jj)
207 jContributing = particleContributing[j];
209 if (!(jContributing && (j < i)))
211 xrij = coordinates[j * DIMENSION + 0] - xcoord;
212 yrij = coordinates[j * DIMENSION + 1] - ycoord;
213 zrij = coordinates[j * DIMENSION + 2] - zcoord;
215 rij2 = xrij * xrij + yrij * yrij + zrij * zrij;
220 r6inv = r2inv * r2inv * r2inv;
221 phi = 0.5 * r6inv * (four12 * r6inv - four6);
222 dphiByR = r6inv * (twentyFour - fortyEight * r6inv) * r2inv;
224 *partialEnergy += phi;
227 *partialEnergy += phi;
232 dEidrByR = 0.5 * dphiByR;
235 xdf = dEidrByR * xrij;
236 ydf = dEidrByR * yrij;
237 zdf = dEidrByR * zrij;
238 partialForces[i * DIMENSION + 0] += xdf;
239 partialForces[i * DIMENSION + 1] += ydf;
240 partialForces[i * DIMENSION + 2] += zdf;
241 partialForces[j * DIMENSION + 0] -= xdf;
242 partialForces[j * DIMENSION + 1] -= ydf;
243 partialForces[j * DIMENSION + 2] -= zdf;
282 (void) modelComputeArgumentsDestroy;
294 double influenceDistance_;
297 int const modelWillNotRequestNeighborsOfNoncontributingParticles_;
300 #undef KIM_LOGGER_OBJECT_NAME 301 #define KIM_LOGGER_OBJECT_NAME modelCreate 320 double convertLength = 1.0;
329 requestedTemperatureUnit,
339 LOG_ERROR(
"Unable to convert length unit");
342 influenceDistance_ *= convertLength;
343 cutoff_ = influenceDistance_;
344 cutoffSq_ = cutoff_ * cutoff_;
345 sigma_ *= convertLength;
348 double convertEnergy = 1.0;
357 requestedTemperatureUnit,
367 LOG_ERROR(
"Unable to convert energy unit");
370 epsilon_ *= convertEnergy;
373 ier = modelCreate->
SetUnits(requestedLengthUnit,
380 LOG_ERROR(
"Unable to set units to requested values");
403 LennardJones_Ar *
const model =
new LennardJones_Ar(modelCreate,
407 requestedTemperatureUnit,
Numbering const zeroBased
The standard zeroBased numbering.
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
#define LOG_ERROR(message)
Convenience macro for ERROR Log entries with compile-time optimization.
TimeUnit const unused
Indicates that a TimeUnit is not used.
EnergyUnit const eV
The standard electronvolt unit of energy.
recursive subroutine, public destroy(model_destroy_handle, ierr)
An Extensible Enumeration for the ChargeUnit's supported by the KIM API.
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
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...
ChargeUnit const unused
Indicates that a ChargeUnit is not used.
TemperatureUnit const unused
Indicates that a TemperatureUnit is not used.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
An Extensible Enumeration for the EnergyUnit's supported by the KIM API.
SpeciesName const Ar
The standard Argon species.
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 SetNeighborListPointers(int const numberOfNeighborLists, double const *const cutoffs, int const *const modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model's neighbor list data pointers.
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...
static int Destroy(KIM::ModelDestroy *const modelDestroy)
int SetSpeciesCode(SpeciesName const speciesName, int const code)
Set integer code for supported SpeciesName.
ModelRoutineName const Destroy
The standard Destroy routine.
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)
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)
void SetModelBufferPointer(void *const ptr)
Set the Model's buffer pointer within the Model object.
static int ComputeArgumentsDestroy(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
int ModelComputeArgumentsCreateFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
ModelRoutineName const ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
ModelRoutineName const ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
ComputeArgumentName const coordinates
The standard coordinates argument.
LengthUnit const A
The standard angstrom unit of length.
ComputeArgumentName const partialEnergy
The standard partialEnergy argument.
ModelRoutineName const Compute
The standard Compute routine.
ComputeArgumentName const particleSpeciesCodes
The standard particleSpeciesCodes argument.
int SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit)
Set the Model's base unit values.
ComputeArgumentName const numberOfParticles
The standard numberOfParticles argument.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
static int Compute(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArguments const *const modelComputeArguments)
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
LanguageName const cpp
The standard cpp language.
SupportStatus const required
The standard required status.
int ModelDestroyFunction(ModelDestroy *const modelDestroy)
Prototype for MODEL_ROUTINE_NAME::Destroy routine.
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::D...
void SetInfluenceDistancePointer(double const *const influenceDistance)
Set the Model's influence distance data pointer.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
LogVerbosity const error
The standard error verbosity.
int ModelComputeArgumentsDestroyFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine.
int SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function *const fptr)
Set the function pointer for the ModelRoutineName of interest.
ComputeArgumentName const particleContributing
The standard particleContributing argument.
ComputeArgumentName const partialForces
The standard partialForces argument.
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 ModelComputeFunction(ModelCompute const *const modelCompute, ModelComputeArguments const *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::Compute routine.
static int ComputeArgumentsCreate(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
int SetModelNumbering(Numbering const numbering)
Set the Model's particle Numbering.