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;
290 double influenceDistance_;
293 int const modelWillNotRequestNeighborsOfNoncontributingParticles_;
296 #undef KIM_LOGGER_OBJECT_NAME 297 #define KIM_LOGGER_OBJECT_NAME modelCreate 316 double convertLength = 1.0;
325 requestedTemperatureUnit,
335 LOG_ERROR(
"Unable to convert length unit");
338 influenceDistance_ *= convertLength;
339 cutoff_ = influenceDistance_;
340 cutoffSq_ = cutoff_ * cutoff_;
341 sigma_ *= convertLength;
344 double convertEnergy = 1.0;
353 requestedTemperatureUnit,
363 LOG_ERROR(
"Unable to convert energy unit");
366 epsilon_ *= convertEnergy;
369 ier = modelCreate->
SetUnits(requestedLengthUnit,
376 LOG_ERROR(
"Unable to set units to requested values");
399 LennardJones_Ar *
const model =
new LennardJones_Ar(modelCreate,
403 requestedTemperatureUnit,
int ModelComputeArgumentsDestroyFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine.
TemperatureUnit const unused
Indicates that a TemperatureUnit is not used.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
SpeciesName const Ar
The standard Argon species.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
int ModelDestroyFunction(ModelDestroy *const modelDestroy)
Prototype for MODEL_ROUTINE_NAME::Destroy routine.
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.
recursive subroutine, public destroy(model_destroy_handle, ierr)
ComputeArgumentName const coordinates
The standard coordinates argument.
#define LOG_ERROR(message)
Convenience macro for ERROR Log entries with compile-time optimization.
ModelRoutineName const Destroy
The standard Destroy routine.
int SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit)
Set the Model's base unit values.
ChargeUnit const unused
Indicates that a ChargeUnit is not used.
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
void SetInfluenceDistancePointer(double const *const influenceDistance)
Set the Model's influence distance data pointer.
int SetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus const supportStatus)
Set the SupportStatus of a ComputeArgumentName.
int ModelComputeFunction(ModelCompute const *const modelCompute, ModelComputeArguments const *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::Compute routine.
void SetModelBufferPointer(void *const ptr)
Set the Model's buffer pointer within the Model object.
SupportStatus const required
The standard required status.
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::D...
int GetArgumentPointer(ComputeArgumentName const computeArgumentName, int const **const ptr) const
Get the data pointer for a ComputeArgumentName.
int ModelComputeArgumentsCreateFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine.
ComputeArgumentName const particleContributing
The standard particleContributing argument.
ComputeArgumentName const partialEnergy
The standard partialEnergy argument.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
ModelRoutineName const ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
ModelRoutineName const ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
void SetNeighborListPointers(int const numberOfNeighborLists, double const *const cutoffs, int const *const modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model's neighbor list data pointers.
An Extensible Enumeration for the EnergyUnit's supported by the KIM API.
LanguageName const cpp
The standard cpp language.
ModelRoutineName const Compute
The standard Compute routine.
LengthUnit const A
The standard angstrom unit of length.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
ComputeArgumentName const partialForces
The standard partialForces argument.
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
EnergyUnit const eV
The standard electronvolt unit of energy.
ComputeArgumentName const particleSpeciesCodes
The standard particleSpeciesCodes argument.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
An Extensible Enumeration for the ChargeUnit's supported by the KIM API.
ComputeArgumentName const numberOfParticles
The standard numberOfParticles argument.
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 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)
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
static int Destroy(KIM::ModelDestroy *const modelDestroy)
Numbering const zeroBased
The standard zeroBased numbering.
TimeUnit const unused
Indicates that a TimeUnit is not used.
static int ComputeArgumentsDestroy(KIM::ModelCompute const *const, KIM::ModelComputeArgumentsDestroy *const)
int SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function *const fptr)
Set the function pointer for the ModelRoutineName of interest.
LogVerbosity const error
The standard error verbosity.
static int Compute(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArguments const *const modelComputeArguments)
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 ...
static int ComputeArgumentsCreate(KIM::ModelCompute const *const, KIM::ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)