50 influenceDistance_(8.1500),
51 cutoff_(influenceDistance_),
52 cutoffSq_(cutoff_ * cutoff_),
53 modelWillNotRequestNeighborsOfNoncontributingParticles_(1)
55 *error = ConvertUnits(modelCreate,
59 requestedTemperatureUnit,
67 1, &cutoff_, &modelWillNotRequestNeighborsOfNoncontributingParticles_);
83 reinterpret_cast<KIM::Function *>(CACreate))
88 reinterpret_cast<KIM::Function *>(compute))
93 reinterpret_cast<KIM::Function *>(CADestroy))
98 reinterpret_cast<KIM::Function *>(destroy));
129 #undef KIM_LOGGER_OBJECT_NAME 130 #define KIM_LOGGER_OBJECT_NAME modelCompute 136 int const * numberOfParticlesPointer;
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");
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);
194 if (particleContributing[i])
196 xcoord = coordinates[i * DIMENSION + 0];
197 ycoord = coordinates[i * DIMENSION + 1];
198 zcoord = coordinates[i * DIMENSION + 2];
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;
237 partialForces[i * DIMENSION + 0] += xdf;
238 partialForces[i * DIMENSION + 1] += ydf;
239 partialForces[i * DIMENSION + 2] += zdf;
240 partialForces[j * DIMENSION + 0] -= xdf;
241 partialForces[j * DIMENSION + 1] -= ydf;
242 partialForces[j * DIMENSION + 2] -= zdf;
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,
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)